@anysoftinc/anydb-sdk 0.5.1 → 0.6.1

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.
Files changed (42) hide show
  1. package/dist/client.d.ts +7 -5
  2. package/dist/client.d.ts.map +1 -1
  3. package/dist/client.js +36 -101
  4. package/dist/nextauth-adapter.js +1 -1
  5. package/package.json +4 -7
  6. package/dist/anydb.datascript.core.js +0 -336
  7. package/dist/anydb.datascript.rules.js +0 -29
  8. package/dist/anydb.datascript.schema.js +0 -35
  9. package/dist/cljs.core.js +0 -38752
  10. package/dist/cljs.reader.js +0 -450
  11. package/dist/cljs.tools.reader.edn.js +0 -945
  12. package/dist/cljs.tools.reader.impl.commons.js +0 -205
  13. package/dist/cljs.tools.reader.impl.errors.js +0 -429
  14. package/dist/cljs.tools.reader.impl.inspect.js +0 -170
  15. package/dist/cljs.tools.reader.impl.utils.js +0 -413
  16. package/dist/cljs.tools.reader.js +0 -1815
  17. package/dist/cljs.tools.reader.reader_types.js +0 -826
  18. package/dist/cljs_env.js +0 -7672
  19. package/dist/clojure.data.js +0 -307
  20. package/dist/clojure.edn.js +0 -107
  21. package/dist/clojure.set.js +0 -394
  22. package/dist/clojure.string.js +0 -490
  23. package/dist/clojure.walk.js +0 -144
  24. package/dist/datascript-backend.d.ts +0 -26
  25. package/dist/datascript-backend.d.ts.map +0 -1
  26. package/dist/datascript-backend.js +0 -113
  27. package/dist/datascript.built_ins.js +0 -680
  28. package/dist/datascript.conn.js +0 -814
  29. package/dist/datascript.core.js +0 -1285
  30. package/dist/datascript.db.js +0 -4058
  31. package/dist/datascript.impl.entity.js +0 -588
  32. package/dist/datascript.lru.js +0 -213
  33. package/dist/datascript.parser.js +0 -8598
  34. package/dist/datascript.pull_api.js +0 -2287
  35. package/dist/datascript.pull_parser.js +0 -865
  36. package/dist/datascript.query.js +0 -2785
  37. package/dist/datascript.serialize.js +0 -352
  38. package/dist/datascript.storage.js +0 -50
  39. package/dist/datascript.util.js +0 -82
  40. package/dist/extend_clj.core.js +0 -134
  41. package/dist/me.tonsky.persistent_sorted_set.arrays.js +0 -54
  42. package/dist/me.tonsky.persistent_sorted_set.js +0 -2485
@@ -1,1285 +0,0 @@
1
- var $CLJS = require("./cljs_env");
2
- var $jscomp = $CLJS.$jscomp;
3
- var COMPILED = false;
4
- require("./cljs.core.js");
5
- require("./cljs.reader.js");
6
- require("./datascript.conn.js");
7
- require("./datascript.db.js");
8
- require("./datascript.pull_api.js");
9
- require("./datascript.serialize.js");
10
- require("./datascript.storage.js");
11
- require("./datascript.query.js");
12
- require("./datascript.impl.entity.js");
13
- require("./datascript.util.js");
14
- require("./me.tonsky.persistent_sorted_set.js");
15
- var anydb=$CLJS.anydb || ($CLJS.anydb = {});
16
- var clojure=$CLJS.clojure || ($CLJS.clojure = {});
17
- var cljs=$CLJS.cljs || ($CLJS.cljs = {});
18
- var goog=$CLJS.goog || ($CLJS.goog = {});
19
- var datascript=$CLJS.datascript || ($CLJS.datascript = {});
20
- var me=$CLJS.me || ($CLJS.me = {});
21
- var extend_clj=$CLJS.extend_clj || ($CLJS.extend_clj = {});
22
-
23
- $CLJS.SHADOW_ENV.setLoaded("datascript.core.js");
24
-
25
- goog.provide('datascript.core');
26
- datascript.core.tx0 = (536870912);
27
- /**
28
- * Retrieves an entity by its id from database. Entities are lazy map-like structures to navigate DataScript database content.
29
- *
30
- * For `eid` pass entity id or lookup attr:
31
- *
32
- * (entity db 1)
33
- * (entity db [:unique-attr :value])
34
- *
35
- * If entity does not exist, `nil` is returned:
36
- *
37
- * (entity db 100500) ; => nil
38
- *
39
- * Creating an entity by id is very cheap, almost no-op, as attr access is on-demand:
40
- *
41
- * (entity db 1) ; => {:db/id 1}
42
- *
43
- * Entity attributes can be lazily accessed through key lookups:
44
- *
45
- * (:attr (entity db 1)) ; => :value
46
- * (get (entity db 1) :attr) ; => :value
47
- *
48
- * Cardinality many attributes are returned sequences:
49
- *
50
- * (:attrs (entity db 1)) ; => [:v1 :v2 :v3]
51
- *
52
- * Reference attributes are returned as another entities:
53
- *
54
- * (:ref (entity db 1)) ; => {:db/id 2}
55
- * (:ns/ref (entity db 1)) ; => {:db/id 2}
56
- *
57
- * References can be walked backwards by prepending `_` to name part of an attribute:
58
- *
59
- * (:_ref (entity db 2)) ; => [{:db/id 1}]
60
- * (:ns/_ref (entity db 2)) ; => [{:db/id 1}]
61
- *
62
- * Reverse reference lookup returns sequence of entities unless attribute is marked as `:db/isComponent`:
63
- *
64
- * (:_component-ref (entity db 2)) ; => {:db/id 1}
65
- *
66
- * Entity gotchas:
67
- *
68
- * - Entities print as map, but are not exactly maps (they have compatible get interface though).
69
- * - Entities are effectively immutable “views” into a particular version of a database.
70
- * - Entities retain reference to the whole database.
71
- * - You can’t change database through entities, only read.
72
- * - Creating an entity by id is very cheap, almost no-op (attributes are looked up on demand).
73
- * - Comparing entities just compares their ids. Be careful when comparing entities taken from different dbs or from different versions of the same db.
74
- * - Accessed entity attributes are cached on entity itself (except backward references).
75
- * - When printing, only cached attributes (the ones you have accessed before) are printed. See [[touch]].
76
- */
77
- datascript.core.entity = datascript.impl.entity.entity;
78
- /**
79
- * Given lookup ref `[unique-attr value]`, returns numberic entity id.
80
- *
81
- * If entity does not exist, returns `nil`.
82
- */
83
- datascript.core.entid = datascript.db.entid;
84
- /**
85
- * Returns a db that entity was created from.
86
- */
87
- datascript.core.entity_db = (function datascript$core$entity_db(entity){
88
- if(datascript.impl.entity.entity_QMARK_(entity)){
89
- } else {
90
- throw (new Error("Assert failed: (de/entity? entity)"));
91
- }
92
-
93
- return entity.db;
94
- });
95
- /**
96
- * Forces all entity attributes to be eagerly fetched and cached. Only usable for debug output.
97
- *
98
- * Usage:
99
- *
100
- * ```
101
- * (entity db 1) ; => {:db/id 1}
102
- * (touch (entity db 1)) ; => {:db/id 1, :dislikes [:pie], :likes [:pizza]}
103
- * ```
104
- */
105
- datascript.core.touch = datascript.impl.entity.touch;
106
- /**
107
- * Fetches data from database using recursive declarative description. See [docs.datomic.com/on-prem/pull.html](https://docs.datomic.com/on-prem/pull.html).
108
- *
109
- * Unlike [[entity]], returns plain Clojure map (not lazy).
110
- *
111
- * Usage:
112
- *
113
- * (pull db [:db/id, :name, :likes, {:friends [:db/id :name]}] 1)
114
- * ; => {:db/id 1,
115
- * ; :name "Ivan"
116
- * ; :likes [:pizza]
117
- * ; :friends [{:db/id 2, :name "Oleg"}]}
118
- */
119
- datascript.core.pull = datascript.pull_api.pull;
120
- /**
121
- * Same as [[pull]], but accepts sequence of ids and returns sequence of maps.
122
- *
123
- * Usage:
124
- *
125
- * ```
126
- * (pull-many db [:db/id :name] [1 2])
127
- * ; => [{:db/id 1, :name "Ivan"}
128
- * ; {:db/id 2, :name "Oleg"}]
129
- * ```
130
- */
131
- datascript.core.pull_many = datascript.pull_api.pull_many;
132
- /**
133
- * Executes a datalog query. See [docs.datomic.com/on-prem/query.html](https://docs.datomic.com/on-prem/query.html).
134
- *
135
- * Usage:
136
- *
137
- * ```
138
- * (q '[:find ?value
139
- * :where [_ :likes ?value]]
140
- * db)
141
- * ; => #{["fries"] ["candy"] ["pie"] ["pizza"]}
142
- * ```
143
- */
144
- datascript.core.q = datascript.query.q;
145
- /**
146
- * Creates an empty database with an optional schema.
147
- *
148
- * Usage:
149
- *
150
- * ```
151
- * (empty-db) ; => #datascript/DB {:schema {}, :datoms []}
152
- *
153
- * (empty-db {:likes {:db/cardinality :db.cardinality/many}})
154
- * ; => #datascript/DB {:schema {:likes {:db/cardinality :db.cardinality/many}}
155
- * ; :datoms []}
156
- * ```
157
- *
158
- * Options are:
159
- *
160
- * :branching-factor <int>, default 512. B-tree max node length
161
- * :ref-type :strong | :soft | :weak, default :soft. How will nodes that are already
162
- * stored on disk be referenced. Soft or weak means they might be unloaded
163
- * from memory under memory pressure and later fetched from storage again.
164
- * :storage <IStorage>. Will be used to store this db later with `(d/store db)`
165
- */
166
- datascript.core.empty_db = (function datascript$core$empty_db(var_args){
167
- var G__15084 = arguments.length;
168
- switch (G__15084) {
169
- case 0:
170
- return datascript.core.empty_db.cljs$core$IFn$_invoke$arity$0();
171
-
172
- break;
173
- case 1:
174
- return datascript.core.empty_db.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
175
-
176
- break;
177
- case 2:
178
- return datascript.core.empty_db.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
179
-
180
- break;
181
- default:
182
- throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
183
-
184
- }
185
- });
186
-
187
- (datascript.core.empty_db.cljs$core$IFn$_invoke$arity$0 = (function (){
188
- return datascript.db.empty_db(null,cljs.core.PersistentArrayMap.EMPTY);
189
- }));
190
-
191
- (datascript.core.empty_db.cljs$core$IFn$_invoke$arity$1 = (function (schema){
192
- return datascript.db.empty_db(schema,cljs.core.PersistentArrayMap.EMPTY);
193
- }));
194
-
195
- (datascript.core.empty_db.cljs$core$IFn$_invoke$arity$2 = (function (schema,opts){
196
- return datascript.db.empty_db(schema,datascript.storage.maybe_adapt_storage(opts));
197
- }));
198
-
199
- (datascript.core.empty_db.cljs$lang$maxFixedArity = 2);
200
-
201
- /**
202
- * Returns `true` if the given value is an immutable database, `false` otherwise.
203
- */
204
- datascript.core.db_QMARK_ = datascript.db.db_QMARK_;
205
- /**
206
- * Low-level fn to create raw datoms.
207
- *
208
- * Optionally with transaction id (number) and `added` flag (`true` for addition, `false` for retraction).
209
- *
210
- * See also [[init-db]].
211
- */
212
- datascript.core.datom = datascript.db.datom;
213
- /**
214
- * Returns `true` if the given value is a datom, `false` otherwise.
215
- */
216
- datascript.core.datom_QMARK_ = datascript.db.datom_QMARK_;
217
- /**
218
- * Low-level fn for creating database quickly from a trusted sequence of datoms.
219
- * Does no validation on inputs, so `datoms` must be well-formed and match schema.
220
- * Used internally in db (de)serialization. See also [[datom]].
221
- * For options, see [[empty-db]]
222
- */
223
- datascript.core.init_db = (function datascript$core$init_db(var_args){
224
- var G__15087 = arguments.length;
225
- switch (G__15087) {
226
- case 1:
227
- return datascript.core.init_db.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
228
-
229
- break;
230
- case 2:
231
- return datascript.core.init_db.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
232
-
233
- break;
234
- case 3:
235
- return datascript.core.init_db.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
236
-
237
- break;
238
- default:
239
- throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
240
-
241
- }
242
- });
243
-
244
- (datascript.core.init_db.cljs$core$IFn$_invoke$arity$1 = (function (datoms){
245
- return datascript.db.init_db(datoms,null,cljs.core.PersistentArrayMap.EMPTY);
246
- }));
247
-
248
- (datascript.core.init_db.cljs$core$IFn$_invoke$arity$2 = (function (datoms,schema){
249
- return datascript.db.init_db(datoms,schema,cljs.core.PersistentArrayMap.EMPTY);
250
- }));
251
-
252
- (datascript.core.init_db.cljs$core$IFn$_invoke$arity$3 = (function (datoms,schema,opts){
253
- return datascript.db.init_db(datoms,schema,datascript.storage.maybe_adapt_storage(opts));
254
- }));
255
-
256
- (datascript.core.init_db.cljs$lang$maxFixedArity = 3);
257
-
258
- /**
259
- * Converts db into a data structure (not string!) that can be fed to serializer
260
- * of your choice (e.g. `js/JSON.stringify` in CLJS, `cheshire.core/generate-string`
261
- * or `jsonista.core/write-value-as-string` in CLJ).
262
- *
263
- * On JVM, `serializable` holds a global lock that prevents any two serializations
264
- * to run in parallel (an implementation constraint, be aware).
265
- *
266
- * Options:
267
- *
268
- * `:freeze-fn` Non-primitive values will be serialized using this. Optional.
269
- * `pr-str` by default.
270
- */
271
- datascript.core.serializable = datascript.serialize.serializable;
272
- /**
273
- * Creates db from a data structure (not string!) produced by serializable.
274
- *
275
- * Opts:
276
- *
277
- * `:thaw-fn` Non-primitive values will be deserialized using this.
278
- * Must match :freeze-fn from serializable. Optional. `clojure.edn/read-string`
279
- * by default.
280
- */
281
- datascript.core.from_serializable = datascript.serialize.from_serializable;
282
- /**
283
- * Returns a schema of a database.
284
- */
285
- datascript.core.schema = datascript.db._schema;
286
- /**
287
- * Returns `true` if this database was filtered using [[filter]], `false` otherwise.
288
- */
289
- datascript.core.is_filtered = (function datascript$core$is_filtered(x){
290
- return (x instanceof datascript.db.FilteredDB);
291
- });
292
- /**
293
- * Returns a view over database that has same interface but only includes datoms for which the `(pred db datom)` is true. Can be applied multiple times.
294
- *
295
- * Filtered DB gotchas:
296
- *
297
- * - All operations on filtered database are proxied to original DB, then filter pred is applied.
298
- * - Not cached. You pay filter penalty every time.
299
- * - Supports entities, pull, queries, index access.
300
- * - Does not support [[with]] and [[db-with]].
301
- */
302
- datascript.core.filter = (function datascript$core$filter(db,pred){
303
- if(datascript.db.db_QMARK_(db)){
304
- } else {
305
- throw (new Error("Assert failed: (db/db? db)"));
306
- }
307
-
308
- if(datascript.core.is_filtered(db)){
309
- var fdb = db;
310
- var orig_pred = fdb.pred;
311
- var orig_db = fdb.unfiltered_db;
312
- return (new datascript.db.FilteredDB(orig_db,(function (p1__15095_SHARP_){
313
- var and__5000__auto__ = (orig_pred.cljs$core$IFn$_invoke$arity$1 ? orig_pred.cljs$core$IFn$_invoke$arity$1(p1__15095_SHARP_) : orig_pred.call(null,p1__15095_SHARP_));
314
- if(cljs.core.truth_(and__5000__auto__)){
315
- return (pred.cljs$core$IFn$_invoke$arity$2 ? pred.cljs$core$IFn$_invoke$arity$2(orig_db,p1__15095_SHARP_) : pred.call(null,orig_db,p1__15095_SHARP_));
316
- } else {
317
- return and__5000__auto__;
318
- }
319
- }),cljs.core.atom.cljs$core$IFn$_invoke$arity$1((0)),null,null,null));
320
- } else {
321
- return (new datascript.db.FilteredDB(db,(function (p1__15096_SHARP_){
322
- return (pred.cljs$core$IFn$_invoke$arity$2 ? pred.cljs$core$IFn$_invoke$arity$2(db,p1__15096_SHARP_) : pred.call(null,db,p1__15096_SHARP_));
323
- }),cljs.core.atom.cljs$core$IFn$_invoke$arity$1((0)),null,null,null));
324
- }
325
- });
326
- /**
327
- * Same as [[transact!]], but applies to an immutable database value. Returns transaction report (see [[transact!]]).
328
- */
329
- datascript.core.with$ = datascript.conn.with$;
330
- /**
331
- * Applies transaction to an immutable db value, returning new immutable db value. Same as `(:db-after (with db tx-data))`.
332
- */
333
- datascript.core.db_with = datascript.conn.db_with;
334
- /**
335
- * Warning! No validation or conversion. Only change schema in a compatible way
336
- */
337
- datascript.core.with_schema = (function datascript$core$with_schema(db,schema){
338
- return datascript.db.with_schema(db,schema);
339
- });
340
- /**
341
- * Index lookup. Returns a sequence of datoms (lazy iterator over actual DB index) which components (e, a, v) match passed arguments.
342
- *
343
- * Datoms are sorted in index sort order. Possible `index` values are: `:eavt`, `:aevt`, `:avet`.
344
- *
345
- * Usage:
346
- *
347
- * ; find all datoms for entity id == 1 (any attrs and values)
348
- * ; sort by attribute, then value
349
- * (datoms db :eavt 1)
350
- * ; => (#datascript/Datom [1 :friends 2]
351
- * ; #datascript/Datom [1 :likes "fries"]
352
- * ; #datascript/Datom [1 :likes "pizza"]
353
- * ; #datascript/Datom [1 :name "Ivan"])
354
- *
355
- * ; find all datoms for entity id == 1 and attribute == :likes (any values)
356
- * ; sorted by value
357
- * (datoms db :eavt 1 :likes)
358
- * ; => (#datascript/Datom [1 :likes "fries"]
359
- * ; #datascript/Datom [1 :likes "pizza"])
360
- *
361
- * ; find all datoms for entity id == 1, attribute == :likes and value == "pizza"
362
- * (datoms db :eavt 1 :likes "pizza")
363
- * ; => (#datascript/Datom [1 :likes "pizza"])
364
- *
365
- * ; find all datoms for attribute == :likes (any entity ids and values)
366
- * ; sorted by entity id, then value
367
- * (datoms db :aevt :likes)
368
- * ; => (#datascript/Datom [1 :likes "fries"]
369
- * ; #datascript/Datom [1 :likes "pizza"]
370
- * ; #datascript/Datom [2 :likes "candy"]
371
- * ; #datascript/Datom [2 :likes "pie"]
372
- * ; #datascript/Datom [2 :likes "pizza"])
373
- *
374
- * ; find all datoms that have attribute == `:likes` and value == `"pizza"` (any entity id)
375
- * ; `:likes` must be a unique attr, reference or marked as `:db/index true`
376
- * (datoms db :avet :likes "pizza")
377
- * ; => (#datascript/Datom [1 :likes "pizza"]
378
- * ; #datascript/Datom [2 :likes "pizza"])
379
- *
380
- * ; find all datoms sorted by entity id, then attribute, then value
381
- * (datoms db :eavt) ; => (...)
382
- *
383
- * Useful patterns:
384
- *
385
- * ; get all values of :db.cardinality/many attribute
386
- * (->> (datoms db :eavt eid attr) (map :v))
387
- *
388
- * ; lookup entity ids by attribute value
389
- * (->> (datoms db :avet attr value) (map :e))
390
- *
391
- * ; find all entities with a specific attribute
392
- * (->> (datoms db :aevt attr) (map :e))
393
- *
394
- * ; find “singleton” entity by its attr
395
- * (->> (datoms db :aevt attr) first :e)
396
- *
397
- * ; find N entities with lowest attr value (e.g. 10 earliest posts)
398
- * (->> (datoms db :avet attr) (take N))
399
- *
400
- * ; find N entities with highest attr value (e.g. 10 latest posts)
401
- * (->> (datoms db :avet attr) (reverse) (take N))
402
- *
403
- * Gotchas:
404
- *
405
- * - Index lookup is usually more efficient than doing a query with a single clause.
406
- * - Resulting iterator is calculated in constant time and small constant memory overhead.
407
- * - Iterator supports efficient `first`, `next`, `reverse`, `seq` and is itself a sequence.
408
- * - Will not return datoms that are not part of the index (e.g. attributes with no `:db/index` in schema when querying `:avet` index).
409
- * - `:eavt` and `:aevt` contain all datoms.
410
- * - `:avet` only contains datoms for references, `:db/unique` and `:db/index` attributes.
411
- */
412
- datascript.core.datoms = (function datascript$core$datoms(var_args){
413
- var G__15105 = arguments.length;
414
- switch (G__15105) {
415
- case 2:
416
- return datascript.core.datoms.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
417
-
418
- break;
419
- case 3:
420
- return datascript.core.datoms.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
421
-
422
- break;
423
- case 4:
424
- return datascript.core.datoms.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
425
-
426
- break;
427
- case 5:
428
- return datascript.core.datoms.cljs$core$IFn$_invoke$arity$5((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]),(arguments[(4)]));
429
-
430
- break;
431
- case 6:
432
- return datascript.core.datoms.cljs$core$IFn$_invoke$arity$6((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]),(arguments[(4)]),(arguments[(5)]));
433
-
434
- break;
435
- default:
436
- throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
437
-
438
- }
439
- });
440
-
441
- (datascript.core.datoms.cljs$core$IFn$_invoke$arity$2 = (function (db,index){
442
- if(datascript.db.db_QMARK_(db)){
443
- } else {
444
- throw (new Error("Assert failed: (db/db? db)"));
445
- }
446
-
447
- return datascript.db._datoms(db,index,null,null,null,null);
448
- }));
449
-
450
- (datascript.core.datoms.cljs$core$IFn$_invoke$arity$3 = (function (db,index,c0){
451
- if(datascript.db.db_QMARK_(db)){
452
- } else {
453
- throw (new Error("Assert failed: (db/db? db)"));
454
- }
455
-
456
- return datascript.db._datoms(db,index,c0,null,null,null);
457
- }));
458
-
459
- (datascript.core.datoms.cljs$core$IFn$_invoke$arity$4 = (function (db,index,c0,c1){
460
- if(datascript.db.db_QMARK_(db)){
461
- } else {
462
- throw (new Error("Assert failed: (db/db? db)"));
463
- }
464
-
465
- return datascript.db._datoms(db,index,c0,c1,null,null);
466
- }));
467
-
468
- (datascript.core.datoms.cljs$core$IFn$_invoke$arity$5 = (function (db,index,c0,c1,c2){
469
- if(datascript.db.db_QMARK_(db)){
470
- } else {
471
- throw (new Error("Assert failed: (db/db? db)"));
472
- }
473
-
474
- return datascript.db._datoms(db,index,c0,c1,c2,null);
475
- }));
476
-
477
- (datascript.core.datoms.cljs$core$IFn$_invoke$arity$6 = (function (db,index,c0,c1,c2,c3){
478
- if(datascript.db.db_QMARK_(db)){
479
- } else {
480
- throw (new Error("Assert failed: (db/db? db)"));
481
- }
482
-
483
- return datascript.db._datoms(db,index,c0,c1,c2,c3);
484
- }));
485
-
486
- (datascript.core.datoms.cljs$lang$maxFixedArity = 6);
487
-
488
- /**
489
- * Same as [[datoms]], but only returns single datom. Faster than `(first (datoms ...))`
490
- */
491
- datascript.core.find_datom = (function datascript$core$find_datom(var_args){
492
- var G__15133 = arguments.length;
493
- switch (G__15133) {
494
- case 2:
495
- return datascript.core.find_datom.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
496
-
497
- break;
498
- case 3:
499
- return datascript.core.find_datom.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
500
-
501
- break;
502
- case 4:
503
- return datascript.core.find_datom.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
504
-
505
- break;
506
- case 5:
507
- return datascript.core.find_datom.cljs$core$IFn$_invoke$arity$5((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]),(arguments[(4)]));
508
-
509
- break;
510
- case 6:
511
- return datascript.core.find_datom.cljs$core$IFn$_invoke$arity$6((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]),(arguments[(4)]),(arguments[(5)]));
512
-
513
- break;
514
- default:
515
- throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
516
-
517
- }
518
- });
519
-
520
- (datascript.core.find_datom.cljs$core$IFn$_invoke$arity$2 = (function (db,index){
521
- if(datascript.db.db_QMARK_(db)){
522
- } else {
523
- throw (new Error("Assert failed: (db/db? db)"));
524
- }
525
-
526
- return datascript.db.find_datom(db,index,null,null,null,null);
527
- }));
528
-
529
- (datascript.core.find_datom.cljs$core$IFn$_invoke$arity$3 = (function (db,index,c0){
530
- if(datascript.db.db_QMARK_(db)){
531
- } else {
532
- throw (new Error("Assert failed: (db/db? db)"));
533
- }
534
-
535
- return datascript.db.find_datom(db,index,c0,null,null,null);
536
- }));
537
-
538
- (datascript.core.find_datom.cljs$core$IFn$_invoke$arity$4 = (function (db,index,c0,c1){
539
- if(datascript.db.db_QMARK_(db)){
540
- } else {
541
- throw (new Error("Assert failed: (db/db? db)"));
542
- }
543
-
544
- return datascript.db.find_datom(db,index,c0,c1,null,null);
545
- }));
546
-
547
- (datascript.core.find_datom.cljs$core$IFn$_invoke$arity$5 = (function (db,index,c0,c1,c2){
548
- if(datascript.db.db_QMARK_(db)){
549
- } else {
550
- throw (new Error("Assert failed: (db/db? db)"));
551
- }
552
-
553
- return datascript.db.find_datom(db,index,c0,c1,c2,null);
554
- }));
555
-
556
- (datascript.core.find_datom.cljs$core$IFn$_invoke$arity$6 = (function (db,index,c0,c1,c2,c3){
557
- if(datascript.db.db_QMARK_(db)){
558
- } else {
559
- throw (new Error("Assert failed: (db/db? db)"));
560
- }
561
-
562
- return datascript.db.find_datom(db,index,c0,c1,c2,c3);
563
- }));
564
-
565
- (datascript.core.find_datom.cljs$lang$maxFixedArity = 6);
566
-
567
- /**
568
- * Similar to [[datoms]], but will return datoms starting from specified components and including rest of the database until the end of the index.
569
- *
570
- * If no datom matches passed arguments exactly, iterator will start from first datom that could be considered “greater” in index order.
571
- *
572
- * Usage:
573
- *
574
- * (seek-datoms db :eavt 1)
575
- * ; => (#datascript/Datom [1 :friends 2]
576
- * ; #datascript/Datom [1 :likes "fries"]
577
- * ; #datascript/Datom [1 :likes "pizza"]
578
- * ; #datascript/Datom [1 :name "Ivan"]
579
- * ; #datascript/Datom [2 :likes "candy"]
580
- * ; #datascript/Datom [2 :likes "pie"]
581
- * ; #datascript/Datom [2 :likes "pizza"])
582
- *
583
- * (seek-datoms db :eavt 1 :name)
584
- * ; => (#datascript/Datom [1 :name "Ivan"]
585
- * ; #datascript/Datom [2 :likes "candy"]
586
- * ; #datascript/Datom [2 :likes "pie"]
587
- * ; #datascript/Datom [2 :likes "pizza"])
588
- *
589
- * (seek-datoms db :eavt 2)
590
- * ; => (#datascript/Datom [2 :likes "candy"]
591
- * ; #datascript/Datom [2 :likes "pie"]
592
- * ; #datascript/Datom [2 :likes "pizza"])
593
- *
594
- * ; no datom [2 :likes "fish"], so starts with one immediately following such in index
595
- * (seek-datoms db :eavt 2 :likes "fish")
596
- * ; => (#datascript/Datom [2 :likes "pie"]
597
- * ; #datascript/Datom [2 :likes "pizza"])
598
- */
599
- datascript.core.seek_datoms = (function datascript$core$seek_datoms(var_args){
600
- var G__15136 = arguments.length;
601
- switch (G__15136) {
602
- case 2:
603
- return datascript.core.seek_datoms.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
604
-
605
- break;
606
- case 3:
607
- return datascript.core.seek_datoms.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
608
-
609
- break;
610
- case 4:
611
- return datascript.core.seek_datoms.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
612
-
613
- break;
614
- case 5:
615
- return datascript.core.seek_datoms.cljs$core$IFn$_invoke$arity$5((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]),(arguments[(4)]));
616
-
617
- break;
618
- case 6:
619
- return datascript.core.seek_datoms.cljs$core$IFn$_invoke$arity$6((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]),(arguments[(4)]),(arguments[(5)]));
620
-
621
- break;
622
- default:
623
- throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
624
-
625
- }
626
- });
627
-
628
- (datascript.core.seek_datoms.cljs$core$IFn$_invoke$arity$2 = (function (db,index){
629
- if(datascript.db.db_QMARK_(db)){
630
- } else {
631
- throw (new Error("Assert failed: (db/db? db)"));
632
- }
633
-
634
- return datascript.db._seek_datoms(db,index,null,null,null,null);
635
- }));
636
-
637
- (datascript.core.seek_datoms.cljs$core$IFn$_invoke$arity$3 = (function (db,index,c0){
638
- if(datascript.db.db_QMARK_(db)){
639
- } else {
640
- throw (new Error("Assert failed: (db/db? db)"));
641
- }
642
-
643
- return datascript.db._seek_datoms(db,index,c0,null,null,null);
644
- }));
645
-
646
- (datascript.core.seek_datoms.cljs$core$IFn$_invoke$arity$4 = (function (db,index,c0,c1){
647
- if(datascript.db.db_QMARK_(db)){
648
- } else {
649
- throw (new Error("Assert failed: (db/db? db)"));
650
- }
651
-
652
- return datascript.db._seek_datoms(db,index,c0,c1,null,null);
653
- }));
654
-
655
- (datascript.core.seek_datoms.cljs$core$IFn$_invoke$arity$5 = (function (db,index,c0,c1,c2){
656
- if(datascript.db.db_QMARK_(db)){
657
- } else {
658
- throw (new Error("Assert failed: (db/db? db)"));
659
- }
660
-
661
- return datascript.db._seek_datoms(db,index,c0,c1,c2,null);
662
- }));
663
-
664
- (datascript.core.seek_datoms.cljs$core$IFn$_invoke$arity$6 = (function (db,index,c0,c1,c2,c3){
665
- if(datascript.db.db_QMARK_(db)){
666
- } else {
667
- throw (new Error("Assert failed: (db/db? db)"));
668
- }
669
-
670
- return datascript.db._seek_datoms(db,index,c0,c1,c2,c3);
671
- }));
672
-
673
- (datascript.core.seek_datoms.cljs$lang$maxFixedArity = 6);
674
-
675
- /**
676
- * Same as [[seek-datoms]], but goes backwards until the beginning of the index.
677
- */
678
- datascript.core.rseek_datoms = (function datascript$core$rseek_datoms(var_args){
679
- var G__15139 = arguments.length;
680
- switch (G__15139) {
681
- case 2:
682
- return datascript.core.rseek_datoms.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
683
-
684
- break;
685
- case 3:
686
- return datascript.core.rseek_datoms.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
687
-
688
- break;
689
- case 4:
690
- return datascript.core.rseek_datoms.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
691
-
692
- break;
693
- case 5:
694
- return datascript.core.rseek_datoms.cljs$core$IFn$_invoke$arity$5((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]),(arguments[(4)]));
695
-
696
- break;
697
- case 6:
698
- return datascript.core.rseek_datoms.cljs$core$IFn$_invoke$arity$6((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]),(arguments[(4)]),(arguments[(5)]));
699
-
700
- break;
701
- default:
702
- throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
703
-
704
- }
705
- });
706
-
707
- (datascript.core.rseek_datoms.cljs$core$IFn$_invoke$arity$2 = (function (db,index){
708
- if(datascript.db.db_QMARK_(db)){
709
- } else {
710
- throw (new Error("Assert failed: (db/db? db)"));
711
- }
712
-
713
- return datascript.db._rseek_datoms(db,index,null,null,null,null);
714
- }));
715
-
716
- (datascript.core.rseek_datoms.cljs$core$IFn$_invoke$arity$3 = (function (db,index,c0){
717
- if(datascript.db.db_QMARK_(db)){
718
- } else {
719
- throw (new Error("Assert failed: (db/db? db)"));
720
- }
721
-
722
- return datascript.db._rseek_datoms(db,index,c0,null,null,null);
723
- }));
724
-
725
- (datascript.core.rseek_datoms.cljs$core$IFn$_invoke$arity$4 = (function (db,index,c0,c1){
726
- if(datascript.db.db_QMARK_(db)){
727
- } else {
728
- throw (new Error("Assert failed: (db/db? db)"));
729
- }
730
-
731
- return datascript.db._rseek_datoms(db,index,c0,c1,null,null);
732
- }));
733
-
734
- (datascript.core.rseek_datoms.cljs$core$IFn$_invoke$arity$5 = (function (db,index,c0,c1,c2){
735
- if(datascript.db.db_QMARK_(db)){
736
- } else {
737
- throw (new Error("Assert failed: (db/db? db)"));
738
- }
739
-
740
- return datascript.db._rseek_datoms(db,index,c0,c1,c2,null);
741
- }));
742
-
743
- (datascript.core.rseek_datoms.cljs$core$IFn$_invoke$arity$6 = (function (db,index,c0,c1,c2,c3){
744
- if(datascript.db.db_QMARK_(db)){
745
- } else {
746
- throw (new Error("Assert failed: (db/db? db)"));
747
- }
748
-
749
- return datascript.db._rseek_datoms(db,index,c0,c1,c2,c3);
750
- }));
751
-
752
- (datascript.core.rseek_datoms.cljs$lang$maxFixedArity = 6);
753
-
754
- /**
755
- * Returns part of `:avet` index between `[_ attr start]` and `[_ attr end]` in AVET sort order.
756
- *
757
- * Same properties as [[datoms]].
758
- *
759
- * `attr` must be a reference, unique attribute or marked as `:db/index true`.
760
- *
761
- * Usage:
762
- *
763
- * (index-range db :likes "a" "zzzzzzzzz")
764
- * ; => (#datascript/Datom [2 :likes "candy"]
765
- * ; #datascript/Datom [1 :likes "fries"]
766
- * ; #datascript/Datom [2 :likes "pie"]
767
- * ; #datascript/Datom [1 :likes "pizza"]
768
- * ; #datascript/Datom [2 :likes "pizza"])
769
- *
770
- * (index-range db :likes "egg" "pineapple")
771
- * ; => (#datascript/Datom [1 :likes "fries"]
772
- * ; #datascript/Datom [2 :likes "pie"])
773
- *
774
- * Useful patterns:
775
- *
776
- * ; find all entities with age in a specific range (inclusive)
777
- * (->> (index-range db :age 18 60) (map :e))
778
- */
779
- datascript.core.index_range = (function datascript$core$index_range(db,attr,start,end){
780
- if(datascript.db.db_QMARK_(db)){
781
- } else {
782
- throw (new Error("Assert failed: (db/db? db)"));
783
- }
784
-
785
- return datascript.db._index_range(db,attr,start,end);
786
- });
787
- /**
788
- * Returns `true` if this is a connection to a DataScript db, `false` otherwise.
789
- */
790
- datascript.core.conn_QMARK_ = datascript.conn.conn_QMARK_;
791
- /**
792
- * Creates a mutable reference to a given immutable database. See [[create-conn]].
793
- */
794
- datascript.core.conn_from_db = datascript.conn.conn_from_db;
795
- /**
796
- * Creates an empty DB and a mutable reference to it. See [[create-conn]].
797
- */
798
- datascript.core.conn_from_datoms = datascript.conn.conn_from_datoms;
799
- /**
800
- * Creates a mutable reference (a “connection”) to an empty immutable database.
801
- *
802
- * Connections are lightweight in-memory structures (~atoms) with direct support of transaction listeners ([[listen!]], [[unlisten!]]) and other handy DataScript APIs ([[transact!]], [[reset-conn!]], [[db]]).
803
- *
804
- * To access underlying immutable DB value, deref: `@conn`.
805
- *
806
- * For list of options, see [[empty-db]].
807
- *
808
- * If you specify `:storage` option, conn will be stored automatically after each transaction
809
- */
810
- datascript.core.create_conn = datascript.conn.create_conn;
811
- /**
812
- * Applies transaction the underlying database value and atomically updates connection reference to point to the result of that transaction, new db value.
813
- *
814
- * Returns transaction report, a map:
815
- *
816
- * { :db-before ... ; db value before transaction
817
- * :db-after ... ; db value after transaction
818
- * :tx-data [...] ; plain datoms that were added/retracted from db-before
819
- * :tempids {...} ; map of tempid from tx-data => assigned entid in db-after
820
- * :tx-meta tx-meta } ; the exact value you passed as `tx-meta`
821
- *
822
- * Note! `conn` will be updated in-place and is not returned from [[transact!]].
823
- *
824
- * Usage:
825
- *
826
- * ; add a single datom to an existing entity (1)
827
- * (transact! conn [[:db/add 1 :name "Ivan"]])
828
- *
829
- * ; retract a single datom
830
- * (transact! conn [[:db/retract 1 :name "Ivan"]])
831
- *
832
- * ; retract single entity attribute
833
- * (transact! conn [[:db.fn/retractAttribute 1 :name]])
834
- *
835
- * ; ... or equivalently (since Datomic changed its API to support this):
836
- * (transact! conn [[:db/retract 1 :name]])
837
- *
838
- * ; retract all entity attributes (effectively deletes entity)
839
- * (transact! conn [[:db.fn/retractEntity 1]])
840
- *
841
- * ; create a new entity (`-1`, as any other negative value, is a tempid
842
- * ; that will be replaced with DataScript to a next unused eid)
843
- * (transact! conn [[:db/add -1 :name "Ivan"]])
844
- *
845
- * ; check assigned id (here `*1` is a result returned from previous `transact!` call)
846
- * (def report *1)
847
- * (:tempids report) ; => {-1 296}
848
- *
849
- * ; check actual datoms inserted
850
- * (:tx-data report) ; => [#datascript/Datom [296 :name "Ivan"]]
851
- *
852
- * ; tempid can also be a string
853
- * (transact! conn [[:db/add "ivan" :name "Ivan"]])
854
- * (:tempids *1) ; => {"ivan" 297}
855
- *
856
- * ; reference another entity (must exist)
857
- * (transact! conn [[:db/add -1 :friend 296]])
858
- *
859
- * ; create an entity and set multiple attributes (in a single transaction
860
- * ; equal tempids will be replaced with the same yet unused entid)
861
- * (transact! conn [[:db/add -1 :name "Ivan"]
862
- * [:db/add -1 :likes "fries"]
863
- * [:db/add -1 :likes "pizza"]
864
- * [:db/add -1 :friend 296]])
865
- *
866
- * ; create an entity and set multiple attributes (alternative map form)
867
- * (transact! conn [{:db/id -1
868
- * :name "Ivan"
869
- * :likes ["fries" "pizza"]
870
- * :friend 296}])
871
- *
872
- * ; update an entity (alternative map form). Can’t retract attributes in
873
- * ; map form. For cardinality many attrs, value (fish in this example)
874
- * ; will be added to the list of existing values
875
- * (transact! conn [{:db/id 296
876
- * :name "Oleg"
877
- * :likes ["fish"]}])
878
- *
879
- * ; ref attributes can be specified as nested map, that will create nested entity as well
880
- * (transact! conn [{:db/id -1
881
- * :name "Oleg"
882
- * :friend {:db/id -2
883
- * :name "Sergey"}}])
884
- *
885
- * ; reverse attribute name can be used if you want created entity to become
886
- * ; a value in another entity reference
887
- * (transact! conn [{:db/id -1
888
- * :name "Oleg"
889
- * :_friend 296}])
890
- * ; equivalent to
891
- * (transact! conn [{:db/id -1, :name "Oleg"}
892
- * {:db/id 296, :friend -1}])
893
- * ; equivalent to
894
- * (transact! conn [[:db/add -1 :name "Oleg"]
895
- * [:db/add 296 :friend -1]])
896
- */
897
- datascript.core.transact_BANG_ = datascript.conn.transact_BANG_;
898
- /**
899
- * Forces underlying `conn` value to become `db`. Will generate a tx-report that will remove everything from old value and insert everything from the new one.
900
- */
901
- datascript.core.reset_conn_BANG_ = datascript.conn.reset_conn_BANG_;
902
- datascript.core.reset_schema_BANG_ = datascript.conn.reset_schema_BANG_;
903
- /**
904
- * Listen for changes on the given connection. Whenever a transaction is applied to the database via [[transact!]], the callback is called
905
- * with the transaction report. `key` is any opaque unique value.
906
- *
907
- * Idempotent. Calling [[listen!]] with the same key twice will override old callback with the new value.
908
- *
909
- * Returns the key under which this listener is registered. See also [[unlisten!]].
910
- */
911
- datascript.core.listen_BANG_ = datascript.conn.listen_BANG_;
912
- /**
913
- * Removes registered listener from connection. See also [[listen!]].
914
- */
915
- datascript.core.unlisten_BANG_ = datascript.conn.unlisten_BANG_;
916
- /**
917
- * Data readers for EDN readers. In CLJS they’re registered automatically. In CLJ, if `data_readers.clj` do not work, you can always do
918
- *
919
- * ```
920
- * (clojure.edn/read-string {:readers data-readers} "...")
921
- * ```
922
- */
923
- datascript.core.data_readers = new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Symbol("datascript","Datom","datascript/Datom",-901340080,null),datascript.db.datom_from_reader,new cljs.core.Symbol("datascript","DB","datascript/DB",-487332776,null),datascript.db.db_from_reader], null);
924
- var seq__15148_15240 = cljs.core.seq(datascript.core.data_readers);
925
- var chunk__15149_15241 = null;
926
- var count__15150_15242 = (0);
927
- var i__15151_15243 = (0);
928
- while(true){
929
- if((i__15151_15243 < count__15150_15242)){
930
- var vec__15169_15244 = chunk__15149_15241.cljs$core$IIndexed$_nth$arity$2(null,i__15151_15243);
931
- var tag_15245 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__15169_15244,(0),null);
932
- var cb_15246 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__15169_15244,(1),null);
933
- cljs.reader.register_tag_parser_BANG_(tag_15245,cb_15246);
934
-
935
-
936
- var G__15247 = seq__15148_15240;
937
- var G__15248 = chunk__15149_15241;
938
- var G__15249 = count__15150_15242;
939
- var G__15250 = (i__15151_15243 + (1));
940
- seq__15148_15240 = G__15247;
941
- chunk__15149_15241 = G__15248;
942
- count__15150_15242 = G__15249;
943
- i__15151_15243 = G__15250;
944
- continue;
945
- } else {
946
- var temp__5804__auto___15251 = cljs.core.seq(seq__15148_15240);
947
- if(temp__5804__auto___15251){
948
- var seq__15148_15252__$1 = temp__5804__auto___15251;
949
- if(cljs.core.chunked_seq_QMARK_(seq__15148_15252__$1)){
950
- var c__5525__auto___15253 = cljs.core.chunk_first(seq__15148_15252__$1);
951
- var G__15254 = cljs.core.chunk_rest(seq__15148_15252__$1);
952
- var G__15255 = c__5525__auto___15253;
953
- var G__15256 = cljs.core.count(c__5525__auto___15253);
954
- var G__15257 = (0);
955
- seq__15148_15240 = G__15254;
956
- chunk__15149_15241 = G__15255;
957
- count__15150_15242 = G__15256;
958
- i__15151_15243 = G__15257;
959
- continue;
960
- } else {
961
- var vec__15179_15261 = cljs.core.first(seq__15148_15252__$1);
962
- var tag_15262 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__15179_15261,(0),null);
963
- var cb_15263 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__15179_15261,(1),null);
964
- cljs.reader.register_tag_parser_BANG_(tag_15262,cb_15263);
965
-
966
-
967
- var G__15267 = cljs.core.next(seq__15148_15252__$1);
968
- var G__15268 = null;
969
- var G__15269 = (0);
970
- var G__15270 = (0);
971
- seq__15148_15240 = G__15267;
972
- chunk__15149_15241 = G__15268;
973
- count__15150_15242 = G__15269;
974
- i__15151_15243 = G__15270;
975
- continue;
976
- }
977
- } else {
978
- }
979
- }
980
- break;
981
- }
982
- datascript.core.last_tempid = cljs.core.atom.cljs$core$IFn$_invoke$arity$1((-1000000));
983
- /**
984
- * Allocates and returns an unique temporary id (a negative integer). Ignores `part`. Returns `x` if it is specified.
985
- *
986
- * Exists for Datomic API compatibility. Prefer using negative integers directly if possible.
987
- */
988
- datascript.core.tempid = (function datascript$core$tempid(var_args){
989
- var G__15183 = arguments.length;
990
- switch (G__15183) {
991
- case 1:
992
- return datascript.core.tempid.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
993
-
994
- break;
995
- case 2:
996
- return datascript.core.tempid.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
997
-
998
- break;
999
- default:
1000
- throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
1001
-
1002
- }
1003
- });
1004
-
1005
- (datascript.core.tempid.cljs$core$IFn$_invoke$arity$1 = (function (part){
1006
- if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(part,new cljs.core.Keyword("db.part","tx","db.part/tx",-1480923213))){
1007
- return new cljs.core.Keyword("db","current-tx","db/current-tx",1600722132);
1008
- } else {
1009
- return cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$2(datascript.core.last_tempid,cljs.core.dec);
1010
- }
1011
- }));
1012
-
1013
- (datascript.core.tempid.cljs$core$IFn$_invoke$arity$2 = (function (part,x){
1014
- if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(part,new cljs.core.Keyword("db.part","tx","db.part/tx",-1480923213))){
1015
- return new cljs.core.Keyword("db","current-tx","db/current-tx",1600722132);
1016
- } else {
1017
- return x;
1018
- }
1019
- }));
1020
-
1021
- (datascript.core.tempid.cljs$lang$maxFixedArity = 2);
1022
-
1023
- /**
1024
- * Does a lookup in tempids map, returning an entity id that tempid was resolved to.
1025
- *
1026
- * Exists for Datomic API compatibility. Prefer using map lookup directly if possible.
1027
- */
1028
- datascript.core.resolve_tempid = (function datascript$core$resolve_tempid(_db,tempids,tempid){
1029
- return cljs.core.get.cljs$core$IFn$_invoke$arity$2(tempids,tempid);
1030
- });
1031
- /**
1032
- * Returns the underlying immutable database value from a connection.
1033
- *
1034
- * Exists for Datomic API compatibility. Prefer using `@conn` directly if possible.
1035
- */
1036
- datascript.core.db = (function datascript$core$db(conn){
1037
- if(cljs.core.truth_((datascript.core.conn_QMARK_.cljs$core$IFn$_invoke$arity$1 ? datascript.core.conn_QMARK_.cljs$core$IFn$_invoke$arity$1(conn) : datascript.core.conn_QMARK_.call(null,conn)))){
1038
- } else {
1039
- throw (new Error("Assert failed: (conn? conn)"));
1040
- }
1041
-
1042
- return cljs.core.deref(conn);
1043
- });
1044
-
1045
- /**
1046
- * @constructor
1047
- * @implements {cljs.core.IDerefWithTimeout}
1048
- * @implements {cljs.core.IPending}
1049
- * @implements {cljs.core.IMeta}
1050
- * @implements {cljs.core.IDeref}
1051
- * @implements {cljs.core.IWithMeta}
1052
- */
1053
- datascript.core.t_datascript$core15189 = (function (conn,tx_data,tx_meta,res,meta15190){
1054
- this.conn = conn;
1055
- this.tx_data = tx_data;
1056
- this.tx_meta = tx_meta;
1057
- this.res = res;
1058
- this.meta15190 = meta15190;
1059
- this.cljs$lang$protocol_mask$partition0$ = 491520;
1060
- this.cljs$lang$protocol_mask$partition1$ = 1;
1061
- });
1062
- (datascript.core.t_datascript$core15189.prototype.cljs$core$IWithMeta$_with_meta$arity$2 = (function (_15191,meta15190__$1){
1063
- var self__ = this;
1064
- var _15191__$1 = this;
1065
- return (new datascript.core.t_datascript$core15189(self__.conn,self__.tx_data,self__.tx_meta,self__.res,meta15190__$1));
1066
- }));
1067
-
1068
- (datascript.core.t_datascript$core15189.prototype.cljs$core$IMeta$_meta$arity$1 = (function (_15191){
1069
- var self__ = this;
1070
- var _15191__$1 = this;
1071
- return self__.meta15190;
1072
- }));
1073
-
1074
- (datascript.core.t_datascript$core15189.prototype.cljs$core$IDeref$_deref$arity$1 = (function (_){
1075
- var self__ = this;
1076
- var ___$1 = this;
1077
- return self__.res;
1078
- }));
1079
-
1080
- (datascript.core.t_datascript$core15189.prototype.cljs$core$IDerefWithTimeout$_deref_with_timeout$arity$3 = (function (_,___$1,___$2){
1081
- var self__ = this;
1082
- var ___$3 = this;
1083
- return self__.res;
1084
- }));
1085
-
1086
- (datascript.core.t_datascript$core15189.prototype.cljs$core$IPending$_realized_QMARK_$arity$1 = (function (_){
1087
- var self__ = this;
1088
- var ___$1 = this;
1089
- return true;
1090
- }));
1091
-
1092
- (datascript.core.t_datascript$core15189.getBasis = (function (){
1093
- return new cljs.core.PersistentVector(null, 5, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"conn","conn",1918841190,null),new cljs.core.Symbol(null,"tx-data","tx-data",-1720276008,null),new cljs.core.Symbol(null,"tx-meta","tx-meta",-1495152575,null),new cljs.core.Symbol(null,"res","res",245523648,null),new cljs.core.Symbol(null,"meta15190","meta15190",-808423817,null)], null);
1094
- }));
1095
-
1096
- (datascript.core.t_datascript$core15189.cljs$lang$type = true);
1097
-
1098
- (datascript.core.t_datascript$core15189.cljs$lang$ctorStr = "datascript.core/t_datascript$core15189");
1099
-
1100
- (datascript.core.t_datascript$core15189.cljs$lang$ctorPrWriter = (function (this__5287__auto__,writer__5288__auto__,opt__5289__auto__){
1101
- return cljs.core._write(writer__5288__auto__,"datascript.core/t_datascript$core15189");
1102
- }));
1103
-
1104
- /**
1105
- * Positional factory function for datascript.core/t_datascript$core15189.
1106
- */
1107
- datascript.core.__GT_t_datascript$core15189 = (function datascript$core$__GT_t_datascript$core15189(conn,tx_data,tx_meta,res,meta15190){
1108
- return (new datascript.core.t_datascript$core15189(conn,tx_data,tx_meta,res,meta15190));
1109
- });
1110
-
1111
-
1112
- /**
1113
- * Same as [[transact!]], but returns an immediately realized future.
1114
- *
1115
- * Exists for Datomic API compatibility. Prefer using [[transact!]] if possible.
1116
- */
1117
- datascript.core.transact = (function datascript$core$transact(var_args){
1118
- var G__15187 = arguments.length;
1119
- switch (G__15187) {
1120
- case 2:
1121
- return datascript.core.transact.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
1122
-
1123
- break;
1124
- case 3:
1125
- return datascript.core.transact.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
1126
-
1127
- break;
1128
- default:
1129
- throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
1130
-
1131
- }
1132
- });
1133
-
1134
- (datascript.core.transact.cljs$core$IFn$_invoke$arity$2 = (function (conn,tx_data){
1135
- return datascript.core.transact.cljs$core$IFn$_invoke$arity$3(conn,tx_data,null);
1136
- }));
1137
-
1138
- (datascript.core.transact.cljs$core$IFn$_invoke$arity$3 = (function (conn,tx_data,tx_meta){
1139
- if(cljs.core.truth_((datascript.core.conn_QMARK_.cljs$core$IFn$_invoke$arity$1 ? datascript.core.conn_QMARK_.cljs$core$IFn$_invoke$arity$1(conn) : datascript.core.conn_QMARK_.call(null,conn)))){
1140
- } else {
1141
- throw (new Error("Assert failed: (conn? conn)"));
1142
- }
1143
-
1144
- var res = (datascript.core.transact_BANG_.cljs$core$IFn$_invoke$arity$3 ? datascript.core.transact_BANG_.cljs$core$IFn$_invoke$arity$3(conn,tx_data,tx_meta) : datascript.core.transact_BANG_.call(null,conn,tx_data,tx_meta));
1145
- return (new datascript.core.t_datascript$core15189(conn,tx_data,tx_meta,res,cljs.core.PersistentArrayMap.EMPTY));
1146
- }));
1147
-
1148
- (datascript.core.transact.cljs$lang$maxFixedArity = 3);
1149
-
1150
-
1151
- /**
1152
- * @constructor
1153
- * @implements {cljs.core.IDerefWithTimeout}
1154
- * @implements {cljs.core.IPending}
1155
- * @implements {cljs.core.IMeta}
1156
- * @implements {cljs.core.IDeref}
1157
- * @implements {cljs.core.IWithMeta}
1158
- */
1159
- datascript.core.t_datascript$core15193 = (function (f,res,realized,meta15194){
1160
- this.f = f;
1161
- this.res = res;
1162
- this.realized = realized;
1163
- this.meta15194 = meta15194;
1164
- this.cljs$lang$protocol_mask$partition0$ = 491520;
1165
- this.cljs$lang$protocol_mask$partition1$ = 1;
1166
- });
1167
- (datascript.core.t_datascript$core15193.prototype.cljs$core$IWithMeta$_with_meta$arity$2 = (function (_15195,meta15194__$1){
1168
- var self__ = this;
1169
- var _15195__$1 = this;
1170
- return (new datascript.core.t_datascript$core15193(self__.f,self__.res,self__.realized,meta15194__$1));
1171
- }));
1172
-
1173
- (datascript.core.t_datascript$core15193.prototype.cljs$core$IMeta$_meta$arity$1 = (function (_15195){
1174
- var self__ = this;
1175
- var _15195__$1 = this;
1176
- return self__.meta15194;
1177
- }));
1178
-
1179
- (datascript.core.t_datascript$core15193.prototype.cljs$core$IDeref$_deref$arity$1 = (function (_){
1180
- var self__ = this;
1181
- var ___$1 = this;
1182
- return cljs.core.deref(self__.res);
1183
- }));
1184
-
1185
- (datascript.core.t_datascript$core15193.prototype.cljs$core$IDerefWithTimeout$_deref_with_timeout$arity$3 = (function (_,___$1,timeout_val){
1186
- var self__ = this;
1187
- var ___$2 = this;
1188
- if(cljs.core.truth_(cljs.core.deref(self__.realized))){
1189
- return cljs.core.deref(self__.res);
1190
- } else {
1191
- return timeout_val;
1192
- }
1193
- }));
1194
-
1195
- (datascript.core.t_datascript$core15193.prototype.cljs$core$IPending$_realized_QMARK_$arity$1 = (function (_){
1196
- var self__ = this;
1197
- var ___$1 = this;
1198
- return cljs.core.deref(self__.realized);
1199
- }));
1200
-
1201
- (datascript.core.t_datascript$core15193.getBasis = (function (){
1202
- return new cljs.core.PersistentVector(null, 4, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"f","f",43394975,null),new cljs.core.Symbol(null,"res","res",245523648,null),new cljs.core.Symbol(null,"realized","realized",1487343404,null),new cljs.core.Symbol(null,"meta15194","meta15194",-1352265001,null)], null);
1203
- }));
1204
-
1205
- (datascript.core.t_datascript$core15193.cljs$lang$type = true);
1206
-
1207
- (datascript.core.t_datascript$core15193.cljs$lang$ctorStr = "datascript.core/t_datascript$core15193");
1208
-
1209
- (datascript.core.t_datascript$core15193.cljs$lang$ctorPrWriter = (function (this__5287__auto__,writer__5288__auto__,opt__5289__auto__){
1210
- return cljs.core._write(writer__5288__auto__,"datascript.core/t_datascript$core15193");
1211
- }));
1212
-
1213
- /**
1214
- * Positional factory function for datascript.core/t_datascript$core15193.
1215
- */
1216
- datascript.core.__GT_t_datascript$core15193 = (function datascript$core$__GT_t_datascript$core15193(f,res,realized,meta15194){
1217
- return (new datascript.core.t_datascript$core15193(f,res,realized,meta15194));
1218
- });
1219
-
1220
-
1221
- datascript.core.future_call = (function datascript$core$future_call(f){
1222
- var res = cljs.core.atom.cljs$core$IFn$_invoke$arity$1(null);
1223
- var realized = cljs.core.atom.cljs$core$IFn$_invoke$arity$1(false);
1224
- setTimeout((function (){
1225
- cljs.core.reset_BANG_(res,(f.cljs$core$IFn$_invoke$arity$0 ? f.cljs$core$IFn$_invoke$arity$0() : f.call(null)));
1226
-
1227
- return cljs.core.reset_BANG_(realized,true);
1228
- }),(0));
1229
-
1230
- return (new datascript.core.t_datascript$core15193(f,res,realized,cljs.core.PersistentArrayMap.EMPTY));
1231
- });
1232
- /**
1233
- * In CLJ, calls [[transact!]] on a future thread pool, returning immediately.
1234
- *
1235
- * In CLJS, just calls [[transact!]] and returns a realized future.
1236
- */
1237
- datascript.core.transact_async = (function datascript$core$transact_async(var_args){
1238
- var G__15198 = arguments.length;
1239
- switch (G__15198) {
1240
- case 2:
1241
- return datascript.core.transact_async.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
1242
-
1243
- break;
1244
- case 3:
1245
- return datascript.core.transact_async.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
1246
-
1247
- break;
1248
- default:
1249
- throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
1250
-
1251
- }
1252
- });
1253
-
1254
- (datascript.core.transact_async.cljs$core$IFn$_invoke$arity$2 = (function (conn,tx_data){
1255
- return datascript.core.transact_async.cljs$core$IFn$_invoke$arity$3(conn,tx_data,null);
1256
- }));
1257
-
1258
- (datascript.core.transact_async.cljs$core$IFn$_invoke$arity$3 = (function (conn,tx_data,tx_meta){
1259
- if(cljs.core.truth_((datascript.core.conn_QMARK_.cljs$core$IFn$_invoke$arity$1 ? datascript.core.conn_QMARK_.cljs$core$IFn$_invoke$arity$1(conn) : datascript.core.conn_QMARK_.call(null,conn)))){
1260
- } else {
1261
- throw (new Error("Assert failed: (conn? conn)"));
1262
- }
1263
-
1264
- return datascript.core.future_call((function (){
1265
- return (datascript.core.transact_BANG_.cljs$core$IFn$_invoke$arity$3 ? datascript.core.transact_BANG_.cljs$core$IFn$_invoke$arity$3(conn,tx_data,tx_meta) : datascript.core.transact_BANG_.call(null,conn,tx_data,tx_meta));
1266
- }));
1267
- }));
1268
-
1269
- (datascript.core.transact_async.cljs$lang$maxFixedArity = 3);
1270
-
1271
- /**
1272
- * Generates a UUID that grow with time. Such UUIDs will always go to the end of the index and that will minimize insertions in the middle.
1273
- *
1274
- * Consist of 64 bits of current UNIX timestamp (in seconds) and 64 random bits (2^64 different unique values per second).
1275
- */
1276
- datascript.core.squuid = datascript.util.squuid;
1277
- /**
1278
- * Returns time that was used in [[squuid]] call, in milliseconds, rounded to the closest second.
1279
- */
1280
- datascript.core.squuid_time_millis = datascript.util.squuid_time_millis;
1281
- datascript.core.settings = (function datascript$core$settings(db){
1282
- return me.tonsky.persistent_sorted_set.settings(new cljs.core.Keyword(null,"eavt","eavt",-666437073).cljs$core$IFn$_invoke$arity$1(db));
1283
- });
1284
-
1285
- //# sourceMappingURL=datascript.core.js.map