@wovin/core 0.1.36 → 0.2.2
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 +0 -12
- package/dist/applog/applog-helpers.d.ts +12 -12
- package/dist/applog/applog-helpers.d.ts.map +1 -1
- package/dist/applog/applog-utils.d.ts +40 -6
- package/dist/applog/applog-utils.d.ts.map +1 -1
- package/dist/applog/datom-types.d.ts +67 -12
- package/dist/applog/datom-types.d.ts.map +1 -1
- package/dist/applog.d.ts +3 -3
- package/dist/applog.d.ts.map +1 -1
- package/dist/{applog.min.js → applog.js} +12 -7
- package/dist/blockstore.d.ts +1 -1
- package/dist/blockstore.d.ts.map +1 -1
- package/dist/{blockstore.min.js → blockstore.js} +1 -3
- package/dist/{blockstore.min.js.map → blockstore.js.map} +1 -1
- package/dist/chunk-22WDFLXO.js +138 -0
- package/dist/chunk-22WDFLXO.js.map +1 -0
- package/dist/chunk-3SUFNJEZ.js +1026 -0
- package/dist/chunk-3SUFNJEZ.js.map +1 -0
- package/dist/chunk-6ALNRM3J.js +435 -0
- package/dist/chunk-6ALNRM3J.js.map +1 -0
- package/dist/chunk-7Z5YDQKK.js +1 -0
- package/dist/{chunk-KXMTKPF4.min.js → chunk-BLF5MAWU.js} +8 -8
- package/dist/chunk-BLF5MAWU.js.map +1 -0
- package/dist/chunk-E46VTKTZ.js +1 -0
- package/dist/{chunk-H3VQJP56.min.js → chunk-HUIQ54TT.js} +9 -9
- package/dist/chunk-HUIQ54TT.js.map +1 -0
- package/dist/{chunk-BRC7LSM6.min.js → chunk-OC6Z6CQW.js} +5 -5
- package/dist/chunk-OC6Z6CQW.js.map +1 -0
- package/dist/chunk-SHUHRHOT.js +1923 -0
- package/dist/chunk-SHUHRHOT.js.map +1 -0
- package/dist/{chunk-QPGEBDMJ.min.js → chunk-YDAKBU6Q.js} +1 -1
- package/dist/chunk-YDAKBU6Q.js.map +1 -0
- package/dist/chunk-ZAADLBSB.js +36 -0
- package/dist/chunk-ZAADLBSB.js.map +1 -0
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/{index.min.js → index.js} +81 -46
- package/dist/ipfs/car.d.ts +11 -11
- package/dist/ipfs/car.d.ts.map +1 -1
- package/dist/ipfs/ipfs-utils.d.ts +2 -2
- package/dist/ipfs/ipfs-utils.d.ts.map +1 -1
- package/dist/ipfs.d.ts +3 -3
- package/dist/ipfs.d.ts.map +1 -1
- package/dist/{ipfs.min.js → ipfs.js} +7 -10
- package/dist/ipns.d.ts +1 -1
- package/dist/ipns.d.ts.map +1 -1
- package/dist/ipns.js +64 -0
- package/dist/ipns.js.map +1 -0
- package/dist/pubsub/pub-pull.d.ts +3 -3
- package/dist/pubsub/pub-pull.d.ts.map +1 -1
- package/dist/pubsub/pubsub-types.d.ts +3 -3
- package/dist/pubsub/pubsub-types.d.ts.map +1 -1
- package/dist/pubsub/snap-push.d.ts +4 -4
- package/dist/pubsub/snap-push.d.ts.map +1 -1
- package/dist/pubsub/ucan.d.ts +1 -1
- package/dist/pubsub/ucan.d.ts.map +1 -1
- package/dist/pubsub.d.ts +4 -4
- package/dist/pubsub.d.ts.map +1 -1
- package/dist/{pubsub.min.js → pubsub.js} +7 -10
- package/dist/query/attr-helpers.d.ts +5 -0
- package/dist/query/attr-helpers.d.ts.map +1 -0
- package/dist/query/basic.d.ts +87 -23
- package/dist/query/basic.d.ts.map +1 -1
- package/dist/query/divergences.d.ts +5 -5
- package/dist/query/divergences.d.ts.map +1 -1
- package/dist/query/entity-collection.d.ts +19 -0
- package/dist/query/entity-collection.d.ts.map +1 -0
- package/dist/query/matchers.d.ts +12 -1
- package/dist/query/matchers.d.ts.map +1 -1
- package/dist/query/memoized.d.ts +66 -0
- package/dist/query/memoized.d.ts.map +1 -0
- package/dist/query/situations.d.ts +2 -1
- package/dist/query/situations.d.ts.map +1 -1
- package/dist/query/subscribable.d.ts +111 -0
- package/dist/query/subscribable.d.ts.map +1 -0
- package/dist/query/types.d.ts +54 -14
- package/dist/query/types.d.ts.map +1 -1
- package/dist/query.d.ts +9 -5
- package/dist/query.d.ts.map +1 -1
- package/dist/{query.min.js → query.js} +55 -34
- package/dist/retrieve/index.d.ts +1 -1
- package/dist/retrieve/index.d.ts.map +1 -1
- package/dist/retrieve/update-thread.d.ts +3 -3
- package/dist/retrieve/update-thread.d.ts.map +1 -1
- package/dist/retrieve.d.ts +1 -1
- package/dist/retrieve.d.ts.map +1 -1
- package/dist/retrieve.js +14 -0
- package/dist/thread/basic.d.ts +15 -19
- package/dist/thread/basic.d.ts.map +1 -1
- package/dist/thread/filters.d.ts +8 -10
- package/dist/thread/filters.d.ts.map +1 -1
- package/dist/thread/indexes.d.ts +57 -0
- package/dist/thread/indexes.d.ts.map +1 -0
- package/dist/thread/mapped.d.ts +40 -11
- package/dist/thread/mapped.d.ts.map +1 -1
- package/dist/thread/utils.d.ts +5 -5
- package/dist/thread/utils.d.ts.map +1 -1
- package/dist/thread/writeable.d.ts +2 -2
- package/dist/thread/writeable.d.ts.map +1 -1
- package/dist/thread.d.ts +6 -5
- package/dist/thread.d.ts.map +1 -1
- package/dist/{thread.min.js → thread.js} +9 -6
- package/dist/types/typescript-utils.d.ts +6 -5
- package/dist/types/typescript-utils.d.ts.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/{types.min.js → types.js} +3 -4
- package/dist/utils/debug-name.d.ts +13 -0
- package/dist/utils/debug-name.d.ts.map +1 -0
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +9 -0
- package/package.json +32 -23
- package/src/applog/applog-helpers.ts +155 -0
- package/src/applog/applog-utils.test.ts +108 -0
- package/src/applog/applog-utils.ts +551 -0
- package/src/applog/datom-types.ts +167 -0
- package/src/applog/object-values.test.ts +106 -0
- package/src/applog.ts +3 -0
- package/src/blockstore/index.ts +36 -0
- package/src/blockstore.ts +1 -0
- package/src/index.ts +8 -0
- package/src/ipfs/car.ts +291 -0
- package/src/ipfs/fetch-snapshot-chain.ts +135 -0
- package/src/ipfs/ipfs-utils.ts +132 -0
- package/src/ipfs.ts +3 -0
- package/src/ipns/ipns-record.ts +115 -0
- package/src/ipns.ts +1 -0
- package/src/pubsub/UCAN Specs Overview.md +217 -0
- package/src/pubsub/connector.ts +9 -0
- package/src/pubsub/pub-pull.ts +31 -0
- package/src/pubsub/pubsub-types.ts +90 -0
- package/src/pubsub/snap-push.ts +278 -0
- package/src/pubsub/ucan-example.ts +61 -0
- package/src/pubsub/ucan.ts +56 -0
- package/src/pubsub.ts +4 -0
- package/src/query/attr-helpers.ts +5 -0
- package/src/query/basic.ts +1245 -0
- package/src/query/divergences.ts +50 -0
- package/src/query/entity-collection.ts +132 -0
- package/src/query/liveFilterAndMap.test.ts +102 -0
- package/src/query/matchers.ts +30 -0
- package/src/query/memoized.test.ts +151 -0
- package/src/query/memoized.ts +180 -0
- package/src/query/query-steps.ts +4 -0
- package/src/query/query.test.ts +538 -0
- package/src/query/situations.ts +261 -0
- package/src/query/subscribable.test.ts +245 -0
- package/src/query/subscribable.ts +234 -0
- package/src/query/types.ts +155 -0
- package/src/query/withoutDeleted.test.ts +204 -0
- package/src/query.ts +9 -0
- package/src/retrieve/index.ts +1 -0
- package/src/retrieve/update-thread.ts +248 -0
- package/src/retrieve.ts +1 -0
- package/src/test/perf/query.1m.perf.test.ts +94 -0
- package/src/test/perf/query.perf.test.ts +389 -0
- package/src/test/perf/query.realdata.perf.test.ts +182 -0
- package/src/thread/basic.ts +209 -0
- package/src/thread/filters.ts +227 -0
- package/src/thread/indexes.ts +256 -0
- package/src/thread/joinThreads.test.ts +304 -0
- package/src/thread/mapped.ts +226 -0
- package/src/thread/utils.ts +144 -0
- package/src/thread/writeable.ts +163 -0
- package/src/thread.ts +6 -0
- package/src/types/typescript-utils.ts +64 -0
- package/src/types.ts +1 -0
- package/src/utils/debug-name.ts +54 -0
- package/src/utils.ts +4 -0
- package/dist/chunk-2Y2PYHGR.min.js +0 -65
- package/dist/chunk-2Y2PYHGR.min.js.map +0 -1
- package/dist/chunk-5MMGBK2U.min.js +0 -1
- package/dist/chunk-7IDQIMQO.min.js +0 -1
- package/dist/chunk-BRC7LSM6.min.js.map +0 -1
- package/dist/chunk-COXXILXC.min.js +0 -512
- package/dist/chunk-COXXILXC.min.js.map +0 -1
- package/dist/chunk-GDX2OO7L.min.js +0 -9080
- package/dist/chunk-GDX2OO7L.min.js.map +0 -1
- package/dist/chunk-H3VQJP56.min.js.map +0 -1
- package/dist/chunk-HYMC7W6S.min.js +0 -1549
- package/dist/chunk-HYMC7W6S.min.js.map +0 -1
- package/dist/chunk-KEHU7HGZ.min.js +0 -5216
- package/dist/chunk-KEHU7HGZ.min.js.map +0 -1
- package/dist/chunk-KXMTKPF4.min.js.map +0 -1
- package/dist/chunk-PHITDXZT.min.js +0 -36
- package/dist/chunk-QO2KMGDN.min.js +0 -3771
- package/dist/chunk-QO2KMGDN.min.js.map +0 -1
- package/dist/chunk-QPGEBDMJ.min.js.map +0 -1
- package/dist/chunk-WXLCBTHX.min.js +0 -1606
- package/dist/chunk-WXLCBTHX.min.js.map +0 -1
- package/dist/ipns.min.js +0 -6419
- package/dist/ipns.min.js.map +0 -1
- package/dist/mobx/mobx-utils.d.ts +0 -82
- package/dist/mobx/mobx-utils.d.ts.map +0 -1
- package/dist/mobx.d.ts +0 -2
- package/dist/mobx.d.ts.map +0 -1
- package/dist/mobx.min.js +0 -141
- package/dist/retrieve.min.js +0 -17
- package/dist/types.min.js.map +0 -1
- package/dist/utils.min.js +0 -10
- package/dist/utils.min.js.map +0 -1
- /package/dist/{applog.min.js.map → applog.js.map} +0 -0
- /package/dist/{chunk-5MMGBK2U.min.js.map → chunk-7Z5YDQKK.js.map} +0 -0
- /package/dist/{chunk-7IDQIMQO.min.js.map → chunk-E46VTKTZ.js.map} +0 -0
- /package/dist/{chunk-PHITDXZT.min.js.map → index.js.map} +0 -0
- /package/dist/{index.min.js.map → ipfs.js.map} +0 -0
- /package/dist/{ipfs.min.js.map → pubsub.js.map} +0 -0
- /package/dist/{mobx.min.js.map → query.js.map} +0 -0
- /package/dist/{pubsub.min.js.map → retrieve.js.map} +0 -0
- /package/dist/{query.min.js.map → thread.js.map} +0 -0
- /package/dist/{retrieve.min.js.map → types.js.map} +0 -0
- /package/dist/{thread.min.js.map → utils.js.map} +0 -0
package/README.md
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
1
|
# @wovin/core
|
|
2
2
|
|
|
3
3
|
Core utilities and types for Wovin applications.
|
|
4
|
-
|
|
5
|
-
## MobX Configuration
|
|
6
|
-
|
|
7
|
-
This package configures MobX with strict mode enabled (`enforceActions: 'always'`). To use non-strict mode in your application, override the configuration after importing:
|
|
8
|
-
|
|
9
|
-
```typescript
|
|
10
|
-
import { configure } from '@wovin/core/mobx'
|
|
11
|
-
|
|
12
|
-
configure({
|
|
13
|
-
enforceActions: 'never'
|
|
14
|
-
})
|
|
15
|
-
```
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { MappedThread, Thread } from '../thread';
|
|
2
|
-
import { PartialBy } from '../types/typescript-utils';
|
|
3
|
-
import { ApplogForInsert, ApplogForInsertOptionalAgent, ApplogNoCid, AgentHash, CidString, Timestamp } from './datom-types';
|
|
1
|
+
import { MappedThread, Thread } from '../thread.ts';
|
|
2
|
+
import { PartialBy } from '../types/typescript-utils.ts';
|
|
3
|
+
import { ApplogForInsert, ApplogForInsertOptionalAgent, ApplogNoCid, AgentHash, CidString, Timestamp } from './datom-types.ts';
|
|
4
4
|
export declare function ensureTsPvAndFinalizeApplogs(appLogsToInsert: ApplogForInsert[], threadForPv: Thread): Readonly<{
|
|
5
5
|
cid: CidString;
|
|
6
|
-
at: import("./datom-types").Attribute;
|
|
6
|
+
at: import("./datom-types.ts").Attribute;
|
|
7
7
|
pv: CidString | null;
|
|
8
8
|
ts: Timestamp;
|
|
9
9
|
ag: AgentHash;
|
|
10
|
-
en: import("./datom-types").EntityID;
|
|
11
|
-
vl: import("./datom-types").ApplogValue;
|
|
10
|
+
en: import("./datom-types.ts").EntityID;
|
|
11
|
+
vl: import("./datom-types.ts").ApplogValue;
|
|
12
12
|
}>[];
|
|
13
13
|
export declare function ensureTsPvAndFinalizeApplog(applogToInsert: ApplogForInsert, threadForPv: Thread): Readonly<{
|
|
14
14
|
cid: CidString;
|
|
15
|
-
at: import("./datom-types").Attribute;
|
|
15
|
+
at: import("./datom-types.ts").Attribute;
|
|
16
16
|
pv: CidString | null;
|
|
17
17
|
ts: Timestamp;
|
|
18
18
|
ag: AgentHash;
|
|
19
|
-
en: import("./datom-types").EntityID;
|
|
20
|
-
vl: import("./datom-types").ApplogValue;
|
|
19
|
+
en: import("./datom-types.ts").EntityID;
|
|
20
|
+
vl: import("./datom-types.ts").ApplogValue;
|
|
21
21
|
}>;
|
|
22
22
|
export declare function finalizeApplogForInsert(log: ApplogForInsert, { ts, threadForPv }?: {
|
|
23
23
|
ts?: string;
|
|
24
24
|
threadForPv?: Thread;
|
|
25
25
|
}): Readonly<{
|
|
26
26
|
cid: CidString;
|
|
27
|
-
at: import("./datom-types").Attribute;
|
|
27
|
+
at: import("./datom-types.ts").Attribute;
|
|
28
28
|
pv: CidString | null;
|
|
29
29
|
ts: Timestamp;
|
|
30
30
|
ag: AgentHash;
|
|
31
|
-
en: import("./datom-types").EntityID;
|
|
32
|
-
vl: import("./datom-types").ApplogValue;
|
|
31
|
+
en: import("./datom-types.ts").EntityID;
|
|
32
|
+
vl: import("./datom-types.ts").ApplogValue;
|
|
33
33
|
}>;
|
|
34
34
|
export declare function hasAg(log: ApplogForInsertOptionalAgent): log is ApplogForInsert;
|
|
35
35
|
export declare function hasTs(log: ApplogForInsert): log is Omit<ApplogForInsert, 'ts'> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applog-helpers.d.ts","sourceRoot":"","sources":["../../src/applog/applog-helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"appl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AE,MAAM,EAAE,MAAM,GAAmB,IAAI,eA8BlG;AACD,wBAAgB,WAAW,CAAC,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,gBA6BzD"}
|
|
@@ -1,9 +1,43 @@
|
|
|
1
|
-
import type { Applog, ApplogValue, DatalogQueryPattern, DatalogQueryResultEntry, ResultContext, SearchContext, ValueOrMatcher } from './datom-types';
|
|
1
|
+
import type { Applog, ApplogValue, DatalogQueryPattern, DatalogQueryResultEntry, ResultContext, SearchContext, ValueOrMatcher } from './datom-types.ts';
|
|
2
2
|
export declare const isoDateStrCompare: (strA: string, strB: string, dir?: "asc" | "desc") => number;
|
|
3
3
|
export declare const objEqualByKeys: (keys: string[], objA: object, objB: object) => boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Deep equality for an `ApplogValue`. `vl` can now hold JSON objects/arrays, so a bare
|
|
6
|
+
* `===` would treat structurally-identical objects as different. `isEqual` short-circuits
|
|
7
|
+
* on referential identity internally, so primitives stay on the cheap path.
|
|
8
|
+
*/
|
|
9
|
+
export declare const valueEq: (a: ApplogValue, b: ApplogValue) => boolean;
|
|
10
|
+
/** Canonical, hashable Map key for an `ApplogValue` (see {@link valueKey}). */
|
|
11
|
+
export type ValueKey = string | number | boolean | null;
|
|
12
|
+
/**
|
|
13
|
+
* Canonical key for using an `ApplogValue` as a Map key. Primitives pass through unchanged
|
|
14
|
+
* (so primitive-keyed lookups are identity-stable); objects/arrays are stably stringified
|
|
15
|
+
* (key-sorted) behind a `\0obj:` sentinel so an object value can't collide with a string
|
|
16
|
+
* value that happens to equal its serialization.
|
|
17
|
+
*/
|
|
18
|
+
export declare const valueKey: (vl: ApplogValue) => ValueKey;
|
|
19
|
+
/** Transitive total-order comparator over (ts, cid). Safe for `Array.sort`. */
|
|
4
20
|
export declare const compareApplogsByTs: (logA: Applog, logB: Applog, dir?: "asc" | "desc") => number;
|
|
5
21
|
export declare const compareApplogsByEnAt: (objA: object, objB: object) => boolean;
|
|
6
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Pairwise: is `a` strictly later than `b` per (ts, pv-chain, cid)?
|
|
24
|
+
*
|
|
25
|
+
* NOT TRANSITIVE. Use only for two-log decisions (e.g. lastWriteWins replacement
|
|
26
|
+
* check). Do NOT pass to `Array.sort` — it can produce cycles at 3+ chain links
|
|
27
|
+
* and break the engine's sort.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isLaterByTsAndPv(a: Applog, b: Applog): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Sort applogs in chain-aware order (modifies array, also returns for chaining).
|
|
32
|
+
*
|
|
33
|
+
* Two-phase:
|
|
34
|
+
* 1. Transitive `(ts, cid)` `Array.sort` — fast, total-order, common case.
|
|
35
|
+
* 2. For each contiguous same-ts cluster (rare), chain-stabilize via `pv`
|
|
36
|
+
* so chain-tail logs land last (asc) / first (desc) within their (en, at)
|
|
37
|
+
* sub-group. Cross-group order within a cluster stays cid-lex.
|
|
38
|
+
*
|
|
39
|
+
* No-tie inputs pay only one linear scan past `Array.sort`.
|
|
40
|
+
*/
|
|
7
41
|
export declare function sortApplogsByTs(appLogArray: Applog[], dir?: 'asc' | 'desc'): Applog[];
|
|
8
42
|
export declare const isTsBefore: (log: Applog, logToCompare: Applog) => boolean;
|
|
9
43
|
export declare const uniqueEnFromAppLogs: (appLogArray: Applog[]) => string[];
|
|
@@ -19,13 +53,13 @@ export declare const getHashID: (stringifiable: any, lngth?: number) => string;
|
|
|
19
53
|
export declare function isVariable(x: any): x is string;
|
|
20
54
|
export declare function variableNameWithoutQuestionmark(str: string): string;
|
|
21
55
|
export declare function isStaticPattern(x: any): x is ApplogValue;
|
|
22
|
-
export declare function resolveOrRemoveVariables(pattern: DatalogQueryPattern, candidate: SearchContext): readonly [Partial<import("./datom-types").WithMatchers<Applog>>, Partial<{
|
|
56
|
+
export declare function resolveOrRemoveVariables(pattern: DatalogQueryPattern, candidate: SearchContext): readonly [Partial<import("./datom-types.ts").WithMatchers<Applog>>, Partial<{
|
|
23
57
|
cid: string;
|
|
24
58
|
pv: string;
|
|
25
|
-
ts: import("./datom-types").Timestamp;
|
|
59
|
+
ts: import("./datom-types.ts").Timestamp;
|
|
26
60
|
ag: string;
|
|
27
|
-
en: import("./datom-types").EntityID;
|
|
28
|
-
at: import("./datom-types").Attribute;
|
|
61
|
+
en: import("./datom-types.ts").EntityID;
|
|
62
|
+
at: import("./datom-types.ts").Attribute;
|
|
29
63
|
vl: string;
|
|
30
64
|
}>];
|
|
31
65
|
export declare function matchPartStatic(field: keyof Applog, patternPart: ValueOrMatcher<ApplogValue>, atomPart: ApplogValue): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applog-utils.d.ts","sourceRoot":"","sources":["../../src/applog/applog-utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACX,MAAM,EAEN,WAAW,EACX,mBAAmB,EACnB,uBAAuB,EACvB,aAAa,EACb,aAAa,EACb,cAAc,EACd,MAAM,
|
|
1
|
+
{"version":3,"file":"applog-utils.d.ts","sourceRoot":"","sources":["../../src/applog/applog-utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACX,MAAM,EAEN,WAAW,EACX,mBAAmB,EACnB,uBAAuB,EACvB,aAAa,EACb,aAAa,EACb,cAAc,EACd,MAAM,kBAAkB,CAAA;AAIzB,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,EAAE,MAAM,MAAM,EAAE,MAAK,KAAK,GAAG,MAAc,WAGpD,CAAA;AACrC,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,EAAE,EAAE,MAAM,MAAM,EAAE,MAAM,MAAM,YAExE,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,GAAG,WAAW,EAAE,GAAG,WAAW,KAAG,OAAwB,CAAA;AAEjF,+EAA+E;AAC/E,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;AAEvD;;;;;GAKG;AACH,eA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WAAW,EAAE,cAAc,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,WAAW,GAAG,OAAO,CAoC7H;AACD,wBAAgB,SAAS,CAAC,WAAW,EAAE,cAAc,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,GAAG,aAAa,CA2BhI;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,aAAa,CAOhH;AAED,wBAAgB,SAAS,CAAC,MAAM,SAAS,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,uBAAuB,CAAC,MAAM,CAAC,CAUjI;AASD,eAAO,MAAM,QAAQ;iBACC,MAAM,EAAE;iBAIR,MAAM,EAAE;mBAIN,MAAM,EAAE;sBAIL,MAAM,EAAE;iBArBH,MAAM,EAAE;kBAKN,MAAM,EAAE;qBAAR,MAAM,EAAE;oBA0BjB,MAAM,EAAE;mBAQT,MAAM,EAAE;sBAqBL,MAAM,EAAE;+BAOC,MAAM,EAAE;mCAIJ,MAAM,EAAE;qBAOtB,MAAM,EAAE;CAOjC,CAAA;AAKD,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,EAAE,OAAO,MAAM,YAAuD,CAAA;AAUhH,eAAO,MAAM,UAAU,GACtB,KAAK,MAAM,EACX,YAAS,EACT,WAAW,MAAM,WAqBjB,CAAA;AACD,wBAAgB,yBAAyB,CAAC,IAAI,KAAA,EAAE,IAAI,KAAA,WAenD;AACD,wBAAgB,UAAU,IAAI,MAAM,CAGnC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Static, TSchema } from '@sinclair/typebox';
|
|
2
2
|
import { CID } from 'multiformats/cid';
|
|
3
|
-
import {
|
|
4
|
-
import type { PartialBy, Tagged } from '../types/typescript-utils';
|
|
3
|
+
import type { PartialBy, Tagged } from '../types/typescript-utils.ts';
|
|
5
4
|
export declare const Nullable: <T extends TSchema>(schema: T) => import("@sinclair/typebox").TUnion<[T, import("@sinclair/typebox").TNull]>;
|
|
6
5
|
export declare const EntityID_LENGTH = 7;
|
|
7
6
|
export declare const EntityID: import("@sinclair/typebox").TString;
|
|
@@ -12,7 +11,13 @@ export type CidString = Tagged<string, CID>;
|
|
|
12
11
|
export type IpnsString = Tagged<CidString, 'IPNS'>;
|
|
13
12
|
export type AgentID = EntityID;
|
|
14
13
|
export type Attribute = string;
|
|
15
|
-
export type
|
|
14
|
+
export type JsonPrimitive = string | boolean | number | null;
|
|
15
|
+
export interface JsonObject {
|
|
16
|
+
[key: string]: JsonValue;
|
|
17
|
+
}
|
|
18
|
+
export type JsonArray = JsonValue[];
|
|
19
|
+
export type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
|
20
|
+
export type ApplogValue = JsonValue;
|
|
16
21
|
export interface Atom {
|
|
17
22
|
en: EntityID;
|
|
18
23
|
at: Attribute;
|
|
@@ -44,7 +49,7 @@ export type AtomPattern = Atom | Applog;
|
|
|
44
49
|
export interface DatalogStateIdentifier {
|
|
45
50
|
lastTS: Timestamp;
|
|
46
51
|
}
|
|
47
|
-
export type ValueOrMatcher<T> = T | readonly T[] | ReadonlySet<T> |
|
|
52
|
+
export type ValueOrMatcher<T> = T | readonly T[] | ReadonlySet<T> | ((value: T) => boolean);
|
|
48
53
|
export type WithMatchers<T extends Record<string, any>> = {
|
|
49
54
|
[K in keyof T & string as `${K}` | `!${K}`]?: ValueOrMatcher<T[K]>;
|
|
50
55
|
};
|
|
@@ -70,10 +75,12 @@ export declare const CIDTB: import("@sinclair/typebox").TString;
|
|
|
70
75
|
export type CIDTB = Static<typeof EntityID>;
|
|
71
76
|
export declare const URL: import("@sinclair/typebox").TString;
|
|
72
77
|
export type URL = Static<typeof URL>;
|
|
78
|
+
export declare const JsonValueTB: import("@sinclair/typebox").TRecursive<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TThis>, import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TThis>]>>;
|
|
79
|
+
export type JsonValueTB = Static<typeof JsonValueTB>;
|
|
73
80
|
export declare const AppLogNoCidTB: import("@sinclair/typebox").TObject<{
|
|
74
81
|
en: import("@sinclair/typebox").TString;
|
|
75
82
|
at: import("@sinclair/typebox").TString;
|
|
76
|
-
vl: import("@sinclair/typebox").
|
|
83
|
+
vl: import("@sinclair/typebox").TRecursive<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TThis>, import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TThis>]>>;
|
|
77
84
|
ts: import("@sinclair/typebox").TString;
|
|
78
85
|
ag: import("@sinclair/typebox").TString;
|
|
79
86
|
pv: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
@@ -82,7 +89,7 @@ export type AppLogNoCidTB = Static<typeof AppLogNoCidTB>;
|
|
|
82
89
|
export declare const AppLogNoCidTBC: import("@sinclair/typebox/compiler").TypeCheck<import("@sinclair/typebox").TObject<{
|
|
83
90
|
en: import("@sinclair/typebox").TString;
|
|
84
91
|
at: import("@sinclair/typebox").TString;
|
|
85
|
-
vl: import("@sinclair/typebox").
|
|
92
|
+
vl: import("@sinclair/typebox").TRecursive<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TThis>, import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TThis>]>>;
|
|
86
93
|
ts: import("@sinclair/typebox").TString;
|
|
87
94
|
ag: import("@sinclair/typebox").TString;
|
|
88
95
|
pv: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
@@ -94,26 +101,50 @@ export declare const isValidApplogNoCid: (value: unknown) => value is {
|
|
|
94
101
|
ts: string;
|
|
95
102
|
ag: string;
|
|
96
103
|
en: string;
|
|
97
|
-
vl: string | number | boolean
|
|
104
|
+
vl: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | {
|
|
105
|
+
[x: string]: string | number | boolean | /*elided*/ any | /*elided*/ any;
|
|
106
|
+
})[] | {
|
|
107
|
+
[x: string]: string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any;
|
|
108
|
+
})[] | {
|
|
109
|
+
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
110
|
+
})[] | {
|
|
111
|
+
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
112
|
+
})[] | {
|
|
113
|
+
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
114
|
+
})[] | {
|
|
115
|
+
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
116
|
+
})[] | {
|
|
117
|
+
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
118
|
+
})[] | {
|
|
119
|
+
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
120
|
+
})[] | {
|
|
121
|
+
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
122
|
+
})[] | {
|
|
123
|
+
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
124
|
+
})[] | {
|
|
125
|
+
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
126
|
+
})[] | {
|
|
127
|
+
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
128
|
+
};
|
|
98
129
|
};
|
|
99
130
|
export declare const AppLogTB: import("@sinclair/typebox").TObject<{
|
|
100
|
-
at: import("@sinclair/typebox").TString;
|
|
101
131
|
cid: import("@sinclair/typebox").TString;
|
|
132
|
+
at: import("@sinclair/typebox").TString;
|
|
102
133
|
pv: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
103
134
|
ts: import("@sinclair/typebox").TString;
|
|
104
135
|
ag: import("@sinclair/typebox").TString;
|
|
105
136
|
en: import("@sinclair/typebox").TString;
|
|
106
|
-
vl: import("@sinclair/typebox").
|
|
137
|
+
vl: import("@sinclair/typebox").TRecursive<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TThis>, import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TThis>]>>;
|
|
107
138
|
}>;
|
|
108
139
|
export type AppLogTB = Static<typeof AppLogTB>;
|
|
109
140
|
export declare const AppLogTBC: import("@sinclair/typebox/compiler").TypeCheck<import("@sinclair/typebox").TObject<{
|
|
110
|
-
at: import("@sinclair/typebox").TString;
|
|
111
141
|
cid: import("@sinclair/typebox").TString;
|
|
142
|
+
at: import("@sinclair/typebox").TString;
|
|
112
143
|
pv: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
113
144
|
ts: import("@sinclair/typebox").TString;
|
|
114
145
|
ag: import("@sinclair/typebox").TString;
|
|
115
146
|
en: import("@sinclair/typebox").TString;
|
|
116
|
-
vl: import("@sinclair/typebox").
|
|
147
|
+
vl: import("@sinclair/typebox").TRecursive<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TThis>, import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TThis>]>>;
|
|
117
148
|
}>>;
|
|
118
149
|
export declare const getApplogTypeErrors: (obj: any) => import("@sinclair/typebox/errors").ValueError[];
|
|
119
150
|
export declare const isValidApplog: (value: unknown) => value is {
|
|
@@ -123,7 +154,31 @@ export declare const isValidApplog: (value: unknown) => value is {
|
|
|
123
154
|
ts: string;
|
|
124
155
|
ag: string;
|
|
125
156
|
en: string;
|
|
126
|
-
vl: string | number | boolean
|
|
157
|
+
vl: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | {
|
|
158
|
+
[x: string]: string | number | boolean | /*elided*/ any | /*elided*/ any;
|
|
159
|
+
})[] | {
|
|
160
|
+
[x: string]: string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any;
|
|
161
|
+
})[] | {
|
|
162
|
+
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
163
|
+
})[] | {
|
|
164
|
+
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
165
|
+
})[] | {
|
|
166
|
+
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
167
|
+
})[] | {
|
|
168
|
+
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
169
|
+
})[] | {
|
|
170
|
+
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
171
|
+
})[] | {
|
|
172
|
+
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
173
|
+
})[] | {
|
|
174
|
+
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
175
|
+
})[] | {
|
|
176
|
+
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
177
|
+
})[] | {
|
|
178
|
+
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
179
|
+
})[] | {
|
|
180
|
+
[x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any)[] | /*elided*/ any;
|
|
181
|
+
};
|
|
127
182
|
};
|
|
128
183
|
export {};
|
|
129
184
|
//# sourceMappingURL=datom-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datom-types.d.ts","sourceRoot":"","sources":["../../src/applog/datom-types.ts"],"names":[],"mappings":"AAEA,OAAO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applog/applog-helpers';
|
|
2
|
-
export * from './applog/applog-utils';
|
|
3
|
-
export * from './applog/datom-types';
|
|
1
|
+
export * from './applog/applog-helpers.ts';
|
|
2
|
+
export * from './applog/applog-utils.ts';
|
|
3
|
+
export * from './applog/datom-types.ts';
|
|
4
4
|
//# sourceMappingURL=applog.d.ts.map
|
package/dist/applog.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applog.d.ts","sourceRoot":"","sources":["../src/applog.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"applog.d.ts","sourceRoot":"","sources":["../src/applog.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA;AAC1C,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-7Z5YDQKK.js";
|
|
2
2
|
import {
|
|
3
3
|
AppLogNoCidTB,
|
|
4
4
|
AppLogNoCidTBC,
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
CIDTB,
|
|
8
8
|
EntityID,
|
|
9
9
|
EntityID_LENGTH,
|
|
10
|
+
JsonValueTB,
|
|
10
11
|
Nullable,
|
|
11
12
|
URL,
|
|
12
13
|
actualize,
|
|
@@ -27,6 +28,7 @@ import {
|
|
|
27
28
|
hasPv,
|
|
28
29
|
hasTs,
|
|
29
30
|
isEncryptedApplog,
|
|
31
|
+
isLaterByTsAndPv,
|
|
30
32
|
isStaticPattern,
|
|
31
33
|
isTsBefore,
|
|
32
34
|
isValidApplog,
|
|
@@ -43,15 +45,14 @@ import {
|
|
|
43
45
|
sortApplogsByTs,
|
|
44
46
|
tsNearlySame,
|
|
45
47
|
uniqueEnFromAppLogs,
|
|
48
|
+
valueEq,
|
|
49
|
+
valueKey,
|
|
46
50
|
variableNameWithoutQuestionmark,
|
|
47
51
|
withAg,
|
|
48
52
|
withPvFrom,
|
|
49
53
|
withTs
|
|
50
|
-
} from "./chunk-
|
|
51
|
-
import "./chunk-
|
|
52
|
-
import "./chunk-QO2KMGDN.min.js";
|
|
53
|
-
import "./chunk-KEHU7HGZ.min.js";
|
|
54
|
-
import "./chunk-PHITDXZT.min.js";
|
|
54
|
+
} from "./chunk-SHUHRHOT.js";
|
|
55
|
+
import "./chunk-ZAADLBSB.js";
|
|
55
56
|
export {
|
|
56
57
|
AppLogNoCidTB,
|
|
57
58
|
AppLogNoCidTBC,
|
|
@@ -60,6 +61,7 @@ export {
|
|
|
60
61
|
CIDTB,
|
|
61
62
|
EntityID,
|
|
62
63
|
EntityID_LENGTH,
|
|
64
|
+
JsonValueTB,
|
|
63
65
|
Nullable,
|
|
64
66
|
URL,
|
|
65
67
|
actualize,
|
|
@@ -80,6 +82,7 @@ export {
|
|
|
80
82
|
hasPv,
|
|
81
83
|
hasTs,
|
|
82
84
|
isEncryptedApplog,
|
|
85
|
+
isLaterByTsAndPv,
|
|
83
86
|
isStaticPattern,
|
|
84
87
|
isTsBefore,
|
|
85
88
|
isValidApplog,
|
|
@@ -96,9 +99,11 @@ export {
|
|
|
96
99
|
sortApplogsByTs,
|
|
97
100
|
tsNearlySame,
|
|
98
101
|
uniqueEnFromAppLogs,
|
|
102
|
+
valueEq,
|
|
103
|
+
valueKey,
|
|
99
104
|
variableNameWithoutQuestionmark,
|
|
100
105
|
withAg,
|
|
101
106
|
withPvFrom,
|
|
102
107
|
withTs
|
|
103
108
|
};
|
|
104
|
-
//# sourceMappingURL=applog.
|
|
109
|
+
//# sourceMappingURL=applog.js.map
|
package/dist/blockstore.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './blockstore/index';
|
|
1
|
+
export * from './blockstore/index.ts';
|
|
2
2
|
//# sourceMappingURL=blockstore.d.ts.map
|
package/dist/blockstore.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blockstore.d.ts","sourceRoot":"","sources":["../src/blockstore.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"blockstore.d.ts","sourceRoot":"","sources":["../src/blockstore.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import "./chunk-PHITDXZT.min.js";
|
|
2
|
-
|
|
3
1
|
// src/blockstore/index.ts
|
|
4
2
|
var LocalFirstBlockStore = class {
|
|
5
3
|
constructor(local, remote) {
|
|
@@ -23,4 +21,4 @@ var LocalFirstBlockStore = class {
|
|
|
23
21
|
export {
|
|
24
22
|
LocalFirstBlockStore
|
|
25
23
|
};
|
|
26
|
-
//# sourceMappingURL=blockstore.
|
|
24
|
+
//# sourceMappingURL=blockstore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/blockstore/index.ts"],"sourcesContent":["import type { CID } from 'multiformats/cid'\n\n/** Minimal async block store interface — get/put/has. */\nexport interface BlockStore {\n\tget(cid: CID): Promise<Uint8Array>\n\tput(cid: CID, bytes: Uint8Array): Promise<void>\n\thas(cid: CID): Promise<boolean>\n}\n\n/**\n * A block store that reads locally first, with optional remote fallback.\n * On get: local hit → return; local miss + remote → fetch, write-back, return.\n * put/has always operate on local only.\n */\nexport class LocalFirstBlockStore implements BlockStore {\n\tconstructor(\n\t\tprivate local: BlockStore,\n\t\tprivate remote?: Pick<BlockStore, 'get'>,\n\t) {}\n\n\tasync get(cid: CID): Promise<Uint8Array> {\n\t\tif (await this.local.has(cid)) return this.local.get(cid)\n\t\tif (!this.remote) throw new Error(`Block not found: ${cid}`)\n\t\tconst bytes = await this.remote.get(cid)\n\t\tawait this.local.put(cid, bytes)\n\t\treturn bytes\n\t}\n\n\tput(cid: CID, bytes: Uint8Array): Promise<void> {\n\t\treturn this.local.put(cid, bytes)\n\t}\n\n\thas(cid: CID): Promise<boolean> {\n\t\treturn this.local.has(cid)\n\t}\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/blockstore/index.ts"],"sourcesContent":["import type { CID } from 'multiformats/cid'\n\n/** Minimal async block store interface — get/put/has. */\nexport interface BlockStore {\n\tget(cid: CID): Promise<Uint8Array>\n\tput(cid: CID, bytes: Uint8Array): Promise<void>\n\thas(cid: CID): Promise<boolean>\n}\n\n/**\n * A block store that reads locally first, with optional remote fallback.\n * On get: local hit → return; local miss + remote → fetch, write-back, return.\n * put/has always operate on local only.\n */\nexport class LocalFirstBlockStore implements BlockStore {\n\tconstructor(\n\t\tprivate local: BlockStore,\n\t\tprivate remote?: Pick<BlockStore, 'get'>,\n\t) {}\n\n\tasync get(cid: CID): Promise<Uint8Array> {\n\t\tif (await this.local.has(cid)) return this.local.get(cid)\n\t\tif (!this.remote) throw new Error(`Block not found: ${cid}`)\n\t\tconst bytes = await this.remote.get(cid)\n\t\tawait this.local.put(cid, bytes)\n\t\treturn bytes\n\t}\n\n\tput(cid: CID, bytes: Uint8Array): Promise<void> {\n\t\treturn this.local.put(cid, bytes)\n\t}\n\n\thas(cid: CID): Promise<boolean> {\n\t\treturn this.local.has(cid)\n\t}\n}\n"],"mappings":";AAcO,IAAM,uBAAN,MAAiD;AAAA,EACvD,YACS,OACA,QACP;AAFO;AACA;AAAA,EACN;AAAA,EAEH,MAAM,IAAI,KAA+B;AACxC,QAAI,MAAM,KAAK,MAAM,IAAI,GAAG,EAAG,QAAO,KAAK,MAAM,IAAI,GAAG;AACxD,QAAI,CAAC,KAAK,OAAQ,OAAM,IAAI,MAAM,oBAAoB,GAAG,EAAE;AAC3D,UAAM,QAAQ,MAAM,KAAK,OAAO,IAAI,GAAG;AACvC,UAAM,KAAK,MAAM,IAAI,KAAK,KAAK;AAC/B,WAAO;AAAA,EACR;AAAA,EAEA,IAAI,KAAU,OAAkC;AAC/C,WAAO,KAAK,MAAM,IAAI,KAAK,KAAK;AAAA,EACjC;AAAA,EAEA,IAAI,KAA4B;AAC/B,WAAO,KAAK,MAAM,IAAI,GAAG;AAAA,EAC1B;AACD;","names":[]}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveKeyMapper
|
|
3
|
+
} from "./chunk-3SUFNJEZ.js";
|
|
4
|
+
import {
|
|
5
|
+
SubscribableImpl,
|
|
6
|
+
ThreadInMemory,
|
|
7
|
+
anyOf,
|
|
8
|
+
createDebugName,
|
|
9
|
+
isInitEvent,
|
|
10
|
+
makeFilter,
|
|
11
|
+
memoizedFn,
|
|
12
|
+
rollingFilter
|
|
13
|
+
} from "./chunk-SHUHRHOT.js";
|
|
14
|
+
|
|
15
|
+
// src/query/divergences.ts
|
|
16
|
+
import { Logger } from "besonders-logger";
|
|
17
|
+
var { WARN, LOG, DEBUG, VERBOSE, ERROR } = Logger.setup(Logger.INFO);
|
|
18
|
+
var queryDivergencesByPrev = memoizedFn("queryDivergencesByPrev", function queryConflictingByPrev(sourceThread) {
|
|
19
|
+
DEBUG(`queryDivergencesByPrev<${sourceThread.nameAndSizeUntracked}>`);
|
|
20
|
+
if (sourceThread.filters.includes("lastWriteWins")) WARN(`queryDivergencesByPrev on thread lastWriteWins`, sourceThread);
|
|
21
|
+
const logsForNode = /* @__PURE__ */ new Map();
|
|
22
|
+
const leafs = /* @__PURE__ */ new Set();
|
|
23
|
+
VERBOSE("all applogs:", sourceThread.applogs);
|
|
24
|
+
for (const log of sourceThread.applogs) {
|
|
25
|
+
let prevLogs;
|
|
26
|
+
if (log.pv) {
|
|
27
|
+
prevLogs = log.pv && logsForNode.get(log.pv.toString());
|
|
28
|
+
leafs.delete(log.pv.toString());
|
|
29
|
+
}
|
|
30
|
+
VERBOSE("traversing log", { log, prevLogs, leafs: Array.from(leafs) });
|
|
31
|
+
logsForNode.set(log.cid, prevLogs ? [...prevLogs, log] : [log]);
|
|
32
|
+
leafs.add(log.cid);
|
|
33
|
+
}
|
|
34
|
+
const divergences = Array.from(leafs).map((leafID) => {
|
|
35
|
+
const thread = new ThreadInMemory(
|
|
36
|
+
createDebugName({
|
|
37
|
+
caller: "DivergenceLeaf",
|
|
38
|
+
thread: sourceThread,
|
|
39
|
+
pattern: `leaf: ${leafID}`
|
|
40
|
+
}),
|
|
41
|
+
logsForNode.get(leafID),
|
|
42
|
+
sourceThread.filters,
|
|
43
|
+
true
|
|
44
|
+
);
|
|
45
|
+
return { log: thread.latestLog, thread };
|
|
46
|
+
});
|
|
47
|
+
return divergences;
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// src/query/entity-collection.ts
|
|
51
|
+
import { Logger as Logger2 } from "besonders-logger";
|
|
52
|
+
var { DEBUG: DEBUG2 } = Logger2.setup(Logger2.INFO);
|
|
53
|
+
function liveEntityCollection(thread, discoveryPattern, liveAttributes, opts) {
|
|
54
|
+
return _liveEntityCollection(
|
|
55
|
+
thread,
|
|
56
|
+
discoveryPattern,
|
|
57
|
+
liveAttributes,
|
|
58
|
+
opts
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
var _liveEntityCollection = memoizedFn(
|
|
62
|
+
"liveEntityCollection",
|
|
63
|
+
function liveEntityCollection2(thread, discoveryPattern, liveAttributes, opts) {
|
|
64
|
+
DEBUG2("liveEntityCollection", discoveryPattern, liveAttributes);
|
|
65
|
+
const discoveryAttr = discoveryPattern.at;
|
|
66
|
+
const allAttrs = /* @__PURE__ */ new Set([discoveryAttr, ...liveAttributes]);
|
|
67
|
+
const filtered = rollingFilter(thread, { at: anyOf(...allAttrs) });
|
|
68
|
+
const isDiscoveryMatch = makeFilter(discoveryPattern);
|
|
69
|
+
const attrSet = new Set(liveAttributes);
|
|
70
|
+
const key = resolveKeyMapper(opts);
|
|
71
|
+
const map = /* @__PURE__ */ new Map();
|
|
72
|
+
function makeRecord(entityId) {
|
|
73
|
+
const record = {};
|
|
74
|
+
for (const attr of liveAttributes) record[key(attr)] = null;
|
|
75
|
+
for (const log of filtered.applogs) {
|
|
76
|
+
if (log.en === entityId && attrSet.has(log.at)) {
|
|
77
|
+
record[key(log.at)] = log.vl;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return record;
|
|
81
|
+
}
|
|
82
|
+
function buildFull(applogs) {
|
|
83
|
+
map.clear();
|
|
84
|
+
for (const log of isDiscoveryMatch(applogs)) {
|
|
85
|
+
if (!map.has(log.en)) map.set(log.en, makeRecord(log.en));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function addLog(log) {
|
|
89
|
+
if (isDiscoveryMatch([log]).length > 0 && !map.has(log.en)) {
|
|
90
|
+
map.set(log.en, makeRecord(log.en));
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (attrSet.has(log.at)) {
|
|
94
|
+
const record = map.get(log.en);
|
|
95
|
+
if (record) record[key(log.at)] = log.vl;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function removeLog(log) {
|
|
99
|
+
if (isDiscoveryMatch([log]).length > 0) {
|
|
100
|
+
const stillDiscovered = filtered.applogs.some(
|
|
101
|
+
(l) => l.en === log.en && isDiscoveryMatch([l]).length > 0
|
|
102
|
+
);
|
|
103
|
+
if (!stillDiscovered) {
|
|
104
|
+
map.delete(log.en);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (attrSet.has(log.at)) {
|
|
109
|
+
const record = map.get(log.en);
|
|
110
|
+
if (record) {
|
|
111
|
+
const current = filtered.applogs.find((l) => l.en === log.en && l.at === log.at);
|
|
112
|
+
record[key(log.at)] = current?.vl ?? null;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
buildFull(filtered.applogs);
|
|
117
|
+
const result = new SubscribableImpl(
|
|
118
|
+
map,
|
|
119
|
+
() => filtered.subscribe((event) => {
|
|
120
|
+
if (isInitEvent(event)) {
|
|
121
|
+
buildFull(event.init);
|
|
122
|
+
} else {
|
|
123
|
+
if (event.removed) for (const log of event.removed) removeLog(log);
|
|
124
|
+
for (const log of event.added) addLog(log);
|
|
125
|
+
}
|
|
126
|
+
result._set(map);
|
|
127
|
+
}, "derived"),
|
|
128
|
+
{ equals: false }
|
|
129
|
+
);
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
export {
|
|
135
|
+
queryDivergencesByPrev,
|
|
136
|
+
liveEntityCollection
|
|
137
|
+
};
|
|
138
|
+
//# sourceMappingURL=chunk-22WDFLXO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/query/divergences.ts","../src/query/entity-collection.ts"],"sourcesContent":["import { Logger } from 'besonders-logger'\nimport stringify from 'safe-stable-stringify'\nimport { Applog, CidString } from '../applog/datom-types.ts'\nimport { createDebugName } from '../utils/debug-name.ts'\nimport { Thread } from '../thread/basic.ts'\nimport { ThreadInMemory } from '../thread/writeable.ts'\nimport { memoizedFn } from './memoized.ts'\n\nconst { WARN, LOG, DEBUG, VERBOSE, ERROR } = Logger.setup(Logger.INFO) // eslint-disable-line no-unused-vars\n\nexport interface DivergenceLeaf {\n\tlog: Applog\n\tthread: Thread\n}\n\nexport const queryDivergencesByPrev = memoizedFn('queryDivergencesByPrev', function queryConflictingByPrev(\n\tsourceThread: Thread,\n) {\n\tDEBUG(`queryDivergencesByPrev<${sourceThread.nameAndSizeUntracked}>`)\n\tif (sourceThread.filters.includes('lastWriteWins')) WARN(`queryDivergencesByPrev on thread lastWriteWins`, sourceThread)\n\n\tconst logsForNode = new Map<CidString, Applog[]>()\n\tconst leafs = new Set<CidString>()\n\tVERBOSE('all applogs:', sourceThread.applogs)\n\tfor (const log of sourceThread.applogs) {\n\t\tlet prevLogs\n\t\tif (log.pv) {\n\t\t\tprevLogs = log.pv && logsForNode.get(log.pv.toString())\n\t\t\tleafs.delete(log.pv.toString())\n\t\t}\n\t\tVERBOSE('traversing log', { log, prevLogs, leafs: Array.from(leafs) })\n\t\tlogsForNode.set(log.cid, prevLogs ? [...prevLogs, log] : [log])\n\t\tleafs.add(log.cid)\n\t}\n\tconst divergences = Array.from(leafs).map(leafID => {\n\t\tconst thread = new ThreadInMemory(\n\t\t\tcreateDebugName({\n\t\t\t\tcaller: 'DivergenceLeaf',\n\t\t\t\tthread: sourceThread,\n\t\t\t\tpattern: `leaf: ${leafID}`,\n\t\t\t}),\n\t\t\tlogsForNode.get(leafID),\n\t\t\tsourceThread.filters,\n\t\t\ttrue,\n\t\t)\n\t\treturn ({ log: thread.latestLog, thread })\n\t})\n\t// TODO: migrate to SubscribableArray for reactive updates\n\treturn divergences\n})\n","import { Logger } from 'besonders-logger'\nimport { Applog, ApplogValue, DatalogQueryPattern, EntityID } from '../applog/datom-types.ts'\nimport { isInitEvent, Thread } from '../thread/basic.ts'\nimport { makeFilter, rollingFilter } from '../thread/filters.ts'\nimport { resolveKeyMapper } from './basic.ts'\nimport { anyOf } from './matchers.ts'\nimport { memoizedFn } from './memoized.ts'\nimport { SubscribableImpl } from './subscribable.ts'\nimport type { Subscribable } from './subscribable.ts'\nimport type { StripExplicitPrefix, StripFirstPrefix } from './attr-helpers.ts'\n\nconst { DEBUG } = Logger.setup(Logger.INFO) // eslint-disable-line no-unused-vars\n\nexport function liveEntityCollection<A extends string>(\n\tthread: Thread, discoveryPattern: DatalogQueryPattern, liveAttributes: readonly A[],\n): Subscribable<ReadonlyMap<EntityID, Record<A, ApplogValue | null>>>\nexport function liveEntityCollection<A extends string>(\n\tthread: Thread, discoveryPattern: DatalogQueryPattern, liveAttributes: readonly A[],\n\topts: { stripAtPrefix: true },\n): Subscribable<ReadonlyMap<EntityID, Record<StripFirstPrefix<A>, ApplogValue | null>>>\nexport function liveEntityCollection<A extends string, P extends string>(\n\tthread: Thread, discoveryPattern: DatalogQueryPattern, liveAttributes: readonly A[],\n\topts: { stripAtPrefix: P },\n): Subscribable<ReadonlyMap<EntityID, Record<StripExplicitPrefix<A, P>, ApplogValue | null>>>\nexport function liveEntityCollection<A extends string>(\n\tthread: Thread, discoveryPattern: DatalogQueryPattern, liveAttributes: readonly A[],\n\topts: { mapKeys: (attr: A) => string },\n): Subscribable<ReadonlyMap<EntityID, Record<string, ApplogValue | null>>>\nexport function liveEntityCollection<A extends string>(\n\tthread: Thread, discoveryPattern: DatalogQueryPattern, liveAttributes: readonly A[],\n\topts: { stripAtPrefix?: true | string; mapKeys?: (attr: A) => string },\n): Subscribable<ReadonlyMap<EntityID, Record<string, ApplogValue | null>>>\nexport function liveEntityCollection<A extends string>(\n\tthread: Thread,\n\tdiscoveryPattern: DatalogQueryPattern,\n\tliveAttributes: readonly A[],\n\topts?: { stripAtPrefix?: true | string; mapKeys?: (attr: A) => string },\n): Subscribable<ReadonlyMap<EntityID, Record<string, ApplogValue | null>>> {\n\treturn _liveEntityCollection(thread, discoveryPattern, liveAttributes,\n\t\topts as { stripAtPrefix?: true | string; mapKeys?: (attr: string) => string })\n}\n\nconst _liveEntityCollection = memoizedFn('liveEntityCollection',\n\tfunction liveEntityCollection<A extends string>(\n\t\tthread: Thread,\n\t\tdiscoveryPattern: DatalogQueryPattern,\n\t\tliveAttributes: readonly A[],\n\t\topts?: { stripAtPrefix?: true | string; mapKeys?: (attr: string) => string },\n\t): Subscribable<ReadonlyMap<EntityID, Record<string, ApplogValue | null>>> {\n\t\tDEBUG('liveEntityCollection', discoveryPattern, liveAttributes)\n\t\tconst discoveryAttr = discoveryPattern.at as string\n\t\tconst allAttrs = new Set([discoveryAttr, ...liveAttributes])\n\t\tconst filtered = rollingFilter(thread, { at: anyOf(...allAttrs) })\n\t\tconst isDiscoveryMatch = makeFilter(discoveryPattern)\n\t\tconst attrSet = new Set<string>(liveAttributes)\n\t\tconst key = resolveKeyMapper(opts)\n\n\t\tconst map = new Map<EntityID, Record<string, ApplogValue | null>>()\n\n\t\tfunction makeRecord(entityId: EntityID): Record<string, ApplogValue | null> {\n\t\t\tconst record = {} as Record<string, ApplogValue | null>\n\t\t\tfor (const attr of liveAttributes) record[key(attr)] = null\n\t\t\t// Backfill from current filtered state\n\t\t\tfor (const log of filtered.applogs) {\n\t\t\t\tif (log.en === entityId && attrSet.has(log.at)) {\n\t\t\t\t\trecord[key(log.at)] = log.vl\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn record\n\t\t}\n\n\t\tfunction buildFull(applogs: readonly Applog[]) {\n\t\t\tmap.clear()\n\t\t\tfor (const log of isDiscoveryMatch(applogs)) {\n\t\t\t\tif (!map.has(log.en)) map.set(log.en, makeRecord(log.en))\n\t\t\t}\n\t\t}\n\n\t\tfunction addLog(log: Applog) {\n\t\t\t// Discovery match → ensure entity exists\n\t\t\tif (isDiscoveryMatch([log]).length > 0 && !map.has(log.en)) {\n\t\t\t\tmap.set(log.en, makeRecord(log.en))\n\t\t\t\treturn // makeRecord already backfilled attrs\n\t\t\t}\n\t\t\t// Attribute match → update value\n\t\t\tif (attrSet.has(log.at)) {\n\t\t\t\tconst record = map.get(log.en)\n\t\t\t\tif (record) record[key(log.at)] = log.vl\n\t\t\t}\n\t\t}\n\n\t\tfunction removeLog(log: Applog) {\n\t\t\tif (isDiscoveryMatch([log]).length > 0) {\n\t\t\t\t// Check if entity still has another discovery match\n\t\t\t\tconst stillDiscovered = filtered.applogs.some(\n\t\t\t\t\tl => l.en === log.en && isDiscoveryMatch([l]).length > 0,\n\t\t\t\t)\n\t\t\t\tif (!stillDiscovered) {\n\t\t\t\t\tmap.delete(log.en)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (attrSet.has(log.at)) {\n\t\t\t\tconst record = map.get(log.en)\n\t\t\t\tif (record) {\n\t\t\t\t\t// Find current value from remaining applogs\n\t\t\t\t\tconst current = filtered.applogs.find(l => l.en === log.en && l.at === log.at)\n\t\t\t\t\trecord[key(log.at)] = current?.vl ?? null\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Initial build\n\t\tbuildFull(filtered.applogs)\n\n\t\tconst result = new SubscribableImpl<ReadonlyMap<EntityID, Record<string, ApplogValue | null>>>(\n\t\t\tmap,\n\t\t\t() => filtered.subscribe((event) => {\n\t\t\t\tif (isInitEvent(event)) {\n\t\t\t\t\tbuildFull(event.init)\n\t\t\t\t} else {\n\t\t\t\t\t// Process removes before adds — LWW updates appear as remove+add in same delta\n\t\t\t\t\tif (event.removed) for (const log of event.removed) removeLog(log)\n\t\t\t\t\tfor (const log of event.added) addLog(log)\n\t\t\t\t}\n\t\t\t\tresult._set(map)\n\t\t\t}, 'derived'),\n\t\t\t{ equals: false },\n\t\t)\n\t\treturn result\n\t},\n)\n"],"mappings":";;;;;;;;;;;;;;;AAAA,SAAS,cAAc;AAQvB,IAAM,EAAE,MAAM,KAAK,OAAO,SAAS,MAAM,IAAI,OAAO,MAAM,OAAO,IAAI;AAO9D,IAAM,yBAAyB,WAAW,0BAA0B,SAAS,uBACnF,cACC;AACD,QAAM,0BAA0B,aAAa,oBAAoB,GAAG;AACpE,MAAI,aAAa,QAAQ,SAAS,eAAe,EAAG,MAAK,kDAAkD,YAAY;AAEvH,QAAM,cAAc,oBAAI,IAAyB;AACjD,QAAM,QAAQ,oBAAI,IAAe;AACjC,UAAQ,gBAAgB,aAAa,OAAO;AAC5C,aAAW,OAAO,aAAa,SAAS;AACvC,QAAI;AACJ,QAAI,IAAI,IAAI;AACX,iBAAW,IAAI,MAAM,YAAY,IAAI,IAAI,GAAG,SAAS,CAAC;AACtD,YAAM,OAAO,IAAI,GAAG,SAAS,CAAC;AAAA,IAC/B;AACA,YAAQ,kBAAkB,EAAE,KAAK,UAAU,OAAO,MAAM,KAAK,KAAK,EAAE,CAAC;AACrE,gBAAY,IAAI,IAAI,KAAK,WAAW,CAAC,GAAG,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC;AAC9D,UAAM,IAAI,IAAI,GAAG;AAAA,EAClB;AACA,QAAM,cAAc,MAAM,KAAK,KAAK,EAAE,IAAI,YAAU;AACnD,UAAM,SAAS,IAAI;AAAA,MAClB,gBAAgB;AAAA,QACf,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,SAAS,SAAS,MAAM;AAAA,MACzB,CAAC;AAAA,MACD,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