mftsccs-node 0.0.57 → 0.0.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/README.md +1148 -11
  2. package/dist/bundle.js +1 -1
  3. package/dist/types/Api/Create/CreateTheCharacter.d.ts +42 -0
  4. package/dist/types/Api/Create/CreateTheConceptApi.d.ts +50 -0
  5. package/dist/types/Api/Create/CreateTheConnectionApi.d.ts +51 -0
  6. package/dist/types/Api/Create/CreateTheTextData.d.ts +56 -0
  7. package/dist/types/Api/Delete/DeleteConceptInBackend.d.ts +43 -0
  8. package/dist/types/Api/DeleteConnectionApiBulk.d.ts +55 -0
  9. package/dist/types/Api/DeleteTheConcept.d.ts +64 -0
  10. package/dist/types/Api/DeleteTheConnection.d.ts +76 -0
  11. package/dist/types/Api/GetAiData.d.ts +36 -0
  12. package/dist/types/Api/GetAllConcepts.d.ts +42 -0
  13. package/dist/types/Api/GetAllConceptsByType.d.ts +45 -0
  14. package/dist/types/Api/GetAllConnections.d.ts +48 -0
  15. package/dist/types/Api/GetAllConnectionsOfComposition.d.ts +79 -0
  16. package/dist/types/Api/GetAllConnectionsOfCompositionBulk.d.ts +90 -0
  17. package/dist/types/Api/GetAllLinkerConnectionsFromTheConcept.d.ts +52 -0
  18. package/dist/types/Api/GetAllLinkerConnectionsToTheConcept.d.ts +61 -0
  19. package/dist/types/Api/GetAllPrefetchConnections.d.ts +51 -0
  20. package/dist/types/Api/GetCharacterDataByCharacter.d.ts +31 -0
  21. package/dist/types/Api/GetCompositionConnectionsBetweenTwoConcepts.d.ts +39 -0
  22. package/dist/types/Api/GetConcept.d.ts +47 -0
  23. package/dist/types/Api/GetConceptBulk.d.ts +68 -0
  24. package/dist/types/Api/GetConceptByCharacterAndType.d.ts +75 -0
  25. package/dist/types/Api/GetConceptByCharacterValue.d.ts +47 -0
  26. package/dist/types/Api/GetConnection.d.ts +49 -0
  27. package/dist/types/Api/GetConnectionBulk.d.ts +46 -0
  28. package/dist/types/Api/GetConnectionOfTheConcept.d.ts +50 -0
  29. package/dist/types/Api/GetConnectionToTheConcept.d.ts +56 -0
  30. package/dist/types/Api/GetReservedConnectionIds.d.ts +36 -0
  31. package/dist/types/Api/GetReservedIds.d.ts +37 -0
  32. package/dist/types/Api/Login.d.ts +38 -0
  33. package/dist/types/Api/MakeTheNameInBackend.d.ts +39 -0
  34. package/dist/types/Api/MakeTheTypeConceptApi.d.ts +40 -0
  35. package/dist/types/Api/RecursiveSearch.d.ts +43 -0
  36. package/dist/types/Api/Search/FreeschemaQueryApi.d.ts +46 -0
  37. package/dist/types/Api/Search/Search.d.ts +67 -0
  38. package/dist/types/Api/Search/SearchInternalApi.d.ts +69 -0
  39. package/dist/types/Api/Search/SearchLinkMultipleApi.d.ts +90 -0
  40. package/dist/types/Api/Search/SearchWithLinker.d.ts +97 -0
  41. package/dist/types/Api/SearchConcept/GetConceptByCharacterAndCategoryApi.d.ts +39 -0
  42. package/dist/types/Api/SearchConcept/GetConceptByCharacterAndCategoryDirect.d.ts +47 -0
  43. package/dist/types/Api/Session/CreateSession.d.ts +45 -0
  44. package/dist/types/Api/Session/CreateSessionVisit.d.ts +43 -0
  45. package/dist/types/Api/Signin.d.ts +48 -0
  46. package/dist/types/Api/Signup.d.ts +44 -0
  47. package/dist/types/Api/View/ViewInternalDataApi.d.ts +50 -0
  48. package/dist/types/Constants/ApiConstants.d.ts +226 -0
  49. package/dist/types/Constants/FormatConstants.d.ts +81 -0
  50. package/dist/types/DataStructures/BaseUrl.d.ts +210 -0
  51. package/dist/types/DataStructures/BinaryCharacterTree.d.ts +211 -0
  52. package/dist/types/DataStructures/BinaryTree.d.ts +139 -0
  53. package/dist/types/DataStructures/BinaryTypeTree.d.ts +196 -0
  54. package/dist/types/DataStructures/CharacterRepository.d.ts +109 -0
  55. package/dist/types/DataStructures/Composition/Composition.d.ts +103 -0
  56. package/dist/types/DataStructures/Composition/CompositionBinaryTree.d.ts +104 -0
  57. package/dist/types/DataStructures/Composition/CompositionNode.d.ts +202 -0
  58. package/dist/types/DataStructures/Concept.d.ts +110 -0
  59. package/dist/types/DataStructures/ConceptData.d.ts +292 -0
  60. package/dist/types/DataStructures/ConceptsToDraw.d.ts +168 -0
  61. package/dist/types/DataStructures/Connection.d.ts +76 -0
  62. package/dist/types/DataStructures/ConnectionBinaryTree/ConnectionBinaryTree.d.ts +115 -0
  63. package/dist/types/DataStructures/ConnectionBinaryTree/ConnectionNode.d.ts +169 -0
  64. package/dist/types/DataStructures/ConnectionBinaryTree/ConnectionTypeTree.d.ts +82 -0
  65. package/dist/types/DataStructures/ConnectionData.d.ts +191 -0
  66. package/dist/types/DataStructures/Count/CountInfo.d.ts +73 -0
  67. package/dist/types/DataStructures/FilterSearch.d.ts +84 -0
  68. package/dist/types/DataStructures/IdentifierFlags.d.ts +34 -0
  69. package/dist/types/DataStructures/Local/LConcept.d.ts +105 -0
  70. package/dist/types/DataStructures/Local/LConnection.d.ts +83 -0
  71. package/dist/types/DataStructures/Local/LNode.d.ts +190 -0
  72. package/dist/types/DataStructures/Local/LocalBinaryCharacterTree.d.ts +133 -0
  73. package/dist/types/DataStructures/Local/LocalBinaryTree.d.ts +135 -0
  74. package/dist/types/DataStructures/Local/LocalBinaryTypeTree.d.ts +147 -0
  75. package/dist/types/DataStructures/Local/LocalConceptData.d.ts +100 -0
  76. package/dist/types/DataStructures/Local/LocalConnectionData.d.ts +109 -0
  77. package/dist/types/DataStructures/Local/LocalSyncData.d.ts +89 -0
  78. package/dist/types/DataStructures/PatcherStructure.d.ts +86 -0
  79. package/dist/types/DataStructures/ReferentInfo.d.ts +68 -0
  80. package/dist/types/DataStructures/ReservedIds.d.ts +101 -0
  81. package/dist/types/DataStructures/Responses/ErrorResponse.d.ts +184 -22
  82. package/dist/types/DataStructures/Responses/StandardResponses.d.ts +65 -0
  83. package/dist/types/DataStructures/Returner.d.ts +59 -0
  84. package/dist/types/DataStructures/Search/FreeschemaQuery.d.ts +165 -0
  85. package/dist/types/DataStructures/Search/SearchStructure.d.ts +69 -0
  86. package/dist/types/DataStructures/SearchQuery.d.ts +130 -0
  87. package/dist/types/DataStructures/Security/TokenStorage.d.ts +48 -0
  88. package/dist/types/DataStructures/Session/SessionData.d.ts +118 -0
  89. package/dist/types/DataStructures/SettingData.d.ts +32 -0
  90. package/dist/types/DataStructures/Settings.d.ts +27 -0
  91. package/dist/types/DataStructures/SigninModel.d.ts +50 -0
  92. package/dist/types/DataStructures/SignupModel.d.ts +50 -0
  93. package/dist/types/DataStructures/SyncData.d.ts +206 -0
  94. package/dist/types/DataStructures/TheCharacter.d.ts +87 -0
  95. package/dist/types/DataStructures/TheTexts.d.ts +92 -0
  96. package/dist/types/DataStructures/Transaction/Transaction.d.ts +294 -4
  97. package/dist/types/DataStructures/User/UserBinaryTree.d.ts +117 -0
  98. package/dist/types/DataStructures/User/UserNode.d.ts +130 -0
  99. package/dist/types/Database/GetConceptFromIndexDb.d.ts +9 -0
  100. package/dist/types/Database/NoIndexDb.d.ts +169 -0
  101. package/dist/types/Database/indexdblocal.d.ts +42 -0
  102. package/dist/types/Database/indexeddb.d.ts +43 -0
  103. package/dist/types/Drawing/ConceptDraw.d.ts +28 -0
  104. package/dist/types/Drawing/ConceptEvents.d.ts +46 -0
  105. package/dist/types/Helpers/CheckIfExists.d.ts +159 -0
  106. package/dist/types/Helpers/RemoveFromArray.d.ts +66 -0
  107. package/dist/types/Helpers/UniqueInsert.d.ts +28 -0
  108. package/dist/types/Services/CheckForConnectionDeletion.d.ts +190 -0
  109. package/dist/types/Services/Common/DecodeCountInfo.d.ts +54 -0
  110. package/dist/types/Services/Common/ErrorPosting.d.ts +49 -0
  111. package/dist/types/Services/Common/RegexFunction.d.ts +28 -0
  112. package/dist/types/Services/Composition/BuildComposition.d.ts +37 -0
  113. package/dist/types/Services/Composition/CompositionCache.d.ts +89 -0
  114. package/dist/types/Services/Composition/CreateCompositionCache.d.ts +43 -0
  115. package/dist/types/Services/Conversion/ConvertConcepts.d.ts +83 -0
  116. package/dist/types/Services/CreateBinaryTreeFromData.d.ts +38 -0
  117. package/dist/types/Services/CreateCharacterBinaryTreeFromData.d.ts +42 -0
  118. package/dist/types/Services/CreateConnectionBetweenTwoConcepts.d.ts +206 -0
  119. package/dist/types/Services/CreateDefaultConcept.d.ts +114 -0
  120. package/dist/types/Services/CreateTheComposition.d.ts +101 -0
  121. package/dist/types/Services/CreateTheConcept.d.ts +179 -0
  122. package/dist/types/Services/CreateTheConnection.d.ts +59 -0
  123. package/dist/types/Services/CreateTheConnectionGeneral.d.ts +127 -0
  124. package/dist/types/Services/CreateTypeTreeFromData.d.ts +43 -0
  125. package/dist/types/Services/Delete/DeleteConnectionByType.d.ts +52 -5
  126. package/dist/types/Services/Delete/GetAllConnectionByType.d.ts +57 -9
  127. package/dist/types/Services/DeleteConcept.d.ts +136 -0
  128. package/dist/types/Services/DeleteConnection.d.ts +194 -0
  129. package/dist/types/Services/FindConeceptsFromConnection.d.ts +179 -0
  130. package/dist/types/Services/FindConnectionsOfCompositionBulkInMemory.d.ts +157 -0
  131. package/dist/types/Services/GenerateHexNumber.d.ts +64 -0
  132. package/dist/types/Services/GetComposition.d.ts +331 -0
  133. package/dist/types/Services/GetCompositionBulk.d.ts +251 -3
  134. package/dist/types/Services/GetCompositionList.d.ts +130 -0
  135. package/dist/types/Services/GetConceptByCharacter.d.ts +84 -0
  136. package/dist/types/Services/GetConnections.d.ts +72 -0
  137. package/dist/types/Services/GetDataFromIndexDb.d.ts +79 -0
  138. package/dist/types/Services/GetLink.d.ts +104 -0
  139. package/dist/types/Services/GetLinkerConnectionFromConcept.d.ts +99 -0
  140. package/dist/types/Services/GetMaximumConnectionSyncTime.d.ts +57 -0
  141. package/dist/types/Services/GetRelation.d.ts +162 -0
  142. package/dist/types/Services/GetTheConcept.d.ts +71 -0
  143. package/dist/types/Services/GetTheReferent.d.ts +74 -0
  144. package/dist/types/Services/InitializeSystem.d.ts +119 -0
  145. package/dist/types/Services/Local/CreateDefaultLConcept.d.ts +48 -0
  146. package/dist/types/Services/Local/CreateLocalBinaryTreeFromData.d.ts +49 -0
  147. package/dist/types/Services/Local/CreateLocalBinaryTypeTreeFromData.d.ts +54 -0
  148. package/dist/types/Services/Local/CreateLocalCharacterBinaryTree.d.ts +60 -0
  149. package/dist/types/Services/Local/CreateTheCompositionLocal.d.ts +70 -0
  150. package/dist/types/Services/Local/CreateTheConceptLocal.d.ts +58 -0
  151. package/dist/types/Services/Local/CreateTheConnectionLocal.d.ts +56 -0
  152. package/dist/types/Services/Local/GetCompositionListLocal.d.ts +103 -0
  153. package/dist/types/Services/Local/GetCompositionLocal.d.ts +96 -0
  154. package/dist/types/Services/Local/GetConceptByCharacterLocal.d.ts +57 -0
  155. package/dist/types/Services/Local/MakeTheConceptLocal.d.ts +71 -0
  156. package/dist/types/Services/Local/MakeTheInstanceConceptLocal.d.ts +89 -0
  157. package/dist/types/Services/Local/MakeTheTypeLocal.d.ts +71 -0
  158. package/dist/types/Services/Local/UpdateCompositionLocal.d.ts +101 -0
  159. package/dist/types/Services/MakeTheCharacter.d.ts +74 -0
  160. package/dist/types/Services/MakeTheCharacterData.d.ts +65 -0
  161. package/dist/types/Services/MakeTheInstanceConcept.d.ts +75 -0
  162. package/dist/types/Services/MakeTheName.d.ts +81 -0
  163. package/dist/types/Services/MakeTheTimestamp.d.ts +68 -0
  164. package/dist/types/Services/MakeTheTypeConcept.d.ts +68 -0
  165. package/dist/types/Services/Mqtt/publishMessage.d.ts +27 -0
  166. package/dist/types/Services/Mqtt/subscribeMessage.d.ts +23 -0
  167. package/dist/types/Services/PatchComposition.d.ts +105 -0
  168. package/dist/types/Services/Search/DataIdFormat.d.ts +96 -24
  169. package/dist/types/Services/Search/FormatData.d.ts +92 -17
  170. package/dist/types/Services/Search/JustIdFormat.d.ts +91 -16
  171. package/dist/types/Services/Search/NewFormat.d.ts +4 -0
  172. package/dist/types/Services/Search/SearchLinkInternal.d.ts +28 -0
  173. package/dist/types/Services/Search/SearchLinkMultiple.d.ts +58 -0
  174. package/dist/types/Services/Search/SearchWithTypeAndLinker.d.ts +92 -24
  175. package/dist/types/Services/Search/orderingConnections.d.ts +34 -0
  176. package/dist/types/Services/SplitStrings.d.ts +50 -0
  177. package/dist/types/Services/UpdateComposition.d.ts +123 -0
  178. package/dist/types/Services/User/UserTranslation.d.ts +102 -0
  179. package/dist/types/Services/View/ViewInternalData.d.ts +32 -0
  180. package/dist/types/WrapperFunctions/SchemaQueryObservable.d.ts +140 -5
  181. package/dist/types/app.d.ts +72 -1
  182. package/package.json +1 -1
@@ -1,11 +1,126 @@
1
+ /**
2
+ * @fileoverview Binary tree data structure for managing connections.
3
+ * This module provides an AVL tree implementation for efficient storage and retrieval of Connection objects.
4
+ * @module DataStructures/ConnectionBinaryTree/ConnectionBinaryTree
5
+ */
1
6
  import { Connection } from "../../DataStructures/Connection";
2
7
  import { ConnectionNode } from "./ConnectionNode";
8
+ /**
9
+ * Binary tree data structure for managing connections with efficient ID-based lookup.
10
+ *
11
+ * @remarks
12
+ * This class implements a self-balancing AVL tree for storing Connection objects.
13
+ * It provides O(log n) search, insertion, and deletion operations. The tree supports
14
+ * asynchronous data loading with timeout capabilities and integrates with the
15
+ * IdentifierFlags system for data synchronization.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const connection = new Connection(123, ...);
20
+ * ConnectionBinaryTree.addConnectionToTree(connection);
21
+ * const node = await ConnectionBinaryTree.getNodeFromTree(123);
22
+ * ```
23
+ */
3
24
  export declare class ConnectionBinaryTree {
25
+ /**
26
+ * The root node of the connection binary tree.
27
+ * Null if the tree is empty.
28
+ */
4
29
  static connectionroot: ConnectionNode | null;
30
+ /**
31
+ * Adds a connection node to the binary tree.
32
+ *
33
+ * @param node - The ConnectionNode to be added to the tree
34
+ * @returns The root node after insertion
35
+ *
36
+ * @remarks
37
+ * If the tree is empty, the provided node becomes the root.
38
+ * Otherwise, the node is inserted using the AVL tree balancing algorithm.
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const node = new ConnectionNode(123, connection, null, null);
43
+ * ConnectionBinaryTree.addNodeToTree(node);
44
+ * ```
45
+ */
5
46
  static addNodeToTree(node: ConnectionNode): ConnectionNode | undefined;
47
+ /**
48
+ * Creates a node from a connection and adds it to the tree.
49
+ *
50
+ * @param connection - The Connection object to be added to the tree
51
+ *
52
+ * @remarks
53
+ * This is a convenience method that wraps the connection in a ConnectionNode
54
+ * and adds it to the tree. The node is keyed by the connection's ID.
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * const connection = new Connection(123, 1, 2, 3, 4, 5);
59
+ * ConnectionBinaryTree.addConnectionToTree(connection);
60
+ * ```
61
+ */
6
62
  static addConnectionToTree(connection: Connection): void;
63
+ /**
64
+ * Waits for connection data to be loaded into the tree.
65
+ *
66
+ * @returns A promise that resolves with "done" when data is loaded, or rejects with "not" after 25 seconds
67
+ *
68
+ * @remarks
69
+ * This method polls the IdentifierFlags.isConnectionLoaded flag every second.
70
+ * Useful for ensuring data is ready before performing operations on the tree.
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * try {
75
+ * await ConnectionBinaryTree.waitForDataToLoad();
76
+ * console.log("Connection data loaded");
77
+ * } catch (error) {
78
+ * console.log("Loading timed out");
79
+ * }
80
+ * ```
81
+ */
7
82
  static waitForDataToLoad(): Promise<unknown>;
83
+ /**
84
+ * Periodically checks if connection data has been loaded.
85
+ *
86
+ * @param resolve - The promise resolve function to call when data is loaded
87
+ *
88
+ * @remarks
89
+ * This method recursively checks the IdentifierFlags.isConnectionLoaded flag every 1000ms.
90
+ */
8
91
  static checkFlag(resolve: any): any;
92
+ /**
93
+ * Removes a connection node from the tree by its ID.
94
+ *
95
+ * @param id - The numeric ID of the connection to remove
96
+ *
97
+ * @remarks
98
+ * This method removes a node from the tree while maintaining AVL balance.
99
+ * The tree is automatically rebalanced after removal.
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * await ConnectionBinaryTree.removeNodeFromTree(123);
104
+ * ```
105
+ */
9
106
  static removeNodeFromTree(id: number): Promise<void>;
107
+ /**
108
+ * Retrieves a connection node from the tree by its ID.
109
+ *
110
+ * @param id - The numeric ID of the connection to retrieve
111
+ * @returns The ConnectionNode if found, the root node otherwise
112
+ *
113
+ * @remarks
114
+ * This method performs a binary search through the tree using the connection ID as the key.
115
+ * The search has O(log n) time complexity in a balanced tree.
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * const node = await ConnectionBinaryTree.getNodeFromTree(123);
120
+ * if (node) {
121
+ * console.log("Found connection:", node.value);
122
+ * }
123
+ * ```
124
+ */
10
125
  static getNodeFromTree(id: number): Promise<ConnectionNode | null>;
11
126
  }
@@ -1,24 +1,193 @@
1
+ /**
2
+ * @fileoverview Node implementation for the ConnectionBinaryTree.
3
+ * This module provides the ConnectionNode class with AVL tree operations and variant management.
4
+ * @module DataStructures/ConnectionBinaryTree/ConnectionNode
5
+ */
1
6
  import { Connection } from "./../Connection";
7
+ /**
8
+ * Represents a node in the connection binary tree with support for variants.
9
+ *
10
+ * @remarks
11
+ * ConnectionNode implements an AVL tree node for Connection objects with special
12
+ * support for managing connection variants (multiple connections with the same key).
13
+ * Each node can store multiple connection variants in the variants array, allowing
14
+ * efficient grouping of related connections by type or other criteria.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const connection = new Connection(123, 1, 2, 3, 4, 5);
19
+ * const node = new ConnectionNode(123, connection, null, null);
20
+ * ```
21
+ */
2
22
  export declare class ConnectionNode {
23
+ /**
24
+ * The key used for tree ordering (typically connection ID or type ID).
25
+ */
3
26
  key: any;
27
+ /**
28
+ * The Connection object stored in this node.
29
+ */
4
30
  value: Connection;
31
+ /**
32
+ * Reference to the left child node.
33
+ */
5
34
  leftNode: ConnectionNode | null;
35
+ /**
36
+ * Reference to the right child node.
37
+ */
6
38
  rightNode: ConnectionNode | null;
39
+ /**
40
+ * Reference to current node for variant chaining.
41
+ */
7
42
  currentNode: ConnectionNode | null;
43
+ /**
44
+ * Array of variant nodes that share the same key.
45
+ * Used for storing multiple connections with the same type or identifier.
46
+ */
8
47
  variants: ConnectionNode[];
48
+ /**
49
+ * The height of this node in the tree.
50
+ * Used for AVL tree balancing calculations.
51
+ */
9
52
  height: number;
53
+ /**
54
+ * Creates a new ConnectionNode.
55
+ *
56
+ * @param key - The key for tree ordering
57
+ * @param value - The Connection object to store
58
+ * @param leftNode - The left child node (or null)
59
+ * @param rightNode - The right child node (or null)
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * const node = new ConnectionNode(123, connection, null, null);
64
+ * ```
65
+ */
10
66
  constructor(key: any, value: Connection, leftNode: ConnectionNode | null, rightNode: ConnectionNode | null);
67
+ /**
68
+ * Adds a node to the current node chain by type ID.
69
+ *
70
+ * @param passedNode - The node to add
71
+ * @param node - The current node in the chain
72
+ * @returns The updated node chain
73
+ *
74
+ * @remarks
75
+ * Used internally for managing connection variants with different type IDs.
76
+ */
11
77
  addCurrentNode(passedNode: ConnectionNode, node: ConnectionNode | null): ConnectionNode;
78
+ /**
79
+ * Adds a connection variant to this node's variants array.
80
+ *
81
+ * @param passedNode - The variant node to add
82
+ * @param node - The current node
83
+ * @returns The updated node with the new variant
84
+ *
85
+ * @remarks
86
+ * This method ensures no duplicate connections are added by checking IDs.
87
+ * Variants are stored in the variants array for efficient retrieval.
88
+ */
12
89
  addCurrentNodeType(passedNode: ConnectionNode, node: ConnectionNode | null): ConnectionNode;
90
+ /**
91
+ * Adds a new node to the tree with AVL balancing.
92
+ *
93
+ * @param passedNode - The node to be added
94
+ * @param node - The current node being evaluated
95
+ * @param height - The height of the current node
96
+ * @returns The root node after insertion and balancing
97
+ *
98
+ * @remarks
99
+ * Implements AVL tree insertion with automatic balancing through rotations.
100
+ */
13
101
  addNode(passedNode: ConnectionNode, node: ConnectionNode | null, height: number): ConnectionNode | null;
102
+ /**
103
+ * Adds a node to the tree indexed by type ID with variant support.
104
+ *
105
+ * @param passedNode - The node to be added
106
+ * @param node - The current node being evaluated
107
+ * @param height - The height of the current node
108
+ * @returns The root node after insertion and balancing
109
+ *
110
+ * @remarks
111
+ * This method is similar to addNode but specifically handles type-based indexing
112
+ * and manages connection variants that share the same type ID.
113
+ */
14
114
  addTypeNode(passedNode: ConnectionNode, node: ConnectionNode | null, height: number): ConnectionNode | null;
115
+ /**
116
+ * Performs a right rotation on the given node for AVL balancing.
117
+ *
118
+ * @param y - The node to rotate right
119
+ * @returns The new root node after rotation
120
+ */
15
121
  rightRotate(y: ConnectionNode | null): ConnectionNode | null;
122
+ /**
123
+ * Performs a left rotation on the given node for AVL balancing.
124
+ *
125
+ * @param x - The node to rotate left
126
+ * @returns The new root node after rotation
127
+ */
16
128
  leftRotate(x: ConnectionNode | null): ConnectionNode | null;
129
+ /**
130
+ * Gets the height of a node.
131
+ *
132
+ * @param node - The node to get the height from
133
+ * @returns The height of the node, or 0 if null
134
+ */
17
135
  getHeight(node: ConnectionNode | null): number;
136
+ /**
137
+ * Calculates the balance factor of a node.
138
+ *
139
+ * @param N - The node to calculate the balance factor for
140
+ * @returns The balance factor (difference between left and right heights)
141
+ */
18
142
  getBalanceFactor(N: ConnectionNode | null): number;
143
+ /**
144
+ * Retrieves a node from the tree by its numeric ID.
145
+ *
146
+ * @param id - The connection ID to search for
147
+ * @param node - The current node being evaluated
148
+ * @returns The matching ConnectionNode if found, null otherwise
149
+ */
19
150
  getFromNode(id: number, node: ConnectionNode | null): ConnectionNode | null;
151
+ /**
152
+ * Retrieves a node from the tree by its character/string value.
153
+ *
154
+ * @param value - The character value to search for
155
+ * @param node - The current node being evaluated
156
+ * @returns The matching ConnectionNode if found, null otherwise
157
+ */
20
158
  getCharacterFromNode(value: string, node: ConnectionNode | null): ConnectionNode | null;
159
+ /**
160
+ * Removes a node from the tree by its ID.
161
+ *
162
+ * @param passedNode - The current node being evaluated
163
+ * @param id - The connection ID to remove
164
+ * @returns The root node after removal
165
+ *
166
+ * @remarks
167
+ * Implements standard BST deletion with in-order successor replacement.
168
+ */
21
169
  removeNode(passedNode: ConnectionNode | null, id: number): ConnectionNode | null;
170
+ /**
171
+ * Removes a specific variant from a node or the entire node if no variants remain.
172
+ *
173
+ * @param passedNode - The current node being evaluated
174
+ * @param typeIdentifier - The type identifier of the node
175
+ * @param conceptId - The specific connection ID to remove
176
+ * @returns The root node after removal
177
+ *
178
+ * @remarks
179
+ * This method handles removal of connection variants. If the main value matches,
180
+ * it's replaced by the first variant. If a variant matches, only that variant is removed.
181
+ */
22
182
  removeNodeWithVariants(passedNode: ConnectionNode | null, typeIdentifier: any, conceptId: number): ConnectionNode | null;
183
+ /**
184
+ * Finds the in-order successor of a node.
185
+ *
186
+ * @param root - The node to find the successor from
187
+ * @returns The in-order successor node (leftmost node in right subtree)
188
+ *
189
+ * @remarks
190
+ * Used during node deletion to find the replacement node.
191
+ */
23
192
  inOrderSuccessor(root: ConnectionNode): ConnectionNode;
24
193
  }
@@ -1,13 +1,95 @@
1
+ /**
2
+ * @fileoverview Binary tree for managing connections indexed by type ID.
3
+ * This module provides a specialized tree for efficient type-based connection lookups and variant retrieval.
4
+ * @module DataStructures/ConnectionBinaryTree/ConnectionTypeTree
5
+ */
1
6
  import { Connection } from "../../DataStructures/Connection";
2
7
  import { ConnectionNode } from "./ConnectionNode";
8
+ /**
9
+ * Binary tree data structure for managing connections indexed by type ID.
10
+ *
11
+ * @remarks
12
+ * This class implements an AVL tree optimized for type-based connection lookups.
13
+ * It enables efficient retrieval of all connections of a specific type and supports
14
+ * variant management for grouping related connections.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const connection = new Connection(123, 1, 2, 3, 4, 5);
19
+ * ConnectionTypeTree.addConnectionToTree(connection);
20
+ * const variants = await ConnectionTypeTree.getTypeVariantsFromTree(5);
21
+ * ```
22
+ */
3
23
  export declare class ConnectionTypeTree {
24
+ /**
25
+ * The root node of the type-indexed connection tree.
26
+ * Null if the tree is empty.
27
+ */
4
28
  static connectionTypeRoot: ConnectionNode | null;
29
+ /**
30
+ * Adds a connection node to the type-indexed tree.
31
+ *
32
+ * @param node - The ConnectionNode to be added
33
+ * @returns The root node after insertion
34
+ *
35
+ * @remarks
36
+ * Uses the addTypeNode method for type-based insertion with variant support.
37
+ */
5
38
  static addNodeToTree(node: ConnectionNode): Promise<ConnectionNode | null>;
39
+ /**
40
+ * Waits for connection type data to be loaded.
41
+ *
42
+ * @returns A promise that resolves when data is loaded, or rejects after 25 seconds
43
+ */
6
44
  static waitForDataToLoad(): Promise<unknown>;
45
+ /**
46
+ * Periodically checks if connection type data has been loaded.
47
+ *
48
+ * @param resolve - The promise resolve function to call when data is loaded
49
+ */
7
50
  static checkFlag(resolve: any): any;
51
+ /**
52
+ * Creates a node from a connection and adds it to the type tree.
53
+ *
54
+ * @param connection - The Connection object to be added
55
+ *
56
+ * @remarks
57
+ * Only adds the connection if it has a non-zero typeId.
58
+ */
8
59
  static addConnectionToTree(connection: Connection): void;
60
+ /**
61
+ * Removes a specific connection variant from the tree.
62
+ *
63
+ * @param typeId - The type ID identifying the node
64
+ * @param id - The connection ID to remove
65
+ */
9
66
  static removeTypeConcept(typeId: number, id: number): void;
67
+ /**
68
+ * Retrieves a node from the tree by its type ID.
69
+ *
70
+ * @param id - The numeric type ID to search for
71
+ * @returns The ConnectionNode if found, the root node otherwise
72
+ */
10
73
  static getNodeFromTree(id: number): ConnectionNode | null;
74
+ /**
75
+ * Retrieves all connection variants for a specific type ID.
76
+ *
77
+ * @param typeId - The type ID to search for
78
+ * @returns An array of Connection objects of the specified type
79
+ *
80
+ * @remarks
81
+ * Returns the primary connection and all its variants that share the same type ID.
82
+ */
11
83
  static getTypeVariantsFromTree(typeId: number): Promise<Connection[] | undefined>;
84
+ /**
85
+ * Retrieves all connection variants for a specific type ID filtered by user ID.
86
+ *
87
+ * @param typeId - The type ID to search for
88
+ * @param userId - The user ID to filter by
89
+ * @returns An array of Connection objects of the specified type belonging to the specified user
90
+ *
91
+ * @remarks
92
+ * Useful for user-specific connection management and filtering.
93
+ */
12
94
  static getTypeVariantsFromTreeWithUserId(typeId: number, userId: number): Promise<Connection[]>;
13
95
  }
@@ -1,18 +1,209 @@
1
+ /**
2
+ * @fileoverview ConnectionData module for managing connection storage and retrieval in CCS-JS.
3
+ * This module provides centralized management of connections using binary tree indexing
4
+ * for efficient ID-based and type-based lookups.
5
+ * @module DataStructures/ConnectionData
6
+ */
1
7
  import { Connection } from "./Connection";
8
+ /**
9
+ * Central repository for managing all connections in the CCS system.
10
+ * Provides binary tree indexing for efficient connection retrieval by ID and type.
11
+ * Maintains both in-memory (tree structures) and persistent (IndexedDB) storage.
12
+ *
13
+ * @class ConnectionData
14
+ * @example
15
+ * ```typescript
16
+ * // Add a connection to the system
17
+ * ConnectionData.AddConnection(myConnection);
18
+ *
19
+ * // Retrieve a connection by ID
20
+ * const connection = await ConnectionData.GetConnection(123);
21
+ *
22
+ * // Get connections of a composition type
23
+ * const connections = await ConnectionData.GetConnectionsOfCompositionLocal(10);
24
+ * ```
25
+ *
26
+ * @remarks
27
+ * This class uses static methods and properties, functioning as a singleton data store.
28
+ * It coordinates ID-based and type-based indexing for optimized query performance.
29
+ */
2
30
  export declare class ConnectionData {
31
+ /** Name identifier for this data structure */
3
32
  name: string;
33
+ /**
34
+ * Creates a new ConnectionData instance.
35
+ * @remarks This is rarely instantiated as the class primarily uses static methods.
36
+ */
4
37
  constructor();
38
+ /** Legacy array storage for connections (deprecated in favor of tree structures) */
5
39
  static connectionArray: Connection[];
40
+ /** Dictionary-style storage for quick connection lookups by ID */
6
41
  static connectionDictionary: Connection[];
42
+ /**
43
+ * Checks if a connection already exists in the connections array.
44
+ *
45
+ * @param {Connection} connection - The connection to check for existence
46
+ * @returns {boolean} True if the connection exists, false otherwise
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * const exists = ConnectionData.CheckContains(myConnection);
51
+ * if (!exists) {
52
+ * // Add the connection
53
+ * }
54
+ * ```
55
+ */
7
56
  static CheckContains(connection: Connection): boolean;
57
+ /**
58
+ * Adds a connection to persistent storage (IndexedDB) only.
59
+ * Does not update in-memory tree structures.
60
+ *
61
+ * @param {Connection} connection - The connection to store persistently
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * ConnectionData.AddConnectionToStorage(myConnection);
66
+ * ```
67
+ */
8
68
  static AddConnectionToStorage(connection: Connection): void;
69
+ /**
70
+ * Adds a connection to both persistent storage and all in-memory tree indexes.
71
+ * This is the primary method for adding connections to the system.
72
+ *
73
+ * @param {Connection} connection - The connection to add
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * const newConnection = new Connection(...);
78
+ * ConnectionData.AddConnection(newConnection);
79
+ * ```
80
+ *
81
+ * @remarks
82
+ * Updates two tree structures:
83
+ * - ConnectionBinaryTree (ID-based lookup)
84
+ * - ConnectionTypeTree (type-based lookup)
85
+ * Skips temporary connections (isTemp = true)
86
+ */
9
87
  static AddConnection(connection: Connection): void;
88
+ /**
89
+ * Adds a connection to in-memory tree structures only, without persisting to storage.
90
+ * Useful for temporary connections or when storage is handled separately.
91
+ *
92
+ * @param {Connection} connection - The connection to add to memory
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * ConnectionData.AddConnectionToMemory(temporaryConnection);
97
+ * ```
98
+ *
99
+ * @remarks
100
+ * Updates tree structures without touching IndexedDB.
101
+ * Skips temporary connections (isTemp = true)
102
+ */
10
103
  static AddConnectionToMemory(connection: Connection): void;
104
+ /**
105
+ * Adds a connection to the dictionary for quick ID-based lookups.
106
+ *
107
+ * @param {Connection} connection - The connection to add to dictionary
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * ConnectionData.AddToDictionary(myConnection);
112
+ * ```
113
+ */
11
114
  static AddToDictionary(connection: Connection): void;
115
+ /**
116
+ * Removes a connection from all storage locations (memory trees and persistent storage).
117
+ *
118
+ * @param {Connection} connection - The connection to remove
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * ConnectionData.RemoveConnection(obsoleteConnection);
123
+ * ```
124
+ *
125
+ * @remarks
126
+ * Removes from:
127
+ * - IndexedDB persistent storage
128
+ * - ConnectionBinaryTree (ID index)
129
+ * - ConnectionTypeTree (type index)
130
+ * Only processes connections with valid IDs (id != 0)
131
+ */
12
132
  static RemoveConnection(connection: Connection): void;
133
+ /**
134
+ * Returns the root node of the connection binary tree.
135
+ * Used for direct tree traversal or debugging.
136
+ *
137
+ * @returns {Node | null} The root node of the connection tree
138
+ *
139
+ * @example
140
+ * ```typescript
141
+ * const tree = ConnectionData.GetConnectionTree();
142
+ * if (tree) {
143
+ * console.log("Tree root:", tree.key);
144
+ * }
145
+ * ```
146
+ */
13
147
  static GetConnectionTree(): import("./ConnectionBinaryTree/ConnectionNode").ConnectionNode | null;
148
+ /**
149
+ * Returns the root node of the connection type tree.
150
+ * Used for direct tree traversal or debugging.
151
+ *
152
+ * @returns {Node | null} The root node of the connection type tree
153
+ *
154
+ * @example
155
+ * ```typescript
156
+ * const tree = ConnectionData.GetConnectionTypeTree();
157
+ * ```
158
+ */
14
159
  static GetConnectionTypeTree(): import("./ConnectionBinaryTree/ConnectionNode").ConnectionNode | null;
160
+ /**
161
+ * Retrieves a connection by its ID from the binary tree index.
162
+ *
163
+ * @param {number} id - The connection ID to retrieve
164
+ * @returns {Promise<Connection>} The connection if found, or a default connection if not found
165
+ *
166
+ * @example
167
+ * ```typescript
168
+ * const connection = await ConnectionData.GetConnection(123);
169
+ * if (connection.id !== 0) {
170
+ * console.log("Found connection:", connection.ofTheConceptId, "->", connection.toTheConceptId);
171
+ * }
172
+ * ```
173
+ *
174
+ * @remarks
175
+ * Returns a default connection (id = 0) if the connection is not found.
176
+ * Uses ConnectionBinaryTree for O(log n) lookup performance.
177
+ */
15
178
  static GetConnection(id: number): Promise<Connection>;
179
+ /**
180
+ * Retrieves all connections of a specific composition type ID from the type tree.
181
+ * Includes the main connection and all its variants.
182
+ *
183
+ * @param {number} id - The type ID to filter by
184
+ * @returns {Promise<Connection[]>} Array of connections with the specified type
185
+ *
186
+ * @example
187
+ * ```typescript
188
+ * const connections = await ConnectionData.GetConnectionsOfCompositionLocal(10);
189
+ * console.log(`Found ${connections.length} connections of type 10`);
190
+ * ```
191
+ *
192
+ * @remarks
193
+ * Uses ConnectionTypeTree to retrieve the main connection and all variant connections.
194
+ * Returns an empty array if no connections are found for the type.
195
+ */
16
196
  static GetConnectionsOfCompositionLocal(id: number): Promise<Connection[]>;
197
+ /**
198
+ * Returns the name identifier of this data structure instance.
199
+ *
200
+ * @returns {string} The name "Connection Array"
201
+ *
202
+ * @example
203
+ * ```typescript
204
+ * const connectionData = new ConnectionData();
205
+ * console.log(connectionData.getName()); // "Connection Array"
206
+ * ```
207
+ */
17
208
  getName(): string;
18
209
  }
@@ -1,6 +1,79 @@
1
+ /**
2
+ * @fileoverview Defines the CountInfo class for storing connection count information.
3
+ * @module DataStructures/Count/CountInfo
4
+ */
5
+ /**
6
+ * Represents information about connection counts for a concept.
7
+ * This class stores the count of connections of a specific type
8
+ * associated with a particular concept, useful for analytics and statistics.
9
+ *
10
+ * @class CountInfo
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const countInfo = new CountInfo();
15
+ * countInfo.conceptId = 123;
16
+ * countInfo.connectionTypeId = 456;
17
+ * countInfo.connectionType = "likes";
18
+ * countInfo.count = 42;
19
+ * ```
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * // Tracking follower counts
24
+ * const followerCount = new CountInfo();
25
+ * followerCount.conceptId = 100; // User ID
26
+ * followerCount.connectionType = "followers";
27
+ * followerCount.count = 1523;
28
+ * ```
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * // Multiple connection counts for a post
33
+ * const likesCount = new CountInfo();
34
+ * likesCount.conceptId = 200; // Post ID
35
+ * likesCount.connectionType = "likes";
36
+ * likesCount.count = 350;
37
+ *
38
+ * const commentsCount = new CountInfo();
39
+ * commentsCount.conceptId = 200; // Same Post ID
40
+ * commentsCount.connectionType = "comments";
41
+ * commentsCount.count = 45;
42
+ * ```
43
+ */
1
44
  export declare class CountInfo {
45
+ /**
46
+ * The ID of the concept for which connections are being counted.
47
+ * Identifies the entity whose connections are being tracked.
48
+ *
49
+ * @type {number}
50
+ * @default 0
51
+ */
2
52
  conceptId: number;
53
+ /**
54
+ * The ID of the connection type being counted.
55
+ * Identifies which type of connection this count represents.
56
+ *
57
+ * @type {number}
58
+ * @default 0
59
+ */
3
60
  connectionTypeId: number;
61
+ /**
62
+ * The string name/description of the connection type.
63
+ * Human-readable identifier for the type of connection being counted.
64
+ *
65
+ * @type {string}
66
+ * @default ""
67
+ *
68
+ * @example "likes", "follows", "comments", "shares"
69
+ */
4
70
  connectionType: string;
71
+ /**
72
+ * The number of connections of this type.
73
+ * The actual count value representing how many connections exist.
74
+ *
75
+ * @type {number}
76
+ * @default 0
77
+ */
5
78
  count: number;
6
79
  }