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,223 @@
1
+ /**
2
+ * @fileoverview Node implementation for the CompositionBinaryTree.
3
+ * This module provides the CompositionNode class with AVL tree operations and automatic expiration.
4
+ * @module DataStructures/Composition/CompositionNode
5
+ */
6
+ import { Composition } from './Composition';
7
+ /**
8
+ * Represents a node in the composition binary tree with time-based expiration.
9
+ *
10
+ * @remarks
11
+ * CompositionNode implements an AVL tree node specifically for Composition objects.
12
+ * Each node has a 10-minute expiration time for automatic cache invalidation.
13
+ * The node supports all standard AVL tree operations including rotations and balancing.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const composition = new Composition();
18
+ * const node = new CompositionNode(123, composition, null, null);
19
+ * if (node.isValid()) {
20
+ * console.log("Node is still valid");
21
+ * }
22
+ * ```
23
+ */
24
+ export declare class CompositionNode {
25
+ /**
26
+ * The expiration timestamp for this node.
27
+ * Defaults to 10 minutes from creation time.
28
+ */
29
+ expiryTime: Date;
30
+ /**
31
+ * The unique key used for tree ordering (composition ID).
32
+ */
33
+ key: number;
34
+ /**
35
+ * The Composition object stored in this node.
36
+ */
37
+ value: Composition;
38
+ /**
39
+ * Reference to the left child node.
40
+ * Null if no left child exists.
41
+ */
42
+ leftNode: CompositionNode | null;
43
+ /**
44
+ * Reference to the right child node.
45
+ * Null if no right child exists.
46
+ */
47
+ rightNode: CompositionNode | null;
48
+ /**
49
+ * The height of this node in the tree.
50
+ * Used for AVL tree balancing calculations.
51
+ */
52
+ height: number;
53
+ /**
54
+ * Creates a new CompositionNode.
55
+ *
56
+ * @param key - The unique identifier for this node (composition ID)
57
+ * @param value - The Composition 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 CompositionNode(123, composition, null, null);
64
+ * ```
65
+ */
66
+ constructor(key: number, value: Composition, leftNode: CompositionNode | null, rightNode: CompositionNode | null);
67
+ /**
68
+ * Checks if this node is still valid (not expired).
69
+ *
70
+ * @returns True if the node is valid, false if expired
71
+ *
72
+ * @remarks
73
+ * If the node has expired, it automatically removes itself from the tree.
74
+ * This ensures automatic cache invalidation after 10 minutes.
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * if (node.isValid()) {
79
+ * console.log("Node data is still fresh");
80
+ * } else {
81
+ * console.log("Node has expired and been removed");
82
+ * }
83
+ * ```
84
+ */
85
+ isValid(): boolean;
86
+ /**
87
+ * Saves data to the composition's cache.
88
+ *
89
+ * @param data - The data to be cached in the composition
90
+ *
91
+ * @remarks
92
+ * This is a convenience method to update the cached property of the stored composition.
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * node.saveToCache({ processed: true, data: [...] });
97
+ * ```
98
+ */
99
+ saveToCache(data: any): void;
100
+ /**
101
+ * Adds a new node to the tree with AVL balancing.
102
+ *
103
+ * @param passedNode - The node to be added
104
+ * @param node - The current node being evaluated
105
+ * @param height - The height of the current node
106
+ * @returns The root node after insertion and balancing
107
+ *
108
+ * @remarks
109
+ * This method implements the AVL tree insertion algorithm with automatic balancing.
110
+ * Performs left and right rotations as needed to maintain O(log n) performance.
111
+ * Also validates nodes during insertion to remove expired entries.
112
+ *
113
+ * @example
114
+ * ```typescript
115
+ * const newNode = new CompositionNode(456, newComposition, null, null);
116
+ * node.addNode(newNode, node, node.height);
117
+ * ```
118
+ */
119
+ addNode(passedNode: CompositionNode, node: CompositionNode | null, height: number): CompositionNode | null;
120
+ /**
121
+ * Performs a right rotation on the given node.
122
+ *
123
+ * @param y - The node to rotate right
124
+ * @returns The new root node after rotation
125
+ *
126
+ * @remarks
127
+ * Right rotation is an AVL tree operation used to rebalance the tree when
128
+ * the left subtree is too heavy. Updates heights after rotation.
129
+ */
130
+ rightRotate(y: CompositionNode | null): CompositionNode | null;
131
+ /**
132
+ * Performs a left rotation on the given node.
133
+ *
134
+ * @param x - The node to rotate left
135
+ * @returns The new root node after rotation
136
+ *
137
+ * @remarks
138
+ * Left rotation is an AVL tree operation used to rebalance the tree when
139
+ * the right subtree is too heavy. Updates heights after rotation.
140
+ */
141
+ leftRotate(x: CompositionNode | null): CompositionNode | null;
142
+ /**
143
+ * Gets the height of a node.
144
+ *
145
+ * @param node - The node to get the height from
146
+ * @returns The height of the node, or 0 if null
147
+ *
148
+ * @remarks
149
+ * Height is used for AVL tree balancing calculations.
150
+ */
151
+ getHeight(node: CompositionNode | null): number;
152
+ /**
153
+ * Calculates the balance factor of a node.
154
+ *
155
+ * @param N - The node to calculate the balance factor for
156
+ * @returns The balance factor (difference between left and right heights)
157
+ *
158
+ * @remarks
159
+ * Balance factor is used to determine if rotations are needed.
160
+ * Values > 1 or < -1 indicate an unbalanced tree.
161
+ */
162
+ getBalanceFactor(N: CompositionNode | null): number;
163
+ /**
164
+ * Retrieves a node from the tree by its ID.
165
+ *
166
+ * @param id - The composition ID to search for
167
+ * @param node - The current node being evaluated
168
+ * @returns The matching CompositionNode if found and valid, null otherwise
169
+ *
170
+ * @remarks
171
+ * Performs a binary search through the tree. Validates nodes during retrieval.
172
+ *
173
+ * @example
174
+ * ```typescript
175
+ * const foundNode = node.getFromNode(123, rootNode);
176
+ * ```
177
+ */
178
+ getFromNode(id: number, node: CompositionNode | null): CompositionNode | null;
179
+ /**
180
+ * Removes a node from the tree by its ID.
181
+ *
182
+ * @param passedNode - The current node being evaluated
183
+ * @param id - The composition ID to remove
184
+ * @returns The root node after removal
185
+ *
186
+ * @remarks
187
+ * Implements standard BST deletion with in-order successor replacement.
188
+ * Maintains tree structure by replacing removed nodes with their successors.
189
+ *
190
+ * @example
191
+ * ```typescript
192
+ * const newRoot = node.removeNode(rootNode, 123);
193
+ * ```
194
+ */
195
+ removeNode(passedNode: CompositionNode | null, id: number): CompositionNode | null;
196
+ /**
197
+ * Counts all nodes below and including the given node.
198
+ *
199
+ * @param root - The root node to start counting from
200
+ * @returns The total number of nodes in the subtree
201
+ *
202
+ * @remarks
203
+ * Recursively traverses the entire subtree to count all nodes.
204
+ *
205
+ * @example
206
+ * ```typescript
207
+ * const count = node.countNodeBelow(rootNode);
208
+ * console.log(`Subtree contains ${count} nodes`);
209
+ * ```
210
+ */
211
+ countNodeBelow(root: CompositionNode | null): number;
212
+ /**
213
+ * Finds the in-order successor of a node.
214
+ *
215
+ * @param root - The node to find the successor from
216
+ * @returns The in-order successor node (leftmost node in right subtree)
217
+ *
218
+ * @remarks
219
+ * Used during node deletion to find the replacement node.
220
+ * Traverses left until finding a node with no left child.
221
+ */
222
+ inOrderSuccessor(root: CompositionNode): CompositionNode;
223
+ }
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Core data structure representing a Concept in the Freeschema system.
3
+ * A Concept is the fundamental unit of knowledge/data with metadata for typing,
4
+ * categorization, security, and relationships. Concepts can reference other concepts
5
+ * through type, category, and referent relationships.
6
+ *
7
+ * @module DataStructures/Concept
8
+ * @see https://documentation.freeschema.com/#concept for concept documentation
9
+ */
10
+ /**
11
+ * Represents a concept with all its metadata and relationships.
12
+ * A Concept is a typed, categorized piece of data with security controls,
13
+ * timestamps, and the ability to reference other concepts.
14
+ *
15
+ * @class Concept
16
+ *
17
+ * @property id - Unique identifier for this concept
18
+ * @property ghostId - Ghost identifier used for local/offline concepts before backend sync
19
+ * @property userId - The ID of the user who owns/created this concept
20
+ * @property typeId - The ID of the concept that defines this concept's type
21
+ * @property typeUserId - The user ID of the type concept owner
22
+ * @property categoryId - The ID of the concept that categorizes this concept
23
+ * @property categoryUserId - The user ID of the category concept owner
24
+ * @property referentId - The ID of the concept this concept refers to (0 if none)
25
+ * @property referentUserId - The user ID of the referent concept owner
26
+ * @property characterValue - The string/text content representing this concept's value
27
+ * @property securityId - The ID of the security concept controlling access rules
28
+ * @property securityUserId - The user ID of the security concept owner
29
+ * @property accessId - The ID of the access concept defining permissions
30
+ * @property accessUserId - The user ID of the access concept owner
31
+ * @property sessionInformationId - The ID of the session concept for tracking
32
+ * @property sessionInformationUserId - The user ID of the session concept owner
33
+ * @property entryTimeStamp - Timestamp when this concept was created
34
+ * @property updatedTimeStamp - Timestamp when this concept was last updated
35
+ * @property referent - Reference to the actual Concept object this concept refers to (lazy loaded)
36
+ * @property type - Reference to the actual Concept object defining this concept's type (lazy loaded)
37
+ * @property isNew - Flag indicating if this concept is newly created and needs backend sync
38
+ * @property updateRecursion - Flag enabling recursive updates through composition hierarchies
39
+ * @property isTemp - Flag indicating if this is a temporary concept (not persisted to backend)
40
+ * @property x - X coordinate for UI visualization/drawing
41
+ * @property y - Y coordinate for UI visualization/drawing
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * // Create a concept representing a person
46
+ * const person = new Concept(
47
+ * 1001, // id
48
+ * 1, // userId
49
+ * 20, 1, // typeId (Person type), typeUserId
50
+ * 10, 1, // categoryId (People category), categoryUserId
51
+ * 0, 0, // referentId (no referent), referentUserId
52
+ * 'John Doe', // characterValue
53
+ * 30, 1, // securityId, securityUserId
54
+ * 40, 1, // accessId, accessUserId
55
+ * 50, 1, // sessionInformationId, sessionInformationUserId
56
+ * true, // isNew
57
+ * new Date(), // entryTimeStamp
58
+ * new Date() // updatedTimeStamp
59
+ * );
60
+ *
61
+ * console.log(person.characterValue); // 'John Doe'
62
+ * console.log(person.isNew); // true
63
+ * person.getType(); // Logs the typeId
64
+ * ```
65
+ *
66
+ * @remarks
67
+ * The Concept class implements a flexible, self-describing data model where:
68
+ * - Every concept has a type (which is itself a concept)
69
+ * - Every concept belongs to a category (which is itself a concept)
70
+ * - Concepts can refer to other concepts via the referent relationship
71
+ * - Security and access control are handled through concept references
72
+ * - All metadata is versioned with timestamps
73
+ * - Concepts support both backend-synced and local-only (temporary) modes
74
+ *
75
+ * @see ConceptsData for the global concept storage and management
76
+ * @see CreateTheConcept for creating new concepts
77
+ * @see https://documentation.freeschema.com/#concept for detailed concept documentation
78
+ */
79
+ export declare class Concept {
80
+ x: number;
81
+ y: number;
82
+ id: number;
83
+ ghostId: number;
84
+ userId: number;
85
+ typeId: number;
86
+ typeUserId: number;
87
+ categoryId: number;
88
+ categoryUserId: number;
89
+ referentId: number;
90
+ referentUserId: number;
91
+ characterValue: string;
92
+ securityId: number;
93
+ securityUserId: number;
94
+ accessId: number;
95
+ accessUserId: number;
96
+ sessionInformationId: number;
97
+ sessionInformationUserId: number;
98
+ entryTimeStamp: Date | string;
99
+ updatedTimeStamp: Date | string;
100
+ referent: Concept | null | void;
101
+ type: Concept | null | void;
102
+ isNew: boolean;
103
+ updateRecursion: boolean;
104
+ isTemp: boolean;
105
+ /**
106
+ * Creates a new Concept instance with all required metadata.
107
+ *
108
+ * @param id - Unique identifier for this concept
109
+ * @param userId - The ID of the user who owns this concept
110
+ * @param typeId - The ID of the type concept defining this concept's type
111
+ * @param typeUserId - The user ID of the type concept owner
112
+ * @param categoryId - The ID of the category concept this belongs to
113
+ * @param categoryUserId - The user ID of the category concept owner
114
+ * @param referentId - The ID of the referent concept (0 if none)
115
+ * @param referentUserId - The user ID of the referent concept owner
116
+ * @param characterValue - The string value representing this concept
117
+ * @param securityId - The ID of the security concept for access control
118
+ * @param securityUserId - The user ID of the security concept owner
119
+ * @param accessId - The ID of the access concept defining permissions
120
+ * @param accessUserId - The user ID of the access concept owner
121
+ * @param sessionId - The ID of the session concept for tracking
122
+ * @param sessionUserId - The user ID of the session concept owner
123
+ * @param isNew - Whether this is a newly created concept needing sync (default: false)
124
+ * @param entryTimeStamp - Creation timestamp
125
+ * @param updatedTimeStamp - Last update timestamp
126
+ */
127
+ constructor(id: number, userId: number, typeId: number, typeUserId: number, categoryId: number, categoryUserId: number, referentId: number, referentUserId: number, characterValue: string, securityId: number, securityUserId: number, accessId: number, accessUserId: number, sessionId: number, sessionUserId: number, isNew: boolean | undefined, entryTimeStamp: Date | string, updatedTimeStamp: Date | string);
128
+ /**
129
+ * Logs the typeId of this concept to the console.
130
+ * This is a utility method for debugging and inspecting the concept's type.
131
+ *
132
+ * @example
133
+ * ```typescript
134
+ * const concept = new Concept(...);
135
+ * concept.getType(); // Logs the typeId to console
136
+ * ```
137
+ */
138
+ getType(): void;
139
+ }
@@ -0,0 +1,317 @@
1
+ /**
2
+ * @fileoverview ConceptsData module for managing concept storage and retrieval in CCS-JS.
3
+ * This module provides centralized management of concepts using multiple indexing strategies
4
+ * including binary trees, character-based trees, and type-based trees for efficient lookups.
5
+ * @module DataStructures/ConceptData
6
+ */
7
+ import { Concept } from "./Concept";
8
+ /**
9
+ * Central repository for managing all concepts in the CCS system.
10
+ * Provides multiple indexing strategies (ID-based, character-based, type-based) for efficient concept retrieval.
11
+ * Maintains both in-memory (tree structures) and persistent (IndexedDB) storage.
12
+ *
13
+ * @class ConceptsData
14
+ * @example
15
+ * ```typescript
16
+ * // Add a concept to the system
17
+ * ConceptsData.AddConcept(myConcept);
18
+ *
19
+ * // Retrieve a concept by ID
20
+ * const concept = await ConceptsData.GetConcept(123);
21
+ *
22
+ * // Get concepts by type
23
+ * const concepts = ConceptsData.GetConceptsByTypeId(10);
24
+ * ```
25
+ *
26
+ * @remarks
27
+ * This class uses static methods and properties, functioning as a singleton data store.
28
+ * It coordinates multiple indexing strategies for optimized query performance.
29
+ */
30
+ export declare class ConceptsData {
31
+ /** Name identifier for this data structure */
32
+ name: string;
33
+ /**
34
+ * Creates a new ConceptsData instance.
35
+ * @remarks This is rarely instantiated as the class primarily uses static methods.
36
+ */
37
+ constructor();
38
+ /** Legacy array storage for concepts (deprecated in favor of tree structures) */
39
+ static conceptsArray: Concept[];
40
+ /**
41
+ * NPC (Non-Persistent Concepts) cache for temporarily tracking accessed concept IDs.
42
+ * Limited to 10 entries for memory management.
43
+ */
44
+ static NPC: number[];
45
+ /** Dictionary-style storage for quick concept lookups by ID */
46
+ static conceptDictionary: Concept[];
47
+ /**
48
+ * Checks if a concept already exists in the concepts array.
49
+ *
50
+ * @param {Concept} concept - The concept to check for existence
51
+ * @returns {boolean} True if the concept exists, false otherwise
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const exists = ConceptsData.CheckContains(myConcept);
56
+ * if (!exists) {
57
+ * // Add the concept
58
+ * }
59
+ * ```
60
+ */
61
+ static CheckContains(concept: Concept): boolean;
62
+ /**
63
+ * Adds a concept ID to the Non-Persistent Concepts (NPC) cache.
64
+ * Used for tracking recently accessed concepts. Automatically clears when exceeding 10 entries.
65
+ *
66
+ * @param {number} id - The concept ID to add to NPC cache
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * ConceptsData.AddNpc(123);
71
+ * ```
72
+ */
73
+ static AddNpc(id: number): void;
74
+ /**
75
+ * Checks if a concept ID exists in the NPC cache.
76
+ *
77
+ * @param {number} id - The concept ID to check
78
+ * @returns {boolean} True if the ID is in the NPC cache, false otherwise
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * if (ConceptsData.GetNpc(123)) {
83
+ * console.log("Concept recently accessed");
84
+ * }
85
+ * ```
86
+ */
87
+ static GetNpc(id: number): boolean;
88
+ /**
89
+ * Adds a concept to persistent storage (IndexedDB) only.
90
+ * Does not update in-memory tree structures.
91
+ *
92
+ * @param {Concept} concept - The concept to store persistently
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * ConceptsData.AddConceptToStorage(myConcept);
97
+ * ```
98
+ *
99
+ * @remarks Only stores concepts with valid IDs (id > 0)
100
+ */
101
+ static AddConceptToStorage(concept: Concept): void;
102
+ /**
103
+ * Adds a concept to both persistent storage and all in-memory tree indexes.
104
+ * This is the primary method for adding concepts to the system.
105
+ *
106
+ * @param {Concept} concept - The concept to add
107
+ *
108
+ * @example
109
+ * ```typescript
110
+ * const newConcept = new Concept(...);
111
+ * ConceptsData.AddConcept(newConcept);
112
+ * ```
113
+ *
114
+ * @remarks
115
+ * Updates three tree structures:
116
+ * - BinaryTree (ID-based lookup)
117
+ * - BinaryTypeTree (type-based lookup)
118
+ * - BinaryCharacterTree (character value lookup)
119
+ * Only processes concepts with valid IDs (id > 0)
120
+ */
121
+ static AddConcept(concept: Concept): void;
122
+ /**
123
+ * Adds a concept to in-memory tree structures only, without persisting to storage.
124
+ * Useful for temporary concepts or when storage is handled separately.
125
+ *
126
+ * @param {Concept} concept - The concept to add to memory
127
+ *
128
+ * @example
129
+ * ```typescript
130
+ * ConceptsData.AddConceptToMemory(temporaryConcept);
131
+ * ```
132
+ *
133
+ * @remarks
134
+ * Updates three tree structures without touching IndexedDB.
135
+ * Only processes concepts with valid IDs (id > 0)
136
+ */
137
+ static AddConceptToMemory(concept: Concept): void;
138
+ /**
139
+ * Adds a concept to the legacy array storage temporarily.
140
+ * Removes existing duplicates before adding.
141
+ *
142
+ * @param {Concept} concept - The concept to add temporarily
143
+ *
144
+ * @example
145
+ * ```typescript
146
+ * ConceptsData.AddConceptTemporary(tempConcept);
147
+ * ```
148
+ *
149
+ * @remarks
150
+ * This method uses the legacy conceptsArray and conceptDictionary.
151
+ * Consider using AddConceptToMemory for new implementations.
152
+ */
153
+ static AddConceptTemporary(concept: Concept): void;
154
+ /**
155
+ * Removes a concept from all storage locations (memory trees and persistent storage).
156
+ *
157
+ * @param {Concept} concept - The concept to remove
158
+ *
159
+ * @example
160
+ * ```typescript
161
+ * ConceptsData.RemoveConcept(obsoleteConcept);
162
+ * ```
163
+ *
164
+ * @remarks
165
+ * Removes from:
166
+ * - Legacy conceptsArray
167
+ * - BinaryTree (ID index)
168
+ * - IndexedDB persistent storage
169
+ */
170
+ static RemoveConcept(concept: Concept): void;
171
+ /**
172
+ * Retrieves a concept by its ID from the binary tree index.
173
+ *
174
+ * @param {number} id - The concept ID to retrieve
175
+ * @returns {Promise<Concept>} The concept if found, or a default concept if not found
176
+ *
177
+ * @example
178
+ * ```typescript
179
+ * const concept = await ConceptsData.GetConcept(123);
180
+ * if (concept.id !== 0) {
181
+ * console.log("Found:", concept.characterValue);
182
+ * }
183
+ * ```
184
+ *
185
+ * @remarks
186
+ * Returns a default concept (id = 0) if the concept is not found.
187
+ * Uses BinaryTree for O(log n) lookup performance.
188
+ */
189
+ static GetConcept(id: number): Promise<Concept>;
190
+ /**
191
+ * Retrieves a concept by its character value from the character tree index.
192
+ *
193
+ * @param {string} characterValue - The character value to search for
194
+ * @returns {Promise<Concept>} The concept if found, or a default concept if not found
195
+ *
196
+ * @example
197
+ * ```typescript
198
+ * const concept = await ConceptsData.GetConceptByCharacter("Hello");
199
+ * ```
200
+ *
201
+ * @remarks
202
+ * Uses BinaryCharacterTree for efficient character-based lookups.
203
+ * Returns a default concept if not found.
204
+ */
205
+ static GetConceptByCharacter(characterValue: string): Promise<Concept>;
206
+ /**
207
+ * Retrieves a concept by its character value (updated version).
208
+ * Currently identical to GetConceptByCharacter.
209
+ *
210
+ * @param {string} characterValue - The character value to search for
211
+ * @returns {Promise<Concept>} The concept if found, or a default concept if not found
212
+ *
213
+ * @example
214
+ * ```typescript
215
+ * const concept = await ConceptsData.GetConceptByCharacterUpdated("Hello");
216
+ * ```
217
+ *
218
+ * @remarks
219
+ * This method may be deprecated or merged with GetConceptByCharacter in future versions.
220
+ */
221
+ static GetConceptByCharacterUpdated(characterValue: string): Promise<Concept>;
222
+ /**
223
+ * Retrieves a concept by both its character value and type ID from local storage.
224
+ * Provides more specific matching than character-only searches.
225
+ *
226
+ * @param {string} character_value - The character value to search for
227
+ * @param {number} typeId - The type ID to filter by
228
+ * @returns {Promise<Concept>} The concept matching both criteria, or a default concept if not found
229
+ *
230
+ * @example
231
+ * ```typescript
232
+ * const concept = await ConceptsData.GetConceptByCharacterAndTypeLocal("Apple", 5);
233
+ * ```
234
+ *
235
+ * @remarks
236
+ * Uses BinaryTypeTree for efficient combined character and type lookups.
237
+ * More specific than GetConceptByCharacter as it filters by type.
238
+ */
239
+ static GetConceptByCharacterAndTypeLocal(character_value: string, typeId: number): Promise<Concept>;
240
+ /**
241
+ * Retrieves a concept by both its character value and category ID from local storage.
242
+ *
243
+ * @param {string} character_value - The character value to search for
244
+ * @param {number} categoryId - The category ID to filter by
245
+ * @returns {Promise<Concept>} The concept matching both criteria, or a default concept if not found
246
+ *
247
+ * @example
248
+ * ```typescript
249
+ * const concept = await ConceptsData.GetConceptByCharacterAndCategoryLocal("Fruit", 3);
250
+ * ```
251
+ *
252
+ * @remarks
253
+ * Uses BinaryCharacterTree with category filtering for specific lookups.
254
+ */
255
+ static GetConceptByCharacterAndCategoryLocal(character_value: string, categoryId: number): Promise<Concept>;
256
+ /**
257
+ * Retrieves all concepts of a specific type ID from local storage.
258
+ *
259
+ * @param {number} typeId - The type ID to filter by
260
+ * @returns {Concept[]} Array of concepts with the specified type
261
+ *
262
+ * @example
263
+ * ```typescript
264
+ * const fruits = ConceptsData.GetConceptsByTypeId(5);
265
+ * console.log(`Found ${fruits.length} fruits`);
266
+ * ```
267
+ *
268
+ * @remarks
269
+ * Currently searches the legacy conceptsArray.
270
+ * Consider using GetConceptsByTypeIdAndUser for more specific queries.
271
+ */
272
+ static GetConceptsByTypeId(typeId: number): Concept[];
273
+ /**
274
+ * Retrieves all concepts of a specific type ID and user ID from the type tree.
275
+ *
276
+ * @param {number} typeId - The type ID to filter by
277
+ * @param {number} userId - The user ID to filter by
278
+ * @returns {Promise<Concept[]>} Array of concepts matching both type and user
279
+ *
280
+ * @example
281
+ * ```typescript
282
+ * const userConcepts = await ConceptsData.GetConceptsByTypeIdAndUser(5, 1);
283
+ * ```
284
+ *
285
+ * @remarks
286
+ * Uses BinaryTypeTree for efficient filtered queries.
287
+ * Useful for multi-user systems to get user-specific concepts of a type.
288
+ */
289
+ static GetConceptsByTypeIdAndUser(typeId: number, userId: number): Promise<Concept[]>;
290
+ /**
291
+ * Returns the root node of the binary character tree.
292
+ * Used for direct tree traversal or debugging.
293
+ *
294
+ * @returns {Node | null} The root node of the character tree
295
+ *
296
+ * @example
297
+ * ```typescript
298
+ * const tree = ConceptsData.GetBinaryCharacterTree();
299
+ * if (tree) {
300
+ * console.log("Tree root:", tree.key);
301
+ * }
302
+ * ```
303
+ */
304
+ static GetBinaryCharacterTree(): import("./Node").Node | null;
305
+ /**
306
+ * Returns the name identifier of this data structure instance.
307
+ *
308
+ * @returns {string} The name "conceptsArray"
309
+ *
310
+ * @example
311
+ * ```typescript
312
+ * const conceptData = new ConceptsData();
313
+ * console.log(conceptData.getName()); // "conceptsArray"
314
+ * ```
315
+ */
316
+ getName(): string;
317
+ }