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,320 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Defines the Transaction class for managing transactional operations.
|
|
3
|
+
* @module DataStructures/Transaction/Transaction
|
|
4
|
+
*/
|
|
5
|
+
import { Concept } from "../Concept";
|
|
6
|
+
import { Connection } from "../Connection";
|
|
7
|
+
/**
|
|
8
|
+
* Manages transactional operations for concepts and connections.
|
|
9
|
+
* This class provides ACID-like transaction capabilities for creating and managing
|
|
10
|
+
* concepts and connections. It supports rollback functionality and ensures data
|
|
11
|
+
* consistency by tracking all actions within a transaction context.
|
|
12
|
+
*
|
|
13
|
+
* @class Transaction
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const transaction = new Transaction();
|
|
18
|
+
* await transaction.initialize();
|
|
19
|
+
*
|
|
20
|
+
* try {
|
|
21
|
+
* const concept = await transaction.MakeTheInstanceConcept(
|
|
22
|
+
* "User", "John Doe", false, 1, 4, 999, 0
|
|
23
|
+
* );
|
|
24
|
+
* await transaction.commitTransaction();
|
|
25
|
+
* } catch (error) {
|
|
26
|
+
* await transaction.rollbackTransaction();
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* // Complex transaction with multiple operations
|
|
33
|
+
* const transaction = new Transaction();
|
|
34
|
+
* await transaction.initialize();
|
|
35
|
+
*
|
|
36
|
+
* try {
|
|
37
|
+
* const user = await transaction.MakeTheInstanceConcept("User", "Alice", false, 1, 4);
|
|
38
|
+
* const post = await transaction.MakeTheInstanceConcept("Post", "My First Post", false, 1, 4);
|
|
39
|
+
* await transaction.CreateConnection(user, post, "authored");
|
|
40
|
+
* await transaction.commitTransaction();
|
|
41
|
+
* } catch (error) {
|
|
42
|
+
* console.error("Transaction failed:", error);
|
|
43
|
+
* await transaction.rollbackTransaction();
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare class Transaction {
|
|
48
|
+
/**
|
|
49
|
+
* Unique identifier for this transaction.
|
|
50
|
+
* Generated randomly to track transaction operations.
|
|
51
|
+
*
|
|
52
|
+
* @protected
|
|
53
|
+
* @type {string}
|
|
54
|
+
*/
|
|
55
|
+
protected transactionId: string;
|
|
56
|
+
/**
|
|
57
|
+
* Collection of all actions performed within this transaction.
|
|
58
|
+
* Tracks concepts and connections created or modified during the transaction.
|
|
59
|
+
*
|
|
60
|
+
* @type {InnerActions}
|
|
61
|
+
*/
|
|
62
|
+
actions: InnerActions;
|
|
63
|
+
/**
|
|
64
|
+
* Flag indicating whether the transaction is still valid.
|
|
65
|
+
* Set to false on failure or after rollback to prevent further operations.
|
|
66
|
+
*
|
|
67
|
+
* @protected
|
|
68
|
+
* @type {boolean}
|
|
69
|
+
* @default true
|
|
70
|
+
*/
|
|
71
|
+
protected success: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Creates a new Transaction instance.
|
|
74
|
+
* Generates a unique transaction ID for tracking purposes.
|
|
75
|
+
*
|
|
76
|
+
* @constructor
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* const transaction = new Transaction();
|
|
81
|
+
* await transaction.initialize();
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
constructor();
|
|
85
|
+
/**
|
|
86
|
+
* Initializes the transaction in the data store.
|
|
87
|
+
* Must be called before performing any transactional operations.
|
|
88
|
+
*
|
|
89
|
+
* @async
|
|
90
|
+
* @returns {Promise<void>}
|
|
91
|
+
* @throws {Error} If initialization fails
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* const transaction = new Transaction();
|
|
96
|
+
* await transaction.initialize();
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
initialize(): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Marks and persists the current transaction actions.
|
|
102
|
+
* Internal method to save concepts and connections to the transaction collection.
|
|
103
|
+
*
|
|
104
|
+
* @protected
|
|
105
|
+
* @async
|
|
106
|
+
* @returns {Promise<void>}
|
|
107
|
+
*
|
|
108
|
+
* @remarks
|
|
109
|
+
* This method is called internally after each concept or connection operation
|
|
110
|
+
* to ensure actions are tracked for potential rollback.
|
|
111
|
+
*/
|
|
112
|
+
protected markAction(): Promise<void>;
|
|
113
|
+
/**
|
|
114
|
+
* Rolls back all operations performed within this transaction.
|
|
115
|
+
* Reverts all changes made during the transaction and marks it as expired.
|
|
116
|
+
* After rollback, no further operations can be performed on this transaction.
|
|
117
|
+
*
|
|
118
|
+
* @async
|
|
119
|
+
* @returns {Promise<void>}
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* try {
|
|
124
|
+
* const concept = await transaction.MakeTheInstanceConcept(...);
|
|
125
|
+
* // ... operation that might fail
|
|
126
|
+
* } catch (error) {
|
|
127
|
+
* await transaction.rollbackTransaction();
|
|
128
|
+
* console.error("Transaction rolled back due to error:", error);
|
|
129
|
+
* }
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
rollbackTransaction(): Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* Commits the transaction, making all changes permanent.
|
|
135
|
+
* Synchronizes all transaction data to the online/persistent store.
|
|
136
|
+
* After commit, the transaction is marked as expired and cannot be used further.
|
|
137
|
+
*
|
|
138
|
+
* @async
|
|
139
|
+
* @returns {Promise<void>}
|
|
140
|
+
* @throws {Error} If the transaction has already expired or failed
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* const transaction = new Transaction();
|
|
145
|
+
* await transaction.initialize();
|
|
146
|
+
*
|
|
147
|
+
* try {
|
|
148
|
+
* await transaction.MakeTheInstanceConcept("User", "Alice", false, 1, 4);
|
|
149
|
+
* await transaction.commitTransaction();
|
|
150
|
+
* console.log("Transaction committed successfully");
|
|
151
|
+
* } catch (error) {
|
|
152
|
+
* await transaction.rollbackTransaction();
|
|
153
|
+
* }
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
commitTransaction(): Promise<void>;
|
|
157
|
+
/**
|
|
158
|
+
* Creates a new instance concept within the transaction.
|
|
159
|
+
* The concept represents a data instance of a specified type with associated metadata.
|
|
160
|
+
*
|
|
161
|
+
* @async
|
|
162
|
+
* @param {string} type - The type of the concept (e.g., "User", "Post")
|
|
163
|
+
* @param {string} referent - The value or name of the concept instance
|
|
164
|
+
* @param {boolean} [composition=false] - Whether this is a composition concept
|
|
165
|
+
* @param {number} userId - The ID of the user creating the concept
|
|
166
|
+
* @param {number} accessId - The access level ID for the concept
|
|
167
|
+
* @param {number} [sessionInformationId=999] - The session information ID
|
|
168
|
+
* @param {number} [referentId=0] - The referent ID for linking
|
|
169
|
+
* @returns {Promise<Concept>} The created concept
|
|
170
|
+
* @throws {Error} If the transaction has expired or creation fails
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```typescript
|
|
174
|
+
* const transaction = new Transaction();
|
|
175
|
+
* await transaction.initialize();
|
|
176
|
+
*
|
|
177
|
+
* try {
|
|
178
|
+
* const userConcept = await transaction.MakeTheInstanceConcept(
|
|
179
|
+
* "User",
|
|
180
|
+
* "John Doe",
|
|
181
|
+
* false,
|
|
182
|
+
* 123,
|
|
183
|
+
* 4,
|
|
184
|
+
* 999,
|
|
185
|
+
* 0
|
|
186
|
+
* );
|
|
187
|
+
* await transaction.commitTransaction();
|
|
188
|
+
* } catch (error) {
|
|
189
|
+
* await transaction.rollbackTransaction();
|
|
190
|
+
* }
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
MakeTheInstanceConcept(type: string, referent: string, composition: boolean | undefined, userId: number, accessId: number, sessionInformationId?: number, referentId?: number): Promise<Concept>;
|
|
194
|
+
/**
|
|
195
|
+
* Creates a connection between two concepts within the transaction.
|
|
196
|
+
* Establishes a typed relationship between source and target concepts.
|
|
197
|
+
*
|
|
198
|
+
* @async
|
|
199
|
+
* @param {Concept} ofTheConcept - The source concept (starting point of the connection)
|
|
200
|
+
* @param {Concept} toTheConcept - The target concept (endpoint of the connection)
|
|
201
|
+
* @param {string} typeConnection - The type of connection/relationship
|
|
202
|
+
* @returns {Promise<Connection>} The created connection
|
|
203
|
+
* @throws {Error} If the transaction has expired or creation fails
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```typescript
|
|
207
|
+
* const transaction = new Transaction();
|
|
208
|
+
* await transaction.initialize();
|
|
209
|
+
*
|
|
210
|
+
* try {
|
|
211
|
+
* const user = await transaction.MakeTheInstanceConcept("User", "Alice", false, 1, 4);
|
|
212
|
+
* const post = await transaction.MakeTheInstanceConcept("Post", "My Post", false, 1, 4);
|
|
213
|
+
* const connection = await transaction.CreateConnection(user, post, "authored");
|
|
214
|
+
* await transaction.commitTransaction();
|
|
215
|
+
* } catch (error) {
|
|
216
|
+
* await transaction.rollbackTransaction();
|
|
217
|
+
* }
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
CreateConnection(ofTheConcept: Concept, toTheConcept: Concept, typeConnection: string): Promise<Connection>;
|
|
221
|
+
/**
|
|
222
|
+
* Creates a new type concept within the transaction.
|
|
223
|
+
* Type concepts define the schema or classification for instance concepts.
|
|
224
|
+
*
|
|
225
|
+
* @async
|
|
226
|
+
* @param {string} typeString - The name of the type to create
|
|
227
|
+
* @param {number} sessionId - The session ID
|
|
228
|
+
* @param {number} sessionUserId - The session user ID
|
|
229
|
+
* @param {number} userId - The ID of the user creating the type
|
|
230
|
+
* @returns {Promise<Concept>} The created type concept
|
|
231
|
+
* @throws {Error} If the transaction has expired or creation fails
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```typescript
|
|
235
|
+
* const transaction = new Transaction();
|
|
236
|
+
* await transaction.initialize();
|
|
237
|
+
*
|
|
238
|
+
* try {
|
|
239
|
+
* const typeConcept = await transaction.MakeTheTypeConcept(
|
|
240
|
+
* "CustomType",
|
|
241
|
+
* 999,
|
|
242
|
+
* 1,
|
|
243
|
+
* 1
|
|
244
|
+
* );
|
|
245
|
+
* await transaction.commitTransaction();
|
|
246
|
+
* } catch (error) {
|
|
247
|
+
* await transaction.rollbackTransaction();
|
|
248
|
+
* }
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
MakeTheTypeConcept(typeString: string, sessionId: number, sessionUserId: number, userId: number): Promise<Concept>;
|
|
252
|
+
/**
|
|
253
|
+
* Creates a connection using concept IDs within the transaction.
|
|
254
|
+
* This is a more general method for creating connections when working directly with IDs
|
|
255
|
+
* rather than Concept objects. Provides fine-grained control over connection properties.
|
|
256
|
+
*
|
|
257
|
+
* @async
|
|
258
|
+
* @param {number} ofTheConceptId - The ID of the source concept
|
|
259
|
+
* @param {number} ofTheConceptUserId - The user ID of the source concept
|
|
260
|
+
* @param {number} toTheConceptId - The ID of the target concept
|
|
261
|
+
* @param {number} toTheConceptUserId - The user ID of the target concept
|
|
262
|
+
* @param {number} typeId - The connection type ID
|
|
263
|
+
* @param {number} sessionInformationId - The session information ID
|
|
264
|
+
* @param {number} sessionInformationUserId - The session information user ID
|
|
265
|
+
* @param {number} [orderId=1] - The order ID for sequencing connections
|
|
266
|
+
* @param {number} [accessId=4] - The access level ID
|
|
267
|
+
* @param {number} [passedUserId=999] - The passed user ID for permissions
|
|
268
|
+
* @returns {Promise<Connection>} The created connection
|
|
269
|
+
* @throws {Error} If the transaction has expired or creation fails
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* ```typescript
|
|
273
|
+
* const transaction = new Transaction();
|
|
274
|
+
* await transaction.initialize();
|
|
275
|
+
*
|
|
276
|
+
* try {
|
|
277
|
+
* const connection = await transaction.CreateTheConnectionGeneral(
|
|
278
|
+
* 123, 1, // source concept
|
|
279
|
+
* 456, 1, // target concept
|
|
280
|
+
* 789, // type ID
|
|
281
|
+
* 999, 1, // session info
|
|
282
|
+
* 1, // order
|
|
283
|
+
* 4, // access
|
|
284
|
+
* 999 // user
|
|
285
|
+
* );
|
|
286
|
+
* await transaction.commitTransaction();
|
|
287
|
+
* } catch (error) {
|
|
288
|
+
* await transaction.rollbackTransaction();
|
|
289
|
+
* }
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
CreateTheConnectionGeneral(ofTheConceptId: number, ofTheConceptUserId: number, toTheConceptId: number, toTheConceptUserId: number, typeId: number, sessionInformationId: number, sessionInformationUserId: number, orderId?: number, accessId?: number, passedUserId?: number): Promise<Connection>;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Represents the collection of actions within a transaction.
|
|
296
|
+
* This interface tracks all concepts and connections created or modified
|
|
297
|
+
* during a transaction for rollback and commit purposes.
|
|
298
|
+
*
|
|
299
|
+
* @interface InnerActions
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* ```typescript
|
|
303
|
+
* const actions: InnerActions = {
|
|
304
|
+
* concepts: [concept1, concept2],
|
|
305
|
+
* connections: [connection1, connection2]
|
|
306
|
+
* };
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
export interface InnerActions {
|
|
310
|
+
/**
|
|
311
|
+
* Array of concepts created or modified in the transaction.
|
|
312
|
+
* @type {Concept[]}
|
|
313
|
+
*/
|
|
314
|
+
concepts: Concept[];
|
|
315
|
+
/**
|
|
316
|
+
* Array of connections created or modified in the transaction.
|
|
317
|
+
* @type {Connection[]}
|
|
318
|
+
*/
|
|
319
|
+
connections: Connection[];
|
|
320
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Binary tree for managing user-specific concepts and connections.
|
|
3
|
+
* This module provides a composite-key based tree for efficient user and session-based data storage.
|
|
4
|
+
* @module DataStructures/User/UserBinaryTree
|
|
5
|
+
*/
|
|
6
|
+
import { LConcept } from "../../DataStructures/Local/LConcept";
|
|
7
|
+
import { UserNode } from "./UserNode";
|
|
8
|
+
import { LConnection } from "../Local/LConnection";
|
|
9
|
+
/**
|
|
10
|
+
* Binary tree data structure for managing user-specific data with composite keys.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* This class implements an AVL tree that uses composite keys (userId + sessionId + randomizer)
|
|
14
|
+
* to organize user-specific concepts and connections. The composite key enables efficient
|
|
15
|
+
* organization and retrieval of data by user, session, and application context.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const concept = new LConcept(123, "example", 5);
|
|
20
|
+
* UserBinaryTree.addConceptToTree(concept, 42, 999);
|
|
21
|
+
* const node = await UserBinaryTree.getNodeFromTree(42, 999, 123);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare class UserBinaryTree {
|
|
25
|
+
/**
|
|
26
|
+
* The root node of the user data binary tree.
|
|
27
|
+
* Null if the tree is empty.
|
|
28
|
+
*/
|
|
29
|
+
static root: UserNode | null;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a composite key from user ID, session ID, and randomizer.
|
|
32
|
+
*
|
|
33
|
+
* @param userId - The user ID
|
|
34
|
+
* @param sessionId - The session ID
|
|
35
|
+
* @param randomizer - Additional identifier (defaults to 999)
|
|
36
|
+
* @returns A 12-character hexadecimal composite key
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* The composite key is formed by concatenating three 4-digit hexadecimal values:
|
|
40
|
+
* userHex (4 chars) + sessionHex (4 chars) + randomizerHex (4 chars) = 12 chars total.
|
|
41
|
+
* This enables unique identification of data across users, sessions, and applications.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const key = UserBinaryTree.compositeKey(42, 999, 123);
|
|
46
|
+
* // Returns something like "002A03E7007B"
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
static compositeKey(userId: number, sessionId: number, randomizer?: number): string;
|
|
50
|
+
/**
|
|
51
|
+
* Adds a user node to the binary tree.
|
|
52
|
+
*
|
|
53
|
+
* @param node - The UserNode to be added to the tree
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* If the tree is empty, the provided node becomes the root.
|
|
57
|
+
* Otherwise, the node is inserted using the AVL tree balancing algorithm.
|
|
58
|
+
*/
|
|
59
|
+
static addNodeToTree(node: UserNode): UserNode | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Waits for user data to be loaded into the tree.
|
|
62
|
+
*
|
|
63
|
+
* @returns A promise that resolves with "done" when data is loaded, or rejects with "not" after 25 seconds
|
|
64
|
+
*/
|
|
65
|
+
static waitForDataToLoad(): Promise<unknown>;
|
|
66
|
+
/**
|
|
67
|
+
* Periodically checks if user data has been loaded.
|
|
68
|
+
*
|
|
69
|
+
* @param resolve - The promise resolve function to call when data is loaded
|
|
70
|
+
*/
|
|
71
|
+
static checkFlag(resolve: any): any;
|
|
72
|
+
/**
|
|
73
|
+
* Creates a node from a concept and adds it to the user tree.
|
|
74
|
+
*
|
|
75
|
+
* @param concept - The LConcept object to be added
|
|
76
|
+
* @param userId - The user ID
|
|
77
|
+
* @param sessionId - The session ID (defaults to 999)
|
|
78
|
+
*
|
|
79
|
+
* @remarks
|
|
80
|
+
* Uses the concept's applicationId as the randomizer in the composite key.
|
|
81
|
+
*/
|
|
82
|
+
static addConceptToTree(concept: LConcept, userId: number, sessionId?: number): void;
|
|
83
|
+
/**
|
|
84
|
+
* Creates a node from a connection and adds it to the user tree.
|
|
85
|
+
*
|
|
86
|
+
* @param connection - The LConnection object to be added
|
|
87
|
+
* @param userId - The user ID
|
|
88
|
+
* @param sessionId - The session ID (defaults to 999)
|
|
89
|
+
*
|
|
90
|
+
* @remarks
|
|
91
|
+
* Uses the connection's applicationId as the randomizer in the composite key.
|
|
92
|
+
*/
|
|
93
|
+
static addConnectionToTree(connection: LConnection, userId: number, sessionId?: number): void;
|
|
94
|
+
/**
|
|
95
|
+
* Retrieves a node from the tree using composite key components.
|
|
96
|
+
*
|
|
97
|
+
* @param userId - The user ID
|
|
98
|
+
* @param sessionId - The session ID
|
|
99
|
+
* @param randomizer - Additional identifier (defaults to 999)
|
|
100
|
+
* @returns The UserNode if found, null otherwise
|
|
101
|
+
*
|
|
102
|
+
* @remarks
|
|
103
|
+
* Constructs a composite key from the parameters and performs a binary search.
|
|
104
|
+
*/
|
|
105
|
+
static getNodeFromTree(userId: number, sessionId: number, randomizer?: number): Promise<UserNode | null>;
|
|
106
|
+
/**
|
|
107
|
+
* Removes a node from the tree using composite key components.
|
|
108
|
+
*
|
|
109
|
+
* @param userId - The user ID
|
|
110
|
+
* @param sessionId - The session ID (defaults to 999)
|
|
111
|
+
* @param randomizer - Additional identifier (defaults to 999)
|
|
112
|
+
*
|
|
113
|
+
* @remarks
|
|
114
|
+
* Constructs a composite key and removes the matching node while maintaining AVL balance.
|
|
115
|
+
*/
|
|
116
|
+
static removeNodeFromTree(userId: number, sessionId?: number, randomizer?: number): Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* Counts the total number of nodes in the tree.
|
|
119
|
+
*
|
|
120
|
+
* @returns The total number of user nodes in the tree
|
|
121
|
+
*
|
|
122
|
+
* @remarks
|
|
123
|
+
* Recursively traverses the entire tree to count all nodes. Returns 0 if the tree is empty.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* const count = UserBinaryTree.countNumberOfNodes();
|
|
128
|
+
* console.log(`Tree contains ${count} user data nodes`);
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
static countNumberOfNodes(): number;
|
|
132
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Node implementation for the UserBinaryTree.
|
|
3
|
+
* This module provides the UserNode class for storing user-specific concepts and connections.
|
|
4
|
+
* @module DataStructures/User/UserNode
|
|
5
|
+
*/
|
|
6
|
+
import { LConcept } from "../Local/LConcept";
|
|
7
|
+
import { LConnection } from "../Local/LConnection";
|
|
8
|
+
/**
|
|
9
|
+
* Represents a node in the user binary tree that stores both concepts and connections.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* UserNode implements an AVL tree node that can store multiple concepts and connections
|
|
13
|
+
* for a given composite key (userId + sessionId + randomizer). This allows efficient
|
|
14
|
+
* storage and retrieval of all user data associated with a specific key combination.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const concept = new LConcept(123, "example", 5);
|
|
19
|
+
* const connection = new LConnection(456, 1, 2, 3, 4, 5);
|
|
20
|
+
* const node = new UserNode("compositeKey", concept, connection, null, null);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare class UserNode {
|
|
24
|
+
/**
|
|
25
|
+
* The composite key used for tree ordering.
|
|
26
|
+
* Typically a hexadecimal string combining userId, sessionId, and randomizer.
|
|
27
|
+
*/
|
|
28
|
+
key: any;
|
|
29
|
+
/**
|
|
30
|
+
* Array of connections stored in this node.
|
|
31
|
+
* Multiple connections can be associated with the same key.
|
|
32
|
+
*/
|
|
33
|
+
connectionValue: LConnection[];
|
|
34
|
+
/**
|
|
35
|
+
* Array of concepts stored in this node.
|
|
36
|
+
* Multiple concepts can be associated with the same key.
|
|
37
|
+
*/
|
|
38
|
+
value: LConcept[];
|
|
39
|
+
/**
|
|
40
|
+
* Reference to the left child node.
|
|
41
|
+
*/
|
|
42
|
+
leftNode: UserNode | null;
|
|
43
|
+
/**
|
|
44
|
+
* Reference to the right child node.
|
|
45
|
+
*/
|
|
46
|
+
rightNode: UserNode | null;
|
|
47
|
+
/**
|
|
48
|
+
* The height of this node in the tree.
|
|
49
|
+
* Used for AVL tree balancing calculations.
|
|
50
|
+
*/
|
|
51
|
+
height: number;
|
|
52
|
+
/**
|
|
53
|
+
* Creates a new UserNode.
|
|
54
|
+
*
|
|
55
|
+
* @param key - The composite key for tree ordering
|
|
56
|
+
* @param value - The LConcept to store (added if ID > 0)
|
|
57
|
+
* @param connectionValue - The LConnection to store (added if ID > 0)
|
|
58
|
+
* @param leftNode - The left child node (or null)
|
|
59
|
+
* @param rightNode - The right child node (or null)
|
|
60
|
+
*
|
|
61
|
+
* @remarks
|
|
62
|
+
* Only adds concepts and connections with valid (> 0) IDs to their respective arrays.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const node = new UserNode("compositeKey", concept, connection, null, null);
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
constructor(key: any, value: LConcept, connectionValue: LConnection, leftNode: UserNode | null, rightNode: UserNode | null);
|
|
70
|
+
/**
|
|
71
|
+
* Adds a new node to the tree with AVL balancing.
|
|
72
|
+
*
|
|
73
|
+
* @param passedNode - The node to be added
|
|
74
|
+
* @param node - The current node being evaluated
|
|
75
|
+
* @param height - The height of the current node
|
|
76
|
+
* @returns The root node after insertion and balancing
|
|
77
|
+
*
|
|
78
|
+
* @remarks
|
|
79
|
+
* Implements AVL tree insertion. When a node with the same key exists,
|
|
80
|
+
* the new node's concepts and connections are added to the existing node's arrays.
|
|
81
|
+
*/
|
|
82
|
+
addNode(passedNode: UserNode, node: UserNode | null, height: number): UserNode | null;
|
|
83
|
+
/**
|
|
84
|
+
* Performs a right rotation on the given node for AVL balancing.
|
|
85
|
+
*
|
|
86
|
+
* @param y - The node to rotate right
|
|
87
|
+
* @returns The new root node after rotation
|
|
88
|
+
*/
|
|
89
|
+
rightRotate(y: UserNode | null): UserNode | null;
|
|
90
|
+
/**
|
|
91
|
+
* Performs a left rotation on the given node for AVL balancing.
|
|
92
|
+
*
|
|
93
|
+
* @param x - The node to rotate left
|
|
94
|
+
* @returns The new root node after rotation
|
|
95
|
+
*/
|
|
96
|
+
leftRotate(x: UserNode | null): UserNode | null;
|
|
97
|
+
/**
|
|
98
|
+
* Gets the height of a node.
|
|
99
|
+
*
|
|
100
|
+
* @param node - The node to get the height from
|
|
101
|
+
* @returns The height of the node, or 0 if null
|
|
102
|
+
*/
|
|
103
|
+
getHeight(node: UserNode | null): number;
|
|
104
|
+
/**
|
|
105
|
+
* Calculates the balance factor of a node.
|
|
106
|
+
*
|
|
107
|
+
* @param N - The node to calculate the balance factor for
|
|
108
|
+
* @returns The balance factor (difference between left and right heights)
|
|
109
|
+
*/
|
|
110
|
+
getBalanceFactor(N: UserNode | null): number;
|
|
111
|
+
/**
|
|
112
|
+
* Retrieves a node from the tree by its composite key.
|
|
113
|
+
*
|
|
114
|
+
* @param id - The composite key string to search for
|
|
115
|
+
* @param node - The current node being evaluated
|
|
116
|
+
* @returns The matching UserNode if found, null otherwise
|
|
117
|
+
*/
|
|
118
|
+
getFromNode(id: string, node: UserNode | null): UserNode | null;
|
|
119
|
+
/**
|
|
120
|
+
* Removes a node from the tree by its composite key.
|
|
121
|
+
*
|
|
122
|
+
* @param passedNode - The current node being evaluated
|
|
123
|
+
* @param id - The composite key string to remove
|
|
124
|
+
* @returns The root node after removal
|
|
125
|
+
*
|
|
126
|
+
* @remarks
|
|
127
|
+
* Implements standard BST deletion with in-order successor replacement.
|
|
128
|
+
*/
|
|
129
|
+
removeNode(passedNode: UserNode | null, id: string): UserNode | null;
|
|
130
|
+
/**
|
|
131
|
+
* Counts all nodes below and including the given node.
|
|
132
|
+
*
|
|
133
|
+
* @param root - The root node to start counting from
|
|
134
|
+
* @returns The total number of nodes in the subtree
|
|
135
|
+
*
|
|
136
|
+
* @remarks
|
|
137
|
+
* Recursively traverses the entire subtree to count all nodes.
|
|
138
|
+
*/
|
|
139
|
+
countNodeBelow(root: UserNode | null): number;
|
|
140
|
+
/**
|
|
141
|
+
* Finds the in-order successor of a node.
|
|
142
|
+
*
|
|
143
|
+
* @param root - The node to find the successor from
|
|
144
|
+
* @returns The in-order successor node (leftmost node in right subtree)
|
|
145
|
+
*
|
|
146
|
+
* @remarks
|
|
147
|
+
* Used during node deletion to find the replacement node.
|
|
148
|
+
*/
|
|
149
|
+
inOrderSuccessor(root: UserNode): UserNode;
|
|
150
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Placeholder module for IndexedDB concept retrieval functionality.
|
|
3
|
+
*
|
|
4
|
+
* This module is reserved for future implementation of concept retrieval operations
|
|
5
|
+
* from IndexedDB storage in the Concept Connection System.
|
|
6
|
+
*
|
|
7
|
+
* @module Database/GetConceptFromIndexDb
|
|
8
|
+
* @see https://documentation.freeschema.com for reference
|
|
9
|
+
*/
|