mftsccs-node 0.0.57 → 0.0.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/README.md +1148 -11
  2. package/dist/bundle.js +1 -1
  3. package/dist/types/Api/Create/CreateTheCharacter.d.ts +42 -0
  4. package/dist/types/Api/Create/CreateTheConceptApi.d.ts +50 -0
  5. package/dist/types/Api/Create/CreateTheConnectionApi.d.ts +51 -0
  6. package/dist/types/Api/Create/CreateTheTextData.d.ts +56 -0
  7. package/dist/types/Api/Delete/DeleteConceptInBackend.d.ts +43 -0
  8. package/dist/types/Api/DeleteConnectionApiBulk.d.ts +55 -0
  9. package/dist/types/Api/DeleteTheConcept.d.ts +64 -0
  10. package/dist/types/Api/DeleteTheConnection.d.ts +76 -0
  11. package/dist/types/Api/GetAiData.d.ts +36 -0
  12. package/dist/types/Api/GetAllConcepts.d.ts +42 -0
  13. package/dist/types/Api/GetAllConceptsByType.d.ts +45 -0
  14. package/dist/types/Api/GetAllConnections.d.ts +48 -0
  15. package/dist/types/Api/GetAllConnectionsOfComposition.d.ts +79 -0
  16. package/dist/types/Api/GetAllConnectionsOfCompositionBulk.d.ts +90 -0
  17. package/dist/types/Api/GetAllLinkerConnectionsFromTheConcept.d.ts +52 -0
  18. package/dist/types/Api/GetAllLinkerConnectionsToTheConcept.d.ts +61 -0
  19. package/dist/types/Api/GetAllPrefetchConnections.d.ts +51 -0
  20. package/dist/types/Api/GetCharacterDataByCharacter.d.ts +31 -0
  21. package/dist/types/Api/GetCompositionConnectionsBetweenTwoConcepts.d.ts +39 -0
  22. package/dist/types/Api/GetConcept.d.ts +47 -0
  23. package/dist/types/Api/GetConceptBulk.d.ts +68 -0
  24. package/dist/types/Api/GetConceptByCharacterAndType.d.ts +75 -0
  25. package/dist/types/Api/GetConceptByCharacterValue.d.ts +47 -0
  26. package/dist/types/Api/GetConnection.d.ts +49 -0
  27. package/dist/types/Api/GetConnectionBulk.d.ts +46 -0
  28. package/dist/types/Api/GetConnectionOfTheConcept.d.ts +50 -0
  29. package/dist/types/Api/GetConnectionToTheConcept.d.ts +56 -0
  30. package/dist/types/Api/GetReservedConnectionIds.d.ts +36 -0
  31. package/dist/types/Api/GetReservedIds.d.ts +37 -0
  32. package/dist/types/Api/Login.d.ts +38 -0
  33. package/dist/types/Api/MakeTheNameInBackend.d.ts +39 -0
  34. package/dist/types/Api/MakeTheTypeConceptApi.d.ts +40 -0
  35. package/dist/types/Api/RecursiveSearch.d.ts +43 -0
  36. package/dist/types/Api/Search/FreeschemaQueryApi.d.ts +46 -0
  37. package/dist/types/Api/Search/Search.d.ts +67 -0
  38. package/dist/types/Api/Search/SearchInternalApi.d.ts +69 -0
  39. package/dist/types/Api/Search/SearchLinkMultipleApi.d.ts +90 -0
  40. package/dist/types/Api/Search/SearchWithLinker.d.ts +97 -0
  41. package/dist/types/Api/SearchConcept/GetConceptByCharacterAndCategoryApi.d.ts +39 -0
  42. package/dist/types/Api/SearchConcept/GetConceptByCharacterAndCategoryDirect.d.ts +47 -0
  43. package/dist/types/Api/Session/CreateSession.d.ts +45 -0
  44. package/dist/types/Api/Session/CreateSessionVisit.d.ts +43 -0
  45. package/dist/types/Api/Signin.d.ts +48 -0
  46. package/dist/types/Api/Signup.d.ts +44 -0
  47. package/dist/types/Api/View/ViewInternalDataApi.d.ts +50 -0
  48. package/dist/types/Constants/ApiConstants.d.ts +226 -0
  49. package/dist/types/Constants/FormatConstants.d.ts +81 -0
  50. package/dist/types/DataStructures/BaseUrl.d.ts +210 -0
  51. package/dist/types/DataStructures/BinaryCharacterTree.d.ts +211 -0
  52. package/dist/types/DataStructures/BinaryTree.d.ts +139 -0
  53. package/dist/types/DataStructures/BinaryTypeTree.d.ts +196 -0
  54. package/dist/types/DataStructures/CharacterRepository.d.ts +109 -0
  55. package/dist/types/DataStructures/Composition/Composition.d.ts +103 -0
  56. package/dist/types/DataStructures/Composition/CompositionBinaryTree.d.ts +104 -0
  57. package/dist/types/DataStructures/Composition/CompositionNode.d.ts +202 -0
  58. package/dist/types/DataStructures/Concept.d.ts +110 -0
  59. package/dist/types/DataStructures/ConceptData.d.ts +292 -0
  60. package/dist/types/DataStructures/ConceptsToDraw.d.ts +168 -0
  61. package/dist/types/DataStructures/Connection.d.ts +76 -0
  62. package/dist/types/DataStructures/ConnectionBinaryTree/ConnectionBinaryTree.d.ts +115 -0
  63. package/dist/types/DataStructures/ConnectionBinaryTree/ConnectionNode.d.ts +169 -0
  64. package/dist/types/DataStructures/ConnectionBinaryTree/ConnectionTypeTree.d.ts +82 -0
  65. package/dist/types/DataStructures/ConnectionData.d.ts +191 -0
  66. package/dist/types/DataStructures/Count/CountInfo.d.ts +73 -0
  67. package/dist/types/DataStructures/FilterSearch.d.ts +84 -0
  68. package/dist/types/DataStructures/IdentifierFlags.d.ts +34 -0
  69. package/dist/types/DataStructures/Local/LConcept.d.ts +105 -0
  70. package/dist/types/DataStructures/Local/LConnection.d.ts +83 -0
  71. package/dist/types/DataStructures/Local/LNode.d.ts +190 -0
  72. package/dist/types/DataStructures/Local/LocalBinaryCharacterTree.d.ts +133 -0
  73. package/dist/types/DataStructures/Local/LocalBinaryTree.d.ts +135 -0
  74. package/dist/types/DataStructures/Local/LocalBinaryTypeTree.d.ts +147 -0
  75. package/dist/types/DataStructures/Local/LocalConceptData.d.ts +100 -0
  76. package/dist/types/DataStructures/Local/LocalConnectionData.d.ts +109 -0
  77. package/dist/types/DataStructures/Local/LocalSyncData.d.ts +89 -0
  78. package/dist/types/DataStructures/PatcherStructure.d.ts +86 -0
  79. package/dist/types/DataStructures/ReferentInfo.d.ts +68 -0
  80. package/dist/types/DataStructures/ReservedIds.d.ts +101 -0
  81. package/dist/types/DataStructures/Responses/ErrorResponse.d.ts +184 -22
  82. package/dist/types/DataStructures/Responses/StandardResponses.d.ts +65 -0
  83. package/dist/types/DataStructures/Returner.d.ts +59 -0
  84. package/dist/types/DataStructures/Search/FreeschemaQuery.d.ts +165 -0
  85. package/dist/types/DataStructures/Search/SearchStructure.d.ts +69 -0
  86. package/dist/types/DataStructures/SearchQuery.d.ts +130 -0
  87. package/dist/types/DataStructures/Security/TokenStorage.d.ts +48 -0
  88. package/dist/types/DataStructures/Session/SessionData.d.ts +118 -0
  89. package/dist/types/DataStructures/SettingData.d.ts +32 -0
  90. package/dist/types/DataStructures/Settings.d.ts +27 -0
  91. package/dist/types/DataStructures/SigninModel.d.ts +50 -0
  92. package/dist/types/DataStructures/SignupModel.d.ts +50 -0
  93. package/dist/types/DataStructures/SyncData.d.ts +206 -0
  94. package/dist/types/DataStructures/TheCharacter.d.ts +87 -0
  95. package/dist/types/DataStructures/TheTexts.d.ts +92 -0
  96. package/dist/types/DataStructures/Transaction/Transaction.d.ts +294 -4
  97. package/dist/types/DataStructures/User/UserBinaryTree.d.ts +117 -0
  98. package/dist/types/DataStructures/User/UserNode.d.ts +130 -0
  99. package/dist/types/Database/GetConceptFromIndexDb.d.ts +9 -0
  100. package/dist/types/Database/NoIndexDb.d.ts +169 -0
  101. package/dist/types/Database/indexdblocal.d.ts +42 -0
  102. package/dist/types/Database/indexeddb.d.ts +43 -0
  103. package/dist/types/Drawing/ConceptDraw.d.ts +28 -0
  104. package/dist/types/Drawing/ConceptEvents.d.ts +46 -0
  105. package/dist/types/Helpers/CheckIfExists.d.ts +159 -0
  106. package/dist/types/Helpers/RemoveFromArray.d.ts +66 -0
  107. package/dist/types/Helpers/UniqueInsert.d.ts +28 -0
  108. package/dist/types/Services/CheckForConnectionDeletion.d.ts +190 -0
  109. package/dist/types/Services/Common/DecodeCountInfo.d.ts +54 -0
  110. package/dist/types/Services/Common/ErrorPosting.d.ts +49 -0
  111. package/dist/types/Services/Common/RegexFunction.d.ts +28 -0
  112. package/dist/types/Services/Composition/BuildComposition.d.ts +37 -0
  113. package/dist/types/Services/Composition/CompositionCache.d.ts +89 -0
  114. package/dist/types/Services/Composition/CreateCompositionCache.d.ts +43 -0
  115. package/dist/types/Services/Conversion/ConvertConcepts.d.ts +83 -0
  116. package/dist/types/Services/CreateBinaryTreeFromData.d.ts +38 -0
  117. package/dist/types/Services/CreateCharacterBinaryTreeFromData.d.ts +42 -0
  118. package/dist/types/Services/CreateConnectionBetweenTwoConcepts.d.ts +206 -0
  119. package/dist/types/Services/CreateDefaultConcept.d.ts +114 -0
  120. package/dist/types/Services/CreateTheComposition.d.ts +101 -0
  121. package/dist/types/Services/CreateTheConcept.d.ts +179 -0
  122. package/dist/types/Services/CreateTheConnection.d.ts +59 -0
  123. package/dist/types/Services/CreateTheConnectionGeneral.d.ts +127 -0
  124. package/dist/types/Services/CreateTypeTreeFromData.d.ts +43 -0
  125. package/dist/types/Services/Delete/DeleteConnectionByType.d.ts +52 -5
  126. package/dist/types/Services/Delete/GetAllConnectionByType.d.ts +57 -9
  127. package/dist/types/Services/DeleteConcept.d.ts +136 -0
  128. package/dist/types/Services/DeleteConnection.d.ts +194 -0
  129. package/dist/types/Services/FindConeceptsFromConnection.d.ts +179 -0
  130. package/dist/types/Services/FindConnectionsOfCompositionBulkInMemory.d.ts +157 -0
  131. package/dist/types/Services/GenerateHexNumber.d.ts +64 -0
  132. package/dist/types/Services/GetComposition.d.ts +331 -0
  133. package/dist/types/Services/GetCompositionBulk.d.ts +251 -3
  134. package/dist/types/Services/GetCompositionList.d.ts +130 -0
  135. package/dist/types/Services/GetConceptByCharacter.d.ts +84 -0
  136. package/dist/types/Services/GetConnections.d.ts +72 -0
  137. package/dist/types/Services/GetDataFromIndexDb.d.ts +79 -0
  138. package/dist/types/Services/GetLink.d.ts +104 -0
  139. package/dist/types/Services/GetLinkerConnectionFromConcept.d.ts +99 -0
  140. package/dist/types/Services/GetMaximumConnectionSyncTime.d.ts +57 -0
  141. package/dist/types/Services/GetRelation.d.ts +162 -0
  142. package/dist/types/Services/GetTheConcept.d.ts +71 -0
  143. package/dist/types/Services/GetTheReferent.d.ts +74 -0
  144. package/dist/types/Services/InitializeSystem.d.ts +119 -0
  145. package/dist/types/Services/Local/CreateDefaultLConcept.d.ts +48 -0
  146. package/dist/types/Services/Local/CreateLocalBinaryTreeFromData.d.ts +49 -0
  147. package/dist/types/Services/Local/CreateLocalBinaryTypeTreeFromData.d.ts +54 -0
  148. package/dist/types/Services/Local/CreateLocalCharacterBinaryTree.d.ts +60 -0
  149. package/dist/types/Services/Local/CreateTheCompositionLocal.d.ts +70 -0
  150. package/dist/types/Services/Local/CreateTheConceptLocal.d.ts +58 -0
  151. package/dist/types/Services/Local/CreateTheConnectionLocal.d.ts +56 -0
  152. package/dist/types/Services/Local/GetCompositionListLocal.d.ts +103 -0
  153. package/dist/types/Services/Local/GetCompositionLocal.d.ts +96 -0
  154. package/dist/types/Services/Local/GetConceptByCharacterLocal.d.ts +57 -0
  155. package/dist/types/Services/Local/MakeTheConceptLocal.d.ts +71 -0
  156. package/dist/types/Services/Local/MakeTheInstanceConceptLocal.d.ts +89 -0
  157. package/dist/types/Services/Local/MakeTheTypeLocal.d.ts +71 -0
  158. package/dist/types/Services/Local/UpdateCompositionLocal.d.ts +101 -0
  159. package/dist/types/Services/MakeTheCharacter.d.ts +74 -0
  160. package/dist/types/Services/MakeTheCharacterData.d.ts +65 -0
  161. package/dist/types/Services/MakeTheInstanceConcept.d.ts +75 -0
  162. package/dist/types/Services/MakeTheName.d.ts +81 -0
  163. package/dist/types/Services/MakeTheTimestamp.d.ts +68 -0
  164. package/dist/types/Services/MakeTheTypeConcept.d.ts +68 -0
  165. package/dist/types/Services/Mqtt/publishMessage.d.ts +27 -0
  166. package/dist/types/Services/Mqtt/subscribeMessage.d.ts +23 -0
  167. package/dist/types/Services/PatchComposition.d.ts +105 -0
  168. package/dist/types/Services/Search/DataIdFormat.d.ts +96 -24
  169. package/dist/types/Services/Search/FormatData.d.ts +92 -17
  170. package/dist/types/Services/Search/JustIdFormat.d.ts +91 -16
  171. package/dist/types/Services/Search/NewFormat.d.ts +4 -0
  172. package/dist/types/Services/Search/SearchLinkInternal.d.ts +28 -0
  173. package/dist/types/Services/Search/SearchLinkMultiple.d.ts +58 -0
  174. package/dist/types/Services/Search/SearchWithTypeAndLinker.d.ts +92 -24
  175. package/dist/types/Services/Search/orderingConnections.d.ts +34 -0
  176. package/dist/types/Services/SplitStrings.d.ts +50 -0
  177. package/dist/types/Services/UpdateComposition.d.ts +123 -0
  178. package/dist/types/Services/User/UserTranslation.d.ts +102 -0
  179. package/dist/types/Services/View/ViewInternalData.d.ts +32 -0
  180. package/dist/types/WrapperFunctions/SchemaQueryObservable.d.ts +140 -5
  181. package/dist/types/app.d.ts +72 -1
  182. package/package.json +1 -1
@@ -1 +1,65 @@
1
+ /**
2
+ * @fileoverview Hexadecimal number generation utility for the CCS-JS system.
3
+ * This module provides functionality to generate negative pseudo-random numbers based on
4
+ * hexadecimal calculations, commonly used for creating unique temporary identifiers for
5
+ * local concepts before they are persisted to the backend.
6
+ * @module Services/GenerateHexNumber
7
+ */
8
+ /**
9
+ * Generates a negative pseudo-random number based on hexadecimal calculations.
10
+ *
11
+ * This function creates a negative integer by accumulating random hexadecimal values.
12
+ * It is primarily used in the CCS-JS system to generate temporary local IDs for concepts
13
+ * and connections that haven't been persisted to the backend yet. The negative value
14
+ * convention helps distinguish local (client-side) entities from persisted (server-side)
15
+ * entities which have positive IDs.
16
+ *
17
+ * The algorithm multiplies random hex digits (0-15) by 16 for each iteration, accumulating
18
+ * the results, then returns the negative of this sum. This ensures the generated numbers
19
+ * are always negative and within a predictable range based on the length parameter.
20
+ *
21
+ * @param len - The number of iterations to perform, affecting the magnitude of the output.
22
+ * Higher values produce larger negative numbers. Common values are 1-4.
23
+ * @returns A negative integer calculated from accumulated random hexadecimal values
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * // Generate a small negative ID for a temporary concept
28
+ * const localId = genHexString(2);
29
+ * // Returns: a negative number like -512, -768, etc.
30
+ * ```
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * // Generate a larger negative ID for more range
35
+ * const localId = genHexString(4);
36
+ * // Returns: a negative number like -2048, -3072, etc.
37
+ * ```
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * // Use in concept creation for temporary local ID
42
+ * import { genHexString } from './GenerateHexNumber';
43
+ *
44
+ * const tempConcept = {
45
+ * id: genHexString(3),
46
+ * type: "tempConcept",
47
+ * isLocal: true
48
+ * };
49
+ * // tempConcept.id will be a negative number like -1280
50
+ * ```
51
+ *
52
+ * @remarks
53
+ * Key characteristics of this function:
54
+ * - Always returns negative numbers to distinguish local entities from persisted ones
55
+ * - Uses Math.random() for pseudo-random generation (not cryptographically secure)
56
+ * - The range of output values is roughly: -256 * len (with random variation)
57
+ * - Multiple calls with the same length can produce the same value (not guaranteed unique)
58
+ * - This is suitable for temporary IDs but not for security-sensitive applications
59
+ *
60
+ * The formula used is: -(sum of [Math.floor(Math.random() * 16) * 16] for len iterations)
61
+ *
62
+ * @see {@link Math.random} for details on the random number generation
63
+ * @see {@link Math.floor} for understanding the rounding behavior
64
+ */
1
65
  export declare function genHexString(len: number): number;
@@ -1,11 +1,342 @@
1
+ /**
2
+ * Composition Retrieval and Reconstruction Service
3
+ *
4
+ * This module provides comprehensive functionality for retrieving compositions (structured
5
+ * concept graphs) and reconstructing them into JSON objects. It's the deserialization
6
+ * counterpart to CreateTheComposition, converting graph structures back into hierarchical
7
+ * data structures.
8
+ *
9
+ * The module offers multiple variants for different use cases:
10
+ * - Basic composition retrieval (from API or memory)
11
+ * - Composition with metadata (ID, timestamps)
12
+ * - Composition with sub-composition IDs included
13
+ * - Bulk operations and optimization strategies
14
+ *
15
+ * @module GetComposition
16
+ */
1
17
  import { Connection } from "../DataStructures/Connection";
18
+ /**
19
+ * Retrieves a composition from the API and reconstructs it as a JSON object.
20
+ *
21
+ * This function fetches all connections that make up a composition from the API,
22
+ * then recursively reconstructs the original hierarchical structure. It's the primary
23
+ * function for deserializing compositions that were created using CreateTheComposition.
24
+ *
25
+ * The returned object has the composition's type as the root key, containing the
26
+ * nested data structure.
27
+ *
28
+ * @param id - The ID of the root concept of the composition
29
+ *
30
+ * @returns A promise that resolves to an object with the composition data
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * // Retrieve a user profile composition
35
+ * const composition = await GetComposition(12345);
36
+ * console.log(composition);
37
+ * // Output:
38
+ * // {
39
+ * // "user_profile": {
40
+ * // "name": "Alice Johnson",
41
+ * // "age": "30",
42
+ * // "address": {
43
+ * // "street": "123 Main St",
44
+ * // "city": "Springfield"
45
+ * // }
46
+ * // }
47
+ * // }
48
+ * ```
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * // Access specific fields in the composition
53
+ * const bookData = await GetComposition(789);
54
+ * const book = bookData["book"];
55
+ * console.log("Title:", book.title);
56
+ * console.log("Author:", book.author);
57
+ * console.log("ISBN:", book.isbn);
58
+ * ```
59
+ *
60
+ * @remarks
61
+ * - Fetches all connections from the API (not from local cache)
62
+ * - Recursively reconstructs the hierarchical structure
63
+ * - The root key is the type of the root concept (e.g., "book", "user_profile")
64
+ * - Numeric keys indicate array-like structures
65
+ * - Leaf nodes contain their characterValue as strings
66
+ * - Uses GetAllConnectionsOfComposition API for data fetching
67
+ * - For better performance with cached data, use GetCompositionFromMemory
68
+ *
69
+ * @see {@link GetCompositionFromMemory} for cached/memory-based retrieval
70
+ * @see {@link GetCompositionWithId} for including composition metadata
71
+ * @see {@link CreateTheComposition} for the inverse operation (JSON to composition)
72
+ * @see {@link recursiveFetch} for the reconstruction algorithm
73
+ */
2
74
  export declare function GetComposition(id: number): Promise<any>;
75
+ /**
76
+ * Retrieves a composition with sub-composition IDs embedded in the structure.
77
+ *
78
+ * Similar to GetComposition, but includes "id" fields for all sub-compositions
79
+ * within the returned JSON structure. This is useful when you need to reference
80
+ * or update specific parts of the composition later.
81
+ *
82
+ * @param id - The ID of the root concept of the composition
83
+ *
84
+ * @returns A promise that resolves to an object with the composition data including IDs
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * // Get composition with IDs for updating specific nodes
89
+ * const composition = await GetCompositionWithAllIds(12345);
90
+ * console.log(composition);
91
+ * // Output includes id fields:
92
+ * // {
93
+ * // "user_profile": {
94
+ * // "id": 12345,
95
+ * // "address": {
96
+ * // "id": 12346,
97
+ * // "street": "123 Main St"
98
+ * // }
99
+ * // }
100
+ * // }
101
+ * ```
102
+ *
103
+ * @remarks
104
+ * - Each sub-composition node includes its concept ID
105
+ * - Uses recursiveFetchWithSubCompositions instead of recursiveFetch
106
+ * - Useful for selective updates or references to composition parts
107
+ *
108
+ * @see {@link GetComposition} for standard retrieval without IDs
109
+ * @see {@link recursiveFetchWithSubCompositions} for the reconstruction algorithm
110
+ */
3
111
  export declare function GetCompositionWithAllIds(id: number): Promise<any>;
112
+ /**
113
+ * Retrieves a composition from local memory cache without API calls.
114
+ *
115
+ * This optimized version retrieves composition data from the local ConnectionData
116
+ * cache rather than making API calls. It's significantly faster but requires that
117
+ * the connections have been previously cached (e.g., via bulk prefetch operations).
118
+ *
119
+ * @param id - The ID of the root concept of the composition
120
+ *
121
+ * @returns A promise that resolves to an object with the composition data
122
+ *
123
+ * @example
124
+ * ```typescript
125
+ * // After bulk prefetch, retrieve from memory
126
+ * await GetAllConnectionsOfCompositionBulk([123, 456, 789]);
127
+ *
128
+ * // Now quickly retrieve from cache
129
+ * const comp1 = await GetCompositionFromMemory(123);
130
+ * const comp2 = await GetCompositionFromMemory(456);
131
+ * const comp3 = await GetCompositionFromMemory(789);
132
+ * // Much faster than individual API calls
133
+ * ```
134
+ *
135
+ * @remarks
136
+ * - Only works if connections are already cached in ConnectionData
137
+ * - Returns empty or incomplete data if connections aren't cached
138
+ * - Use after bulk prefetch operations for optimal performance
139
+ * - Much faster than GetComposition for batch operations
140
+ *
141
+ * @see {@link GetComposition} for API-based retrieval
142
+ * @see {@link GetAllConnectionsOfCompositionBulk} for bulk prefetching
143
+ */
4
144
  export declare function GetCompositionFromMemory(id: number): Promise<any>;
145
+ /**
146
+ * Retrieves a composition from memory with metadata wrapper.
147
+ *
148
+ * Returns composition data wrapped in an object that includes the root concept's
149
+ * ID and creation timestamp along with the data. This is useful for tracking
150
+ * when compositions were created and referencing them by ID.
151
+ *
152
+ * @param id - The ID of the root concept of the composition
153
+ *
154
+ * @returns A promise that resolves to an object with id, created_at, and data fields
155
+ *
156
+ * @example
157
+ * ```typescript
158
+ * const result = await GetCompositionWithIdFromMemory(12345);
159
+ * console.log(result);
160
+ * // Output:
161
+ * // {
162
+ * // id: 12345,
163
+ * // created_at: "1/15/2024 3:45:30 PM",
164
+ * // data: {
165
+ * // "book": {
166
+ * // "title": "Example Book",
167
+ * // "author": "Jane Doe"
168
+ * // }
169
+ * // }
170
+ * // }
171
+ * ```
172
+ *
173
+ * @remarks
174
+ * - Requires connections to be cached in memory
175
+ * - Includes root concept's entryTimeStamp as created_at
176
+ * - Data structure: { id, created_at, data }
177
+ *
178
+ * @see {@link GetCompositionFromMemory} for unwrapped retrieval
179
+ * @see {@link GetCompositionWithId} for API-based version
180
+ */
5
181
  export declare function GetCompositionWithIdFromMemory(id: number): Promise<any>;
182
+ /**
183
+ * Retrieves a composition from memory with ID and timestamp metadata.
184
+ *
185
+ * Similar to GetCompositionWithIdFromMemory but with a slightly different
186
+ * field order in the returned object. This variant exists for backward
187
+ * compatibility with different parts of the codebase.
188
+ *
189
+ * @param id - The ID of the root concept of the composition
190
+ *
191
+ * @returns A promise that resolves to an object with data, id, and created_at fields
192
+ *
193
+ * @remarks
194
+ * - Field order: data, id, created_at (vs id, created_at, data in other variant)
195
+ * - Otherwise identical to GetCompositionWithIdFromMemory
196
+ *
197
+ * @see {@link GetCompositionWithIdFromMemory} for the primary variant
198
+ */
6
199
  export declare function GetCompositionWithIdAndDateFromMemory(id: number): Promise<any>;
200
+ /**
201
+ * Reconstructs a composition from a provided list of connections.
202
+ *
203
+ * This specialized function allows you to reconstruct a composition when you
204
+ * already have the connections in memory. Useful for optimized bulk operations
205
+ * where connections have been fetched once and reused for multiple compositions.
206
+ *
207
+ * @param id - The ID of the root concept of the composition
208
+ * @param connectionList - Pre-fetched array of Connection objects
209
+ *
210
+ * @returns A promise that resolves to an object with id, created_at, and data fields
211
+ *
212
+ * @example
213
+ * ```typescript
214
+ * // Fetch connections once for multiple compositions
215
+ * const connections = await GetAllConnectionsOfCompositionBulk([123, 456]);
216
+ *
217
+ * // Reconstruct multiple compositions from the same connection set
218
+ * const comp1 = await GetCompositionWithIdFromMemoryFromConnections(123, connections);
219
+ * const comp2 = await GetCompositionWithIdFromMemoryFromConnections(456, connections);
220
+ * ```
221
+ *
222
+ * @remarks
223
+ * - Most efficient when connections are shared across compositions
224
+ * - Extracts composition list from provided connections
225
+ * - No API or cache lookups for connections
226
+ *
227
+ * @see {@link GetCompositionFromConnectionsWithDataId} for newer variant
228
+ */
7
229
  export declare function GetCompositionWithIdFromMemoryFromConnections(id: number, connectionList: Connection[]): Promise<any>;
230
+ /**
231
+ * Reconstructs a composition from connections with optional pre-computed composition list.
232
+ *
233
+ * An optimized variant that accepts an optional pre-computed list of composition IDs,
234
+ * avoiding the need to extract it from connections. This is the most efficient variant
235
+ * for bulk operations.
236
+ *
237
+ * @param id - The ID of the root concept of the composition
238
+ * @param connectionList - Pre-fetched array of Connection objects
239
+ * @param compositionList - Optional pre-computed array of composition concept IDs (default: empty array)
240
+ *
241
+ * @returns A promise that resolves to an object with id, created_at, and data fields
242
+ *
243
+ * @remarks
244
+ * - Most efficient variant when composition list is pre-computed
245
+ * - If compositionList is empty, computes it from connections
246
+ * - Useful in high-performance scenarios with many compositions
247
+ *
248
+ * @see {@link GetCompositionWithIdFromMemoryFromConnections} for basic variant
249
+ */
8
250
  export declare function GetCompositionWithIdFromMemoryFromConnectionsNew(id: number, connectionList: Connection[], compositionList?: number[]): Promise<any>;
251
+ /**
252
+ * Retrieves a composition from API with metadata wrapper.
253
+ *
254
+ * Similar to GetComposition but includes the composition ID and wraps the data
255
+ * in a structured object. Uses API calls rather than memory cache.
256
+ *
257
+ * @param id - The ID of the root concept of the composition
258
+ *
259
+ * @returns A promise that resolves to an object with data and id fields
260
+ *
261
+ * @example
262
+ * ```typescript
263
+ * const result = await GetCompositionWithId(12345);
264
+ * console.log("Composition ID:", result.id);
265
+ * console.log("Data:", result.data);
266
+ * ```
267
+ *
268
+ * @remarks
269
+ * - Fetches from API, not from cache
270
+ * - Includes composition ID in return structure
271
+ * - Data structure: { data, id }
272
+ *
273
+ * @see {@link GetComposition} for unwrapped version
274
+ * @see {@link GetCompositionWithIdFromMemory} for cached version
275
+ */
9
276
  export declare function GetCompositionWithId(id: number): Promise<any>;
277
+ /**
278
+ * Recursively reconstructs a composition structure from connections.
279
+ *
280
+ * This is the core algorithm that traverses connections and rebuilds the hierarchical
281
+ * JSON structure from the graph representation. It handles both object-like structures
282
+ * (with string keys) and array-like structures (with numeric keys).
283
+ *
284
+ * The algorithm works by:
285
+ * 1. Checking if the concept is a leaf node (not in compositionList) - returns its value
286
+ * 2. For composition nodes, iterating through all outgoing connections
287
+ * 3. Recursively processing each connected concept
288
+ * 4. Building either an object or array based on key type
289
+ * 5. Preventing infinite loops by tracking visited concepts
290
+ *
291
+ * @param id - The ID of the concept to process
292
+ * @param connectionList - All connections in the composition
293
+ * @param compositionList - Array of concept IDs that are composition nodes (not leaves)
294
+ * @param visitedConcepts - Internal tracker to prevent circular reference loops (default: empty array)
295
+ *
296
+ * @returns A promise that resolves to the reconstructed data structure (object, array, or primitive value)
297
+ *
298
+ * @example
299
+ * ```typescript
300
+ * // This function is typically called internally by GetComposition functions
301
+ * // Manual usage:
302
+ * const connections = await GetAllConnectionsOfComposition(12345);
303
+ * const compositionList = extractCompositionList(connections);
304
+ * const result = await recursiveFetch(12345, connections, compositionList);
305
+ * ```
306
+ *
307
+ * @remarks
308
+ * - Strips "the_" prefix from concept type names when used as keys
309
+ * - Numeric keys create array-like structures, string keys create object structures
310
+ * - Leaf nodes (not in compositionList) return their characterValue
311
+ * - Returns empty string for circular references (visited concepts)
312
+ * - Fetches concept type information if not cached
313
+ * - Handles null/undefined concept types gracefully
314
+ * - Returns null for id=0
315
+ *
316
+ * @see {@link GetComposition} which uses this function
317
+ * @see {@link recursiveFetchWithSubCompositions} for variant that includes IDs
318
+ */
10
319
  export declare function recursiveFetch(id: number, connectionList: Connection[], compositionList: number[], visitedConcepts?: number[]): Promise<any>;
320
+ /**
321
+ * Recursively reconstructs a composition with concept IDs embedded in the structure.
322
+ *
323
+ * Similar to recursiveFetch but adds an "id" field to each sub-composition node in the
324
+ * returned structure. This enables tracking which concept ID corresponds to each part
325
+ * of the reconstructed data.
326
+ *
327
+ * @param id - The ID of the concept to process
328
+ * @param connectionList - All connections in the composition
329
+ * @param compositionList - Array of concept IDs that are composition nodes
330
+ * @param visitedConcepts - Internal tracker to prevent circular loops (default: empty array)
331
+ *
332
+ * @returns A promise that resolves to the reconstructed structure with embedded IDs
333
+ *
334
+ * @remarks
335
+ * - Each composition node includes an "id" field
336
+ * - Otherwise identical to recursiveFetch
337
+ * - Used by GetCompositionWithAllIds
338
+ *
339
+ * @see {@link recursiveFetch} for the standard version
340
+ * @see {@link GetCompositionWithAllIds} which uses this function
341
+ */
11
342
  export declare function recursiveFetchWithSubCompositions(id: number, connectionList: Connection[], compositionList: number[], visitedConcepts?: number[]): Promise<any>;
@@ -1,11 +1,259 @@
1
+ /**
2
+ * Bulk Composition Retrieval Service
3
+ *
4
+ * This module provides high-performance functions for retrieving multiple compositions
5
+ * simultaneously. It implements sophisticated bulk prefetching and caching strategies
6
+ * to minimize API calls and optimize performance when dealing with large batches of
7
+ * compositions.
8
+ *
9
+ * The module offers several variants optimized for different scenarios:
10
+ * - Basic bulk retrieval
11
+ * - Bulk with metadata (IDs and timestamps)
12
+ * - Optimized variants using pre-fetched connection data
13
+ * - Connection and concept prefetching utilities
14
+ *
15
+ * @module GetCompositionBulk
16
+ */
1
17
  import { Connection } from "../DataStructures/Connection";
18
+ /**
19
+ * Retrieves multiple compositions in bulk with optimized prefetching.
20
+ *
21
+ * This function fetches multiple compositions simultaneously by first bulk-prefetching
22
+ * all their connections in a single API call, then reconstructing each composition
23
+ * from cached data. This is significantly more efficient than fetching compositions
24
+ * individually.
25
+ *
26
+ * @param ids - Array of composition root concept IDs to retrieve (default: empty array)
27
+ *
28
+ * @returns A promise that resolves to an array of composition objects
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * // Fetch multiple blog posts at once
33
+ * const postIds = [123, 456, 789, 101112];
34
+ * const posts = await GetCompositionBulk(postIds);
35
+ *
36
+ * console.log(`Retrieved ${posts.length} posts`);
37
+ * posts.forEach((post, index) => {
38
+ * console.log(`Post ${postIds[index]}:`, post);
39
+ * });
40
+ * ```
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * // Load user profiles for a list of users
45
+ * const userIds = await getUserIdsFromSearch("John");
46
+ * const profiles = await GetCompositionBulk(userIds);
47
+ *
48
+ * profiles.forEach(profile => {
49
+ * const userData = profile["user_profile"];
50
+ * console.log(`Name: ${userData.name}, Email: ${userData.email}`);
51
+ * });
52
+ * ```
53
+ *
54
+ * @remarks
55
+ * - Bulk prefetches all connections in a single API call
56
+ * - Reconstructs compositions from cached connection data
57
+ * - Much more efficient than individual GetComposition calls
58
+ * - Returns compositions in the same order as input IDs
59
+ * - Empty compositions returned for invalid IDs
60
+ * - Uses GetAllConnectionsOfCompositionBulk for prefetch
61
+ * - Uses GetCompositionFromMemory for reconstruction
62
+ *
63
+ * @see {@link GetCompositionBulkWithDataId} for version with metadata
64
+ * @see {@link GetAllConnectionsOfCompositionBulk} for bulk connection prefetch
65
+ * @see {@link GetCompositionFromMemory} for individual reconstruction
66
+ */
2
67
  export declare function GetCompositionBulk(ids?: number[]): Promise<any[]>;
68
+ /**
69
+ * Retrieves multiple compositions in bulk with metadata wrappers.
70
+ *
71
+ * Similar to GetCompositionBulk, but each composition includes metadata (ID and
72
+ * creation timestamp) in the returned structure. This is useful when you need to
73
+ * track or reference individual compositions while processing bulk data.
74
+ *
75
+ * @param ids - Array of composition root concept IDs to retrieve (default: empty array)
76
+ *
77
+ * @returns A promise that resolves to an array of objects with id, created_at, and data fields
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * // Fetch posts with metadata for display
82
+ * const postIds = [123, 456, 789];
83
+ * const postsWithMeta = await GetCompositionBulkWithDataId(postIds);
84
+ *
85
+ * postsWithMeta.forEach(post => {
86
+ * console.log(`Post ID: ${post.id}`);
87
+ * console.log(`Created: ${post.created_at}`);
88
+ * console.log(`Title: ${post.data["blog_post"].title}`);
89
+ * });
90
+ * ```
91
+ *
92
+ * @remarks
93
+ * - Each item includes: { id, created_at, data }
94
+ * - Uses bulk prefetch for optimal performance
95
+ * - Otherwise identical to GetCompositionBulk
96
+ *
97
+ * @see {@link GetCompositionBulk} for version without metadata
98
+ * @see {@link GetCompositionWithIdFromMemory} for individual retrieval with metadata
99
+ */
3
100
  export declare function GetCompositionBulkWithDataId(ids?: number[]): Promise<any[]>;
101
+ /**
102
+ * Retrieves compositions using a specific set of connection IDs.
103
+ *
104
+ * This function fetches compositions but allows you to specify exactly which connections
105
+ * to use for reconstruction. It also performs connection deletion checking to ensure
106
+ * cached data is up-to-date.
107
+ *
108
+ * @param ids - Array of composition root concept IDs
109
+ * @param connections - Array of specific connection IDs to use (default: empty array)
110
+ *
111
+ * @returns A promise that resolves to an array of objects with id, created_at, and data fields
112
+ *
113
+ * @example
114
+ * ```typescript
115
+ * // Fetch compositions using specific connections
116
+ * const compositionIds = [123, 456];
117
+ * const connectionIds = [789, 101112, 131415];
118
+ *
119
+ * const compositions = await GetCompositionFromConnectionsWithDataId(
120
+ * compositionIds,
121
+ * connectionIds
122
+ * );
123
+ * ```
124
+ *
125
+ * @remarks
126
+ * - Fetches only specified connections
127
+ * - Checks for connection deletions to maintain cache validity
128
+ * - Updates cache with newly fetched connections
129
+ * - Uses GetCompositionWithIdFromMemory for reconstruction
130
+ *
131
+ * @see {@link GetCompositionBulkWithDataId} for standard bulk retrieval
132
+ * @see {@link CheckForConnectionDeletionWithIds} for deletion checking
133
+ */
4
134
  export declare function GetCompositionFromConnectionsWithDataId(ids?: number[], connections?: number[]): Promise<any[]>;
5
135
  /**
6
- * Used to prefetch all the connections and their related concepts.
7
- * @param connectionIds these are the connection ids that are used to fetch all the connections and also their related concepts.
8
- * @returns all the connections that are passed as ids.
136
+ * Prefetches connections and their related concepts for optimal performance.
137
+ *
138
+ * This utility function fetches a batch of connections by ID and also prefetches all
139
+ * the concepts referenced by those connections (ofTheConcept, toTheConcept, and type).
140
+ * This ensures that when you later reconstruct compositions, all necessary data is
141
+ * already in the cache.
142
+ *
143
+ * The function implements a smart caching strategy: it first checks the local cache
144
+ * for each connection, then bulk-fetches only the missing ones from the API.
145
+ *
146
+ * @param connectionIds - Array of connection IDs to prefetch (default: empty array)
147
+ *
148
+ * @returns A promise that resolves to an array of all prefetched Connection objects
149
+ *
150
+ * @example
151
+ * ```typescript
152
+ * // Prefetch connections before processing
153
+ * const connectionIds = [123, 456, 789, 101112];
154
+ * const connections = await GetConnectionDataPrefetch(connectionIds);
155
+ *
156
+ * console.log(`Prefetched ${connections.length} connections`);
157
+ * // Now all related concepts are also cached
158
+ *
159
+ * // Subsequent operations will be faster
160
+ * for (const conn of connections) {
161
+ * const fromConcept = await GetTheConcept(conn.ofTheConceptId); // Fast, from cache
162
+ * const toConcept = await GetTheConcept(conn.toTheConceptId); // Fast, from cache
163
+ * }
164
+ * ```
165
+ *
166
+ * @example
167
+ * ```typescript
168
+ * // Use before bulk composition operations
169
+ * const compositionIds = [123, 456, 789];
170
+ *
171
+ * // First, get all connection IDs for these compositions
172
+ * const allConnectionIds = await getConnectionIdsForCompositions(compositionIds);
173
+ *
174
+ * // Prefetch everything
175
+ * await GetConnectionDataPrefetch(allConnectionIds);
176
+ *
177
+ * // Now reconstruct compositions - will be very fast
178
+ * const compositions = await Promise.all(
179
+ * compositionIds.map(id => GetCompositionFromMemory(id))
180
+ * );
181
+ * ```
182
+ *
183
+ * @remarks
184
+ * - Checks ConnectionData cache before making API calls
185
+ * - Only fetches connections that aren't already cached
186
+ * - Automatically prefetches all concepts referenced by connections:
187
+ * - ofTheConceptId (source concept)
188
+ * - toTheConceptId (target concept)
189
+ * - typeId (connection type concept)
190
+ * - Uses GetConnectionBulk for efficient batch fetching
191
+ * - Uses GetConceptBulk to prefetch all related concepts
192
+ * - Returns all connections, both cached and newly fetched
193
+ * - Significantly improves performance for composition reconstruction
194
+ *
195
+ * @see {@link GetConnectionBulk} for bulk connection fetching
196
+ * @see {@link GetConceptBulk} for bulk concept prefetching
197
+ * @see {@link ConnectionData.GetConnection} for cache lookup
9
198
  */
10
199
  export declare function GetConnectionDataPrefetch(connectionIds?: number[]): Promise<Connection[]>;
200
+ /**
201
+ * Retrieves compositions in bulk with optimized connection reuse, returning an object map.
202
+ *
203
+ * This is a highly optimized function for retrieving multiple compositions. Instead of
204
+ * returning an array, it returns an object where keys are composition IDs and values
205
+ * are the composition data. It reuses a single set of connections for all compositions,
206
+ * making it extremely efficient for large batches.
207
+ *
208
+ * The function fetches connections once, then reconstructs all compositions from the
209
+ * same connection pool. This approach minimizes memory usage and processing time.
210
+ *
211
+ * @param ids - Array of composition root concept IDs
212
+ * @param connections - Array of connection IDs to use for all compositions (default: empty array)
213
+ *
214
+ * @returns A promise that resolves to an object mapping composition IDs to their data
215
+ *
216
+ * @example
217
+ * ```typescript
218
+ * // Fetch multiple compositions as a map
219
+ * const compositionIds = [123, 456, 789];
220
+ * const connectionIds = [1001, 1002, 1003, 1004, 1005];
221
+ *
222
+ * const compositionMap = await GetCompositionFromConnectionsWithDataIdInObject(
223
+ * compositionIds,
224
+ * connectionIds
225
+ * );
226
+ *
227
+ * // Access by ID
228
+ * console.log("Composition 123:", compositionMap[123]);
229
+ * console.log("Composition 456:", compositionMap[456]);
230
+ * console.log("Composition 789:", compositionMap[789]);
231
+ * ```
232
+ *
233
+ * @example
234
+ * ```typescript
235
+ * // Efficient lookup for UI rendering
236
+ * const ids = [10, 20, 30, 40, 50];
237
+ * const connectionIds = await getAllConnectionIds(ids);
238
+ * const dataMap = await GetCompositionFromConnectionsWithDataIdInObject(ids, connectionIds);
239
+ *
240
+ * // Fast random access
241
+ * renderComponent(dataMap[20]);
242
+ * renderComponent(dataMap[40]);
243
+ * ```
244
+ *
245
+ * @remarks
246
+ * - Returns object instead of array for O(1) lookup by ID
247
+ * - Fetches connections once and reuses for all compositions
248
+ * - Separates cached and non-cached connections for efficiency
249
+ * - Computes composition list once and reuses it
250
+ * - Each composition includes: { id, created_at, data }
251
+ * - Uses GetCompositionWithIdFromMemoryFromConnectionsNew for reconstruction
252
+ * - Includes console.time/timeEnd for performance monitoring
253
+ * - Most efficient for large batches with shared connections
254
+ *
255
+ * @see {@link GetCompositionBulkWithDataId} for array-based bulk retrieval
256
+ * @see {@link GetConnectionBulk} for connection fetching
257
+ * @see {@link GetCompositionWithIdFromMemoryFromConnectionsNew} for reconstruction
258
+ */
11
259
  export declare function GetCompositionFromConnectionsWithDataIdInObject(ids?: number[], connections?: number[]): Promise<any>;