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.
- package/README.md +1148 -11
- package/dist/bundle.js +1 -0
- package/dist/types/Api/Create/CreateTheCharacter.d.ts +45 -0
- package/dist/types/Api/Create/CreateTheConceptApi.d.ts +52 -0
- package/dist/types/Api/Create/CreateTheConnectionApi.d.ts +53 -0
- package/dist/types/Api/Create/CreateTheTextData.d.ts +58 -0
- package/dist/types/Api/Delete/DeleteConceptInBackend.d.ts +44 -0
- package/dist/types/Api/DeleteConnectionApiBulk.d.ts +56 -0
- package/dist/types/Api/DeleteTheConcept.d.ts +65 -0
- package/dist/types/Api/DeleteTheConnection.d.ts +77 -0
- package/dist/types/Api/GetAiData.d.ts +37 -0
- package/dist/types/Api/GetAllConcepts.d.ts +43 -0
- package/dist/types/Api/GetAllConceptsByType.d.ts +46 -0
- package/dist/types/Api/GetAllConnections.d.ts +49 -0
- package/dist/types/Api/GetAllConnectionsOfComposition.d.ts +82 -0
- package/dist/types/Api/GetAllConnectionsOfCompositionBulk.d.ts +93 -0
- package/dist/types/Api/GetAllLinkerConnectionsFromTheConcept.d.ts +54 -0
- package/dist/types/Api/GetAllLinkerConnectionsToTheConcept.d.ts +63 -0
- package/dist/types/Api/GetAllPrefetchConnections.d.ts +52 -0
- package/dist/types/Api/GetCharacterDataByCharacter.d.ts +33 -0
- package/dist/types/Api/GetCompositionConnectionsBetweenTwoConcepts.d.ts +41 -0
- package/dist/types/Api/GetConcept.d.ts +49 -0
- package/dist/types/Api/GetConceptBulk.d.ts +71 -0
- package/dist/types/Api/GetConceptByCharacterAndType.d.ts +78 -0
- package/dist/types/Api/GetConceptByCharacterValue.d.ts +49 -0
- package/dist/types/Api/GetConnection.d.ts +51 -0
- package/dist/types/Api/GetConnectionBulk.d.ts +48 -0
- package/dist/types/Api/GetConnectionOfTheConcept.d.ts +52 -0
- package/dist/types/Api/GetConnectionToTheConcept.d.ts +58 -0
- package/dist/types/Api/GetReservedConnectionIds.d.ts +37 -0
- package/dist/types/Api/GetReservedIds.d.ts +38 -0
- package/dist/types/Api/Login.d.ts +39 -0
- package/dist/types/Api/MakeTheNameInBackend.d.ts +40 -0
- package/dist/types/Api/MakeTheTypeConceptApi.d.ts +42 -0
- package/dist/types/Api/RecursiveSearch.d.ts +44 -0
- package/dist/types/Api/Search/FreeschemaQueryApi.d.ts +48 -0
- package/dist/types/Api/Search/Search.d.ts +68 -0
- package/dist/types/Api/Search/SearchInternalApi.d.ts +71 -0
- package/dist/types/Api/Search/SearchLinkMultipleApi.d.ts +92 -0
- package/dist/types/Api/Search/SearchWithLinker.d.ts +99 -0
- package/dist/types/Api/SearchConcept/GetConceptByCharacterAndCategoryApi.d.ts +41 -0
- package/dist/types/Api/SearchConcept/GetConceptByCharacterAndCategoryDirect.d.ts +49 -0
- package/dist/types/Api/Session/CreateSession.d.ts +47 -0
- package/dist/types/Api/Session/CreateSessionVisit.d.ts +44 -0
- package/dist/types/Api/Signin.d.ts +51 -0
- package/dist/types/Api/Signup.d.ts +47 -0
- package/dist/types/Api/View/ViewInternalDataApi.d.ts +51 -0
- package/dist/types/Constants/ApiConstants.d.ts +249 -0
- package/dist/types/Constants/FormatConstants.d.ts +87 -0
- package/dist/types/DataStructures/BaseUrl.d.ts +262 -0
- package/dist/types/DataStructures/BinaryCharacterTree.d.ts +227 -0
- package/dist/types/DataStructures/BinaryTree.d.ts +151 -0
- package/dist/types/DataStructures/BinaryTypeTree.d.ts +211 -0
- package/dist/types/DataStructures/CharacterRepository.d.ts +117 -0
- package/dist/types/DataStructures/Composition/Composition.d.ts +117 -0
- package/dist/types/DataStructures/Composition/CompositionBinaryTree.d.ts +114 -0
- package/dist/types/DataStructures/Composition/CompositionNode.d.ts +223 -0
- package/dist/types/DataStructures/Concept.d.ts +139 -0
- package/dist/types/DataStructures/ConceptData.d.ts +317 -0
- package/dist/types/DataStructures/ConceptsToDraw.d.ts +179 -0
- package/dist/types/DataStructures/Connection.d.ts +103 -0
- package/dist/types/DataStructures/ConnectionBinaryTree/ConnectionBinaryTree.d.ts +126 -0
- package/dist/types/DataStructures/ConnectionBinaryTree/ConnectionNode.d.ts +193 -0
- package/dist/types/DataStructures/ConnectionBinaryTree/ConnectionTypeTree.d.ts +95 -0
- package/dist/types/DataStructures/ConnectionData.d.ts +209 -0
- package/dist/types/DataStructures/Count/CountInfo.d.ts +79 -0
- package/dist/types/DataStructures/FilterSearch.d.ts +93 -0
- package/dist/types/DataStructures/IdentifierFlags.d.ts +45 -0
- package/dist/types/DataStructures/Local/LConcept.d.ts +126 -0
- package/dist/types/DataStructures/Local/LConnection.d.ts +101 -0
- package/dist/types/DataStructures/Local/LNode.d.ts +217 -0
- package/dist/types/DataStructures/Local/LocalBinaryCharacterTree.d.ts +145 -0
- package/dist/types/DataStructures/Local/LocalBinaryTree.d.ts +147 -0
- package/dist/types/DataStructures/Local/LocalBinaryTypeTree.d.ts +160 -0
- package/dist/types/DataStructures/Local/LocalConceptData.d.ts +114 -0
- package/dist/types/DataStructures/Local/LocalConnectionData.d.ts +125 -0
- package/dist/types/DataStructures/Local/LocalSyncData.d.ts +103 -0
- package/dist/types/DataStructures/Node.d.ts +29 -0
- package/dist/types/DataStructures/PatcherStructure.d.ts +94 -0
- package/dist/types/DataStructures/ReferentInfo.d.ts +75 -0
- package/dist/types/DataStructures/ReservedIds.d.ts +111 -0
- package/dist/types/DataStructures/Responses/ErrorResponse.d.ts +236 -0
- package/dist/types/DataStructures/Responses/StandardResponses.d.ts +71 -0
- package/dist/types/DataStructures/Returner.d.ts +66 -0
- package/dist/types/DataStructures/Search/FreeschemaQuery.d.ts +187 -0
- package/dist/types/DataStructures/Search/SearchStructure.d.ts +78 -0
- package/dist/types/DataStructures/SearchQuery.d.ts +146 -0
- package/dist/types/DataStructures/Security/TokenStorage.d.ts +51 -0
- package/dist/types/DataStructures/Session/SessionData.d.ts +131 -0
- package/dist/types/DataStructures/SettingData.d.ts +37 -0
- package/dist/types/DataStructures/Settings.d.ts +31 -0
- package/dist/types/DataStructures/SigninModel.d.ts +54 -0
- package/dist/types/DataStructures/SignupModel.d.ts +54 -0
- package/dist/types/DataStructures/SyncData.d.ts +232 -0
- package/dist/types/DataStructures/TheCharacter.d.ts +100 -0
- package/dist/types/DataStructures/TheTexts.d.ts +106 -0
- package/dist/types/DataStructures/Transaction/Transaction.d.ts +320 -0
- package/dist/types/DataStructures/User/UserBinaryTree.d.ts +132 -0
- package/dist/types/DataStructures/User/UserNode.d.ts +150 -0
- package/dist/types/Database/GetConceptFromIndexDb.d.ts +9 -0
- package/dist/types/Database/NoIndexDb.d.ts +178 -0
- package/dist/types/Database/indexdblocal.d.ts +45 -0
- package/dist/types/Database/indexeddb.d.ts +46 -0
- package/dist/types/Drawing/ConceptDraw.d.ts +29 -0
- package/dist/types/Drawing/ConceptEvents.d.ts +47 -0
- package/dist/types/Helpers/CheckIfExists.d.ts +169 -0
- package/dist/types/Helpers/RemoveFromArray.d.ts +72 -0
- package/dist/types/Helpers/UniqueInsert.d.ts +29 -0
- package/dist/types/Services/CheckForConnectionDeletion.d.ts +193 -0
- package/dist/types/Services/Common/DecodeCountInfo.d.ts +57 -0
- package/dist/types/Services/Common/ErrorPosting.d.ts +51 -0
- package/dist/types/Services/Common/RegexFunction.d.ts +29 -0
- package/dist/types/Services/Composition/BuildComposition.d.ts +40 -0
- package/dist/types/Services/Composition/CompositionCache.d.ts +93 -0
- package/dist/types/Services/Composition/CreateCompositionCache.d.ts +46 -0
- package/dist/types/Services/ConceptFinding/GetConceptByCharacterAndCategory.d.ts +5 -0
- package/dist/types/Services/Conversion/ConvertConcepts.d.ts +90 -0
- package/dist/types/Services/CreateBinaryTreeFromData.d.ts +39 -0
- package/dist/types/Services/CreateCharacterBinaryTreeFromData.d.ts +43 -0
- package/dist/types/Services/CreateConnectionBetweenTwoConcepts.d.ts +211 -0
- package/dist/types/Services/CreateDefaultConcept.d.ts +117 -0
- package/dist/types/Services/CreateTheComposition.d.ts +103 -0
- package/dist/types/Services/CreateTheConcept.d.ts +184 -0
- package/dist/types/Services/CreateTheConnection.d.ts +61 -0
- package/dist/types/Services/CreateTheConnectionGeneral.d.ts +132 -0
- package/dist/types/Services/CreateTypeTreeFromData.d.ts +44 -0
- package/dist/types/Services/Delete/DeleteConnectionByType.d.ts +60 -0
- package/dist/types/Services/Delete/GetAllConnectionByType.d.ts +64 -0
- package/dist/types/Services/DeleteConcept.d.ts +137 -0
- package/dist/types/Services/DeleteConnection.d.ts +196 -0
- package/dist/types/Services/FindConeceptsFromConnection.d.ts +181 -0
- package/dist/types/Services/FindConnectionsOfCompositionBulkInMemory.d.ts +159 -0
- package/dist/types/Services/GenerateHexNumber.d.ts +65 -0
- package/dist/types/Services/GetAccessIdOfUser.d.ts +0 -0
- package/dist/types/Services/GetComposition.d.ts +342 -0
- package/dist/types/Services/GetCompositionBulk.d.ts +259 -0
- package/dist/types/Services/GetCompositionList.d.ts +132 -0
- package/dist/types/Services/GetConceptByCharacter.d.ts +87 -0
- package/dist/types/Services/GetConnections.d.ts +74 -0
- package/dist/types/Services/GetDataFromIndexDb.d.ts +81 -0
- package/dist/types/Services/GetLink.d.ts +107 -0
- package/dist/types/Services/GetLinkerConnectionFromConcept.d.ts +102 -0
- package/dist/types/Services/GetMaximumConnectionSyncTime.d.ts +59 -0
- package/dist/types/Services/GetRelation.d.ts +167 -0
- package/dist/types/Services/GetTheConcept.d.ts +73 -0
- package/dist/types/Services/GetTheReferent.d.ts +76 -0
- package/dist/types/Services/InitializeSystem.d.ts +121 -0
- package/dist/types/Services/Local/CreateConnectionListFromDatat.d.ts +0 -0
- package/dist/types/Services/Local/CreateDefaultLConcept.d.ts +50 -0
- package/dist/types/Services/Local/CreateLocalBinaryTreeFromData.d.ts +50 -0
- package/dist/types/Services/Local/CreateLocalBinaryTypeTreeFromData.d.ts +55 -0
- package/dist/types/Services/Local/CreateLocalCharacterBinaryTree.d.ts +61 -0
- package/dist/types/Services/Local/CreateTheCompositionLocal.d.ts +72 -0
- package/dist/types/Services/Local/CreateTheConceptLocal.d.ts +60 -0
- package/dist/types/Services/Local/CreateTheConnectionLocal.d.ts +58 -0
- package/dist/types/Services/Local/GetCompositionListLocal.d.ts +105 -0
- package/dist/types/Services/Local/GetCompositionLocal.d.ts +98 -0
- package/dist/types/Services/Local/GetConceptByCharacterLocal.d.ts +58 -0
- package/dist/types/Services/Local/MakeTheConceptLocal.d.ts +73 -0
- package/dist/types/Services/Local/MakeTheInstanceConceptLocal.d.ts +91 -0
- package/dist/types/Services/Local/MakeTheTypeLocal.d.ts +73 -0
- package/dist/types/Services/Local/UpdateCompositionLocal.d.ts +103 -0
- package/dist/types/Services/MakeTheCharacter.d.ts +76 -0
- package/dist/types/Services/MakeTheCharacterData.d.ts +67 -0
- package/dist/types/Services/MakeTheConcept.d.ts +2 -0
- package/dist/types/Services/MakeTheInstanceConcept.d.ts +78 -0
- package/dist/types/Services/MakeTheLocalConcept.d.ts +0 -0
- package/dist/types/Services/MakeTheName.d.ts +83 -0
- package/dist/types/Services/MakeTheTimestamp.d.ts +70 -0
- package/dist/types/Services/MakeTheTypeConcept.d.ts +71 -0
- package/dist/types/Services/Mqtt/publishMessage.d.ts +28 -0
- package/dist/types/Services/Mqtt/subscribeMessage.d.ts +23 -0
- package/dist/types/Services/PatchComposition.d.ts +107 -0
- package/dist/types/Services/Search/DataIdFormat.d.ts +104 -0
- package/dist/types/Services/Search/FormatData.d.ts +101 -0
- package/dist/types/Services/Search/JustIdFormat.d.ts +98 -0
- package/dist/types/Services/Search/SearchLinkInternal.d.ts +30 -0
- package/dist/types/Services/Search/SearchLinkMultiple.d.ts +61 -0
- package/dist/types/Services/Search/SearchWithTypeAndLinker.d.ts +101 -0
- package/dist/types/Services/Search/orderingConnections.d.ts +36 -0
- package/dist/types/Services/Security/GetRequestHeader.d.ts +10 -0
- package/dist/types/Services/SplitStrings.d.ts +51 -0
- package/dist/types/Services/UpdateComposition.d.ts +125 -0
- package/dist/types/Services/User/UserTranslation.d.ts +108 -0
- package/dist/types/Services/View/ViewInternalData.d.ts +33 -0
- package/dist/types/WrapperFunctions/SchemaQueryObservable.d.ts +159 -0
- package/dist/types/app.d.ts +162 -0
- package/package.json +1 -1
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Connection deletion check service for the CCS-JS system.
|
|
3
|
+
* This module provides utilities for identifying and removing connections that are no longer
|
|
4
|
+
* needed by comparing old and new connection sets. It's essential for maintaining cache
|
|
5
|
+
* consistency when compositions are updated or refreshed.
|
|
6
|
+
* @module Services/CheckForConnectionDeletion
|
|
7
|
+
*/
|
|
8
|
+
import { Connection } from "../DataStructures/Connection";
|
|
9
|
+
/**
|
|
10
|
+
* Identifies and removes connections that exist in the old set but not in the new set.
|
|
11
|
+
*
|
|
12
|
+
* This function performs a differential check between old and new connection arrays to find
|
|
13
|
+
* connections that should be deleted. It's commonly used when updating compositions or
|
|
14
|
+
* refreshing data from the backend, ensuring that removed connections are cleaned from
|
|
15
|
+
* the local cache.
|
|
16
|
+
*
|
|
17
|
+
* The function iterates through old connections and checks if each one exists in the new
|
|
18
|
+
* connections array by comparing IDs. If a connection is not found in the new array,
|
|
19
|
+
* it's removed from the ConnectionData cache.
|
|
20
|
+
*
|
|
21
|
+
* @param newConnections - Array of current/updated connections. Defaults to empty array.
|
|
22
|
+
* @param oldConnections - Array of previous connections to check against. Defaults to empty array.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* // Check and remove deleted connections after composition update
|
|
27
|
+
* import { CheckForConnectionDeletion } from './CheckForConnectionDeletion';
|
|
28
|
+
*
|
|
29
|
+
* const oldConnections = await getCompositionConnections(compositionId);
|
|
30
|
+
* const newConnections = await refreshCompositionFromBackend(compositionId);
|
|
31
|
+
*
|
|
32
|
+
* CheckForConnectionDeletion(newConnections, oldConnections);
|
|
33
|
+
* // Removes any connections that were deleted on the backend
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* // Handle composition refresh with connection cleanup
|
|
39
|
+
* const cachedConnections = composition.connections;
|
|
40
|
+
* const freshConnections = await fetchLatestConnections();
|
|
41
|
+
*
|
|
42
|
+
* CheckForConnectionDeletion(freshConnections, cachedConnections);
|
|
43
|
+
* composition.connections = freshConnections;
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* // Clean up connections when switching between compositions
|
|
49
|
+
* const currentCompositionConnections = getCurrentConnections();
|
|
50
|
+
* const newCompositionConnections = loadNewComposition();
|
|
51
|
+
*
|
|
52
|
+
* CheckForConnectionDeletion(newCompositionConnections, currentCompositionConnections);
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* **Comparison Logic:**
|
|
57
|
+
* - Uses array.find() to check if each old connection exists in new connections
|
|
58
|
+
* - Compares connections by ID (obj.id === oldConnections[i].id)
|
|
59
|
+
* - Only removes connections that are completely absent from new array
|
|
60
|
+
*
|
|
61
|
+
* **Safety Check:**
|
|
62
|
+
* - Verifies newConnections is an array before comparison
|
|
63
|
+
* - This prevents errors if newConnections is null or undefined
|
|
64
|
+
* - Skips deletion if newConnections is not a valid array
|
|
65
|
+
*
|
|
66
|
+
* **Side Effects:**
|
|
67
|
+
* - Directly modifies ConnectionData cache by removing connections
|
|
68
|
+
* - Permanent removal from cache (cannot be undone)
|
|
69
|
+
* - Does not affect backend data, only local cache
|
|
70
|
+
*
|
|
71
|
+
* **Performance:**
|
|
72
|
+
* - O(n*m) complexity where n = oldConnections.length, m = newConnections.length
|
|
73
|
+
* - Uses array.find() for each old connection
|
|
74
|
+
* - Consider using CheckForConnectionDeletionWithIds for better performance with large arrays
|
|
75
|
+
*
|
|
76
|
+
* **Use Cases:**
|
|
77
|
+
* - Synchronizing local cache with backend state
|
|
78
|
+
* - Cleaning up after composition updates
|
|
79
|
+
* - Maintaining cache consistency during data refresh
|
|
80
|
+
* - Removing orphaned connections
|
|
81
|
+
*
|
|
82
|
+
* @see {@link CheckForConnectionDeletionWithIds} for ID-based comparison (better performance)
|
|
83
|
+
* @see {@link ConnectionData.RemoveConnection} for connection removal implementation
|
|
84
|
+
* @see {@link Connection} for connection data structure
|
|
85
|
+
*/
|
|
86
|
+
export declare function CheckForConnectionDeletion(newConnections?: Connection[], oldConnections?: Connection[]): void;
|
|
87
|
+
/**
|
|
88
|
+
* Identifies and removes connections using ID-based comparison for improved performance.
|
|
89
|
+
*
|
|
90
|
+
* This function is a more efficient variant of CheckForConnectionDeletion that compares
|
|
91
|
+
* connection IDs directly instead of searching through connection objects. It uses
|
|
92
|
+
* Array.includes() which is faster than array.find() for ID lookups, making it better
|
|
93
|
+
* suited for large datasets.
|
|
94
|
+
*
|
|
95
|
+
* The function checks each old connection against an array of new connection IDs.
|
|
96
|
+
* If an old connection's ID is not in the new ID array, it's removed from the cache.
|
|
97
|
+
* This is particularly useful when you already have a list of IDs or when working
|
|
98
|
+
* with large numbers of connections.
|
|
99
|
+
*
|
|
100
|
+
* @param newConnectionIds - Array of current connection IDs. Defaults to empty array.
|
|
101
|
+
* @param oldConnections - Array of previous connection objects to check. Defaults to empty array.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* // Efficient cleanup using ID array
|
|
106
|
+
* import { CheckForConnectionDeletionWithIds } from './CheckForConnectionDeletion';
|
|
107
|
+
*
|
|
108
|
+
* const newConnectionIds = [123, 456, 789];
|
|
109
|
+
* const oldConnections = cachedComposition.connections;
|
|
110
|
+
*
|
|
111
|
+
* CheckForConnectionDeletionWithIds(newConnectionIds, oldConnections);
|
|
112
|
+
* // Removes connections whose IDs are not in [123, 456, 789]
|
|
113
|
+
* ```
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* // Use when fetching connections from API
|
|
118
|
+
* const apiResponse = await getConnectionsFromBackend(compositionId);
|
|
119
|
+
* const newIds = apiResponse.map(conn => conn.id);
|
|
120
|
+
* const cachedConnections = getLocalConnections();
|
|
121
|
+
*
|
|
122
|
+
* CheckForConnectionDeletionWithIds(newIds, cachedConnections);
|
|
123
|
+
* ```
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* // Cleanup connections for a composition update
|
|
128
|
+
* const updatedConnectionIds = composition.connections.map(c => c.id);
|
|
129
|
+
* const previousConnections = await getPreviousConnections(composition.id);
|
|
130
|
+
*
|
|
131
|
+
* CheckForConnectionDeletionWithIds(updatedConnectionIds, previousConnections);
|
|
132
|
+
* ```
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```typescript
|
|
136
|
+
* // Filter out deleted connections during sync
|
|
137
|
+
* const syncedIds = syncData.connectionIds;
|
|
138
|
+
* const localConnections = ConnectionData.GetAllConnections();
|
|
139
|
+
*
|
|
140
|
+
* CheckForConnectionDeletionWithIds(syncedIds, localConnections);
|
|
141
|
+
* // Removes any local connections not present in sync data
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* @remarks
|
|
145
|
+
* **Performance Advantages:**
|
|
146
|
+
* - Uses Array.includes() which is O(n) instead of array.find()
|
|
147
|
+
* - More efficient for large connection arrays
|
|
148
|
+
* - Better memory usage as only IDs are compared
|
|
149
|
+
* - Recommended for datasets with 100+ connections
|
|
150
|
+
*
|
|
151
|
+
* **Comparison Logic:**
|
|
152
|
+
* - Checks if oldConnection.id exists in newConnectionIds array
|
|
153
|
+
* - Simple inclusion check without object comparison
|
|
154
|
+
* - No need to iterate through connection properties
|
|
155
|
+
*
|
|
156
|
+
* **No Safety Check:**
|
|
157
|
+
* - Does not verify if newConnectionIds is an array
|
|
158
|
+
* - Will throw if newConnectionIds is null/undefined
|
|
159
|
+
* - Caller should ensure newConnectionIds is a valid array
|
|
160
|
+
*
|
|
161
|
+
* **Side Effects:**
|
|
162
|
+
* - Removes connections from ConnectionData cache
|
|
163
|
+
* - Permanent local cache modification
|
|
164
|
+
* - Does not affect backend or persistent storage
|
|
165
|
+
*
|
|
166
|
+
* **When to Use:**
|
|
167
|
+
* - Large numbers of connections (100+)
|
|
168
|
+
* - When you already have ID arrays
|
|
169
|
+
* - Performance-critical operations
|
|
170
|
+
* - Batch processing scenarios
|
|
171
|
+
*
|
|
172
|
+
* **When to Use CheckForConnectionDeletion Instead:**
|
|
173
|
+
* - Small datasets (< 100 connections)
|
|
174
|
+
* - When you don't have IDs readily available
|
|
175
|
+
* - When newConnections might be null/undefined
|
|
176
|
+
* - When the array check is needed
|
|
177
|
+
*
|
|
178
|
+
* **Common Patterns:**
|
|
179
|
+
* ```typescript
|
|
180
|
+
* // Pattern 1: Extract IDs from API response
|
|
181
|
+
* const ids = apiData.map(conn => conn.id);
|
|
182
|
+
* CheckForConnectionDeletionWithIds(ids, oldConnections);
|
|
183
|
+
*
|
|
184
|
+
* // Pattern 2: Use with composition updates
|
|
185
|
+
* const validIds = getValidConnectionIds(composition);
|
|
186
|
+
* CheckForConnectionDeletionWithIds(validIds, currentConnections);
|
|
187
|
+
* ```
|
|
188
|
+
*
|
|
189
|
+
* @see {@link CheckForConnectionDeletion} for object-based comparison with safety checks
|
|
190
|
+
* @see {@link ConnectionData.RemoveConnection} for connection removal implementation
|
|
191
|
+
* @see {@link Connection} for connection data structure
|
|
192
|
+
*/
|
|
193
|
+
export declare function CheckForConnectionDeletionWithIds(newConnectionIds?: number[], oldConnections?: Connection[]): void;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module DecodeCountInfo
|
|
3
|
+
* @description Provides functions to decode and process count information for connections
|
|
4
|
+
*/
|
|
5
|
+
import { CountInfo } from "../../DataStructures/Count/CountInfo";
|
|
6
|
+
/**
|
|
7
|
+
* Decodes an array of count information strings into CountInfo objects.
|
|
8
|
+
* Parses encoded count data for connection statistics.
|
|
9
|
+
*
|
|
10
|
+
* @param {string[]} [countStrings=[]] - Array of count strings in format "conceptId_connectionTypeId_count"
|
|
11
|
+
* @returns {CountInfo[]} Array of decoded CountInfo objects
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const countStrings = ["123_456_42", "789_456_15"];
|
|
16
|
+
* const countInfos = DecodeCountInfo(countStrings);
|
|
17
|
+
* // countInfos = [
|
|
18
|
+
* // { conceptId: 123, connectionTypeId: 456, count: 42 },
|
|
19
|
+
* // { conceptId: 789, connectionTypeId: 456, count: 15 }
|
|
20
|
+
* // ]
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* - Each string must be in format: "conceptId_connectionTypeId_count"
|
|
25
|
+
* - All three parts must be numeric
|
|
26
|
+
* - Returns empty array if no strings provided
|
|
27
|
+
* - Throws error if string format is invalid
|
|
28
|
+
*/
|
|
29
|
+
export declare function DecodeCountInfo(countStrings?: string[]): CountInfo[];
|
|
30
|
+
/**
|
|
31
|
+
* Fetches connection type concepts for count information and creates a dictionary.
|
|
32
|
+
* Enriches CountInfo objects with connection type names and indexes them by concept ID.
|
|
33
|
+
*
|
|
34
|
+
* @async
|
|
35
|
+
* @param {CountInfo[]} countInfos - Array of CountInfo objects to process
|
|
36
|
+
* @returns {Promise<any>} A promise that resolves to a dictionary mapping concept IDs to enriched CountInfo objects
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const countInfos: CountInfo[] = [
|
|
41
|
+
* { conceptId: 123, connectionTypeId: 456, count: 42 },
|
|
42
|
+
* { conceptId: 789, connectionTypeId: 456, count: 15 }
|
|
43
|
+
* ];
|
|
44
|
+
* const dictionary = await GetConnectionTypeForCount(countInfos);
|
|
45
|
+
* // dictionary = {
|
|
46
|
+
* // 123: { conceptId: 123, connectionTypeId: 456, count: 42, connectionType: "follows" },
|
|
47
|
+
* // 789: { conceptId: 789, connectionTypeId: 456, count: 15, connectionType: "follows" }
|
|
48
|
+
* // }
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @remarks
|
|
52
|
+
* - Fetches concept objects for each connectionTypeId
|
|
53
|
+
* - Adds connectionType (character value) to each CountInfo
|
|
54
|
+
* - Returns dictionary indexed by conceptId for fast lookup
|
|
55
|
+
* - Used by formatting functions to add count information
|
|
56
|
+
*/
|
|
57
|
+
export declare function GetConnectionTypeForCount(countInfos: CountInfo[]): Promise<any>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module ErrorPosting
|
|
3
|
+
* @description Provides error handling functions for HTTP and internal errors with structured error responses
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Handles HTTP errors by creating and throwing structured error responses.
|
|
7
|
+
* Specifically handles 401 Unauthorized errors.
|
|
8
|
+
*
|
|
9
|
+
* @param {Response} response - The HTTP Response object to process
|
|
10
|
+
* @throws {FreeSchemaResponse} Throws a structured error response for unauthorized requests
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const response = await fetch("https://api.example.com/data");
|
|
15
|
+
* HandleHttpError(response);
|
|
16
|
+
* // Throws FreeSchemaResponse if status is 401
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* - Currently only handles 401 status codes
|
|
21
|
+
* - Creates FreeSchemaResponse with status text, success=false, status code, and URL
|
|
22
|
+
* - Other status codes are not handled (function returns normally)
|
|
23
|
+
* - Useful for API call error handling
|
|
24
|
+
*/
|
|
25
|
+
export declare function HandleHttpError(response: Response): void;
|
|
26
|
+
/**
|
|
27
|
+
* Handles internal application errors by creating and throwing structured error responses.
|
|
28
|
+
* Wraps any error object into a FreeSchemaResponse.
|
|
29
|
+
*
|
|
30
|
+
* @param {any} error - The error object to process
|
|
31
|
+
* @param {string} [url=""] - Optional URL associated with the error
|
|
32
|
+
* @throws {FreeSchemaResponse} Always throws a structured error response
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* try {
|
|
37
|
+
* // Some operation
|
|
38
|
+
* throw new Error("Something went wrong");
|
|
39
|
+
* } catch (error) {
|
|
40
|
+
* HandleInternalError(error, "https://api.example.com/data");
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* - Checks if error has a status property to use, defaults to 500
|
|
46
|
+
* - Creates FreeSchemaResponse with error message, success=false, status, and stack trace
|
|
47
|
+
* - Sets URL if provided
|
|
48
|
+
* - Useful for consistent error handling throughout the application
|
|
49
|
+
* - Always throws after creating the response (never returns)
|
|
50
|
+
*/
|
|
51
|
+
export declare function HandleInternalError(error: any, url?: string): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module RegexFunction
|
|
3
|
+
* @description Provides string manipulation functions for concept type names
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Removes the "the_" prefix from a string if it exists.
|
|
7
|
+
* Used for cleaning concept type names in the CCS system.
|
|
8
|
+
*
|
|
9
|
+
* @param {string} inputString - The string to process
|
|
10
|
+
* @returns {string} The string with "the_" prefix removed, or the original string if prefix not found
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const typeName = "the_user";
|
|
15
|
+
* const cleaned = removeThePrefix(typeName);
|
|
16
|
+
* // cleaned = "user"
|
|
17
|
+
*
|
|
18
|
+
* const noPrefix = "post";
|
|
19
|
+
* const unchanged = removeThePrefix(noPrefix);
|
|
20
|
+
* // unchanged = "post"
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* - Only removes prefix if string starts with exactly "the_"
|
|
25
|
+
* - Case-sensitive matching
|
|
26
|
+
* - Returns original string if prefix not found
|
|
27
|
+
* - Used throughout formatting functions to clean type names
|
|
28
|
+
*/
|
|
29
|
+
export declare function removeThePrefix(inputString: string): string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module BuildComposition
|
|
3
|
+
* @description Provides functions to recursively build composition structures from concepts and connections with caching support
|
|
4
|
+
*/
|
|
5
|
+
import { Connection } from '../../DataStructures/Connection';
|
|
6
|
+
import { Concept } from '../../DataStructures/Concept';
|
|
7
|
+
/**
|
|
8
|
+
* Recursively fetches and builds a composition structure from provided concepts and connections.
|
|
9
|
+
* Uses passed data rather than querying externally, with backend fallback for missing data.
|
|
10
|
+
*
|
|
11
|
+
* @async
|
|
12
|
+
* @param {number} id - The concept ID to start building the composition from
|
|
13
|
+
* @param {Connection[]} connectionList - Array of all connections to use for building
|
|
14
|
+
* @param {Concept[]} conceptList - Array of all concepts available for building
|
|
15
|
+
* @param {compositionList} compositionList - Array of concept IDs that are compositions (not leaf values)
|
|
16
|
+
* @param {number[]} [visitedConcepts=[]] - Array tracking visited concept IDs to prevent circular references
|
|
17
|
+
* @returns {Promise<any>} A promise that resolves to the built composition object or character value
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const conceptId = 123;
|
|
22
|
+
* const connections: Connection[] = [...];
|
|
23
|
+
* const concepts: Concept[] = [...];
|
|
24
|
+
* const compositionIds = [123, 456];
|
|
25
|
+
* const visited: number[] = [];
|
|
26
|
+
* const result = await recursiveFetchNew(conceptId, connections, concepts, compositionIds, visited);
|
|
27
|
+
* // result = { user: { name: "John", email: "john@example.com" } }
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* This function:
|
|
32
|
+
* - Works with pre-loaded concepts and connections (no external queries during recursion)
|
|
33
|
+
* - Falls back to backend API if concept/connection not found in provided lists
|
|
34
|
+
* - Tracks visited concepts to prevent infinite loops in circular relationships
|
|
35
|
+
* - Distinguishes between composition nodes (objects/arrays) and leaf values (strings)
|
|
36
|
+
* - Removes "the_" prefix from type names for cleaner keys
|
|
37
|
+
* - Handles numeric types as arrays, string types as objects
|
|
38
|
+
* - Returns empty string for concepts not in compositionList (leaf values)
|
|
39
|
+
*/
|
|
40
|
+
export declare function recursiveFetchNew(id: number, connectionList: Connection[], conceptList: Concept[], compositionList: number[], visitedConcepts?: number[]): Promise<any>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module CompositionCache
|
|
3
|
+
* @description Provides composition retrieval functions with caching support for improved performance
|
|
4
|
+
*/
|
|
5
|
+
import { Connection } from '../../DataStructures/Connection';
|
|
6
|
+
/**
|
|
7
|
+
* Retrieves a composition by ID with caching support, optionally using provided connections.
|
|
8
|
+
* Returns a formatted composition object with all internal connections.
|
|
9
|
+
*
|
|
10
|
+
* @async
|
|
11
|
+
* @param {number} id - The composition concept ID to retrieve
|
|
12
|
+
* @param {Connection[]} [connectionListPassed=[]] - Optional pre-fetched connections for this composition
|
|
13
|
+
* @returns {Promise<any>} A promise that resolves to the formatted composition object
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // Retrieve composition without pre-loaded connections
|
|
18
|
+
* const composition = await GetCompositionWithCache(123);
|
|
19
|
+
* // composition = { user: { name: "John", email: "john@example.com" } }
|
|
20
|
+
*
|
|
21
|
+
* // Retrieve composition with pre-loaded connections (more efficient)
|
|
22
|
+
* const connections: Connection[] = [...]; // Previously fetched
|
|
23
|
+
* const composition = await GetCompositionWithCache(123, connections);
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* This function:
|
|
28
|
+
* - Checks local cache (ConceptsData) before making API calls
|
|
29
|
+
* - Uses provided connections if available, otherwise fetches them
|
|
30
|
+
* - Builds list of composition IDs and concept IDs from connections
|
|
31
|
+
* - Recursively builds the composition structure
|
|
32
|
+
* - Returns empty string if concept ID is 0
|
|
33
|
+
* - Uses concept type as the root key in returned object
|
|
34
|
+
*/
|
|
35
|
+
export declare function GetCompositionWithCache(id: number, connectionListPassed?: Connection[]): Promise<any>;
|
|
36
|
+
/**
|
|
37
|
+
* Retrieves a composition by ID in DATA-ID format with caching support.
|
|
38
|
+
* Returns composition with id, data, and created_at fields.
|
|
39
|
+
*
|
|
40
|
+
* @async
|
|
41
|
+
* @param {number} id - The composition concept ID to retrieve
|
|
42
|
+
* @param {Connection[]} [connectionListPassed=[]] - Optional pre-fetched connections for this composition
|
|
43
|
+
* @returns {Promise<any>} A promise that resolves to composition object with id, data, and created_at properties
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const composition = await GetCompositionWithDataIdWithCache(123);
|
|
48
|
+
* // composition = {
|
|
49
|
+
* // id: 123,
|
|
50
|
+
* // data: { user: { name: "John", email: "john@example.com" } },
|
|
51
|
+
* // created_at: "2023-10-30T12:00:00Z"
|
|
52
|
+
* // }
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* Format: DATA-ID - Includes explicit ID and timestamp information
|
|
57
|
+
* This function:
|
|
58
|
+
* - Similar to GetCompositionWithCache but includes ID metadata
|
|
59
|
+
* - Returns object with id, data (composition tree), and created_at
|
|
60
|
+
* - Uses caching for improved performance
|
|
61
|
+
* - Returns empty string if concept ID is 0
|
|
62
|
+
*/
|
|
63
|
+
export declare function GetCompositionWithDataIdWithCache(id: number, connectionListPassed?: Connection[]): Promise<any>;
|
|
64
|
+
/**
|
|
65
|
+
* Retrieves multiple compositions in bulk using DATA-ID format.
|
|
66
|
+
* Efficiently fetches multiple compositions with their internal connections in one operation.
|
|
67
|
+
*
|
|
68
|
+
* @async
|
|
69
|
+
* @param {number[]} ids - Array of composition concept IDs to retrieve
|
|
70
|
+
* @param {number[]} connections - Array of connection IDs for all compositions
|
|
71
|
+
* @returns {Promise<any[]>} A promise that resolves to array of composition objects with DATA-ID format
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const compositionIds = [123, 456, 789];
|
|
76
|
+
* const connectionIds = [1, 2, 3, 4, 5];
|
|
77
|
+
* const compositions = await GetCompositionWithDataIdBulk(compositionIds, connectionIds);
|
|
78
|
+
* // compositions = [
|
|
79
|
+
* // { id: 123, data: {...}, created_at: timestamp },
|
|
80
|
+
* // { id: 456, data: {...}, created_at: timestamp },
|
|
81
|
+
* // { id: 789, data: {...}, created_at: timestamp }
|
|
82
|
+
* // ]
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* @remarks
|
|
86
|
+
* This function:
|
|
87
|
+
* - Optimized for bulk operations to reduce API calls
|
|
88
|
+
* - Fetches all connections once, then filters per composition
|
|
89
|
+
* - Each result includes id, data object, and created_at timestamp
|
|
90
|
+
* - Filters out null/undefined compositions from results
|
|
91
|
+
* - More efficient than calling GetCompositionWithDataIdWithCache individually
|
|
92
|
+
*/
|
|
93
|
+
export declare function GetCompositionWithDataIdBulk(ids: number[], connections: number[]): Promise<any[]>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module CreateCompositionCache
|
|
3
|
+
* @description Provides functionality to create compositions from JSON objects with caching support
|
|
4
|
+
*/
|
|
5
|
+
import { Concept } from '../../DataStructures/Concept';
|
|
6
|
+
import { Composition } from '../../DataStructures/Composition/Composition';
|
|
7
|
+
/**
|
|
8
|
+
* Creates a composition from a JSON object with caching mechanism.
|
|
9
|
+
* Recursively processes nested objects/arrays to create concepts and connections.
|
|
10
|
+
*
|
|
11
|
+
* @async
|
|
12
|
+
* @param {any} json - The JSON object to convert into a composition
|
|
13
|
+
* @param {number | null} [ofTheConceptId=null] - Parent concept ID (null for root)
|
|
14
|
+
* @param {number | null} [ofTheConceptUserId=null] - Parent concept's user ID
|
|
15
|
+
* @param {number | null} [mainKey=null] - Main composition ID (root concept ID)
|
|
16
|
+
* @param {number | null} [userId=null] - User ID creating the composition (defaults to 999)
|
|
17
|
+
* @param {number | null} [accessId=null] - Access level ID (defaults to 4)
|
|
18
|
+
* @param {number | null} [sessionInformationId=null] - Session ID (defaults to 999)
|
|
19
|
+
* @param {Composition | null} [composition=null] - Existing Composition object to populate
|
|
20
|
+
* @returns {Promise<Concept>} A promise that resolves to the main (root) Concept of the composition
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const jsonData = {
|
|
25
|
+
* user: {
|
|
26
|
+
* name: "John",
|
|
27
|
+
* email: "john@example.com",
|
|
28
|
+
* age: 30
|
|
29
|
+
* }
|
|
30
|
+
* };
|
|
31
|
+
* const mainConcept = await CreateTheCompositionWithCache(jsonData, null, null, null, 1, 4, 1);
|
|
32
|
+
* // Creates concepts for user, name, email, age with proper connections
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
* This function:
|
|
37
|
+
* - Recursively processes nested JSON structures
|
|
38
|
+
* - Creates concepts for each key-value pair
|
|
39
|
+
* - Establishes connections between parent and child concepts
|
|
40
|
+
* - Distinguishes between composition nodes (objects/arrays) and leaf values (primitives)
|
|
41
|
+
* - Populates the Composition object with all concepts and connections
|
|
42
|
+
* - Uses caching for improved performance
|
|
43
|
+
* - First call (no parent) creates the root concept
|
|
44
|
+
* - Subsequent recursive calls create child concepts linked to parents
|
|
45
|
+
*/
|
|
46
|
+
export declare function CreateTheCompositionWithCache(json: any, ofTheConceptId?: number | null, ofTheConceptUserId?: number | null, mainKey?: number | null, userId?: number | null, accessId?: number | null, sessionInformationId?: number | null, composition?: Composition | null): Promise<Concept>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Concept } from "../../app";
|
|
2
|
+
export declare function GetConceptByCharacterAndCategory(character: string): Promise<Concept>;
|
|
3
|
+
export declare function GetConceptByCharacter(characterValue: string): Promise<Concept>;
|
|
4
|
+
export declare function GetConceptByCharacterSingle(characterValue: string): Promise<Concept>;
|
|
5
|
+
export declare function GetConceptByCharacterAndCategoryFromMemory(character: string, category: number): Promise<Concept>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module ConvertConcepts
|
|
3
|
+
* @description Provides conversion functions between Concept/Connection and LConcept/LConnection (local versions)
|
|
4
|
+
*/
|
|
5
|
+
import { Concept } from "../../DataStructures/Concept";
|
|
6
|
+
import { Connection } from "../../DataStructures/Connection";
|
|
7
|
+
import { LConcept } from "../../DataStructures/Local/LConcept";
|
|
8
|
+
import { LConnection } from "../../DataStructures/Local/LConnection";
|
|
9
|
+
/**
|
|
10
|
+
* Converts a standard Concept to a Local Concept (LConcept).
|
|
11
|
+
* LConcepts include additional properties for local/optimistic operations.
|
|
12
|
+
*
|
|
13
|
+
* @param {Concept} concept - The standard Concept to convert
|
|
14
|
+
* @returns {LConcept} The converted LConcept with all properties mapped
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const concept: Concept = {
|
|
19
|
+
* id: 123,
|
|
20
|
+
* characterValue: "John",
|
|
21
|
+
* typeId: 456,
|
|
22
|
+
* ...
|
|
23
|
+
* };
|
|
24
|
+
* const lConcept = convertFromConceptToLConcept(concept);
|
|
25
|
+
* // lConcept includes all concept properties plus isTemp, typeCharacter
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* - Maps all standard Concept properties to LConcept
|
|
30
|
+
* - Sets isTemp to false (not a temporary concept)
|
|
31
|
+
* - Includes typeCharacter from concept.type.characterValue
|
|
32
|
+
* - Used when loading concepts from backend into local cache
|
|
33
|
+
* - LConcepts are used for optimistic UI updates
|
|
34
|
+
*/
|
|
35
|
+
export declare function convertFromConceptToLConcept(concept: Concept): LConcept;
|
|
36
|
+
/**
|
|
37
|
+
* Converts a Local Concept (LConcept) back to a standard Concept.
|
|
38
|
+
* Used when persisting local concepts to the backend.
|
|
39
|
+
*
|
|
40
|
+
* @param {LConcept} lconcept - The LConcept to convert
|
|
41
|
+
* @returns {Concept} The converted standard Concept
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const lConcept: LConcept = {
|
|
46
|
+
* id: 123,
|
|
47
|
+
* ghostId: 456,
|
|
48
|
+
* characterValue: "John",
|
|
49
|
+
* isTemp: true,
|
|
50
|
+
* ...
|
|
51
|
+
* };
|
|
52
|
+
* const concept = convertFromLConceptToConcept(lConcept);
|
|
53
|
+
* // concept is now a standard Concept without local-specific properties
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @remarks
|
|
57
|
+
* - Maps LConcept properties back to standard Concept
|
|
58
|
+
* - Drops local-specific properties (isTemp, typeCharacter)
|
|
59
|
+
* - Used when saving concepts to backend
|
|
60
|
+
* - Reverse operation of convertFromConceptToLConcept
|
|
61
|
+
*/
|
|
62
|
+
export declare function convertFromLConceptToConcept(lconcept: LConcept): Concept;
|
|
63
|
+
/**
|
|
64
|
+
* Converts a standard Connection to a Local Connection (LConnection).
|
|
65
|
+
* LConnections include additional properties for local/optimistic operations.
|
|
66
|
+
*
|
|
67
|
+
* @param {Connection} connection - The standard Connection to convert
|
|
68
|
+
* @returns {LConnection} The converted LConnection with all properties mapped
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const connection: Connection = {
|
|
73
|
+
* id: 789,
|
|
74
|
+
* ofTheConceptId: 123,
|
|
75
|
+
* toTheConceptId: 456,
|
|
76
|
+
* typeId: 999,
|
|
77
|
+
* ...
|
|
78
|
+
* };
|
|
79
|
+
* const lConnection = convertFromConnectionToLConnection(connection);
|
|
80
|
+
* // lConnection includes all connection properties plus isTemp flag
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @remarks
|
|
84
|
+
* - Maps all standard Connection properties to LConnection
|
|
85
|
+
* - Sets isTemp to false (not a temporary connection)
|
|
86
|
+
* - Used when loading connections from backend into local cache
|
|
87
|
+
* - LConnections are used for optimistic UI updates
|
|
88
|
+
* - Enables local connection management before backend persistence
|
|
89
|
+
*/
|
|
90
|
+
export declare function convertFromConnectionToLConnection(connection: Connection): LConnection;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Binary Tree Data Loading Service
|
|
3
|
+
*
|
|
4
|
+
* This module provides functionality for creating and populating binary tree data structures
|
|
5
|
+
* from persisted concept data stored in IndexedDB. It loads concept records and adds them
|
|
6
|
+
* to in-memory data structures for efficient access and querying.
|
|
7
|
+
*
|
|
8
|
+
* @module CreateBinaryTreeFromData
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Creates and populates a binary tree structure from concept data stored in the database.
|
|
12
|
+
*
|
|
13
|
+
* This function loads all concept records from IndexedDB and adds them to the in-memory
|
|
14
|
+
* ConceptsData structure for fast retrieval and manipulation. It measures the time taken
|
|
15
|
+
* to load all concepts for performance monitoring purposes.
|
|
16
|
+
*
|
|
17
|
+
* The function retrieves all records of type "concept" from the database and iterates through
|
|
18
|
+
* them, adding each concept to the ConceptsData memory structure. Note that the actual binary
|
|
19
|
+
* tree node creation is currently commented out, with only memory storage being active.
|
|
20
|
+
*
|
|
21
|
+
* @returns A promise that resolves when all concepts have been loaded into memory
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* // Initialize the binary tree with database data
|
|
26
|
+
* await CreateBinaryTreeFromData();
|
|
27
|
+
* console.log('Binary tree populated from database');
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* - Performance is tracked using start and end timestamps
|
|
32
|
+
* - The actual BinaryTree node creation (lines 14-15) is commented out in current implementation
|
|
33
|
+
* - Only adds concepts to ConceptsData memory structure, not to the BinaryTree itself
|
|
34
|
+
* - Time measurement variables (startTime, endTime, time) are calculated but not returned or logged
|
|
35
|
+
*
|
|
36
|
+
* @see {@link ConceptsData.AddConceptToMemory} for how concepts are stored in memory
|
|
37
|
+
* @see {@link getFromDatabaseWithTypeOld} for database retrieval implementation
|
|
38
|
+
*/
|
|
39
|
+
export default function CreateBinaryTreeFromData(): Promise<void>;
|