@note3/utils 0.0.21 → 0.0.24

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.
@@ -0,0 +1,49 @@
1
+ import type { Applog, EntityID } from '@wovin/core/applog';
2
+ import type { ThreadOnlyCurrentNoDeleted } from '@wovin/core/thread';
3
+ /**
4
+ * Generic recursive traversal utility for note tree structures.
5
+ *
6
+ * Traverses a note and all its descendants, applying a mapping function to each
7
+ * node and combining results using a join function.
8
+ *
9
+ * @param thread - Pre-filtered thread (from `lastWriteWins(withoutDeleted(raw))`)
10
+ * @param blockID - The root block ID to start traversal from
11
+ * @param mapKid - Function to apply to each block/relation pair
12
+ * @param joinResults - Function to combine parent result with children results
13
+ * @returns The combined result of the traversal
14
+ *
15
+ * @throws Error if circular references are detected or depth exceeds 42 levels
16
+ *
17
+ * @internal Used by collectSubtreeApplogs; not typically used directly
18
+ */
19
+ export declare function mapAndRecurseKids<R = void>(thread: ThreadOnlyCurrentNoDeleted, blockID: EntityID, mapKid: (kid: {
20
+ relID: EntityID | null;
21
+ blockID: EntityID;
22
+ }) => R, joinResults: (blockResult: R, kidResults: R[]) => R): any;
23
+ /**
24
+ * Collects all applogs for a note and its entire subtree (descendants).
25
+ *
26
+ * This is a non-reactive utility version for use in non-UI contexts (CLI, scripts, MCP server).
27
+ * It returns a flat array of all applogs found during tree traversal.
28
+ *
29
+ * **Important**: The thread parameter MUST be pre-filtered using `lastWriteWins(withoutDeleted(thread))`
30
+ * to ensure correct tree traversal. Unfiltered threads may:
31
+ * - Include deleted blocks/relations (incorrect tree structure)
32
+ * - Include multiple versions of the same applog (redundant)
33
+ *
34
+ * @param thread - Pre-filtered thread (must be result of `lastWriteWins(withoutDeleted(raw))`)
35
+ * @param blockID - The root block ID to collect from
36
+ * @returns Flat array of all applogs from the block and its descendants
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * import { collectSubtreeApplogs } from '@note3/utils'
41
+ * import { lastWriteWins, withoutDeleted } from '@wovin/core'
42
+ *
43
+ * const filteredThread = withoutDeleted(lastWriteWins(rawThread))
44
+ * const applogs = collectSubtreeApplogs(filteredThread, blockID)
45
+ * console.log(`Collected ${applogs.length} applogs`)
46
+ * ```
47
+ */
48
+ export declare function collectSubtreeApplogs(thread: ThreadOnlyCurrentNoDeleted, blockID: EntityID): Applog[];
49
+ //# sourceMappingURL=applog-collection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applog-collection.d.ts","sourceRoot":"","sources":["../src/applog-collection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAA;AAGpE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,GAAG,IAAI,EACzC,MAAM,EAAE,0BAA0B,EAClC,OAAO,EAAE,QAAQ,EACjB,MAAM,EAAE,CAAC,GAAG,EAAE;IAAE,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;IAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,KAAK,CAAC,EACjE,WAAW,EAAE,CAAC,WAAW,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,KAAK,CAAC,OA0BnD;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,qBAAqB,CACpC,MAAM,EAAE,0BAA0B,EAClC,OAAO,EAAE,QAAQ,GACf,MAAM,EAAE,CAoBV"}
@@ -0,0 +1,2 @@
1
+ import{a,b}from"./chunk-WZPDIIA2.min.js";import"./chunk-7XDDTUI3.min.js";import"./chunk-MXMMU6NF.min.js";export{b as collectSubtreeApplogs,a as mapAndRecurseKids};
2
+ //# sourceMappingURL=applog-collection.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}