mftsccs-node 0.0.56 → 0.0.58

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 (188) hide show
  1. package/README.md +1148 -11
  2. package/dist/bundle.js +1 -0
  3. package/dist/types/Api/Create/CreateTheCharacter.d.ts +45 -0
  4. package/dist/types/Api/Create/CreateTheConceptApi.d.ts +52 -0
  5. package/dist/types/Api/Create/CreateTheConnectionApi.d.ts +53 -0
  6. package/dist/types/Api/Create/CreateTheTextData.d.ts +58 -0
  7. package/dist/types/Api/Delete/DeleteConceptInBackend.d.ts +44 -0
  8. package/dist/types/Api/DeleteConnectionApiBulk.d.ts +56 -0
  9. package/dist/types/Api/DeleteTheConcept.d.ts +65 -0
  10. package/dist/types/Api/DeleteTheConnection.d.ts +77 -0
  11. package/dist/types/Api/GetAiData.d.ts +37 -0
  12. package/dist/types/Api/GetAllConcepts.d.ts +43 -0
  13. package/dist/types/Api/GetAllConceptsByType.d.ts +46 -0
  14. package/dist/types/Api/GetAllConnections.d.ts +49 -0
  15. package/dist/types/Api/GetAllConnectionsOfComposition.d.ts +82 -0
  16. package/dist/types/Api/GetAllConnectionsOfCompositionBulk.d.ts +93 -0
  17. package/dist/types/Api/GetAllLinkerConnectionsFromTheConcept.d.ts +54 -0
  18. package/dist/types/Api/GetAllLinkerConnectionsToTheConcept.d.ts +63 -0
  19. package/dist/types/Api/GetAllPrefetchConnections.d.ts +52 -0
  20. package/dist/types/Api/GetCharacterDataByCharacter.d.ts +33 -0
  21. package/dist/types/Api/GetCompositionConnectionsBetweenTwoConcepts.d.ts +41 -0
  22. package/dist/types/Api/GetConcept.d.ts +49 -0
  23. package/dist/types/Api/GetConceptBulk.d.ts +71 -0
  24. package/dist/types/Api/GetConceptByCharacterAndType.d.ts +78 -0
  25. package/dist/types/Api/GetConceptByCharacterValue.d.ts +49 -0
  26. package/dist/types/Api/GetConnection.d.ts +51 -0
  27. package/dist/types/Api/GetConnectionBulk.d.ts +48 -0
  28. package/dist/types/Api/GetConnectionOfTheConcept.d.ts +52 -0
  29. package/dist/types/Api/GetConnectionToTheConcept.d.ts +58 -0
  30. package/dist/types/Api/GetReservedConnectionIds.d.ts +37 -0
  31. package/dist/types/Api/GetReservedIds.d.ts +38 -0
  32. package/dist/types/Api/Login.d.ts +39 -0
  33. package/dist/types/Api/MakeTheNameInBackend.d.ts +40 -0
  34. package/dist/types/Api/MakeTheTypeConceptApi.d.ts +42 -0
  35. package/dist/types/Api/RecursiveSearch.d.ts +44 -0
  36. package/dist/types/Api/Search/FreeschemaQueryApi.d.ts +48 -0
  37. package/dist/types/Api/Search/Search.d.ts +68 -0
  38. package/dist/types/Api/Search/SearchInternalApi.d.ts +71 -0
  39. package/dist/types/Api/Search/SearchLinkMultipleApi.d.ts +92 -0
  40. package/dist/types/Api/Search/SearchWithLinker.d.ts +99 -0
  41. package/dist/types/Api/SearchConcept/GetConceptByCharacterAndCategoryApi.d.ts +41 -0
  42. package/dist/types/Api/SearchConcept/GetConceptByCharacterAndCategoryDirect.d.ts +49 -0
  43. package/dist/types/Api/Session/CreateSession.d.ts +47 -0
  44. package/dist/types/Api/Session/CreateSessionVisit.d.ts +44 -0
  45. package/dist/types/Api/Signin.d.ts +51 -0
  46. package/dist/types/Api/Signup.d.ts +47 -0
  47. package/dist/types/Api/View/ViewInternalDataApi.d.ts +51 -0
  48. package/dist/types/Constants/ApiConstants.d.ts +249 -0
  49. package/dist/types/Constants/FormatConstants.d.ts +87 -0
  50. package/dist/types/DataStructures/BaseUrl.d.ts +262 -0
  51. package/dist/types/DataStructures/BinaryCharacterTree.d.ts +227 -0
  52. package/dist/types/DataStructures/BinaryTree.d.ts +151 -0
  53. package/dist/types/DataStructures/BinaryTypeTree.d.ts +211 -0
  54. package/dist/types/DataStructures/CharacterRepository.d.ts +117 -0
  55. package/dist/types/DataStructures/Composition/Composition.d.ts +117 -0
  56. package/dist/types/DataStructures/Composition/CompositionBinaryTree.d.ts +114 -0
  57. package/dist/types/DataStructures/Composition/CompositionNode.d.ts +223 -0
  58. package/dist/types/DataStructures/Concept.d.ts +139 -0
  59. package/dist/types/DataStructures/ConceptData.d.ts +317 -0
  60. package/dist/types/DataStructures/ConceptsToDraw.d.ts +179 -0
  61. package/dist/types/DataStructures/Connection.d.ts +103 -0
  62. package/dist/types/DataStructures/ConnectionBinaryTree/ConnectionBinaryTree.d.ts +126 -0
  63. package/dist/types/DataStructures/ConnectionBinaryTree/ConnectionNode.d.ts +193 -0
  64. package/dist/types/DataStructures/ConnectionBinaryTree/ConnectionTypeTree.d.ts +95 -0
  65. package/dist/types/DataStructures/ConnectionData.d.ts +209 -0
  66. package/dist/types/DataStructures/Count/CountInfo.d.ts +79 -0
  67. package/dist/types/DataStructures/FilterSearch.d.ts +93 -0
  68. package/dist/types/DataStructures/IdentifierFlags.d.ts +45 -0
  69. package/dist/types/DataStructures/Local/LConcept.d.ts +126 -0
  70. package/dist/types/DataStructures/Local/LConnection.d.ts +101 -0
  71. package/dist/types/DataStructures/Local/LNode.d.ts +217 -0
  72. package/dist/types/DataStructures/Local/LocalBinaryCharacterTree.d.ts +145 -0
  73. package/dist/types/DataStructures/Local/LocalBinaryTree.d.ts +147 -0
  74. package/dist/types/DataStructures/Local/LocalBinaryTypeTree.d.ts +160 -0
  75. package/dist/types/DataStructures/Local/LocalConceptData.d.ts +114 -0
  76. package/dist/types/DataStructures/Local/LocalConnectionData.d.ts +125 -0
  77. package/dist/types/DataStructures/Local/LocalSyncData.d.ts +103 -0
  78. package/dist/types/DataStructures/Node.d.ts +29 -0
  79. package/dist/types/DataStructures/PatcherStructure.d.ts +94 -0
  80. package/dist/types/DataStructures/ReferentInfo.d.ts +75 -0
  81. package/dist/types/DataStructures/ReservedIds.d.ts +111 -0
  82. package/dist/types/DataStructures/Responses/ErrorResponse.d.ts +236 -0
  83. package/dist/types/DataStructures/Responses/StandardResponses.d.ts +71 -0
  84. package/dist/types/DataStructures/Returner.d.ts +66 -0
  85. package/dist/types/DataStructures/Search/FreeschemaQuery.d.ts +187 -0
  86. package/dist/types/DataStructures/Search/SearchStructure.d.ts +78 -0
  87. package/dist/types/DataStructures/SearchQuery.d.ts +146 -0
  88. package/dist/types/DataStructures/Security/TokenStorage.d.ts +51 -0
  89. package/dist/types/DataStructures/Session/SessionData.d.ts +131 -0
  90. package/dist/types/DataStructures/SettingData.d.ts +37 -0
  91. package/dist/types/DataStructures/Settings.d.ts +31 -0
  92. package/dist/types/DataStructures/SigninModel.d.ts +54 -0
  93. package/dist/types/DataStructures/SignupModel.d.ts +54 -0
  94. package/dist/types/DataStructures/SyncData.d.ts +232 -0
  95. package/dist/types/DataStructures/TheCharacter.d.ts +100 -0
  96. package/dist/types/DataStructures/TheTexts.d.ts +106 -0
  97. package/dist/types/DataStructures/Transaction/Transaction.d.ts +320 -0
  98. package/dist/types/DataStructures/User/UserBinaryTree.d.ts +132 -0
  99. package/dist/types/DataStructures/User/UserNode.d.ts +150 -0
  100. package/dist/types/Database/GetConceptFromIndexDb.d.ts +9 -0
  101. package/dist/types/Database/NoIndexDb.d.ts +178 -0
  102. package/dist/types/Database/indexdblocal.d.ts +45 -0
  103. package/dist/types/Database/indexeddb.d.ts +46 -0
  104. package/dist/types/Drawing/ConceptDraw.d.ts +29 -0
  105. package/dist/types/Drawing/ConceptEvents.d.ts +47 -0
  106. package/dist/types/Helpers/CheckIfExists.d.ts +169 -0
  107. package/dist/types/Helpers/RemoveFromArray.d.ts +72 -0
  108. package/dist/types/Helpers/UniqueInsert.d.ts +29 -0
  109. package/dist/types/Services/CheckForConnectionDeletion.d.ts +193 -0
  110. package/dist/types/Services/Common/DecodeCountInfo.d.ts +57 -0
  111. package/dist/types/Services/Common/ErrorPosting.d.ts +51 -0
  112. package/dist/types/Services/Common/RegexFunction.d.ts +29 -0
  113. package/dist/types/Services/Composition/BuildComposition.d.ts +40 -0
  114. package/dist/types/Services/Composition/CompositionCache.d.ts +93 -0
  115. package/dist/types/Services/Composition/CreateCompositionCache.d.ts +46 -0
  116. package/dist/types/Services/ConceptFinding/GetConceptByCharacterAndCategory.d.ts +5 -0
  117. package/dist/types/Services/Conversion/ConvertConcepts.d.ts +90 -0
  118. package/dist/types/Services/CreateBinaryTreeFromData.d.ts +39 -0
  119. package/dist/types/Services/CreateCharacterBinaryTreeFromData.d.ts +43 -0
  120. package/dist/types/Services/CreateConnectionBetweenTwoConcepts.d.ts +211 -0
  121. package/dist/types/Services/CreateDefaultConcept.d.ts +117 -0
  122. package/dist/types/Services/CreateTheComposition.d.ts +103 -0
  123. package/dist/types/Services/CreateTheConcept.d.ts +184 -0
  124. package/dist/types/Services/CreateTheConnection.d.ts +61 -0
  125. package/dist/types/Services/CreateTheConnectionGeneral.d.ts +132 -0
  126. package/dist/types/Services/CreateTypeTreeFromData.d.ts +44 -0
  127. package/dist/types/Services/Delete/DeleteConnectionByType.d.ts +60 -0
  128. package/dist/types/Services/Delete/GetAllConnectionByType.d.ts +64 -0
  129. package/dist/types/Services/DeleteConcept.d.ts +137 -0
  130. package/dist/types/Services/DeleteConnection.d.ts +196 -0
  131. package/dist/types/Services/FindConeceptsFromConnection.d.ts +181 -0
  132. package/dist/types/Services/FindConnectionsOfCompositionBulkInMemory.d.ts +159 -0
  133. package/dist/types/Services/GenerateHexNumber.d.ts +65 -0
  134. package/dist/types/Services/GetAccessIdOfUser.d.ts +0 -0
  135. package/dist/types/Services/GetComposition.d.ts +342 -0
  136. package/dist/types/Services/GetCompositionBulk.d.ts +259 -0
  137. package/dist/types/Services/GetCompositionList.d.ts +132 -0
  138. package/dist/types/Services/GetConceptByCharacter.d.ts +87 -0
  139. package/dist/types/Services/GetConnections.d.ts +74 -0
  140. package/dist/types/Services/GetDataFromIndexDb.d.ts +81 -0
  141. package/dist/types/Services/GetLink.d.ts +107 -0
  142. package/dist/types/Services/GetLinkerConnectionFromConcept.d.ts +102 -0
  143. package/dist/types/Services/GetMaximumConnectionSyncTime.d.ts +59 -0
  144. package/dist/types/Services/GetRelation.d.ts +167 -0
  145. package/dist/types/Services/GetTheConcept.d.ts +73 -0
  146. package/dist/types/Services/GetTheReferent.d.ts +76 -0
  147. package/dist/types/Services/InitializeSystem.d.ts +121 -0
  148. package/dist/types/Services/Local/CreateConnectionListFromDatat.d.ts +0 -0
  149. package/dist/types/Services/Local/CreateDefaultLConcept.d.ts +50 -0
  150. package/dist/types/Services/Local/CreateLocalBinaryTreeFromData.d.ts +50 -0
  151. package/dist/types/Services/Local/CreateLocalBinaryTypeTreeFromData.d.ts +55 -0
  152. package/dist/types/Services/Local/CreateLocalCharacterBinaryTree.d.ts +61 -0
  153. package/dist/types/Services/Local/CreateTheCompositionLocal.d.ts +72 -0
  154. package/dist/types/Services/Local/CreateTheConceptLocal.d.ts +60 -0
  155. package/dist/types/Services/Local/CreateTheConnectionLocal.d.ts +58 -0
  156. package/dist/types/Services/Local/GetCompositionListLocal.d.ts +105 -0
  157. package/dist/types/Services/Local/GetCompositionLocal.d.ts +98 -0
  158. package/dist/types/Services/Local/GetConceptByCharacterLocal.d.ts +58 -0
  159. package/dist/types/Services/Local/MakeTheConceptLocal.d.ts +73 -0
  160. package/dist/types/Services/Local/MakeTheInstanceConceptLocal.d.ts +91 -0
  161. package/dist/types/Services/Local/MakeTheTypeLocal.d.ts +73 -0
  162. package/dist/types/Services/Local/UpdateCompositionLocal.d.ts +103 -0
  163. package/dist/types/Services/MakeTheCharacter.d.ts +76 -0
  164. package/dist/types/Services/MakeTheCharacterData.d.ts +67 -0
  165. package/dist/types/Services/MakeTheConcept.d.ts +2 -0
  166. package/dist/types/Services/MakeTheInstanceConcept.d.ts +78 -0
  167. package/dist/types/Services/MakeTheLocalConcept.d.ts +0 -0
  168. package/dist/types/Services/MakeTheName.d.ts +83 -0
  169. package/dist/types/Services/MakeTheTimestamp.d.ts +70 -0
  170. package/dist/types/Services/MakeTheTypeConcept.d.ts +71 -0
  171. package/dist/types/Services/Mqtt/publishMessage.d.ts +28 -0
  172. package/dist/types/Services/Mqtt/subscribeMessage.d.ts +23 -0
  173. package/dist/types/Services/PatchComposition.d.ts +107 -0
  174. package/dist/types/Services/Search/DataIdFormat.d.ts +104 -0
  175. package/dist/types/Services/Search/FormatData.d.ts +101 -0
  176. package/dist/types/Services/Search/JustIdFormat.d.ts +98 -0
  177. package/dist/types/Services/Search/SearchLinkInternal.d.ts +30 -0
  178. package/dist/types/Services/Search/SearchLinkMultiple.d.ts +61 -0
  179. package/dist/types/Services/Search/SearchWithTypeAndLinker.d.ts +101 -0
  180. package/dist/types/Services/Search/orderingConnections.d.ts +36 -0
  181. package/dist/types/Services/Security/GetRequestHeader.d.ts +10 -0
  182. package/dist/types/Services/SplitStrings.d.ts +51 -0
  183. package/dist/types/Services/UpdateComposition.d.ts +125 -0
  184. package/dist/types/Services/User/UserTranslation.d.ts +108 -0
  185. package/dist/types/Services/View/ViewInternalData.d.ts +33 -0
  186. package/dist/types/WrapperFunctions/SchemaQueryObservable.d.ts +159 -0
  187. package/dist/types/app.d.ts +162 -0
  188. package/package.json +1 -1
@@ -0,0 +1,211 @@
1
+ /**
2
+ * @fileoverview BinaryTypeTree module providing self-balancing AVL tree for concept storage by type ID.
3
+ * This module implements an AVL tree structure for efficient concept retrieval by type
4
+ * with support for variant nodes (multiple concepts of the same type).
5
+ * @module DataStructures/BinaryTypeTree
6
+ */
7
+ import { Concept } from "../DataStructures/Concept";
8
+ import { Node } from "./Node";
9
+ /**
10
+ * Self-balancing AVL binary tree for storing and retrieving concepts by their type ID.
11
+ * Supports multiple concepts with the same type through variant nodes.
12
+ * Provides O(log n) time complexity for insertions, deletions, and lookups.
13
+ *
14
+ * @class BinaryTypeTree
15
+ * @example
16
+ * ```typescript
17
+ * // Add a concept to the type tree
18
+ * BinaryTypeTree.addConceptToTree(myConcept);
19
+ *
20
+ * // Get all concepts of a specific type
21
+ * const concepts = BinaryTypeTree.getTypeVariantsFromTree(5);
22
+ * console.log(`Found ${concepts.length} concepts of type 5`);
23
+ *
24
+ * // Get concepts by type and user
25
+ * const userConcepts = await BinaryTypeTree.getTypeVariantsFromTreeWithUserId(5, 1);
26
+ * ```
27
+ *
28
+ * @remarks
29
+ * This class uses static methods and maintains a single root node for the entire tree.
30
+ * Multiple concepts with the same type ID are stored as variants for efficient batch retrieval.
31
+ */
32
+ export declare class BinaryTypeTree {
33
+ /** Root node of the type-based binary tree, null if tree is empty */
34
+ static typeRoot: Node | null;
35
+ /**
36
+ * Adds a node to the type-based binary tree, maintaining AVL balance.
37
+ * Supports adding variant nodes for concepts with the same type ID.
38
+ *
39
+ * @param {Node} node - The node to add to the tree
40
+ * @returns {Promise<Node>} The new root node after insertion and balancing
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * const node = new Node(5, myConcept, null, null);
45
+ * await BinaryTypeTree.addNodeToTree(node);
46
+ * ```
47
+ *
48
+ * @remarks
49
+ * If the tree is empty, the node becomes the root.
50
+ * If a node with the same type ID exists, the new concept is added as a variant.
51
+ */
52
+ static addNodeToTree(node: Node): Promise<Node | null>;
53
+ /**
54
+ * Convenience method to add a concept to the type tree.
55
+ *
56
+ * @param {Concept} concept - The concept to add to the tree
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * BinaryTypeTree.addConceptToTree(myConcept);
61
+ * ```
62
+ *
63
+ * @remarks
64
+ * Only adds concepts with valid type IDs (typeId != 0).
65
+ * Creates a node with the concept's type ID as the key.
66
+ */
67
+ static addConceptToTree(concept: Concept): void;
68
+ /**
69
+ * Removes a specific concept from a type node by type ID and concept ID.
70
+ *
71
+ * @param {number} typeId - The type ID to search for
72
+ * @param {number} id - The concept ID to remove
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * BinaryTypeTree.removeTypeConcept(5, 123);
77
+ * ```
78
+ *
79
+ * @remarks
80
+ * If multiple concepts share the same type ID, only the one with matching concept ID is removed.
81
+ * Does nothing if the tree is empty.
82
+ */
83
+ static removeTypeConcept(typeId: number, id: number): void;
84
+ /**
85
+ * Retrieves a node from the tree by its type ID.
86
+ *
87
+ * @param {number} id - The type ID to search for
88
+ * @returns {Node | null} The node if found, null otherwise
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * const node = BinaryTypeTree.getNodeFromTree(5);
93
+ * if (node) {
94
+ * console.log("Found type node with", node.variants.length, "variants");
95
+ * }
96
+ * ```
97
+ *
98
+ * @remarks
99
+ * Uses binary search for O(log n) time complexity.
100
+ * Returns the main node; access all concepts of this type through node.value and node.variants.
101
+ */
102
+ static getNodeFromTree(id: number): Node | null;
103
+ /**
104
+ * Retrieves all concepts of a specific type ID as an array.
105
+ * Includes both the main concept and all variants.
106
+ *
107
+ * @param {number} typeId - The type ID to search for
108
+ * @returns {Concept[]} Array of all concepts with the specified type ID
109
+ *
110
+ * @example
111
+ * ```typescript
112
+ * const concepts = BinaryTypeTree.getTypeVariantsFromTree(5);
113
+ * concepts.forEach(concept => {
114
+ * console.log(concept.characterValue);
115
+ * });
116
+ * ```
117
+ *
118
+ * @remarks
119
+ * Returns an empty array if no concepts of the type are found.
120
+ * Useful for batch operations on all concepts of a type.
121
+ */
122
+ static getTypeVariantsFromTree(typeId: number): Concept[] | undefined;
123
+ /**
124
+ * Waits for the type data loading flag to be set before proceeding.
125
+ * Used for synchronization when loading initial data.
126
+ *
127
+ * @returns {Promise<string>} Resolves with "done" when data is loaded, rejects with "not" after 25 seconds
128
+ *
129
+ * @example
130
+ * ```typescript
131
+ * try {
132
+ * await BinaryTypeTree.waitForDataToLoad();
133
+ * console.log("Type data loaded");
134
+ * } catch (error) {
135
+ * console.log("Type data load timeout");
136
+ * }
137
+ * ```
138
+ *
139
+ * @remarks
140
+ * Uses IdentifierFlags.isTypeLoaded to determine when data is ready.
141
+ * Times out after 25 seconds to prevent infinite waiting.
142
+ */
143
+ static waitForDataToLoad(): Promise<unknown>;
144
+ /**
145
+ * Recursively checks if the type data loaded flag is set.
146
+ * Internal helper method for waitForDataToLoad.
147
+ *
148
+ * @param {any} resolve - Promise resolve function
149
+ *
150
+ * @remarks
151
+ * Checks IdentifierFlags.isTypeLoaded every 1000ms until it's true.
152
+ * This is an internal method used by waitForDataToLoad.
153
+ */
154
+ static checkFlag(resolve: any): any;
155
+ /**
156
+ * Retrieves all concepts of a specific type ID filtered by user ID.
157
+ * Includes both the main concept and all variants belonging to the specified user.
158
+ *
159
+ * @param {number} typeId - The type ID to search for
160
+ * @param {number} userId - The user ID to filter by
161
+ * @returns {Promise<Concept[]>} Array of concepts matching both type and user
162
+ *
163
+ * @example
164
+ * ```typescript
165
+ * const userConcepts = await BinaryTypeTree.getTypeVariantsFromTreeWithUserId(5, 1);
166
+ * console.log(`User 1 has ${userConcepts.length} concepts of type 5`);
167
+ * ```
168
+ *
169
+ * @remarks
170
+ * Returns an empty array if no matching concepts are found.
171
+ * Automatically deduplicates concepts with the same ID.
172
+ */
173
+ static getTypeVariantsFromTreeWithUserId(typeId: number, userId: number): Promise<Concept[]>;
174
+ /**
175
+ * Retrieves a concept matching both type ID and character value.
176
+ * Searches through all concepts of the type for a matching character value.
177
+ *
178
+ * @param {string} characterValue - The character value to search for
179
+ * @param {number} typeId - The type ID to filter by
180
+ * @returns {Promise<Concept>} The concept matching both criteria, or a default concept if not found
181
+ *
182
+ * @example
183
+ * ```typescript
184
+ * const concept = await BinaryTypeTree.getTypeVariantsWithCharacterValue("Apple", 5);
185
+ * if (concept.id !== 0) {
186
+ * console.log("Found Apple of type 5");
187
+ * }
188
+ * ```
189
+ *
190
+ * @remarks
191
+ * Returns a default concept (id = 0) if no match is found.
192
+ * More efficient than searching by character first when type is known.
193
+ */
194
+ static getTypeVariantsWithCharacterValue(characterValue: string, typeId: number): Promise<Concept>;
195
+ /**
196
+ * Counts the total number of nodes in the type tree.
197
+ *
198
+ * @returns {number} The total count of nodes in the tree
199
+ *
200
+ * @example
201
+ * ```typescript
202
+ * const nodeCount = BinaryTypeTree.countNumberOfNodes();
203
+ * console.log(`Tree contains ${nodeCount} type nodes`);
204
+ * ```
205
+ *
206
+ * @remarks
207
+ * Recursively traverses the entire tree to count nodes.
208
+ * Returns 0 if the tree is empty.
209
+ */
210
+ static countNumberOfNodes(): number;
211
+ }
@@ -0,0 +1,117 @@
1
+ /**
2
+ * @fileoverview Static repository for managing character data in the CCS-JS system.
3
+ * @module DataStructures/CharacterRepository
4
+ */
5
+ import { TheCharacter } from "./TheCharacter";
6
+ /**
7
+ * Manages a static collection of character entities with indexed storage and retrieval.
8
+ *
9
+ * @remarks
10
+ * CharacterRepository provides a centralized, static repository for storing and retrieving
11
+ * TheCharacter instances. Characters are stored in an array indexed by their ID for fast
12
+ * access. The class also provides lookup functionality to find characters by their data value.
13
+ *
14
+ * This repository uses static methods and properties, meaning the character collection is
15
+ * shared across all instances of the class. The instance method `name` is provided for
16
+ * identification purposes only.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * // Add a character to the repository
21
+ * const char = new TheCharacter(1, "A", 100, 1, 200, 1, 300, 1, "2025-10-30", false);
22
+ * CharacterRepository.AddCharacter(char);
23
+ *
24
+ * // Retrieve character by data value
25
+ * const found = CharacterRepository.GetCharacter("A");
26
+ * if (found.id !== 0) {
27
+ * console.log('Found character:', found.data);
28
+ * }
29
+ * ```
30
+ */
31
+ export declare class CharacterRepository {
32
+ /**
33
+ * Descriptive name for this character repository.
34
+ * @defaultValue "character Repository"
35
+ */
36
+ name: string;
37
+ /**
38
+ * Creates a new CharacterRepository instance.
39
+ *
40
+ * @remarks
41
+ * While the class can be instantiated, the primary functionality is accessed
42
+ * through static methods. Instances are mainly useful for accessing the descriptive
43
+ * name property.
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * const repo = new CharacterRepository();
48
+ * console.log(repo.name); // "character Repository"
49
+ * ```
50
+ */
51
+ constructor();
52
+ /**
53
+ * Static array holding all character data indexed by character ID.
54
+ *
55
+ * @remarks
56
+ * Characters are stored at index positions corresponding to their ID values.
57
+ * This provides O(1) access time when retrieving characters by ID, but may
58
+ * result in sparse arrays if character IDs are not sequential.
59
+ *
60
+ * This array should be managed through the static methods provided by the class.
61
+ */
62
+ static characterData: TheCharacter[];
63
+ /**
64
+ * Adds a character to the repository, indexed by its ID.
65
+ *
66
+ * @param character - The character to add to the repository
67
+ *
68
+ * @remarks
69
+ * The character is stored at the array index matching its ID value. If a character
70
+ * with the same ID already exists, it will be overwritten. This indexed approach
71
+ * allows for fast retrieval by ID but may create sparse arrays.
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * const char1 = new TheCharacter(1, "A", 100, 1, 200, 1, 300, 1, "2025-10-30", false);
76
+ * const char2 = new TheCharacter(5, "B", 100, 1, 200, 1, 300, 1, "2025-10-30", false);
77
+ *
78
+ * CharacterRepository.AddCharacter(char1);
79
+ * CharacterRepository.AddCharacter(char2);
80
+ *
81
+ * // char1 is at index 1, char2 is at index 5
82
+ * console.log(CharacterRepository.characterData[1].data); // "A"
83
+ * ```
84
+ */
85
+ static AddCharacter(character: TheCharacter): void;
86
+ /**
87
+ * Retrieves a character from the repository by matching its data value.
88
+ *
89
+ * @param value - The data string to search for
90
+ * @returns The matching TheCharacter instance, or a default empty character if not found
91
+ *
92
+ * @remarks
93
+ * Performs a linear search through the entire characterData array to find a character
94
+ * whose `data` property matches the provided value. If no match is found, returns a
95
+ * default TheCharacter instance with ID 0 and data "0".
96
+ *
97
+ * Note: The default character returned has all numeric fields set to 0, data set to "0",
98
+ * and isNew set to false. Callers should check the ID to determine if a valid character
99
+ * was found (a valid character should have a non-zero ID).
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * const char = new TheCharacter(1, "A", 100, 1, 200, 1, 300, 1, "2025-10-30", false);
104
+ * CharacterRepository.AddCharacter(char);
105
+ *
106
+ * // Find existing character
107
+ * const found = CharacterRepository.GetCharacter("A");
108
+ * console.log(found.id); // 1
109
+ *
110
+ * // Search for non-existent character
111
+ * const notFound = CharacterRepository.GetCharacter("Z");
112
+ * console.log(notFound.id); // 0 (default)
113
+ * console.log(notFound.data); // "0" (default)
114
+ * ```
115
+ */
116
+ static GetCharacter(value: string): TheCharacter;
117
+ }
@@ -0,0 +1,117 @@
1
+ /**
2
+ * @fileoverview Composition data structure for managing complex concept relationships.
3
+ * This module provides the core Composition class for building and managing hierarchical
4
+ * concept structures with caching and distributed system synchronization.
5
+ * @module DataStructures/Composition/Composition
6
+ */
7
+ import { Connection } from '../../DataStructures/Connection';
8
+ import { Concept } from '../../DataStructures/Concept';
9
+ /**
10
+ * Represents a composition of concepts and their relationships.
11
+ *
12
+ * @remarks
13
+ * A Composition is a hierarchical structure that combines multiple concepts through connections.
14
+ * It supports caching for performance optimization and can synchronize updates across distributed systems
15
+ * via MQTT messaging. Compositions can contain subcompositions for complex nested structures.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const composition = new Composition();
20
+ * composition.id = 123;
21
+ * composition.mainConcept = myConcept;
22
+ * await composition.updateCache();
23
+ * const data = composition.GetDataCache();
24
+ * ```
25
+ */
26
+ export declare class Composition {
27
+ /**
28
+ * Unique identifier for this composition.
29
+ */
30
+ id: number;
31
+ /**
32
+ * The primary concept at the root of this composition.
33
+ * Defaults to a default concept if not set.
34
+ */
35
+ mainConcept: Concept;
36
+ /**
37
+ * Array of connections between concepts in this composition.
38
+ */
39
+ connections: Connection[];
40
+ /**
41
+ * Array of all concepts included in this composition.
42
+ */
43
+ concepts: Concept[];
44
+ /**
45
+ * Array of IDs referencing nested subcompositions.
46
+ */
47
+ subcompositions: number[];
48
+ /**
49
+ * Cached composition data for performance optimization.
50
+ * Stores the processed composition structure.
51
+ */
52
+ cached: any;
53
+ /**
54
+ * Updates the composition cache by recursively fetching related data.
55
+ *
56
+ * @returns A promise that resolves when the cache is updated
57
+ *
58
+ * @remarks
59
+ * This method performs the following operations:
60
+ * 1. Sets the mainConcept if not already set (by matching ID with concepts array)
61
+ * 2. Recursively fetches all related concepts, connections, and subcompositions
62
+ * 3. Stores the result in the cached property for fast retrieval
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * await composition.updateCache();
67
+ * console.log("Cache updated:", composition.cached);
68
+ * ```
69
+ */
70
+ updateCache(): Promise<void>;
71
+ /**
72
+ * Publishes a composition update message to the distributed system.
73
+ *
74
+ * @remarks
75
+ * This method broadcasts an update notification via MQTT to inform other
76
+ * system components that this composition has been modified. Only publishes
77
+ * if the composition has a valid (non-zero) ID.
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * composition.UpdateAcrossDistributedSystem();
82
+ * // Other system nodes will receive the update notification
83
+ * ```
84
+ */
85
+ UpdateAcrossDistributedSystem(): void;
86
+ /**
87
+ * Triggers a distributed system update notification.
88
+ *
89
+ * @remarks
90
+ * This is a convenience method that calls UpdateAcrossDistributedSystem.
91
+ * Indicates that the composition is being updated and needs to notify other system nodes.
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * composition.isUpdating();
96
+ * ```
97
+ */
98
+ isUpdating(): void;
99
+ /**
100
+ * Retrieves the cached composition data in a structured format.
101
+ *
102
+ * @returns An object containing the formatted cache data with the composition ID
103
+ *
104
+ * @remarks
105
+ * The returned object has the following structure:
106
+ * - `data`: An object keyed by the main concept's type characterValue
107
+ * - `id`: The composition's ID
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * const cacheData = composition.GetDataCache();
112
+ * console.log("Composition ID:", cacheData.id);
113
+ * console.log("Cached data:", cacheData.data);
114
+ * ```
115
+ */
116
+ GetDataCache(): any;
117
+ }
@@ -0,0 +1,114 @@
1
+ /**
2
+ * @fileoverview Binary tree data structure for managing compositions.
3
+ * This module provides an efficient AVL tree implementation for storing and retrieving compositions.
4
+ * @module DataStructures/Composition/CompositionBinaryTree
5
+ */
6
+ import { Composition } from './Composition';
7
+ import { CompositionNode } from './CompositionNode';
8
+ /**
9
+ * Binary tree data structure for managing compositions with automatic expiration.
10
+ *
11
+ * @remarks
12
+ * This class implements an AVL tree specifically designed for storing Composition objects.
13
+ * Each node in the tree has an expiration time, allowing automatic cache invalidation.
14
+ * The tree provides O(log n) operations for insert, search, and delete.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const composition = new Composition();
19
+ * composition.id = 123;
20
+ * CompositionBinaryTree.addCompositionToTree(composition);
21
+ * const node = await CompositionBinaryTree.getNodeFromTree(123);
22
+ * ```
23
+ */
24
+ export declare class CompositionBinaryTree {
25
+ /**
26
+ * The root node of the composition binary tree.
27
+ * Null if the tree is empty.
28
+ */
29
+ static root: CompositionNode | null;
30
+ /**
31
+ * Adds a composition node to the binary tree.
32
+ *
33
+ * @param node - The CompositionNode 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 AVL tree balancing algorithm.
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const node = new CompositionNode(123, composition, null, null);
43
+ * CompositionBinaryTree.addNodeToTree(node);
44
+ * ```
45
+ */
46
+ static addNodeToTree(node: CompositionNode): CompositionNode | undefined;
47
+ /**
48
+ * Creates a node from a composition and adds it to the tree.
49
+ *
50
+ * @param composition - The Composition object to be added to the tree
51
+ *
52
+ * @remarks
53
+ * This is a convenience method that wraps the composition in a CompositionNode
54
+ * and adds it to the tree. The node is keyed by the composition's ID.
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * const composition = new Composition();
59
+ * composition.id = 123;
60
+ * CompositionBinaryTree.addCompositionToTree(composition);
61
+ * ```
62
+ */
63
+ static addCompositionToTree(composition: Composition): void;
64
+ /**
65
+ * Retrieves a composition node from the tree by its ID.
66
+ *
67
+ * @param id - The numeric ID of the composition to retrieve
68
+ * @returns The CompositionNode if found and valid, null otherwise
69
+ *
70
+ * @remarks
71
+ * This method performs a binary search through the tree.
72
+ * The node's validity is checked during retrieval (expiration check).
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * const node = await CompositionBinaryTree.getNodeFromTree(123);
77
+ * if (node) {
78
+ * console.log("Found composition:", node.value);
79
+ * }
80
+ * ```
81
+ */
82
+ static getNodeFromTree(id: number): Promise<CompositionNode | null>;
83
+ /**
84
+ * Removes a composition node from the tree by its ID.
85
+ *
86
+ * @param id - The numeric ID of the composition to remove
87
+ *
88
+ * @remarks
89
+ * This method removes a node from the tree while maintaining AVL balance.
90
+ * The tree is automatically rebalanced after removal.
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * await CompositionBinaryTree.removeNodeFromTree(123);
95
+ * ```
96
+ */
97
+ static removeNodeFromTree(id: number): Promise<void>;
98
+ /**
99
+ * Counts the total number of nodes in the tree.
100
+ *
101
+ * @returns The total number of composition nodes in the tree
102
+ *
103
+ * @remarks
104
+ * This method recursively traverses the entire tree to count all nodes.
105
+ * Returns 0 if the tree is empty.
106
+ *
107
+ * @example
108
+ * ```typescript
109
+ * const count = CompositionBinaryTree.countNumberOfNodes();
110
+ * console.log(`Tree contains ${count} compositions`);
111
+ * ```
112
+ */
113
+ static countNumberOfNodes(): number;
114
+ }