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.
- package/README.md +1148 -11
- package/dist/bundle.js +1 -1
- package/dist/types/Api/Create/CreateTheCharacter.d.ts +42 -0
- package/dist/types/Api/Create/CreateTheConceptApi.d.ts +50 -0
- package/dist/types/Api/Create/CreateTheConnectionApi.d.ts +51 -0
- package/dist/types/Api/Create/CreateTheTextData.d.ts +56 -0
- package/dist/types/Api/Delete/DeleteConceptInBackend.d.ts +43 -0
- package/dist/types/Api/DeleteConnectionApiBulk.d.ts +55 -0
- package/dist/types/Api/DeleteTheConcept.d.ts +64 -0
- package/dist/types/Api/DeleteTheConnection.d.ts +76 -0
- package/dist/types/Api/GetAiData.d.ts +36 -0
- package/dist/types/Api/GetAllConcepts.d.ts +42 -0
- package/dist/types/Api/GetAllConceptsByType.d.ts +45 -0
- package/dist/types/Api/GetAllConnections.d.ts +48 -0
- package/dist/types/Api/GetAllConnectionsOfComposition.d.ts +79 -0
- package/dist/types/Api/GetAllConnectionsOfCompositionBulk.d.ts +90 -0
- package/dist/types/Api/GetAllLinkerConnectionsFromTheConcept.d.ts +52 -0
- package/dist/types/Api/GetAllLinkerConnectionsToTheConcept.d.ts +61 -0
- package/dist/types/Api/GetAllPrefetchConnections.d.ts +51 -0
- package/dist/types/Api/GetCharacterDataByCharacter.d.ts +31 -0
- package/dist/types/Api/GetCompositionConnectionsBetweenTwoConcepts.d.ts +39 -0
- package/dist/types/Api/GetConcept.d.ts +47 -0
- package/dist/types/Api/GetConceptBulk.d.ts +68 -0
- package/dist/types/Api/GetConceptByCharacterAndType.d.ts +75 -0
- package/dist/types/Api/GetConceptByCharacterValue.d.ts +47 -0
- package/dist/types/Api/GetConnection.d.ts +49 -0
- package/dist/types/Api/GetConnectionBulk.d.ts +46 -0
- package/dist/types/Api/GetConnectionOfTheConcept.d.ts +50 -0
- package/dist/types/Api/GetConnectionToTheConcept.d.ts +56 -0
- package/dist/types/Api/GetReservedConnectionIds.d.ts +36 -0
- package/dist/types/Api/GetReservedIds.d.ts +37 -0
- package/dist/types/Api/Login.d.ts +38 -0
- package/dist/types/Api/MakeTheNameInBackend.d.ts +39 -0
- package/dist/types/Api/MakeTheTypeConceptApi.d.ts +40 -0
- package/dist/types/Api/RecursiveSearch.d.ts +43 -0
- package/dist/types/Api/Search/FreeschemaQueryApi.d.ts +46 -0
- package/dist/types/Api/Search/Search.d.ts +67 -0
- package/dist/types/Api/Search/SearchInternalApi.d.ts +69 -0
- package/dist/types/Api/Search/SearchLinkMultipleApi.d.ts +90 -0
- package/dist/types/Api/Search/SearchWithLinker.d.ts +97 -0
- package/dist/types/Api/SearchConcept/GetConceptByCharacterAndCategoryApi.d.ts +39 -0
- package/dist/types/Api/SearchConcept/GetConceptByCharacterAndCategoryDirect.d.ts +47 -0
- package/dist/types/Api/Session/CreateSession.d.ts +45 -0
- package/dist/types/Api/Session/CreateSessionVisit.d.ts +43 -0
- package/dist/types/Api/Signin.d.ts +48 -0
- package/dist/types/Api/Signup.d.ts +44 -0
- package/dist/types/Api/View/ViewInternalDataApi.d.ts +50 -0
- package/dist/types/Constants/ApiConstants.d.ts +226 -0
- package/dist/types/Constants/FormatConstants.d.ts +81 -0
- package/dist/types/DataStructures/BaseUrl.d.ts +210 -0
- package/dist/types/DataStructures/BinaryCharacterTree.d.ts +211 -0
- package/dist/types/DataStructures/BinaryTree.d.ts +139 -0
- package/dist/types/DataStructures/BinaryTypeTree.d.ts +196 -0
- package/dist/types/DataStructures/CharacterRepository.d.ts +109 -0
- package/dist/types/DataStructures/Composition/Composition.d.ts +103 -0
- package/dist/types/DataStructures/Composition/CompositionBinaryTree.d.ts +104 -0
- package/dist/types/DataStructures/Composition/CompositionNode.d.ts +202 -0
- package/dist/types/DataStructures/Concept.d.ts +110 -0
- package/dist/types/DataStructures/ConceptData.d.ts +292 -0
- package/dist/types/DataStructures/ConceptsToDraw.d.ts +168 -0
- package/dist/types/DataStructures/Connection.d.ts +76 -0
- package/dist/types/DataStructures/ConnectionBinaryTree/ConnectionBinaryTree.d.ts +115 -0
- package/dist/types/DataStructures/ConnectionBinaryTree/ConnectionNode.d.ts +169 -0
- package/dist/types/DataStructures/ConnectionBinaryTree/ConnectionTypeTree.d.ts +82 -0
- package/dist/types/DataStructures/ConnectionData.d.ts +191 -0
- package/dist/types/DataStructures/Count/CountInfo.d.ts +73 -0
- package/dist/types/DataStructures/FilterSearch.d.ts +84 -0
- package/dist/types/DataStructures/IdentifierFlags.d.ts +34 -0
- package/dist/types/DataStructures/Local/LConcept.d.ts +105 -0
- package/dist/types/DataStructures/Local/LConnection.d.ts +83 -0
- package/dist/types/DataStructures/Local/LNode.d.ts +190 -0
- package/dist/types/DataStructures/Local/LocalBinaryCharacterTree.d.ts +133 -0
- package/dist/types/DataStructures/Local/LocalBinaryTree.d.ts +135 -0
- package/dist/types/DataStructures/Local/LocalBinaryTypeTree.d.ts +147 -0
- package/dist/types/DataStructures/Local/LocalConceptData.d.ts +100 -0
- package/dist/types/DataStructures/Local/LocalConnectionData.d.ts +109 -0
- package/dist/types/DataStructures/Local/LocalSyncData.d.ts +89 -0
- package/dist/types/DataStructures/PatcherStructure.d.ts +86 -0
- package/dist/types/DataStructures/ReferentInfo.d.ts +68 -0
- package/dist/types/DataStructures/ReservedIds.d.ts +101 -0
- package/dist/types/DataStructures/Responses/ErrorResponse.d.ts +184 -22
- package/dist/types/DataStructures/Responses/StandardResponses.d.ts +65 -0
- package/dist/types/DataStructures/Returner.d.ts +59 -0
- package/dist/types/DataStructures/Search/FreeschemaQuery.d.ts +165 -0
- package/dist/types/DataStructures/Search/SearchStructure.d.ts +69 -0
- package/dist/types/DataStructures/SearchQuery.d.ts +130 -0
- package/dist/types/DataStructures/Security/TokenStorage.d.ts +48 -0
- package/dist/types/DataStructures/Session/SessionData.d.ts +118 -0
- package/dist/types/DataStructures/SettingData.d.ts +32 -0
- package/dist/types/DataStructures/Settings.d.ts +27 -0
- package/dist/types/DataStructures/SigninModel.d.ts +50 -0
- package/dist/types/DataStructures/SignupModel.d.ts +50 -0
- package/dist/types/DataStructures/SyncData.d.ts +206 -0
- package/dist/types/DataStructures/TheCharacter.d.ts +87 -0
- package/dist/types/DataStructures/TheTexts.d.ts +92 -0
- package/dist/types/DataStructures/Transaction/Transaction.d.ts +294 -4
- package/dist/types/DataStructures/User/UserBinaryTree.d.ts +117 -0
- package/dist/types/DataStructures/User/UserNode.d.ts +130 -0
- package/dist/types/Database/GetConceptFromIndexDb.d.ts +9 -0
- package/dist/types/Database/NoIndexDb.d.ts +169 -0
- package/dist/types/Database/indexdblocal.d.ts +42 -0
- package/dist/types/Database/indexeddb.d.ts +43 -0
- package/dist/types/Drawing/ConceptDraw.d.ts +28 -0
- package/dist/types/Drawing/ConceptEvents.d.ts +46 -0
- package/dist/types/Helpers/CheckIfExists.d.ts +159 -0
- package/dist/types/Helpers/RemoveFromArray.d.ts +66 -0
- package/dist/types/Helpers/UniqueInsert.d.ts +28 -0
- package/dist/types/Services/CheckForConnectionDeletion.d.ts +190 -0
- package/dist/types/Services/Common/DecodeCountInfo.d.ts +54 -0
- package/dist/types/Services/Common/ErrorPosting.d.ts +49 -0
- package/dist/types/Services/Common/RegexFunction.d.ts +28 -0
- package/dist/types/Services/Composition/BuildComposition.d.ts +37 -0
- package/dist/types/Services/Composition/CompositionCache.d.ts +89 -0
- package/dist/types/Services/Composition/CreateCompositionCache.d.ts +43 -0
- package/dist/types/Services/Conversion/ConvertConcepts.d.ts +83 -0
- package/dist/types/Services/CreateBinaryTreeFromData.d.ts +38 -0
- package/dist/types/Services/CreateCharacterBinaryTreeFromData.d.ts +42 -0
- package/dist/types/Services/CreateConnectionBetweenTwoConcepts.d.ts +206 -0
- package/dist/types/Services/CreateDefaultConcept.d.ts +114 -0
- package/dist/types/Services/CreateTheComposition.d.ts +101 -0
- package/dist/types/Services/CreateTheConcept.d.ts +179 -0
- package/dist/types/Services/CreateTheConnection.d.ts +59 -0
- package/dist/types/Services/CreateTheConnectionGeneral.d.ts +127 -0
- package/dist/types/Services/CreateTypeTreeFromData.d.ts +43 -0
- package/dist/types/Services/Delete/DeleteConnectionByType.d.ts +52 -5
- package/dist/types/Services/Delete/GetAllConnectionByType.d.ts +57 -9
- package/dist/types/Services/DeleteConcept.d.ts +136 -0
- package/dist/types/Services/DeleteConnection.d.ts +194 -0
- package/dist/types/Services/FindConeceptsFromConnection.d.ts +179 -0
- package/dist/types/Services/FindConnectionsOfCompositionBulkInMemory.d.ts +157 -0
- package/dist/types/Services/GenerateHexNumber.d.ts +64 -0
- package/dist/types/Services/GetComposition.d.ts +331 -0
- package/dist/types/Services/GetCompositionBulk.d.ts +251 -3
- package/dist/types/Services/GetCompositionList.d.ts +130 -0
- package/dist/types/Services/GetConceptByCharacter.d.ts +84 -0
- package/dist/types/Services/GetConnections.d.ts +72 -0
- package/dist/types/Services/GetDataFromIndexDb.d.ts +79 -0
- package/dist/types/Services/GetLink.d.ts +104 -0
- package/dist/types/Services/GetLinkerConnectionFromConcept.d.ts +99 -0
- package/dist/types/Services/GetMaximumConnectionSyncTime.d.ts +57 -0
- package/dist/types/Services/GetRelation.d.ts +162 -0
- package/dist/types/Services/GetTheConcept.d.ts +71 -0
- package/dist/types/Services/GetTheReferent.d.ts +74 -0
- package/dist/types/Services/InitializeSystem.d.ts +119 -0
- package/dist/types/Services/Local/CreateDefaultLConcept.d.ts +48 -0
- package/dist/types/Services/Local/CreateLocalBinaryTreeFromData.d.ts +49 -0
- package/dist/types/Services/Local/CreateLocalBinaryTypeTreeFromData.d.ts +54 -0
- package/dist/types/Services/Local/CreateLocalCharacterBinaryTree.d.ts +60 -0
- package/dist/types/Services/Local/CreateTheCompositionLocal.d.ts +70 -0
- package/dist/types/Services/Local/CreateTheConceptLocal.d.ts +58 -0
- package/dist/types/Services/Local/CreateTheConnectionLocal.d.ts +56 -0
- package/dist/types/Services/Local/GetCompositionListLocal.d.ts +103 -0
- package/dist/types/Services/Local/GetCompositionLocal.d.ts +96 -0
- package/dist/types/Services/Local/GetConceptByCharacterLocal.d.ts +57 -0
- package/dist/types/Services/Local/MakeTheConceptLocal.d.ts +71 -0
- package/dist/types/Services/Local/MakeTheInstanceConceptLocal.d.ts +89 -0
- package/dist/types/Services/Local/MakeTheTypeLocal.d.ts +71 -0
- package/dist/types/Services/Local/UpdateCompositionLocal.d.ts +101 -0
- package/dist/types/Services/MakeTheCharacter.d.ts +74 -0
- package/dist/types/Services/MakeTheCharacterData.d.ts +65 -0
- package/dist/types/Services/MakeTheInstanceConcept.d.ts +75 -0
- package/dist/types/Services/MakeTheName.d.ts +81 -0
- package/dist/types/Services/MakeTheTimestamp.d.ts +68 -0
- package/dist/types/Services/MakeTheTypeConcept.d.ts +68 -0
- package/dist/types/Services/Mqtt/publishMessage.d.ts +27 -0
- package/dist/types/Services/Mqtt/subscribeMessage.d.ts +23 -0
- package/dist/types/Services/PatchComposition.d.ts +105 -0
- package/dist/types/Services/Search/DataIdFormat.d.ts +96 -24
- package/dist/types/Services/Search/FormatData.d.ts +92 -17
- package/dist/types/Services/Search/JustIdFormat.d.ts +91 -16
- package/dist/types/Services/Search/NewFormat.d.ts +4 -0
- package/dist/types/Services/Search/SearchLinkInternal.d.ts +28 -0
- package/dist/types/Services/Search/SearchLinkMultiple.d.ts +58 -0
- package/dist/types/Services/Search/SearchWithTypeAndLinker.d.ts +92 -24
- package/dist/types/Services/Search/orderingConnections.d.ts +34 -0
- package/dist/types/Services/SplitStrings.d.ts +50 -0
- package/dist/types/Services/UpdateComposition.d.ts +123 -0
- package/dist/types/Services/User/UserTranslation.d.ts +102 -0
- package/dist/types/Services/View/ViewInternalData.d.ts +32 -0
- package/dist/types/WrapperFunctions/SchemaQueryObservable.d.ts +140 -5
- package/dist/types/app.d.ts +72 -1
- package/package.json +1 -1
|
@@ -1 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Concept deletion service for the CCS-JS system.
|
|
3
|
+
* This module provides comprehensive functionality for deleting concepts from the system,
|
|
4
|
+
* including removal from all cache structures (binary trees, type trees, character trees),
|
|
5
|
+
* local database cleanup, and backend synchronization.
|
|
6
|
+
* @module Services/DeleteConcept
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Deletes a concept from the entire CCS-JS system, including all caches and the backend.
|
|
10
|
+
*
|
|
11
|
+
* This function performs a comprehensive deletion of a concept by removing it from multiple
|
|
12
|
+
* data structures and storage layers:
|
|
13
|
+
* 1. Retrieves the concept to get its metadata (typeId, characterValue)
|
|
14
|
+
* 2. Removes the concept from the main BinaryTree index
|
|
15
|
+
* 3. Removes it from the BinaryTypeTree (type-based indexing)
|
|
16
|
+
* 4. Removes it from the BinaryCharacterTree (character-based indexing)
|
|
17
|
+
* 5. Removes it from the local IndexedDB database
|
|
18
|
+
* 6. Deletes it from the backend server
|
|
19
|
+
*
|
|
20
|
+
* This ensures complete cleanup across all layers of the application, maintaining data
|
|
21
|
+
* consistency and preventing orphaned references. The deletion is performed in a specific
|
|
22
|
+
* order to ensure safe removal from all dependent structures.
|
|
23
|
+
*
|
|
24
|
+
* @param id - The unique identifier of the concept to delete
|
|
25
|
+
* @param token - Optional authentication token for backend deletion. If not provided,
|
|
26
|
+
* the function will attempt deletion without authentication
|
|
27
|
+
* @returns A promise that resolves to a boolean indicating whether the backend deletion was successful
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* // Delete a concept with authentication
|
|
32
|
+
* import { DeleteConceptById } from './DeleteConcept';
|
|
33
|
+
*
|
|
34
|
+
* const conceptId = 12345;
|
|
35
|
+
* const authToken = "user-auth-token-xyz";
|
|
36
|
+
*
|
|
37
|
+
* const isDeleted = await DeleteConceptById(conceptId, authToken);
|
|
38
|
+
* if (isDeleted) {
|
|
39
|
+
* console.log("Concept successfully deleted from all systems");
|
|
40
|
+
* } else {
|
|
41
|
+
* console.log("Backend deletion failed, but local caches cleared");
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* // Delete a concept without authentication token
|
|
48
|
+
* const conceptId = 67890;
|
|
49
|
+
* const result = await DeleteConceptById(conceptId);
|
|
50
|
+
* console.log(`Deletion status: ${result}`);
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* // Delete multiple concepts in sequence
|
|
56
|
+
* const conceptIds = [123, 456, 789];
|
|
57
|
+
* const authToken = "user-token";
|
|
58
|
+
*
|
|
59
|
+
* for (const id of conceptIds) {
|
|
60
|
+
* const deleted = await DeleteConceptById(id, authToken);
|
|
61
|
+
* if (!deleted) {
|
|
62
|
+
* console.error(`Failed to delete concept ${id}`);
|
|
63
|
+
* }
|
|
64
|
+
* }
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* // Delete concept with error handling
|
|
70
|
+
* try {
|
|
71
|
+
* const conceptId = 999;
|
|
72
|
+
* const isDeleted = await DeleteConceptById(conceptId, "auth-token");
|
|
73
|
+
*
|
|
74
|
+
* if (isDeleted) {
|
|
75
|
+
* // Update UI to reflect deletion
|
|
76
|
+
* updateConceptList();
|
|
77
|
+
* }
|
|
78
|
+
* } catch (error) {
|
|
79
|
+
* console.error("Error during concept deletion:", error);
|
|
80
|
+
* }
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @remarks
|
|
84
|
+
* Important implementation details and considerations:
|
|
85
|
+
*
|
|
86
|
+
* **Deletion Order:**
|
|
87
|
+
* The function follows a specific deletion sequence:
|
|
88
|
+
* 1. First retrieves concept data (needed for type and character indices)
|
|
89
|
+
* 2. Removes from main binary tree (ID-based index)
|
|
90
|
+
* 3. Removes from type tree (type-based index)
|
|
91
|
+
* 4. Removes from character tree (character-based index)
|
|
92
|
+
* 5. Removes from local database (IndexedDB)
|
|
93
|
+
* 6. Finally deletes from backend server
|
|
94
|
+
*
|
|
95
|
+
* **Cache Consistency:**
|
|
96
|
+
* - Removes the concept from all three binary tree structures
|
|
97
|
+
* - BinaryTree: Main ID-based concept index
|
|
98
|
+
* - BinaryTypeTree: Type-categorized concept index
|
|
99
|
+
* - BinaryCharacterTree: Character/name-based concept index
|
|
100
|
+
* - This ensures no dangling references remain in any cache
|
|
101
|
+
*
|
|
102
|
+
* **Local Database:**
|
|
103
|
+
* - Uses removeFromDatabase to clear from IndexedDB
|
|
104
|
+
* - This is synchronous local storage cleanup
|
|
105
|
+
* - Ensures offline-first capability remains consistent
|
|
106
|
+
*
|
|
107
|
+
* **Backend Synchronization:**
|
|
108
|
+
* - Calls DeleteTheConcept API to remove from server
|
|
109
|
+
* - Uses optional authentication token
|
|
110
|
+
* - Returns backend deletion status
|
|
111
|
+
* - Local cleanup happens regardless of backend success
|
|
112
|
+
*
|
|
113
|
+
* **Error Handling:**
|
|
114
|
+
* - If GetTheConcept fails, the function will throw
|
|
115
|
+
* - Tree removal operations are awaited but may not throw
|
|
116
|
+
* - Backend deletion status is returned but doesn't affect local cleanup
|
|
117
|
+
* - Consider wrapping in try-catch for production use
|
|
118
|
+
*
|
|
119
|
+
* **Side Effects:**
|
|
120
|
+
* - Permanently removes concept from all storage layers
|
|
121
|
+
* - Cannot be undone without re-creating the concept
|
|
122
|
+
* - May orphan connections that reference this concept
|
|
123
|
+
* - Consider deleting associated connections first
|
|
124
|
+
*
|
|
125
|
+
* **Performance:**
|
|
126
|
+
* - Multiple async operations performed sequentially
|
|
127
|
+
* - May take longer for concepts with complex relationships
|
|
128
|
+
* - Consider using connection cleanup functions before deletion
|
|
129
|
+
*
|
|
130
|
+
* @see {@link DeleteTheConcept} for backend deletion API
|
|
131
|
+
* @see {@link GetTheConcept} for concept retrieval
|
|
132
|
+
* @see {@link BinaryTree} for main concept indexing
|
|
133
|
+
* @see {@link BinaryTypeTree} for type-based indexing
|
|
134
|
+
* @see {@link BinaryCharacterTree} for character-based indexing
|
|
135
|
+
* @see {@link DeleteConnectionById} for deleting associated connections
|
|
136
|
+
*/
|
|
1
137
|
export declare function DeleteConceptById(id: number, token?: string): Promise<boolean>;
|
|
@@ -1,2 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Connection deletion service for the CCS-JS system.
|
|
3
|
+
* This module provides functionality for deleting connections between concepts, supporting both
|
|
4
|
+
* individual and bulk deletion operations. It handles removal from cache structures, local
|
|
5
|
+
* database, and backend synchronization to maintain system consistency.
|
|
6
|
+
* @module Services/DeleteConnection
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Deletes a single connection from the entire CCS-JS system.
|
|
10
|
+
*
|
|
11
|
+
* This function performs comprehensive deletion of a connection by removing it from:
|
|
12
|
+
* 1. The backend server via API call
|
|
13
|
+
* 2. The local IndexedDB database
|
|
14
|
+
* 3. The ConnectionBinaryTree (main ID-based index)
|
|
15
|
+
* 4. The ConnectionTypeTree (type-based index)
|
|
16
|
+
*
|
|
17
|
+
* The function first retrieves the connection to obtain its metadata (particularly the typeId),
|
|
18
|
+
* then performs deletion across all storage and indexing layers to maintain consistency.
|
|
19
|
+
*
|
|
20
|
+
* @param id - The unique identifier of the connection to delete
|
|
21
|
+
* @param token - Optional authentication token for backend deletion. If empty, will attempt
|
|
22
|
+
* deletion without authentication
|
|
23
|
+
* @returns A promise that resolves to a boolean indicating whether the backend deletion was successful
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* // Delete a connection with authentication
|
|
28
|
+
* import { DeleteConnectionById } from './DeleteConnection';
|
|
29
|
+
*
|
|
30
|
+
* const connectionId = 12345;
|
|
31
|
+
* const authToken = "user-auth-token-xyz";
|
|
32
|
+
*
|
|
33
|
+
* const isDeleted = await DeleteConnectionById(connectionId, authToken);
|
|
34
|
+
* if (isDeleted) {
|
|
35
|
+
* console.log("Connection deleted successfully");
|
|
36
|
+
* } else {
|
|
37
|
+
* console.log("Backend deletion failed, but local cleanup completed");
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* // Delete connection without authentication token
|
|
44
|
+
* const result = await DeleteConnectionById(54321);
|
|
45
|
+
* console.log(`Deletion status: ${result}`);
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* // Delete connection as part of composition update
|
|
51
|
+
* const oldConnections = [123, 456, 789];
|
|
52
|
+
*
|
|
53
|
+
* for (const connId of oldConnections) {
|
|
54
|
+
* await DeleteConnectionById(connId, userToken);
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @remarks
|
|
59
|
+
* **Deletion Process:**
|
|
60
|
+
* - Retrieves connection first to access typeId for tree removal
|
|
61
|
+
* - Backend deletion is performed before local cleanup
|
|
62
|
+
* - Local cleanup occurs regardless of backend deletion success
|
|
63
|
+
* - Returns backend deletion status
|
|
64
|
+
*
|
|
65
|
+
* **Cache Consistency:**
|
|
66
|
+
* - Removes from ConnectionBinaryTree (main index)
|
|
67
|
+
* - Removes from ConnectionTypeTree (type-based index)
|
|
68
|
+
* - Ensures no dangling references in memory
|
|
69
|
+
*
|
|
70
|
+
* **Data Persistence:**
|
|
71
|
+
* - Removes from IndexedDB for offline consistency
|
|
72
|
+
* - Backend deletion provides server-side cleanup
|
|
73
|
+
*
|
|
74
|
+
* @see {@link DeleteTheConnection} for backend deletion API
|
|
75
|
+
* @see {@link GetConnectionById} for connection retrieval
|
|
76
|
+
* @see {@link DeleteConnectionByIdBulk} for bulk deletion operations
|
|
77
|
+
* @see {@link ConnectionBinaryTree} for main connection indexing
|
|
78
|
+
* @see {@link ConnectionTypeTree} for type-based indexing
|
|
79
|
+
*/
|
|
1
80
|
export declare function DeleteConnectionById(id: number, token?: string): Promise<boolean>;
|
|
81
|
+
/**
|
|
82
|
+
* Deletes multiple connections in bulk from the CCS-JS system.
|
|
83
|
+
*
|
|
84
|
+
* This function provides optimized bulk deletion of connections by:
|
|
85
|
+
* 1. Making a single API call to delete all connections at once on the backend
|
|
86
|
+
* 2. Removing each connection from the ConnectionBinaryTree cache
|
|
87
|
+
* 3. Only processing positive IDs (skipping local/temporary connections)
|
|
88
|
+
*
|
|
89
|
+
* Bulk deletion is significantly more efficient than individual deletions when
|
|
90
|
+
* removing multiple connections, as it reduces network overhead and API calls.
|
|
91
|
+
* The function currently performs a lighter cleanup compared to single deletion,
|
|
92
|
+
* focusing on the main binary tree index.
|
|
93
|
+
*
|
|
94
|
+
* @param ids - Array of connection IDs to delete. Can include negative (local) IDs which will be skipped
|
|
95
|
+
* @returns A promise that resolves to a boolean indicating whether the bulk backend deletion was successful
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* // Delete multiple connections at once
|
|
100
|
+
* import { DeleteConnectionByIdBulk } from './DeleteConnection';
|
|
101
|
+
*
|
|
102
|
+
* const connectionIds = [123, 456, 789, 1011];
|
|
103
|
+
* const isDeleted = await DeleteConnectionByIdBulk(connectionIds);
|
|
104
|
+
*
|
|
105
|
+
* if (isDeleted) {
|
|
106
|
+
* console.log("All connections deleted successfully");
|
|
107
|
+
* } else {
|
|
108
|
+
* console.log("Bulk deletion failed");
|
|
109
|
+
* }
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* // Delete connections when updating composition
|
|
115
|
+
* const oldConnectionIds = composition.connections
|
|
116
|
+
* .filter(conn => shouldDelete(conn))
|
|
117
|
+
* .map(conn => conn.id);
|
|
118
|
+
*
|
|
119
|
+
* if (oldConnectionIds.length > 0) {
|
|
120
|
+
* await DeleteConnectionByIdBulk(oldConnectionIds);
|
|
121
|
+
* }
|
|
122
|
+
* ```
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* // Delete connections with mixed local and persisted IDs
|
|
127
|
+
* const connectionIds = [123, -456, 789, -1011];
|
|
128
|
+
* // Only 123 and 789 will be deleted (positive IDs)
|
|
129
|
+
* const result = await DeleteConnectionByIdBulk(connectionIds);
|
|
130
|
+
* ```
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```typescript
|
|
134
|
+
* // Handle bulk deletion with error checking
|
|
135
|
+
* try {
|
|
136
|
+
* const idsToDelete = getConnectionsToRemove();
|
|
137
|
+
* const success = await DeleteConnectionByIdBulk(idsToDelete);
|
|
138
|
+
*
|
|
139
|
+
* if (success) {
|
|
140
|
+
* updateUIAfterDeletion();
|
|
141
|
+
* } else {
|
|
142
|
+
* showErrorMessage("Failed to delete connections");
|
|
143
|
+
* }
|
|
144
|
+
* } catch (error) {
|
|
145
|
+
* console.error("Error during bulk deletion:", error);
|
|
146
|
+
* }
|
|
147
|
+
* ```
|
|
148
|
+
*
|
|
149
|
+
* @remarks
|
|
150
|
+
* Important implementation details:
|
|
151
|
+
*
|
|
152
|
+
* **Performance Optimization:**
|
|
153
|
+
* - Single API call for all deletions (not one per connection)
|
|
154
|
+
* - Significantly faster than multiple individual DeleteConnectionById calls
|
|
155
|
+
* - Recommended for deleting 2 or more connections
|
|
156
|
+
*
|
|
157
|
+
* **Partial Cleanup:**
|
|
158
|
+
* - Only removes from ConnectionBinaryTree, not ConnectionTypeTree
|
|
159
|
+
* - Does not remove from local IndexedDB (commented out)
|
|
160
|
+
* - Does not retrieve connection objects to save on queries
|
|
161
|
+
* - This is intentional for performance but may leave some cache inconsistencies
|
|
162
|
+
*
|
|
163
|
+
* **ID Filtering:**
|
|
164
|
+
* - Only processes positive IDs (id > 0)
|
|
165
|
+
* - Negative IDs represent local/temporary connections not yet persisted
|
|
166
|
+
* - Local connections don't exist on backend so they're skipped
|
|
167
|
+
*
|
|
168
|
+
* **Atomic Backend Operation:**
|
|
169
|
+
* - Backend deletion is all-or-nothing via the bulk API
|
|
170
|
+
* - If backend deletion succeeds, all local cleanup is performed
|
|
171
|
+
* - If backend deletion fails, no local cleanup occurs
|
|
172
|
+
*
|
|
173
|
+
* **Use Cases:**
|
|
174
|
+
* - Cleaning up connections when updating compositions
|
|
175
|
+
* - Removing all connections to a deleted concept
|
|
176
|
+
* - Batch operations in composition management
|
|
177
|
+
* - Performance-critical deletion scenarios
|
|
178
|
+
*
|
|
179
|
+
* **Trade-offs:**
|
|
180
|
+
* - Faster but less thorough cleanup than individual deletions
|
|
181
|
+
* - May leave some entries in ConnectionTypeTree
|
|
182
|
+
* - May leave some entries in IndexedDB
|
|
183
|
+
* - Acceptable for most use cases where cache will be rebuilt
|
|
184
|
+
*
|
|
185
|
+
* **Commented Code:**
|
|
186
|
+
* The function contains commented-out code for:
|
|
187
|
+
* - Connection retrieval: `let connection = await GetConnectionById(id);`
|
|
188
|
+
* - Database cleanup: `removeFromDatabase("connection",id);`
|
|
189
|
+
* These may be intentionally disabled for performance reasons
|
|
190
|
+
*
|
|
191
|
+
* @see {@link DeleteTheConnectionBulkApi} for bulk backend deletion API
|
|
192
|
+
* @see {@link DeleteConnectionById} for single connection deletion with full cleanup
|
|
193
|
+
* @see {@link ConnectionBinaryTree} for main connection indexing
|
|
194
|
+
* @see {@link ConnectionTypeTree} for type-based connection indexing
|
|
195
|
+
*/
|
|
2
196
|
export declare function DeleteConnectionByIdBulk(ids: number[]): Promise<boolean>;
|
|
@@ -1,2 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Concept discovery service from connections for the CCS-JS system.
|
|
3
|
+
* This module provides functionality to identify and batch-load all concepts referenced by
|
|
4
|
+
* a set of connections. This is essential for efficiently hydrating the concept cache when
|
|
5
|
+
* working with compositions and connection graphs.
|
|
6
|
+
* @module Services/FindConceptsFromConnection
|
|
7
|
+
*/
|
|
1
8
|
import { Connection } from "../DataStructures/Connection";
|
|
9
|
+
/**
|
|
10
|
+
* Discovers and loads all unique concepts referenced by a list of connections.
|
|
11
|
+
*
|
|
12
|
+
* This function analyzes a list of connections to extract all unique concept IDs (both source
|
|
13
|
+
* and target concepts) and loads them into the local cache via a single bulk API call. This is
|
|
14
|
+
* a critical optimization function that ensures all concepts needed for a composition or
|
|
15
|
+
* connection graph are available locally before processing.
|
|
16
|
+
*
|
|
17
|
+
* The function performs two main operations:
|
|
18
|
+
* 1. Extracts all unique concept IDs from the connection list (both ofTheConceptId and toTheConceptId)
|
|
19
|
+
* 2. Fetches all concepts in a single bulk operation and caches them locally
|
|
20
|
+
*
|
|
21
|
+
* This batch loading approach is significantly more efficient than fetching concepts individually
|
|
22
|
+
* as they're needed, reducing network overhead and improving application performance.
|
|
23
|
+
*
|
|
24
|
+
* @param connectionList - Array of connections to analyze for concept references. Defaults to empty array.
|
|
25
|
+
* @returns A promise that resolves when all concepts have been fetched and cached.
|
|
26
|
+
* The function does not return the concepts directly; they are stored in the concept cache.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* // Load concepts for a composition
|
|
31
|
+
* import { FindConceptsFromConnections } from './FindConeceptsFromConnection';
|
|
32
|
+
*
|
|
33
|
+
* const compositionConnections = await GetAllConnectionsOfComposition(123);
|
|
34
|
+
* await FindConceptsFromConnections(compositionConnections);
|
|
35
|
+
*
|
|
36
|
+
* // Now all concepts are cached and can be retrieved synchronously
|
|
37
|
+
* const concept = await GetTheConcept(456); // Fast cache lookup
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* // Prepare concepts for graph visualization
|
|
43
|
+
* const connections = await FindConnectionsOfCompositionsBulkInMemory([100, 101, 102]);
|
|
44
|
+
* await FindConceptsFromConnections(connections);
|
|
45
|
+
*
|
|
46
|
+
* // All concepts in the graph are now cached
|
|
47
|
+
* connections.forEach(conn => {
|
|
48
|
+
* const fromConcept = GetTheConceptSync(conn.ofTheConceptId);
|
|
49
|
+
* const toConcept = GetTheConceptSync(conn.toTheConceptId);
|
|
50
|
+
* renderConnection(fromConcept, toConcept);
|
|
51
|
+
* });
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* // Hydrate cache before processing composition
|
|
57
|
+
* async function loadCompositionWithConcepts(compositionId: number) {
|
|
58
|
+
* // First, get all connections
|
|
59
|
+
* const connections = await GetAllConnectionsOfComposition(compositionId);
|
|
60
|
+
*
|
|
61
|
+
* // Then, ensure all concepts are cached
|
|
62
|
+
* await FindConceptsFromConnections(connections);
|
|
63
|
+
*
|
|
64
|
+
* // Now process the composition with all data locally available
|
|
65
|
+
* return processComposition(connections);
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* // Handle empty connection list safely
|
|
72
|
+
* const emptyConnections: Connection[] = [];
|
|
73
|
+
* await FindConceptsFromConnections(emptyConnections);
|
|
74
|
+
* // No API call made, function returns immediately
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* // Load concepts for multiple compositions
|
|
80
|
+
* const compositionIds = [200, 201, 202];
|
|
81
|
+
* const allConnections = await FindConnectionsOfCompositionsBulkInMemory(compositionIds);
|
|
82
|
+
*
|
|
83
|
+
* // Single bulk load for all concepts across all compositions
|
|
84
|
+
* await FindConceptsFromConnections(allConnections);
|
|
85
|
+
*
|
|
86
|
+
* // All concepts are now available
|
|
87
|
+
* console.log("All concepts loaded for compositions:", compositionIds);
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @remarks
|
|
91
|
+
* Important implementation details and considerations:
|
|
92
|
+
*
|
|
93
|
+
* **Concept ID Extraction:**
|
|
94
|
+
* - Extracts both ofTheConceptId (source concept) and toTheConceptId (target concept)
|
|
95
|
+
* - Uses includes() to ensure uniqueness - no duplicate IDs in the final list
|
|
96
|
+
* - Maintains insertion order of concept IDs
|
|
97
|
+
* - Only adds IDs that haven't been seen before
|
|
98
|
+
*
|
|
99
|
+
* **Duplicate Prevention:**
|
|
100
|
+
* - Checks if concept ID already exists in list before adding
|
|
101
|
+
* - Prevents redundant API requests for the same concept
|
|
102
|
+
* - Important when connections share common concepts
|
|
103
|
+
* - Uses array.includes() which has O(n) complexity per check
|
|
104
|
+
*
|
|
105
|
+
* **Bulk Loading:**
|
|
106
|
+
* - Makes a single API call via GetConceptBulk instead of individual requests
|
|
107
|
+
* - Significantly reduces network overhead
|
|
108
|
+
* - All concepts are fetched and cached in one operation
|
|
109
|
+
* - More efficient for large connection sets
|
|
110
|
+
*
|
|
111
|
+
* **Cache Population:**
|
|
112
|
+
* - GetConceptBulk automatically stores concepts in the local cache
|
|
113
|
+
* - Concepts become available for synchronous retrieval after this function completes
|
|
114
|
+
* - No need to manually cache the results
|
|
115
|
+
* - Persists to IndexedDB for offline availability
|
|
116
|
+
*
|
|
117
|
+
* **Empty Input Handling:**
|
|
118
|
+
* - Returns immediately if connectionList is empty (length === 0)
|
|
119
|
+
* - No API call made for empty input
|
|
120
|
+
* - Safe to call with empty arrays
|
|
121
|
+
*
|
|
122
|
+
* **No Return Value:**
|
|
123
|
+
* - Function doesn't return the loaded concepts
|
|
124
|
+
* - Concepts are stored in the global concept cache
|
|
125
|
+
* - Access loaded concepts via GetTheConcept() or similar functions
|
|
126
|
+
* - This is intentional for cache-based architecture
|
|
127
|
+
*
|
|
128
|
+
* **Performance Characteristics:**
|
|
129
|
+
* - O(n*m) complexity for duplicate checking where n = connections, m = unique concepts
|
|
130
|
+
* - Could be optimized with Set for better performance on large datasets
|
|
131
|
+
* - Single API call regardless of number of concepts
|
|
132
|
+
* - Network time dominates execution time
|
|
133
|
+
*
|
|
134
|
+
* **Performance Optimization Alternative:**
|
|
135
|
+
* ```typescript
|
|
136
|
+
* // More efficient approach using Set
|
|
137
|
+
* const conceptIds = new Set<number>();
|
|
138
|
+
* connectionList.forEach(conn => {
|
|
139
|
+
* conceptIds.add(conn.ofTheConceptId);
|
|
140
|
+
* conceptIds.add(conn.toTheConceptId);
|
|
141
|
+
* });
|
|
142
|
+
* await GetConceptBulk([...conceptIds]);
|
|
143
|
+
* ```
|
|
144
|
+
*
|
|
145
|
+
* **Common Use Cases:**
|
|
146
|
+
* - Loading concepts before rendering compositions
|
|
147
|
+
* - Hydrating cache for offline-first operations
|
|
148
|
+
* - Preparing data for graph analysis
|
|
149
|
+
* - Ensuring all dependencies are cached before processing
|
|
150
|
+
* - Optimizing batch operations
|
|
151
|
+
*
|
|
152
|
+
* **Integration Patterns:**
|
|
153
|
+
* ```typescript
|
|
154
|
+
* // Pattern 1: Composition loading
|
|
155
|
+
* async function loadComposition(id: number) {
|
|
156
|
+
* const connections = await getConnections(id);
|
|
157
|
+
* await FindConceptsFromConnections(connections);
|
|
158
|
+
* return buildCompositionObject(connections);
|
|
159
|
+
* }
|
|
160
|
+
*
|
|
161
|
+
* // Pattern 2: Graph preparation
|
|
162
|
+
* async function prepareGraph(compositionIds: number[]) {
|
|
163
|
+
* const connections = await FindConnectionsOfCompositionsBulkInMemory(compositionIds);
|
|
164
|
+
* await FindConceptsFromConnections(connections);
|
|
165
|
+
* return buildGraph();
|
|
166
|
+
* }
|
|
167
|
+
* ```
|
|
168
|
+
*
|
|
169
|
+
* **Error Handling:**
|
|
170
|
+
* - No explicit error handling in current implementation
|
|
171
|
+
* - Will throw if GetConceptBulk fails
|
|
172
|
+
* - Consider wrapping in try-catch for production use
|
|
173
|
+
* - Failed bulk load means concepts won't be cached
|
|
174
|
+
*
|
|
175
|
+
* @see {@link GetConceptBulk} for bulk concept loading API
|
|
176
|
+
* @see {@link Connection} for connection data structure
|
|
177
|
+
* @see {@link Concept} for concept data structure
|
|
178
|
+
* @see {@link FindConnectionsOfCompositionsBulkInMemory} for bulk connection retrieval
|
|
179
|
+
* @see {@link GetTheConcept} for retrieving cached concepts
|
|
180
|
+
*/
|
|
2
181
|
export declare function FindConceptsFromConnections(connectionList?: Connection[]): Promise<void>;
|
|
@@ -1,2 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Bulk composition connection retrieval service for the CCS-JS system.
|
|
3
|
+
* This module provides functionality to efficiently retrieve connections for multiple
|
|
4
|
+
* compositions from local memory/cache, which is essential for performance optimization
|
|
5
|
+
* when working with complex nested compositions.
|
|
6
|
+
* @module Services/FindConnectionsOfCompositionBulkInMemory
|
|
7
|
+
*/
|
|
1
8
|
import { Connection } from "../DataStructures/Connection";
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves all connections for multiple compositions from local memory in a single operation.
|
|
11
|
+
*
|
|
12
|
+
* This function is designed for efficient bulk retrieval of connections across multiple
|
|
13
|
+
* compositions. Instead of making individual API calls or database queries for each composition,
|
|
14
|
+
* it retrieves all connections from the local ConnectionData cache, aggregating results from
|
|
15
|
+
* multiple compositions into a single array.
|
|
16
|
+
*
|
|
17
|
+
* The function iterates through each composition ID, fetches its connections from local cache,
|
|
18
|
+
* and accumulates all connections into a unified list. This is particularly useful for:
|
|
19
|
+
* - Loading nested composition structures
|
|
20
|
+
* - Analyzing relationship graphs across multiple compositions
|
|
21
|
+
* - Preparing data for bulk operations
|
|
22
|
+
* - Optimizing performance when working with complex composition hierarchies
|
|
23
|
+
*
|
|
24
|
+
* @param composition_ids - Array of composition IDs to retrieve connections for. Defaults to empty array.
|
|
25
|
+
* @returns A promise that resolves to an array containing all connections from all specified compositions.
|
|
26
|
+
* The returned array combines connections from all compositions with potential duplicates
|
|
27
|
+
* if the same connection belongs to multiple compositions.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* // Retrieve connections for multiple related compositions
|
|
32
|
+
* import { FindConnectionsOfCompositionsBulkInMemory } from './FindConnectionsOfCompositionBulkInMemory';
|
|
33
|
+
*
|
|
34
|
+
* const compositionIds = [123, 456, 789];
|
|
35
|
+
* const allConnections = await FindConnectionsOfCompositionsBulkInMemory(compositionIds);
|
|
36
|
+
*
|
|
37
|
+
* console.log(`Found ${allConnections.length} total connections`);
|
|
38
|
+
* // Returns all connections from compositions 123, 456, and 789
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* // Load nested composition structure
|
|
44
|
+
* const mainComposition = await GetComposition(100);
|
|
45
|
+
* const subcompositionIds = mainComposition.subcompositions; // [101, 102, 103]
|
|
46
|
+
*
|
|
47
|
+
* // Get all connections for the nested structure
|
|
48
|
+
* const nestedConnections = await FindConnectionsOfCompositionsBulkInMemory(subcompositionIds);
|
|
49
|
+
*
|
|
50
|
+
* // Process all connections together
|
|
51
|
+
* nestedConnections.forEach(conn => {
|
|
52
|
+
* console.log(`Connection: ${conn.ofTheConceptId} -> ${conn.toTheConceptId}`);
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* // Analyze relationship graph across compositions
|
|
59
|
+
* const compositionIds = [200, 201, 202];
|
|
60
|
+
* const connections = await FindConnectionsOfCompositionsBulkInMemory(compositionIds);
|
|
61
|
+
*
|
|
62
|
+
* // Find all unique concepts involved
|
|
63
|
+
* const conceptIds = new Set();
|
|
64
|
+
* connections.forEach(conn => {
|
|
65
|
+
* conceptIds.add(conn.ofTheConceptId);
|
|
66
|
+
* conceptIds.add(conn.toTheConceptId);
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
69
|
+
* console.log(`Graph contains ${conceptIds.size} unique concepts`);
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* // Prepare data for bulk deletion
|
|
75
|
+
* const compositionsToDelete = [301, 302, 303];
|
|
76
|
+
* const connectionsToRemove = await FindConnectionsOfCompositionsBulkInMemory(compositionsToDelete);
|
|
77
|
+
*
|
|
78
|
+
* // Delete all connections in bulk
|
|
79
|
+
* const connectionIds = connectionsToRemove.map(conn => conn.id);
|
|
80
|
+
* await DeleteConnectionByIdBulk(connectionIds);
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* // Handle empty composition list
|
|
86
|
+
* const emptyResult = await FindConnectionsOfCompositionsBulkInMemory([]);
|
|
87
|
+
* console.log(emptyResult); // Returns: []
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @remarks
|
|
91
|
+
* Important implementation details and considerations:
|
|
92
|
+
*
|
|
93
|
+
* **Data Source:**
|
|
94
|
+
* - Retrieves data from local cache (ConnectionData) only, not from backend
|
|
95
|
+
* - Uses GetConnectionsOfCompositionLocal which accesses in-memory storage
|
|
96
|
+
* - Does not make network requests or database queries
|
|
97
|
+
* - Assumes connections are already cached locally
|
|
98
|
+
*
|
|
99
|
+
* **Performance Characteristics:**
|
|
100
|
+
* - Significantly faster than making individual API calls for each composition
|
|
101
|
+
* - Memory-efficient as it uses spread operator to accumulate results
|
|
102
|
+
* - Sequential processing (not parallel) but from fast local cache
|
|
103
|
+
* - Suitable for real-time operations without network latency
|
|
104
|
+
*
|
|
105
|
+
* **Connection Aggregation:**
|
|
106
|
+
* - Uses spread operator (...) to merge connection arrays
|
|
107
|
+
* - Maintains order: connections from first composition ID appear first
|
|
108
|
+
* - May include duplicate connections if they belong to multiple compositions
|
|
109
|
+
* - Does not deduplicate results
|
|
110
|
+
*
|
|
111
|
+
* **Duplicate Handling:**
|
|
112
|
+
* - Same connection may appear multiple times if it's in multiple compositions
|
|
113
|
+
* - Caller should deduplicate if needed using connection IDs
|
|
114
|
+
* - Example deduplication: `const unique = [...new Map(connections.map(c => [c.id, c])).values()]`
|
|
115
|
+
*
|
|
116
|
+
* **Empty Input:**
|
|
117
|
+
* - Returns empty array if composition_ids is empty
|
|
118
|
+
* - No error thrown for empty input
|
|
119
|
+
* - Safe to call with empty array
|
|
120
|
+
*
|
|
121
|
+
* **Async Behavior:**
|
|
122
|
+
* - Function is async due to GetConnectionsOfCompositionLocal being async
|
|
123
|
+
* - However, it processes compositions sequentially, not in parallel
|
|
124
|
+
* - For better performance with many compositions, consider parallelizing
|
|
125
|
+
*
|
|
126
|
+
* **Error Handling:**
|
|
127
|
+
* - No explicit error handling in current implementation
|
|
128
|
+
* - Will throw if GetConnectionsOfCompositionLocal throws
|
|
129
|
+
* - Consider wrapping in try-catch for production use
|
|
130
|
+
*
|
|
131
|
+
* **Use Cases:**
|
|
132
|
+
* - Loading nested composition structures
|
|
133
|
+
* - Building relationship graphs
|
|
134
|
+
* - Preparing bulk operations
|
|
135
|
+
* - Analyzing composition hierarchies
|
|
136
|
+
* - Offline-first operations
|
|
137
|
+
*
|
|
138
|
+
* **Limitations:**
|
|
139
|
+
* - Only works with cached data (must be loaded first)
|
|
140
|
+
* - Does not fetch from backend if cache is empty
|
|
141
|
+
* - May return stale data if cache isn't updated
|
|
142
|
+
* - No automatic cache validation
|
|
143
|
+
*
|
|
144
|
+
* **Best Practices:**
|
|
145
|
+
* ```typescript
|
|
146
|
+
* // Ensure compositions are loaded first
|
|
147
|
+
* await loadCompositionsIntoCache(compositionIds);
|
|
148
|
+
* const connections = await FindConnectionsOfCompositionsBulkInMemory(compositionIds);
|
|
149
|
+
*
|
|
150
|
+
* // Deduplicate if needed
|
|
151
|
+
* const uniqueConnections = [...new Map(connections.map(c => [c.id, c])).values()];
|
|
152
|
+
* ```
|
|
153
|
+
*
|
|
154
|
+
* @see {@link ConnectionData.GetConnectionsOfCompositionLocal} for single composition connection retrieval
|
|
155
|
+
* @see {@link Connection} for connection data structure
|
|
156
|
+
* @see {@link FindConceptsFromConnections} for retrieving concepts from connection lists
|
|
157
|
+
* @see {@link DeleteConnectionByIdBulk} for bulk connection deletion
|
|
158
|
+
*/
|
|
2
159
|
export declare function FindConnectionsOfCompositionsBulkInMemory(composition_ids?: number[]): Promise<Connection[]>;
|