mftsccs-node 0.2.7 → 0.2.9

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,5 +1,167 @@
1
+ /**
2
+ * @module GetRelation
3
+ * @description Retrieves related concepts in the Concept Connection System (CCS).
4
+ * This module provides functions to traverse concept relationships, supporting both
5
+ * forward and reverse traversal, pagination, and multiple return formats (compositions,
6
+ * raw concepts, or connections). Relations define semantic connections between concepts.
7
+ */
1
8
  import { Connection } from "../DataStructures/Connection";
2
9
  import { Concept } from "./../DataStructures/Concept";
10
+ /**
11
+ * Retrieves related concepts as compositions through a specified relation.
12
+ *
13
+ * This function traverses concept relationships in either forward or reverse direction:
14
+ * - Forward: Finds concepts that the source concept points TO via the relation
15
+ * - Reverse: Finds concepts that point TO the source concept via the relation
16
+ *
17
+ * The process:
18
+ * 1. Gets the source concept by ID
19
+ * 2. Finds the relation concept by character and category
20
+ * 3. Retrieves connections in the specified direction
21
+ * 4. Prefetches all related concepts for performance
22
+ * 5. Converts each concept to its composition representation
23
+ *
24
+ * @param id - The ID of the source concept to find relations for
25
+ * @param relation - The name of the relation (e.g., "author", "parent", "tag")
26
+ * @param inpage - Number of results per page (default: 10)
27
+ * @param page - Page number to retrieve (default: 1)
28
+ * @param reverse - If true, finds concepts pointing TO this concept; if false, finds concepts this concept points TO (default: false)
29
+ *
30
+ * @returns Promise resolving to an array of compositions representing related concepts
31
+ *
32
+ * @remarks
33
+ * - Uses GetConceptByCharacterAndCategory to find the relation concept
34
+ * - Forward direction uses GetConnectionOfTheConcept (from -> to)
35
+ * - Reverse direction uses GetConnectionToTheConcept (to <- from)
36
+ * - Uses bulk prefetching for performance optimization
37
+ * - Returns compositions with full connection data
38
+ * - Empty array if relation concept not found
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * // Get all posts authored by a user (forward relation)
43
+ * const userPosts = await GetRelation(123, "author", 10, 1, false);
44
+ *
45
+ * // Get the author of a post (reverse relation)
46
+ * const postAuthor = await GetRelation(456, "author", 1, 1, true);
47
+ *
48
+ * // Get tags for an article (forward)
49
+ * const tags = await GetRelation(789, "tag", 20, 1, false);
50
+ *
51
+ * // Get all articles with a specific tag (reverse)
52
+ * const taggedArticles = await GetRelation(789, "tag", 20, 1, true);
53
+ *
54
+ * // Each result is a composition with connections
55
+ * userPosts.forEach(post => {
56
+ * console.log("Related composition:", post);
57
+ * });
58
+ * ```
59
+ *
60
+ * @see {@link GetRelationRaw} - Returns raw concepts instead of compositions
61
+ * @see {@link GetRelationConnections} - Returns connection objects
62
+ * @see {@link GetTheConcept} - Retrieves individual concepts
63
+ * @see {@link GetCompositionWithIdAndDateFromMemory} - Converts concepts to compositions
64
+ */
3
65
  export declare function GetRelation(id: number, relation: string, inpage?: number, page?: number, reverse?: boolean): Promise<any[]>;
66
+ /**
67
+ * Retrieves related concepts in raw form through a specified relation.
68
+ *
69
+ * This function is similar to GetRelation but returns raw Concept objects instead
70
+ * of compositions. It supports both forward and reverse traversal and uses bulk
71
+ * concept retrieval for optimal performance. This is more lightweight when only
72
+ * concept data is needed without full composition details.
73
+ *
74
+ * @param id - The ID of the source concept to find relations for
75
+ * @param relation - The name of the relation (e.g., "author", "parent", "tag")
76
+ * @param inpage - Number of results per page (default: 10)
77
+ * @param page - Page number to retrieve (default: 1)
78
+ * @param reverse - If true, finds concepts pointing TO this concept; if false, finds concepts this concept points TO (default: false)
79
+ *
80
+ * @returns Promise resolving to an array of raw Concept objects
81
+ *
82
+ * @remarks
83
+ * - Returns Concept objects directly without composition wrapper
84
+ * - More lightweight than GetRelation - use when compositions not needed
85
+ * - Uses GetConceptBulk for efficient bulk retrieval
86
+ * - Supports both forward and reverse traversal
87
+ * - Empty array if relation concept not found
88
+ * - Better performance for simple concept retrieval
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * // Get raw author concepts
93
+ * const authors = await GetRelationRaw(123, "author", 10, 1, true);
94
+ * authors.forEach(author => {
95
+ * console.log("Author ID:", author.id);
96
+ * console.log("Author Type:", author.type);
97
+ * });
98
+ *
99
+ * // Get related tags without composition overhead
100
+ * const tags = await GetRelationRaw(456, "tag", 20, 1, false);
101
+ *
102
+ * // Quick check for existence
103
+ * const parents = await GetRelationRaw(789, "parent", 1, 1, false);
104
+ * const hasParent = parents.length > 0;
105
+ * ```
106
+ *
107
+ * @see {@link GetRelation} - Returns full compositions instead of raw concepts
108
+ * @see {@link GetRelationConnections} - Returns connection objects
109
+ * @see {@link GetConceptBulk} - Bulk concept retrieval
110
+ */
4
111
  export declare function GetRelationRaw(id: number, relation: string, inpage?: number, page?: number, reverse?: boolean): Promise<Concept[]>;
112
+ /**
113
+ * Retrieves connection objects for a specified relation.
114
+ *
115
+ * This function returns the actual Connection objects that link concepts through
116
+ * a relation, rather than the related concepts themselves. This is useful when
117
+ * you need to inspect or manipulate the connection metadata, timestamps, or
118
+ * relationship properties directly.
119
+ *
120
+ * Unlike GetRelation and GetRelationRaw which return concepts, this returns the
121
+ * connections that define the relationships, allowing access to connection-specific
122
+ * data like creation time, sync status, and connection properties.
123
+ *
124
+ * @param id - The ID of the source concept to find relation connections for
125
+ * @param relation - The name of the relation (e.g., "author", "parent", "tag")
126
+ * @param inpage - Number of results per page (default: 10)
127
+ * @param page - Page number to retrieve (default: 1)
128
+ * @param reverse - If true, finds connections pointing TO this concept; if false, finds connections FROM this concept (default: false)
129
+ *
130
+ * @returns Promise resolving to an array of Connection objects
131
+ *
132
+ * @remarks
133
+ * - Returns Connection objects, not Concept objects
134
+ * - Provides access to connection metadata and properties
135
+ * - Supports both forward and reverse traversal
136
+ * - Does not fetch or return the actual concepts being connected
137
+ * - Empty array if relation concept not found
138
+ * - Useful for connection-level operations and analysis
139
+ * - Connection objects contain: typeId, ofTheConceptId, toTheConceptId, etc.
140
+ *
141
+ * @example
142
+ * ```typescript
143
+ * // Get connection objects for author relations
144
+ * const authorConnections = await GetRelationConnections(123, "author", 10, 1, false);
145
+ * authorConnections.forEach(conn => {
146
+ * console.log("Connection Type ID:", conn.typeId);
147
+ * console.log("From Concept:", conn.ofTheConceptId);
148
+ * console.log("To Concept:", conn.toTheConceptId);
149
+ * console.log("Created:", conn.localSyncTime);
150
+ * });
151
+ *
152
+ * // Get tag connections in reverse
153
+ * const tagConnections = await GetRelationConnections(456, "tag", 20, 1, true);
154
+ *
155
+ * // Check connection metadata
156
+ * const parentConnections = await GetRelationConnections(789, "parent", 1, 1, false);
157
+ * if (parentConnections.length > 0) {
158
+ * console.log("Parent connection exists");
159
+ * console.log("Connection details:", parentConnections[0]);
160
+ * }
161
+ * ```
162
+ *
163
+ * @see {@link GetRelation} - Returns related concepts as compositions
164
+ * @see {@link GetRelationRaw} - Returns related concepts as raw objects
165
+ * @see {@link Connection} - Connection data structure
166
+ */
5
167
  export declare function GetRelationConnections(id: number, relation: string, inpage?: number, page?: number, reverse?: boolean): Promise<Connection[]>;
@@ -1,2 +1,73 @@
1
+ /**
2
+ * Concept Retrieval Service
3
+ *
4
+ * This module provides the primary interface for retrieving concepts from the system.
5
+ * It implements a multi-tier caching strategy that checks local memory first, then
6
+ * falls back to API calls. It also handles special ghost concepts (negative IDs) and
7
+ * ensures concept type information is properly populated.
8
+ *
9
+ * @module GetTheConcept
10
+ */
1
11
  import { Concept } from "../DataStructures/Concept";
12
+ /**
13
+ * Retrieves a concept by ID with automatic caching and type population.
14
+ *
15
+ * This is the primary function for concept retrieval in the CCS system. It implements
16
+ * a sophisticated multi-tier lookup strategy:
17
+ * 1. For negative IDs: Retrieves ghost concepts from user-specific storage
18
+ * 2. For positive IDs: Checks local cache (ConceptsData) first
19
+ * 3. Falls back to API call (GetConcept) if not in cache
20
+ * 4. Ensures the concept's type information is populated
21
+ * 5. Returns default concept if all retrieval attempts fail
22
+ *
23
+ * Ghost concepts (negative IDs) are special user-specific concepts that exist in
24
+ * local storage rather than the main database. They're converted from LConcept format
25
+ * to standard Concept format during retrieval.
26
+ *
27
+ * @param id - The ID of the concept to retrieve (negative IDs are ghost concepts)
28
+ * @param userId - The user ID for ghost concept lookup (default: 999)
29
+ *
30
+ * @returns A promise that resolves to the retrieved Concept, or a default concept if not found
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * // Retrieve a regular concept
35
+ * const concept = await GetTheConcept(12345);
36
+ * console.log("Concept type:", concept.type?.characterValue);
37
+ * console.log("Concept value:", concept.characterValue);
38
+ * ```
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * // Retrieve a ghost concept (negative ID)
43
+ * const ghostConcept = await GetTheConcept(-100, 456);
44
+ * console.log("Ghost concept:", ghostConcept.characterValue);
45
+ * ```
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * // Check if concept was found
50
+ * const concept = await GetTheConcept(99999);
51
+ * if (concept.id === 0) {
52
+ * console.log("Concept not found, using default");
53
+ * } else {
54
+ * console.log("Found concept:", concept.id);
55
+ * }
56
+ * ```
57
+ *
58
+ * @remarks
59
+ * - Negative IDs indicate ghost concepts stored in user-specific storage
60
+ * - Ghost concepts are converted from LConcept to Concept format
61
+ * - The function checks local cache (ConceptsData) before making API calls
62
+ * - If a concept is found but has no type populated, fetches and attaches the type
63
+ * - Type concepts are also cached for efficiency
64
+ * - Returns a default concept (id=0) if retrieval fails at all levels
65
+ * - The function is null-safe; always returns a Concept instance
66
+ * - Automatically populates concept.type if it's null but typeId exists
67
+ *
68
+ * @see {@link CreateDefaultConcept} for the default concept structure
69
+ * @see {@link ConceptsData.GetConcept} for cache lookup
70
+ * @see {@link GetConcept} for API-based retrieval
71
+ * @see {@link GetUserGhostId} for ghost concept retrieval
72
+ */
2
73
  export default function GetTheConcept(id: number, userId?: number): Promise<Concept>;
@@ -1,2 +1,76 @@
1
+ /**
2
+ * @module GetTheReferent
3
+ * @description Retrieves referent concepts in the Concept Connection System (CCS).
4
+ * This module provides functionality to fetch the referent concept of a given concept.
5
+ * Referents are concepts that serve as the actual data or value that another concept
6
+ * points to, creating a level of indirection that enables flexible data modeling.
7
+ */
1
8
  import { Concept } from "../DataStructures/Concept";
9
+ /**
10
+ * Retrieves the referent concept for a given concept.
11
+ *
12
+ * This function fetches the concept that serves as the referent (the actual value or
13
+ * data) for another concept. In the CCS system, concepts often point to other concepts
14
+ * as their referents, creating a flexible hierarchy where concepts can reference
15
+ * other concepts as their underlying data.
16
+ *
17
+ * For example, a name concept might reference a character concept as its referent,
18
+ * or a typed instance might reference its data concept as a referent.
19
+ *
20
+ * @param id - The ID of the concept (currently unused in implementation)
21
+ * @param userId - The user ID of the concept (currently unused in implementation)
22
+ * @param referentId - The ID of the referent concept to retrieve
23
+ *
24
+ * @returns Promise resolving to the referent Concept
25
+ *
26
+ * @remarks
27
+ * - Currently only uses the referentId parameter, id and userId are not utilized
28
+ * - The id and userId parameters may be used for future access control or validation
29
+ * - Returns the full Concept object of the referent
30
+ * - Uses nullish coalescing to default referentId to 0 if null/undefined
31
+ * - Previously returned ReferentInfo (commented out code shows this)
32
+ * - Simplified to directly return the referent concept
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * // Get the referent of a name concept
37
+ * const nameConcept = await GetTheConcept(123);
38
+ * const referent = await GetTheReferent(
39
+ * nameConcept.id,
40
+ * nameConcept.userId,
41
+ * nameConcept.referentId
42
+ * );
43
+ * console.log("Referent concept:", referent);
44
+ * // referent might be a character concept
45
+ *
46
+ * // Get character data from a typed concept
47
+ * const typedConcept = await GetTheConcept(456);
48
+ * const characterData = await GetTheReferent(
49
+ * typedConcept.id,
50
+ * typedConcept.userId,
51
+ * typedConcept.referentId
52
+ * );
53
+ * console.log("Character value:", characterData.characterValue);
54
+ *
55
+ * // Chain referent lookups
56
+ * const concept = await GetTheConcept(789);
57
+ * const firstReferent = await GetTheReferent(
58
+ * concept.id,
59
+ * concept.userId,
60
+ * concept.referentId
61
+ * );
62
+ * if (firstReferent.referentId) {
63
+ * const secondReferent = await GetTheReferent(
64
+ * firstReferent.id,
65
+ * firstReferent.userId,
66
+ * firstReferent.referentId
67
+ * );
68
+ * console.log("Nested referent:", secondReferent);
69
+ * }
70
+ * ```
71
+ *
72
+ * @see {@link GetTheConcept} - Retrieves the referent concept by ID
73
+ * @see {@link ReferentInfo} - Data structure for referent information (legacy)
74
+ * @see {@link Concept} - The concept data structure
75
+ */
2
76
  export default function GetTheReferent(id: number, userId: number, referentId: number): Promise<Concept>;
@@ -1,2 +1,121 @@
1
+ /**
2
+ * System Initialization Service
3
+ *
4
+ * This module provides core initialization functionality for the CCS-JS system, handling
5
+ * the startup sequence including settings retrieval, AI data synchronization, and system
6
+ * configuration. It manages both the initial system bootstrap and subsequent synchronization
7
+ * status updates.
8
+ *
9
+ * The initialization process ensures that all necessary data structures, settings, and
10
+ * AI-related data are properly loaded before the application becomes fully operational.
11
+ *
12
+ * @module InitializeSystem
13
+ */
14
+ /**
15
+ * Initializes the CCS-JS system by loading settings and AI data.
16
+ *
17
+ * This is the primary initialization function that bootstraps the application by:
18
+ * 1. Retrieving system statistics and settings from the database
19
+ * 2. Loading AI-related data through the GetAiData API call
20
+ * 3. Returning a success indicator to confirm initialization completion
21
+ *
22
+ * This function should be called once during application startup before any other
23
+ * operations are performed. It ensures the system is in a ready state with all
24
+ * necessary configuration and data loaded.
25
+ *
26
+ * @returns A promise that resolves to true when initialization is complete
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * // Initialize the system at application startup
31
+ * const initialized = await InitializeSystem();
32
+ * if (initialized) {
33
+ * console.log('System initialized successfully');
34
+ * // Proceed with application logic
35
+ * }
36
+ * ```
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * // Use in an async initialization flow
41
+ * async function startApplication() {
42
+ * try {
43
+ * await InitializeSystem();
44
+ * // Load additional data structures
45
+ * await CreateBinaryTreeFromData();
46
+ * console.log('Application ready');
47
+ * } catch (error) {
48
+ * console.error('Initialization failed:', error);
49
+ * }
50
+ * }
51
+ * ```
52
+ *
53
+ * @remarks
54
+ * - Should be called once during application bootstrap
55
+ * - Loads statsData from database and casts it to SettingData type
56
+ * - Retrieves AI data from external API or data source
57
+ * - Always returns true upon successful completion
58
+ * - Does not handle errors explicitly; calling code should wrap in try-catch if needed
59
+ *
60
+ * @see {@link GetStatsFromDatabase} for statistics and settings retrieval
61
+ * @see {@link GetAiData} for AI data loading implementation
62
+ * @see {@link SettingData} for the settings data structure
63
+ * @see {@link PurgatoryDatabaseUpdated} for post-sync initialization
64
+ */
1
65
  export default function InitializeSystem(): Promise<boolean>;
66
+ /**
67
+ * Updates the system settings to reflect that the purgatory database has been synchronized.
68
+ *
69
+ * This function is called after the purgatory database (a staging or temporary database)
70
+ * has been successfully updated or synchronized with the main system. It marks the system
71
+ * as being in an online sync state and persists this status to the database.
72
+ *
73
+ * The purgatory database concept typically represents a temporary holding area for data
74
+ * that needs to be processed, reviewed, or synchronized before being committed to the
75
+ * main data structures. This function signals that such synchronization has completed.
76
+ *
77
+ * @returns A promise that resolves when the sync flag has been updated in the database
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * // After synchronizing the purgatory database
82
+ * async function syncPurgatoryData() {
83
+ * // ... perform synchronization logic ...
84
+ *
85
+ * // Update the system to reflect successful sync
86
+ * await PurgatoryDatabaseUpdated();
87
+ * console.log('System marked as synced');
88
+ * }
89
+ * ```
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * // Use in a data migration or sync workflow
94
+ * async function migrateDataFromPurgatory() {
95
+ * try {
96
+ * // Migrate concepts and connections
97
+ * await migratePurgatoryData();
98
+ *
99
+ * // Mark the operation as complete
100
+ * await PurgatoryDatabaseUpdated();
101
+ *
102
+ * console.log('Purgatory sync complete, system online');
103
+ * } catch (error) {
104
+ * console.error('Sync failed:', error);
105
+ * }
106
+ * }
107
+ * ```
108
+ *
109
+ * @remarks
110
+ * - Sets Settings.isOnlineSync to true, indicating the system is in sync
111
+ * - Creates a new SettingData instance with the updated sync status
112
+ * - Persists the updated settings to the database via AiUpdateFlag
113
+ * - Should be called after completing purgatory database synchronization
114
+ * - Part of the data synchronization lifecycle management
115
+ *
116
+ * @see {@link AiUpdateFlag} for database update implementation
117
+ * @see {@link SettingData} for the settings data structure
118
+ * @see {@link Settings} for the global settings object
119
+ * @see {@link InitializeSystem} for system initialization
120
+ */
2
121
  export declare function PurgatoryDatabaseUpdated(): Promise<void>;
@@ -1,2 +1,50 @@
1
+ /**
2
+ * Default Local Concept Creation Module
3
+ *
4
+ * This module provides a factory function for creating empty/default local concepts.
5
+ * These default concepts are useful as placeholders, initial values, or for representing
6
+ * "not found" states in the Concept Connection System.
7
+ *
8
+ * @module CreateDefaultLConcept
9
+ */
1
10
  import { LConcept } from "../../DataStructures/Local/LConcept";
11
+ /**
12
+ * Creates a default empty local concept with all fields initialized to zero or default values.
13
+ *
14
+ * This function generates a placeholder concept that can be used for initialization,
15
+ * default return values, or to represent the absence of a concept. All numeric fields
16
+ * are set to 0, and string fields are set to "0", which allows calling code to check
17
+ * for validity (e.g., `if (concept.id === 0)` to detect a default concept).
18
+ *
19
+ * @returns A new LConcept instance with all fields set to default/zero values
20
+ *
21
+ * @remarks
22
+ * - All numeric IDs (id, userId, typeId, categoryId, accessId, referentId) are set to 0
23
+ * - Character fields (referent, typecharacter) are set to "0"
24
+ * - isNew flag is set to false (not a new concept)
25
+ * - created_on and updated_on are set to current timestamp
26
+ * - Commonly used as a null object pattern to avoid null checks
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * // Use as a default return value when concept is not found
31
+ * function findConcept(id: number): LConcept {
32
+ * const found = database.find(id);
33
+ * return found || CreateDefaultLConcept();
34
+ * }
35
+ *
36
+ * const concept = findConcept(123);
37
+ * if (concept.id === 0) {
38
+ * console.log("Concept not found");
39
+ * }
40
+ *
41
+ * // Use as initial value for variables
42
+ * let mainConcept = CreateDefaultLConcept();
43
+ * // ... later assign actual concept
44
+ * mainConcept = await fetchConcept();
45
+ * ```
46
+ *
47
+ * @see {@link LConcept} - The local concept data structure
48
+ * @see {@link CreateTheConceptLocal} - Creates actual concepts with real data
49
+ */
2
50
  export declare function CreateDefaultLConcept(): LConcept;
@@ -1 +1,50 @@
1
+ /**
2
+ * Local Binary Tree Initialization Module
3
+ *
4
+ * This module handles the initialization of the in-memory binary tree data structure
5
+ * from persisted local concepts stored in IndexedDB. It loads all concepts from the
6
+ * database and populates the in-memory cache for fast access.
7
+ *
8
+ * @module CreateLocalBinaryTreeFromData
9
+ */
10
+ /**
11
+ * Initializes the local binary tree structure by loading concepts from IndexedDB.
12
+ *
13
+ * This function retrieves all locally stored concepts from the IndexedDB database
14
+ * and populates the in-memory LocalConceptsData structure. This is typically called
15
+ * during application initialization to hydrate the memory cache from persistent storage.
16
+ *
17
+ * The function ensures that all previously created local concepts are available in
18
+ * memory for fast lookup operations without needing to query the database repeatedly.
19
+ *
20
+ * @returns A promise that resolves when all concepts have been loaded into memory
21
+ *
22
+ * @remarks
23
+ * - Retrieves all concepts from the "localconcept" store in IndexedDB
24
+ * - Uses `LocalConceptsData.AddConceptToMemory` to add each concept to the in-memory structure
25
+ * - The commented code suggests this originally used a traditional binary tree (Node-based)
26
+ * but now uses a more efficient data structure via LocalConceptsData
27
+ * - Safe to call multiple times; duplicate concepts will be handled by AddConceptToMemory
28
+ * - This is a synchronization step from persistent storage to volatile memory
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * // During application initialization
33
+ * async function initializeApp() {
34
+ * console.log("Loading local concepts...");
35
+ * await CreateLocalBinaryTreeFromData();
36
+ * console.log("Local concepts loaded into memory");
37
+ *
38
+ * // Now concepts can be accessed quickly from memory
39
+ * const concept = await LocalConceptsData.GetConcept(123);
40
+ * }
41
+ *
42
+ * initializeApp();
43
+ * ```
44
+ *
45
+ * @see {@link LocalConceptsData.AddConceptToMemory} - Adds concepts to in-memory storage
46
+ * @see {@link getAllFromLocalDb} - Retrieves all records from IndexedDB
47
+ * @see {@link CreateLocalBinaryTypeTreeFromData} - Similar function for type-indexed tree
48
+ * @see {@link CreateLocalCharacterBinaryTreeFromData} - Similar function for character-indexed tree
49
+ */
1
50
  export default function CreateLocalBinaryTreeFromData(): Promise<void>;
@@ -1 +1,55 @@
1
+ /**
2
+ * Local Binary Type Tree Initialization Module
3
+ *
4
+ * This module creates and populates a binary search tree indexed by concept type IDs.
5
+ * This specialized tree structure enables efficient lookup of concepts by their type,
6
+ * which is crucial for querying all concepts of a particular type.
7
+ *
8
+ * @module CreateLocalBinaryTypeTreeFromData
9
+ */
10
+ /**
11
+ * Initializes a binary search tree indexed by concept type IDs from IndexedDB.
12
+ *
13
+ * This function retrieves all locally stored concepts and builds a binary search tree
14
+ * where each node is indexed by the concept's typeId. This structure allows for O(log n)
15
+ * lookup time when searching for concepts of a specific type, significantly improving
16
+ * performance over linear searches.
17
+ *
18
+ * The function includes performance measurement via timestamps to monitor initialization time.
19
+ *
20
+ * @returns A promise that resolves when the type-indexed tree is fully populated
21
+ *
22
+ * @remarks
23
+ * - Creates LNode instances with typeId as the key for each concept
24
+ * - Builds a balanced binary search tree structure via LocalBinaryTypeTree
25
+ * - Measures execution time for performance monitoring (though not returned)
26
+ * - Called during application initialization, typically after CreateLocalBinaryTreeFromData
27
+ * - Enables efficient queries like "get all concepts of type X"
28
+ * - Tree structure allows for fast insertion, deletion, and lookup operations
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * // Initialize the type-indexed tree during app startup
33
+ * async function initializeTrees() {
34
+ * await CreateLocalBinaryTreeFromData(); // General tree first
35
+ * await CreateLocalBinaryTypeTreeFromData(); // Then type-specific tree
36
+ *
37
+ * // Now can efficiently query concepts by type
38
+ * const userConcepts = LocalBinaryTypeTree.getConceptsByType(51); // typeId 51
39
+ * console.log(`Found ${userConcepts.length} concepts of type 51`);
40
+ * }
41
+ *
42
+ * // Measure initialization performance
43
+ * const start = performance.now();
44
+ * await CreateLocalBinaryTypeTreeFromData();
45
+ * const duration = performance.now() - start;
46
+ * console.log(`Type tree initialized in ${duration}ms`);
47
+ * ```
48
+ *
49
+ * @see {@link LocalBinaryTypeTree} - The binary tree structure for type-indexed concepts
50
+ * @see {@link LNode} - The node structure used in the tree
51
+ * @see {@link getAllFromLocalDb} - Retrieves all concepts from IndexedDB
52
+ * @see {@link CreateLocalBinaryTreeFromData} - General concept tree initialization
53
+ * @see {@link CreateLocalCharacterBinaryTreeFromData} - Character-indexed tree initialization
54
+ */
1
55
  export declare function CreateLocalBinaryTypeTreeFromData(): Promise<void>;
@@ -1 +1,61 @@
1
+ /**
2
+ * Local Character Binary Tree Initialization Module
3
+ *
4
+ * This module creates and populates a binary search tree indexed by concept character values.
5
+ * This specialized tree structure enables efficient lookup of concepts by their character/name,
6
+ * supporting fast string-based queries without requiring full database scans.
7
+ *
8
+ * @module CreateLocalCharacterBinaryTree
9
+ */
10
+ /**
11
+ * Initializes a binary search tree indexed by concept character values from IndexedDB.
12
+ *
13
+ * This function retrieves all locally stored concepts and builds a binary search tree
14
+ * where each node is indexed by the concept's characterValue (the string content/name
15
+ * of the concept). This structure enables efficient O(log n) lookup when searching for
16
+ * concepts by their character/string value.
17
+ *
18
+ * The function includes performance measurement to monitor initialization time.
19
+ *
20
+ * @returns A promise that resolves when the character-indexed tree is fully populated
21
+ *
22
+ * @remarks
23
+ * - Creates LNode instances with characterValue as the key for each concept
24
+ * - Builds a balanced binary search tree structure via LocalBinaryCharacterTree
25
+ * - Measures execution time for performance monitoring (though not returned)
26
+ * - Particularly useful for autocomplete, search, and lookup-by-name operations
27
+ * - Called during application initialization alongside other tree structures
28
+ * - Enables queries like "find concept with character value 'John Doe'"
29
+ * - Character values are typically stored as strings and compared lexicographically
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * // Initialize all tree structures during app startup
34
+ * async function initializeAllTrees() {
35
+ * await CreateLocalBinaryTreeFromData();
36
+ * await CreateLocalBinaryTypeTreeFromData();
37
+ * await CreateLocalCharacterBinaryTreeFromData();
38
+ *
39
+ * // Now can efficiently query concepts by character value
40
+ * const concept = LocalBinaryCharacterTree.findByCharacter("John Doe");
41
+ * if (concept) {
42
+ * console.log(`Found concept: ${concept.id}`);
43
+ * }
44
+ * }
45
+ *
46
+ * // Use for autocomplete functionality
47
+ * async function searchConcepts(prefix: string) {
48
+ * await CreateLocalCharacterBinaryTreeFromData();
49
+ * const results = LocalBinaryCharacterTree.findByPrefix(prefix);
50
+ * return results; // All concepts starting with prefix
51
+ * }
52
+ * ```
53
+ *
54
+ * @see {@link LocalBinaryCharacterTree} - The binary tree structure for character-indexed concepts
55
+ * @see {@link LNode} - The node structure used in the tree
56
+ * @see {@link getAllFromLocalDb} - Retrieves all concepts from IndexedDB
57
+ * @see {@link CreateLocalBinaryTreeFromData} - General concept tree initialization
58
+ * @see {@link CreateLocalBinaryTypeTreeFromData} - Type-indexed tree initialization
59
+ * @see {@link GetConceptByCharacterLocal} - Related function that uses this tree
60
+ */
1
61
  export declare function CreateLocalCharacterBinaryTreeFromData(): Promise<void>;