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,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
|
+
*/
|
|
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
|
+
*/
|
|
196
|
+
export declare function DeleteConnectionByIdBulk(ids: number[]): Promise<boolean>;
|
|
@@ -0,0 +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
|
+
*/
|
|
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
|
+
*/
|
|
181
|
+
export declare function FindConceptsFromConnections(connectionList?: Connection[]): Promise<void>;
|
|
@@ -0,0 +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
|
+
*/
|
|
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
|
+
*/
|
|
159
|
+
export declare function FindConnectionsOfCompositionsBulkInMemory(composition_ids?: number[]): Promise<Connection[]>;
|
|
@@ -0,0 +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
|
+
*/
|
|
65
|
+
export declare function genHexString(len: number): number;
|
|
File without changes
|