@wovin/core 0.1.36 → 0.2.0
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 +25 -6
- package/dist/applog/applog-utils.d.ts.map +1 -1
- package/dist/applog/datom-types.d.ts +4 -5
- 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} +6 -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-KXMTKPF4.min.js → chunk-3JZMOEOD.js} +8 -8
- package/dist/chunk-3JZMOEOD.js.map +1 -0
- package/dist/chunk-3WZVG277.js +434 -0
- package/dist/chunk-3WZVG277.js.map +1 -0
- package/dist/chunk-7Z5YDQKK.js +1 -0
- package/dist/chunk-CPSDKFBG.js +147 -0
- package/dist/chunk-CPSDKFBG.js.map +1 -0
- package/dist/chunk-E46VTKTZ.js +1 -0
- package/dist/{chunk-H3VQJP56.min.js → chunk-J2FDHGOZ.js} +9 -9
- package/dist/chunk-J2FDHGOZ.js.map +1 -0
- package/dist/chunk-L5EEEGE6.js +1862 -0
- package/dist/chunk-L5EEEGE6.js.map +1 -0
- package/dist/{chunk-BRC7LSM6.min.js → chunk-PD3C7XUM.js} +5 -5
- package/dist/chunk-PD3C7XUM.js.map +1 -0
- package/dist/chunk-QZXKQCAY.js +1026 -0
- package/dist/chunk-QZXKQCAY.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} +73 -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 +85 -21
- 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 +1 -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} +51 -32
- 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 +56 -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 +507 -0
- package/src/applog/datom-types.ts +148 -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 +277 -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 +131 -0
- package/src/query/liveFilterAndMap.test.ts +102 -0
- package/src/query/matchers.ts +8 -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 +250 -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/dist/thread/mapped.d.ts
CHANGED
|
@@ -1,27 +1,56 @@
|
|
|
1
|
-
import { Applog, ApplogForInsert } from '../applog/datom-types';
|
|
2
|
-
import { Thread, ThreadEvent } from './basic';
|
|
3
|
-
|
|
1
|
+
import { Applog, ApplogForInsert } from '../applog/datom-types.ts';
|
|
2
|
+
import { Thread, ThreadEvent } from './basic.ts';
|
|
3
|
+
/** Delta event — only incremental changes (no init) */
|
|
4
|
+
export type DeltaEvent = {
|
|
5
|
+
added: readonly Applog[];
|
|
6
|
+
removed: readonly Applog[] | null;
|
|
7
|
+
};
|
|
8
|
+
/** Context passed to mapDelta — explicit deps, no `this` needed */
|
|
9
|
+
export interface DeltaContext {
|
|
10
|
+
/** The parent thread that emitted the delta */
|
|
11
|
+
source: Thread;
|
|
12
|
+
/** All current parent threads */
|
|
13
|
+
parents: readonly Thread[];
|
|
14
|
+
/** The mapped thread's output before this delta is applied */
|
|
15
|
+
state: readonly Applog[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Derivation for a MappedThread — separates full recomputation from incremental updates.
|
|
19
|
+
*
|
|
20
|
+
* - `compute` produces full state from parents (construction, reset, parent reinit)
|
|
21
|
+
* - `mapDelta` transforms a parent's incremental delta (optional — falls back to compute)
|
|
22
|
+
*/
|
|
23
|
+
export interface ThreadDerivation {
|
|
24
|
+
/** Compute full state from parents. Called at construction, triggerRemap, and parent reinit. */
|
|
25
|
+
compute(parents: readonly Thread[]): Applog[];
|
|
26
|
+
/**
|
|
27
|
+
* Transform an incremental delta from a parent.
|
|
28
|
+
* Return null to fall back to full recompute via compute().
|
|
29
|
+
* Optional — if omitted, every parent change triggers compute().
|
|
30
|
+
*/
|
|
31
|
+
mapDelta?: (delta: DeltaEvent, ctx: DeltaContext) => DeltaEvent | null;
|
|
32
|
+
}
|
|
4
33
|
export type ApplogWriteMapper = (this: MappedThread, applogs: Applog[] | ApplogForInsert[]) => Applog[] | ApplogForInsert[] | null;
|
|
5
34
|
export declare class MappedThread extends Thread {
|
|
6
35
|
readonly name: string;
|
|
7
|
-
|
|
8
|
-
private _eventMapper;
|
|
36
|
+
private _derivation;
|
|
9
37
|
private _writeMapper;
|
|
10
38
|
private _readOnly?;
|
|
11
39
|
static mapWrites(parent: Thread, name: string, mapper: ApplogWriteMapper): MappedThread;
|
|
12
40
|
static asReadOnly(parent: Thread): Thread;
|
|
13
41
|
private _parentSubscriptions;
|
|
14
|
-
constructor(name: string, parents: Thread | readonly Thread[], filters: readonly string[],
|
|
42
|
+
constructor(name: string, parents: Thread | readonly Thread[], filters: readonly string[], _derivation: ThreadDerivation | null, _writeMapper?: ApplogWriteMapper, _readOnly?: boolean);
|
|
15
43
|
insert(appLogsToInsert: ApplogForInsert[]): void;
|
|
16
44
|
insertRaw(appLogsToInsert: Applog[]): void;
|
|
17
45
|
private subscribeToParents;
|
|
46
|
+
/** Tear down parent subscriptions and clear internal state */
|
|
47
|
+
dispose(): void;
|
|
48
|
+
/** Swap parents at runtime — re-subscribes and recomputes applogs, notifying downstream */
|
|
49
|
+
setParents(newParents: readonly Thread[]): void;
|
|
18
50
|
subscribe(callback: (event: ThreadEvent) => void, type?: 'derived' | 'reaction'): () => void;
|
|
19
|
-
/**
|
|
20
|
-
* // HACK to trigger remap on pattern change in rollingFilter
|
|
21
|
-
* should not be used lightly
|
|
22
|
-
*/
|
|
51
|
+
/** Recompute full state from parents via compute() */
|
|
23
52
|
triggerRemap(): void;
|
|
24
|
-
protected onParentUpdate(
|
|
53
|
+
protected onParentUpdate(sourceThread: Thread, event: ThreadEvent): void;
|
|
25
54
|
get readOnly(): boolean;
|
|
26
55
|
}
|
|
27
56
|
//# sourceMappingURL=mapped.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapped.d.ts","sourceRoot":"","sources":["../../src/thread/mapped.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mapped.d.ts","sourceRoot":"","sources":["../../src/thread/mapped.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAElE,OAAO,EAAe,MAAM,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAM7D,uDAAuD;AACvD,MAAM,MAAM,UAAU,GAAG;IAAE,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAA;CAAE,CAAA;AAExF,mEAAmE;AACnE,MAAM,WAAW,YAAY;IAC5B,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAA;IACd,iCAAiC;IACjC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;IAC1B,8DAA8D;IAC9D,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CACxB;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAChC,gGAAgG;IAChG,OAAO,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAAA;IAE7C;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,YAAY,KAAK,UAAU,GAAG,IAAI,CAAA;CACtE;AAKD,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,eAAe,EAAE,KAAK,MAAM,EAAE,GAAG,eAAe,EAAE,GAAG,IAAI,CAAA;AAIlI,qBAAa,YAAa,SAAQ,MAAM;IAwBtC,QAAQ,CAAC,IAAI,EAAE,MAAM;IAGrB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,SAAS,CAAC;IA5BnB,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB;IASxE,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM;IAWhC,OAAO,CAAC,oBAAoB,CAAkC;gBAGpD,IAAI,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,EACnC,OAAO,EAAE,SAAS,MAAM,EAAE,EAClB,WAAW,EAAE,gBAAgB,GAAG,IAAI,EACpC,YAAY,GAAE,iBAAwB,EACtC,SAAS,CAAC,EAAE,OAAO;IAwBrB,MAAM,CAAC,eAAe,EAAE,eAAe,EAAE;IAMzC,SAAS,CAAC,eAAe,EAAE,MAAM,EAAE;IAO1C,OAAO,CAAC,kBAAkB;IAe1B,8DAA8D;IAC9D,OAAO;IASP,2FAA2F;IAC3F,UAAU,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE;IAOxC,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,UAAU;IAO/E,sDAAsD;IACtD,YAAY;IASZ,SAAS,CAAC,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW;IA0DjE,IAAI,QAAQ,YAEX;CACD"}
|
package/dist/thread/utils.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CID } from 'multiformats';
|
|
2
|
-
import { compareApplogsByEnAt } from '../applog/applog-utils';
|
|
3
|
-
import { Applog, ApplogForInsert, CidString } from '../applog/datom-types';
|
|
4
|
-
import { Thread } from './basic';
|
|
5
|
-
import { MappedThread } from './mapped';
|
|
2
|
+
import { compareApplogsByEnAt } from '../applog/applog-utils.ts';
|
|
3
|
+
import { Applog, ApplogForInsert, CidString } from '../applog/datom-types.ts';
|
|
4
|
+
import { Thread } from './basic.ts';
|
|
5
|
+
import { MappedThread } from './mapped.ts';
|
|
6
6
|
export declare function entityCount(thread: Thread): number;
|
|
7
7
|
export declare function allEntityIDs(thread: Thread): Set<string>;
|
|
8
8
|
export declare function debounceWrites(thread: Thread, wait?: number, removeDuplicatesWith?: (objA: object, objB: object) => boolean): MappedThread;
|
|
@@ -14,7 +14,7 @@ export declare function holdTillFirstWrite(thread: Thread, applogsToHold: Applog
|
|
|
14
14
|
deduplicateHoldItemsWith?: typeof compareApplogsByEnAt;
|
|
15
15
|
onFirstWrite: (heldLogsToInsert: Applog[]) => Applog[] | undefined;
|
|
16
16
|
}): MappedThread;
|
|
17
|
-
export declare function getAgents(thread: Thread): import("
|
|
17
|
+
export declare function getAgents(thread: Thread): import("../applog.ts").AgentHash[];
|
|
18
18
|
/**
|
|
19
19
|
* Returns applogs NOT contained in the exclusion set.
|
|
20
20
|
* Uses CID-based comparison (consistent with removeDuplicateAppLogs).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/thread/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAElC,OAAO,EAAE,oBAAoB,EAAsC,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/thread/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAElC,OAAO,EAAE,oBAAoB,EAAsC,MAAM,2BAA2B,CAAA;AACpG,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,SAAS,EAAY,MAAM,0BAA0B,CAAA;AACvF,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAK1C,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,UAEzC;AACD,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,eAE1C;AAcD,wBAAgB,cAAc,CAC7B,MAAM,EAAE,MAAM,EACd,IAAI,SAAM,EACV,oBAAoB,0CAAuB,gBA4B3C;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CACjC,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,eAAe,EAAE,EAChC,IAAI,EAAE;IACL,wBAAwB,CAAC,EAAE,OAAO,oBAAoB,CAAA;IACtD,YAAY,EAAE,CAAC,gBAAgB,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,GAAG,SAAS,CAAA;CAClE,gBAyCD;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,sCAEvC;AAED;;;GAGG;AACH,eAAO,MAAM,yBAAyB,GACrC,SAAS,SAAS,MAAM,EAAE,EAC1B,SAAS,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,GAAG,CAAC,GAAG,GAAG,SAAS,CAAC,KACxD,MAAM,EAcR,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type Applog, ApplogForInsert, CidString } from '../applog/datom-types';
|
|
2
|
-
import { Thread } from './basic';
|
|
1
|
+
import { type Applog, ApplogForInsert, CidString } from '../applog/datom-types.ts';
|
|
2
|
+
import { Thread } from './basic.ts';
|
|
3
3
|
export declare abstract class WriteableThread extends Thread {
|
|
4
4
|
constructor(name: string, applogs: Applog[], filters: readonly string[]);
|
|
5
5
|
purge(cidsToPurge: CidString[]): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeable.d.ts","sourceRoot":"","sources":["../../src/thread/writeable.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"writeable.d.ts","sourceRoot":"","sources":["../../src/thread/writeable.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,MAAM,EAAE,eAAe,EAAE,SAAS,EAAiB,MAAM,0BAA0B,CAAA;AACjG,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAInC,8BAAsB,eAAgB,SAAQ,MAAM;gBAElD,IAAI,EAAE,MAAM,EAEZ,OAAO,EAAE,MAAM,EAAO,EACtB,OAAO,EAAE,SAAS,MAAM,EAAE;IAKpB,KAAK,CAAC,WAAW,EAAE,SAAS,EAAE;IAM9B,MAAM,CAAC,eAAe,EAAE,eAAe,EAAE;IAWhD;;;;OAIG;IACI,aAAa,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,UAAQ,GAAG,MAAM,EAAE;IASjF;;;;;;;;;;;;;;OAcG;IACI,SAAS,CAAC,eAAe,EAAE,MAAM,EAAE;IA6D1C,IAAI,QAAQ,YAEX;IAED,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CACzD;AACD,qBAAa,cAAe,SAAQ,eAAe;IAgBjD,QAAQ,CAAC,SAAS,EAAE,OAAO;IAf5B,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM;IAG1B,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,UAAQ;IAGnE,MAAM,CAAC,iBAAiB,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE,MAAM;gBAMjE,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE,SAAS,MAAM,EAAE,EACjB,SAAS,EAAE,OAAO;IAK5B,IAAI,QAAQ,YAEX;cAEe,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE;CAMtC"}
|
package/dist/thread.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export * from './thread/basic';
|
|
2
|
-
export * from './thread/filters';
|
|
3
|
-
export * from './thread/
|
|
4
|
-
export * from './thread/
|
|
5
|
-
export * from './thread/
|
|
1
|
+
export * from './thread/basic.ts';
|
|
2
|
+
export * from './thread/filters.ts';
|
|
3
|
+
export * from './thread/indexes.ts';
|
|
4
|
+
export * from './thread/mapped.ts';
|
|
5
|
+
export * from './thread/writeable.ts';
|
|
6
|
+
export * from './thread/utils.ts';
|
|
6
7
|
//# sourceMappingURL=thread.d.ts.map
|
package/dist/thread.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread.d.ts","sourceRoot":"","sources":["../src/thread.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"thread.d.ts","sourceRoot":"","sources":["../src/thread.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,mBAAmB,CAAA"}
|
|
@@ -5,11 +5,14 @@ import {
|
|
|
5
5
|
ThreadInMemory,
|
|
6
6
|
WriteableThread,
|
|
7
7
|
allEntityIDs,
|
|
8
|
+
applogsByAttrValue,
|
|
9
|
+
applogsByEntity,
|
|
8
10
|
asReadOnly,
|
|
9
11
|
assertOnlyCurrent,
|
|
10
12
|
assertRaw,
|
|
11
13
|
debounceWrites,
|
|
12
14
|
entityCount,
|
|
15
|
+
entityLinkIndex,
|
|
13
16
|
excludeApplogsContainedIn,
|
|
14
17
|
getAgents,
|
|
15
18
|
getLogsFromThread,
|
|
@@ -23,11 +26,8 @@ import {
|
|
|
23
26
|
rollingFilter,
|
|
24
27
|
rollingMapper,
|
|
25
28
|
simpleApplogMapper
|
|
26
|
-
} from "./chunk-
|
|
27
|
-
import "./chunk-
|
|
28
|
-
import "./chunk-QO2KMGDN.min.js";
|
|
29
|
-
import "./chunk-KEHU7HGZ.min.js";
|
|
30
|
-
import "./chunk-PHITDXZT.min.js";
|
|
29
|
+
} from "./chunk-L5EEEGE6.js";
|
|
30
|
+
import "./chunk-ZAADLBSB.js";
|
|
31
31
|
export {
|
|
32
32
|
MappedThread,
|
|
33
33
|
StaticThread,
|
|
@@ -35,11 +35,14 @@ export {
|
|
|
35
35
|
ThreadInMemory,
|
|
36
36
|
WriteableThread,
|
|
37
37
|
allEntityIDs,
|
|
38
|
+
applogsByAttrValue,
|
|
39
|
+
applogsByEntity,
|
|
38
40
|
asReadOnly,
|
|
39
41
|
assertOnlyCurrent,
|
|
40
42
|
assertRaw,
|
|
41
43
|
debounceWrites,
|
|
42
44
|
entityCount,
|
|
45
|
+
entityLinkIndex,
|
|
43
46
|
excludeApplogsContainedIn,
|
|
44
47
|
getAgents,
|
|
45
48
|
getLogsFromThread,
|
|
@@ -54,4 +57,4 @@ export {
|
|
|
54
57
|
rollingMapper,
|
|
55
58
|
simpleApplogMapper
|
|
56
59
|
};
|
|
57
|
-
//# sourceMappingURL=thread.
|
|
60
|
+
//# sourceMappingURL=thread.js.map
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { Type as T } from '@sinclair/typebox';
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
declare const StringTB: (options?: import("@sinclair/typebox").StringOptions) => import("@sinclair/typebox").TString, OptionalTB: {
|
|
3
|
+
<Type extends import("@sinclair/typebox").TMappedResult, Flag extends boolean>(type: Type, enable: Flag): import("@sinclair/typebox").TOptionalFromMappedResult<Type, Flag>;
|
|
4
|
+
<Type extends import("@sinclair/typebox").TSchema, Flag extends boolean>(type: Type, enable: Flag): import("@sinclair/typebox").TOptionalWithFlag<Type, Flag>;
|
|
5
|
+
<Type extends import("@sinclair/typebox").TMappedResult>(type: Type): import("@sinclair/typebox").TOptionalFromMappedResult<Type, true>;
|
|
6
|
+
<Type extends import("@sinclair/typebox").TSchema>(type: Type): import("@sinclair/typebox").TOptionalWithFlag<Type, true>;
|
|
7
|
+
}, BooleanTB: (options?: import("@sinclair/typebox").SchemaOptions) => import("@sinclair/typebox").TBoolean, ObjectTB: <T extends import("@sinclair/typebox").TProperties>(properties: T, options?: import("@sinclair/typebox").ObjectOptions) => import("@sinclair/typebox").TObject<T>, NumberTB: (options?: import("@sinclair/typebox").NumberOptions) => import("@sinclair/typebox").TNumber;
|
|
4
8
|
export declare const Str: typeof StringTB;
|
|
5
9
|
export declare const Num: typeof NumberTB;
|
|
6
10
|
export declare const Obj: typeof ObjectTB;
|
|
@@ -28,9 +32,6 @@ export type ArrayOrSingle<T> = T | T[] | readonly T[];
|
|
|
28
32
|
export declare function arrayIfSingle<T>(arrOrSingle: ArrayOrSingle<T>): readonly T[];
|
|
29
33
|
export type ArrayType<T> = T extends (infer U)[] ? U : T;
|
|
30
34
|
export type ArrayElementType<T> = T extends readonly (infer U)[] ? Extract<U, string> : never;
|
|
31
|
-
export type X<T> = ArrayType<IObservableArray<T>>;
|
|
32
|
-
export type ReadonlyObservableArray<T> = ReadonlyArray<T>;
|
|
33
|
-
export type ReadonlyObservableSet<T> = ObservableSet<T>;
|
|
34
35
|
export type ConstructorType<T, S = {}> = {
|
|
35
36
|
new (...args: any[]): T;
|
|
36
37
|
} & S;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript-utils.d.ts","sourceRoot":"","sources":["../../src/types/typescript-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,CAAC,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"typescript-utils.d.ts","sourceRoot":"","sources":["../../src/types/typescript-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,CAAC,EAAE,MAAM,mBAAmB,CAAA;AAO7C,QAAA,MAAgB,QAAQ,gGAAY,UAAU;;;;;GAAW,SAAS,iGAAU,QAAQ,qKAAU,QAAQ,8FAAM,CAAA;AAC5G,eAAO,MAAM,GAAG,EAAE,OAAO,QAA2B,CAAA;AACpD,eAAO,MAAM,GAAG,EAAE,OAAO,QAA2B,CAAA;AACpD,eAAO,MAAM,GAAG,EAAE,OAAO,QAA2B,CAAA;AACpD,eAAO,MAAM,GAAG,EAAE,OAAO,UAA+B,CAAA;AACxD,eAAO,MAAM,IAAI,EAAE,OAAO,SAA6B,CAAA;AAEvD,eAAO,MAAM,GAAG,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,MAAM,CAAS,CAAA;AACrD,eAAO,MAAM,GAAG,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,MAAM,CAAS,CAAA;AACrD,eAAO,MAAM,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,OAAO,CAAU,CAAA;AAExD,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAC/C,MAAM,MAAM,IAAI,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AACrE,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AAC9E,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;AAExF,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG,CAAC,GAAG,KAAK,CAAA;AAE5D;;GAEG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,GAAG,CAAA;CAAE,CAAA;AAU9C,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,IAAI,CAAC,SAAS,SAAS,CAAC,GAAG,OAAO,EAAE,EAAE,MAAM,IAAI,CAAC,GAAG,IAAI,GAAG,KAAK,CAAA;AAEtH,wBAAgB,aAAa,SAS5B;AAED,uEAAuE;AACvE,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK,IAAI,CAAA;AAEpD,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,CAAA;AACrD,wBAAgB,aAAa,CAAC,CAAC,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,EAAE,CAG5E;AACD,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAA;AACxD,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,KAAK,CAAA;AAC7F,MAAM,MAAM,eAAe,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI;IACxC,KAAI,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;CACtB,GAAG,CAAC,CAAA"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './types/typescript-utils';
|
|
1
|
+
export * from './types/typescript-utils.ts';
|
|
2
2
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-E46VTKTZ.js";
|
|
2
2
|
import {
|
|
3
3
|
BOOL,
|
|
4
4
|
Bool,
|
|
@@ -10,8 +10,7 @@ import {
|
|
|
10
10
|
Str,
|
|
11
11
|
arrayIfSingle,
|
|
12
12
|
checkParityTB
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-PHITDXZT.min.js";
|
|
13
|
+
} from "./chunk-ZAADLBSB.js";
|
|
15
14
|
export {
|
|
16
15
|
BOOL,
|
|
17
16
|
Bool,
|
|
@@ -24,4 +23,4 @@ export {
|
|
|
24
23
|
arrayIfSingle,
|
|
25
24
|
checkParityTB
|
|
26
25
|
};
|
|
27
|
-
//# sourceMappingURL=types.
|
|
26
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Applog, DatalogQueryPattern } from '../applog/datom-types.ts';
|
|
2
|
+
import type { Thread } from '../thread/basic.ts';
|
|
3
|
+
export declare const createDebugName: ({ caller, thread, pattern, args }: {
|
|
4
|
+
caller?: string;
|
|
5
|
+
thread?: Thread | Applog[];
|
|
6
|
+
pattern?: DatalogQueryPattern | DatalogQueryPattern[] | string;
|
|
7
|
+
args?: any;
|
|
8
|
+
}) => string;
|
|
9
|
+
export declare const createDebugNameObj: (args: Parameters<typeof createDebugName>[0]) => {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function prettifyThreadName(input: string): string;
|
|
13
|
+
//# sourceMappingURL=debug-name.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug-name.d.ts","sourceRoot":"","sources":["../../src/utils/debug-name.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC3E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAEhD,eAAO,MAAM,eAAe,GAAI,mCAAmC;IAClE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC1B,OAAO,CAAC,EAAE,mBAAmB,GAAG,mBAAmB,EAAE,GAAG,MAAM,CAAA;IAC9D,IAAI,CAAC,EAAE,GAAG,CAAA;CACV,WAMA,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,MAAM,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC;;CAE7E,CAAA;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAgCxD"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Applog, ApplogEncNoCid } from './applog/datom-types';
|
|
1
|
+
import { Applog, ApplogEncNoCid } from './applog/datom-types.ts';
|
|
2
2
|
export declare const isTruthy: (l: Applog | ApplogEncNoCid) => boolean;
|
|
3
3
|
export declare const keepTruthy: (arr: readonly any[]) => any[];
|
|
4
4
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAEhE,eAAO,MAAM,QAAQ,GAAI,GAAG,MAAM,GAAG,cAAc,KAAG,OAAc,CAAA;AACpE,eAAO,MAAM,UAAU,GAAI,KAAK,SAAS,GAAG,EAAE,KAAG,GAAG,EAA0B,CAAA"}
|
package/dist/utils.js
ADDED
package/package.json
CHANGED
|
@@ -1,70 +1,78 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wovin/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"main": "./dist/index.
|
|
6
|
-
"module": "./dist/index.
|
|
7
|
-
"browser": "./dist/index.
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"browser": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"
|
|
11
|
+
"source": "./src/index.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
12
13
|
"types": "./dist/index.d.ts"
|
|
13
14
|
},
|
|
14
15
|
"./applog": {
|
|
15
|
-
"
|
|
16
|
+
"source": "./src/applog.ts",
|
|
17
|
+
"import": "./dist/applog.js",
|
|
16
18
|
"types": "./dist/applog.d.ts"
|
|
17
19
|
},
|
|
18
20
|
"./blockstore": {
|
|
19
|
-
"
|
|
21
|
+
"source": "./src/blockstore.ts",
|
|
22
|
+
"import": "./dist/blockstore.js",
|
|
20
23
|
"types": "./dist/blockstore.d.ts"
|
|
21
24
|
},
|
|
22
25
|
"./ipfs": {
|
|
23
|
-
"
|
|
26
|
+
"source": "./src/ipfs.ts",
|
|
27
|
+
"import": "./dist/ipfs.js",
|
|
24
28
|
"types": "./dist/ipfs.d.ts"
|
|
25
29
|
},
|
|
26
30
|
"./pubsub": {
|
|
27
|
-
"
|
|
31
|
+
"source": "./src/pubsub.ts",
|
|
32
|
+
"import": "./dist/pubsub.js",
|
|
28
33
|
"types": "./dist/pubsub.d.ts"
|
|
29
34
|
},
|
|
30
35
|
"./query": {
|
|
31
|
-
"
|
|
36
|
+
"source": "./src/query.ts",
|
|
37
|
+
"import": "./dist/query.js",
|
|
32
38
|
"types": "./dist/query.d.ts"
|
|
33
39
|
},
|
|
34
40
|
"./retrieve": {
|
|
35
|
-
"
|
|
41
|
+
"source": "./src/retrieve.ts",
|
|
42
|
+
"import": "./dist/retrieve.js",
|
|
36
43
|
"types": "./dist/retrieve.d.ts"
|
|
37
44
|
},
|
|
38
45
|
"./thread": {
|
|
39
|
-
"
|
|
46
|
+
"source": "./src/thread.ts",
|
|
47
|
+
"import": "./dist/thread.js",
|
|
40
48
|
"types": "./dist/thread.d.ts"
|
|
41
49
|
},
|
|
42
50
|
"./types": {
|
|
43
|
-
"
|
|
51
|
+
"source": "./src/types.ts",
|
|
52
|
+
"import": "./dist/types.js",
|
|
44
53
|
"types": "./dist/types.d.ts"
|
|
45
54
|
},
|
|
46
55
|
"./utils": {
|
|
47
|
-
"
|
|
56
|
+
"source": "./src/utils.ts",
|
|
57
|
+
"import": "./dist/utils.js",
|
|
48
58
|
"types": "./dist/utils.d.ts"
|
|
49
59
|
},
|
|
50
|
-
"./mobx": {
|
|
51
|
-
"import": "./dist/mobx.min.js",
|
|
52
|
-
"types": "./dist/mobx.d.ts"
|
|
53
|
-
},
|
|
54
60
|
"./ipns": {
|
|
55
|
-
"
|
|
61
|
+
"source": "./src/ipns.ts",
|
|
62
|
+
"import": "./dist/ipns.js",
|
|
56
63
|
"types": "./dist/ipns.d.ts"
|
|
57
64
|
}
|
|
58
65
|
},
|
|
59
66
|
"files": [
|
|
60
|
-
"./dist/"
|
|
67
|
+
"./dist/",
|
|
68
|
+
"./src/"
|
|
61
69
|
],
|
|
62
70
|
"packageManager": "pnpm",
|
|
63
71
|
"esm.sh": {
|
|
64
72
|
"bundle": false
|
|
65
73
|
},
|
|
66
74
|
"peerDependencies": {
|
|
67
|
-
"@sinclair/typebox": "
|
|
75
|
+
"@sinclair/typebox": ">=0.31.28 <1"
|
|
68
76
|
},
|
|
69
77
|
"dependencies": {
|
|
70
78
|
"@ipld/car": "^5.4.2",
|
|
@@ -78,8 +86,6 @@
|
|
|
78
86
|
"iso-signatures": "^0.5.1",
|
|
79
87
|
"iso-ucan": "^0.4.2",
|
|
80
88
|
"lodash-es": "^4.17.21",
|
|
81
|
-
"mobx": "^6.13.7",
|
|
82
|
-
"mobx-utils": "^6.1.1",
|
|
83
89
|
"@libp2p/crypto": "^5.0.0",
|
|
84
90
|
"ipns": "^10.1.2",
|
|
85
91
|
"multiformats": "^13.4.1",
|
|
@@ -93,6 +99,7 @@
|
|
|
93
99
|
"tsup": "^8.5.0",
|
|
94
100
|
"typescript": "^5.9.2",
|
|
95
101
|
"vite": "^7.1.7",
|
|
102
|
+
"vitest": "^3.1.3",
|
|
96
103
|
"tsupconfig": "^0.0.0"
|
|
97
104
|
},
|
|
98
105
|
"repository": {
|
|
@@ -109,6 +116,8 @@
|
|
|
109
116
|
"dev:code": "tsup --watch",
|
|
110
117
|
"dev:types": "tsc --emitDeclarationOnly --declaration --watch",
|
|
111
118
|
"lint": "eslint .",
|
|
119
|
+
"test": "vitest run",
|
|
120
|
+
"test:watch": "vitest",
|
|
112
121
|
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
|
|
113
122
|
"pub": "npm publish --tag latest --access=public"
|
|
114
123
|
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { Logger } from 'besonders-logger'
|
|
2
|
+
import { encodeApplogAndGetCid } from '../ipfs/ipfs-utils.ts'
|
|
3
|
+
import { lastWriteWins } from '../query/basic.ts'
|
|
4
|
+
import { MappedThread, rollingFilter, Thread, ThreadOnlyCurrent, type ThreadDerivation } from '../thread.ts'
|
|
5
|
+
import { PartialBy } from '../types/typescript-utils.ts'
|
|
6
|
+
import { dateNowIso, objEqualByKeys, removeDuplicateAppLogs, sortApplogsByTs } from './applog-utils.ts'
|
|
7
|
+
import {
|
|
8
|
+
Applog,
|
|
9
|
+
ApplogForInsert,
|
|
10
|
+
ApplogForInsertOptionalAgent,
|
|
11
|
+
ApplogNoCid,
|
|
12
|
+
AgentHash,
|
|
13
|
+
CidString,
|
|
14
|
+
getApplogTypeErrors,
|
|
15
|
+
isValidApplog,
|
|
16
|
+
Timestamp,
|
|
17
|
+
} from './datom-types.ts'
|
|
18
|
+
|
|
19
|
+
const { WARN, LOG, DEBUG, VERBOSE, ERROR } = Logger.setup(Logger.INFO) // eslint-disable-line no-unused-vars
|
|
20
|
+
|
|
21
|
+
export function ensureTsPvAndFinalizeApplogs(appLogsToInsert: ApplogForInsert[], threadForPv: Thread) {
|
|
22
|
+
DEBUG(`[ensureTsPvAndFinalizeApplogs] ENTER - ${appLogsToInsert.length} applogs, thread size=${threadForPv.size}`)
|
|
23
|
+
const ts = dateNowIso()
|
|
24
|
+
// const currentThread = lastWriteWins(threadForPv, { tolerateAlreadyFiltered: true }) // HACK to get `pv` from last write
|
|
25
|
+
const currentThread = threadForPv // HACK to not do un-cached lastWriteWins
|
|
26
|
+
|
|
27
|
+
// Within-batch (en, at) duplicates produce same-ts logs whose `pv` all point to the
|
|
28
|
+
// pre-batch tail (not to each other) — chain order is then ambiguous and the second
|
|
29
|
+
// insert is at the mercy of cid lex tie-break. Caller bug; warn so it's findable.
|
|
30
|
+
const seenInBatch = new Set<string>()
|
|
31
|
+
for (const log of appLogsToInsert) {
|
|
32
|
+
const key = log.en + '|' + log.at
|
|
33
|
+
if (seenInBatch.has(key)) {
|
|
34
|
+
WARN(
|
|
35
|
+
`[ensureTsPvAndFinalizeApplogs] within-batch duplicate (en, at)=(${log.en}, ${log.at}) — chain-pv won't link these; consider separate insert calls`,
|
|
36
|
+
{ log },
|
|
37
|
+
)
|
|
38
|
+
break // one warning per batch is plenty
|
|
39
|
+
}
|
|
40
|
+
seenInBatch.add(key)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
DEBUG(`[ensureTsPvAndFinalizeApplogs] About to map over applogs`)
|
|
44
|
+
const mapped = appLogsToInsert.map((log, idx) => {
|
|
45
|
+
DEBUG(`[ensureTsPvAndFinalizeApplogs] Processing applog ${idx + 1}/${appLogsToInsert.length}`)
|
|
46
|
+
const result = finalizeApplogForInsert(log, { ts, threadForPv: currentThread })
|
|
47
|
+
DEBUG(`[ensureTsPvAndFinalizeApplogs] Finalized applog ${idx + 1}/${appLogsToInsert.length}`)
|
|
48
|
+
return result
|
|
49
|
+
})
|
|
50
|
+
DEBUG(`[ensureTsPvAndFinalizeApplogs] EXIT - mapped ${mapped.length} applogs`)
|
|
51
|
+
return mapped
|
|
52
|
+
}
|
|
53
|
+
export function ensureTsPvAndFinalizeApplog(applogToInsert: ApplogForInsert, threadForPv: Thread) {
|
|
54
|
+
return ensureTsPvAndFinalizeApplogs([applogToInsert], threadForPv)[0]
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function finalizeApplogForInsert(
|
|
58
|
+
log: ApplogForInsert,
|
|
59
|
+
{ ts, threadForPv }: { ts?: string; threadForPv?: Thread /*OnlyCurrent*/ } = {},
|
|
60
|
+
) {
|
|
61
|
+
DEBUG(`[finalizeApplogForInsert] ENTER - en=${log.en}, at=${log.at}`)
|
|
62
|
+
DEBUG(`[finalizeApplogForInsert] About to call withTs`)
|
|
63
|
+
const logWithTs = withTs(log, ts ?? dateNowIso())
|
|
64
|
+
DEBUG(`[finalizeApplogForInsert] About to call withPvFrom (thread size=${threadForPv?.size ?? 'null'})`)
|
|
65
|
+
const logWithPv = withPvFrom(logWithTs, threadForPv)
|
|
66
|
+
DEBUG(`[finalizeApplogForInsert] About to call encodeApplogAndGetCid`)
|
|
67
|
+
const cid = encodeApplogAndGetCid(logWithPv).toString() as CidString
|
|
68
|
+
DEBUG(`[finalizeApplogForInsert] CID created: ${cid}`)
|
|
69
|
+
if ((log as Applog).cid && (log as Applog).cid !== cid) WARN(`[finalizeApplogForInsert] overwriting wrong CID`, { log, cid, logWithPv })
|
|
70
|
+
const logWithCid = { ...logWithPv, cid } satisfies Applog
|
|
71
|
+
DEBUG(`[finalizeApplogForInsert] About to validate applog`)
|
|
72
|
+
if (!isValidApplog(logWithCid)) {
|
|
73
|
+
throw ERROR(`Bogus Applog ${JSON.stringify(logWithCid)}`, getApplogTypeErrors(logWithCid))
|
|
74
|
+
}
|
|
75
|
+
DEBUG(`[finalizeApplogForInsert] EXIT - CID=${cid}`)
|
|
76
|
+
return Object.freeze(logWithCid)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function hasAg(log: ApplogForInsertOptionalAgent): log is ApplogForInsert {
|
|
80
|
+
return !!log.ag
|
|
81
|
+
}
|
|
82
|
+
export function hasTs(log: ApplogForInsert): log is Omit<ApplogForInsert, 'ts'> & { ts: Timestamp } {
|
|
83
|
+
return !!log.ts
|
|
84
|
+
}
|
|
85
|
+
export function hasPv(log: ApplogForInsert): log is ApplogForInsert & { pv: string } {
|
|
86
|
+
return !!log.pv
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function withTs(log: ApplogForInsert, ts: Timestamp) {
|
|
90
|
+
return hasTs(log) ? log : { ...log, ts }
|
|
91
|
+
}
|
|
92
|
+
export function withAg(log: ApplogForInsertOptionalAgent, ag: AgentHash) {
|
|
93
|
+
return hasAg(log) ? log : { ...log, ag }
|
|
94
|
+
}
|
|
95
|
+
export function withPvFrom(log: PartialBy<ApplogNoCid, 'pv'>, thread: Thread /*OnlyCurrent*/ | null) {
|
|
96
|
+
DEBUG(`[withPvFrom] ENTER - en=${log.en}, at=${log.at}, hasPv=${log.pv !== undefined}`)
|
|
97
|
+
if (log.pv !== undefined) {
|
|
98
|
+
DEBUG(`[withPvFrom] EXIT early - pv already set`)
|
|
99
|
+
return log as ApplogNoCid // TODO: ? devMode WARN if it's different for catching bugs)
|
|
100
|
+
}
|
|
101
|
+
if (!thread) {
|
|
102
|
+
if (!hasPv(log)) throw ERROR(`[withPvFrom] no thread and no pv:`, log)
|
|
103
|
+
DEBUG(`[withPvFrom] EXIT - no thread, returning log with existing pv`)
|
|
104
|
+
return log // satisfies Pick<Applog, 'pv'>
|
|
105
|
+
} else {
|
|
106
|
+
const { en, at } = log
|
|
107
|
+
DEBUG(`[withPvFrom] About to call thread.findLast for en=${en}, at=${at}, thread.size=${thread.size}`)
|
|
108
|
+
const prevLog = thread.findLast(l => l.en == en && l.at == at) // HACK to not do lastWriteWins calc
|
|
109
|
+
DEBUG(`[withPvFrom] findLast completed, found=${!!prevLog}`)
|
|
110
|
+
// const prevLogs = rollingFilter(thread, { en, at }) // ? use some non-reactive filter here?
|
|
111
|
+
// if (prevLogs.size > 1) throw ERROR(`[withPvFrom] unexpected previous count:`, prevLogs.size, { log, prevLogs, thread }) // `thread` arg must be only current
|
|
112
|
+
// let prevLog = prevLogs.isEmpty ? null : prevLogs.applogs[0]
|
|
113
|
+
// const isMatchingPv = prevLog?.cid === log.pv
|
|
114
|
+
DEBUG(`[withPvFrom] About to check equality`)
|
|
115
|
+
if (objEqualByKeys(['en', 'at', 'vl', 'ts', 'ag'], log, prevLog)) {
|
|
116
|
+
throw ERROR(`[withPvFrom] Same as previous:`, { log, pv: prevLog, thread }) // bug catcher
|
|
117
|
+
}
|
|
118
|
+
// if (log.pv && !isMatchingPv) { // ineffective bc. shortcut in the beginning of this func
|
|
119
|
+
// WARN(`[withPvFrom] different than pre-set pv:`, { queriedPv: prevLog, logPv: log.pv })
|
|
120
|
+
// }
|
|
121
|
+
const prevLogCid = (log.pv !== undefined ? log.pv : prevLog?.cid) ?? null
|
|
122
|
+
DEBUG(`[withPvFrom] EXIT - prevLogCid=${prevLogCid}`)
|
|
123
|
+
return { ...log, pv: prevLogCid }
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
export function joinThreads(threads: ReadonlyArray<Thread>) {
|
|
127
|
+
const derivation: ThreadDerivation = {
|
|
128
|
+
compute(parents) {
|
|
129
|
+
if (parents.length < 2) DEBUG(`joinThreads with count=${parents.length}`) // ? EmptyThread
|
|
130
|
+
return sortApplogsByTs(
|
|
131
|
+
removeDuplicateAppLogs(parents.flatMap(s => {
|
|
132
|
+
const logs = s.applogs
|
|
133
|
+
if (!logs) {
|
|
134
|
+
ERROR(`falsy applogs of thread`, s)
|
|
135
|
+
throw new Error(`falsy applogs of thread`)
|
|
136
|
+
}
|
|
137
|
+
return logs
|
|
138
|
+
}), 'cleanup'),
|
|
139
|
+
)
|
|
140
|
+
},
|
|
141
|
+
mapDelta: (delta, { source, parents, state }) => ({
|
|
142
|
+
added: delta.added.filter(log => !state.includes(log)),
|
|
143
|
+
removed: delta.removed?.filter(log =>
|
|
144
|
+
state.includes(log) &&
|
|
145
|
+
!parents.some(p => p !== source && p.hasApplog(log, true))
|
|
146
|
+
),
|
|
147
|
+
}),
|
|
148
|
+
}
|
|
149
|
+
return new MappedThread(
|
|
150
|
+
`join(~ ${threads.map(s => s.name).join(', ')})`,
|
|
151
|
+
threads,
|
|
152
|
+
['?'], // HACK this basically says "we're not sure what filters are applied"
|
|
153
|
+
derivation,
|
|
154
|
+
)
|
|
155
|
+
}
|