mftsccs-node 0.0.57 → 0.0.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,14 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Text data structure for the CCS-JS system.
|
|
3
|
+
* @module DataStructures/TheTexts
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Represents a text entity in the system with comprehensive metadata and security tracking.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* TheTexts class encapsulates text data along with user ownership, security credentials,
|
|
10
|
+
* access control, session tracking, and timestamp information. This class is similar to
|
|
11
|
+
* TheCharacter but designed for longer text strings and includes an entry timestamp for
|
|
12
|
+
* temporal tracking. It provides complete audit trail capabilities through its multiple
|
|
13
|
+
* user context references.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const text = new TheTexts(
|
|
18
|
+
* 1001, // userId
|
|
19
|
+
* "Hello World", // data
|
|
20
|
+
* 5001, // securityId
|
|
21
|
+
* 1001, // securityUserId
|
|
22
|
+
* 6001, // accessId
|
|
23
|
+
* 1001, // accessUserId
|
|
24
|
+
* 7001, // sessionId
|
|
25
|
+
* 1001, // sessionUserId
|
|
26
|
+
* "2025-10-30T12:00:00Z", // entryTimestamp
|
|
27
|
+
* true // isNew
|
|
28
|
+
* );
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
1
31
|
export declare class TheTexts {
|
|
32
|
+
/**
|
|
33
|
+
* Unique identifier for the text entity.
|
|
34
|
+
* @defaultValue 0
|
|
35
|
+
*/
|
|
2
36
|
id: number;
|
|
37
|
+
/**
|
|
38
|
+
* ID of the user who owns this text.
|
|
39
|
+
*/
|
|
3
40
|
userId: number;
|
|
41
|
+
/**
|
|
42
|
+
* The actual text data content.
|
|
43
|
+
*/
|
|
4
44
|
data: string;
|
|
45
|
+
/**
|
|
46
|
+
* Security level or security context identifier for this text.
|
|
47
|
+
*/
|
|
5
48
|
securityId: number;
|
|
49
|
+
/**
|
|
50
|
+
* User ID associated with the security context.
|
|
51
|
+
*/
|
|
6
52
|
securityUserId: number;
|
|
53
|
+
/**
|
|
54
|
+
* Access control identifier for this text.
|
|
55
|
+
*/
|
|
7
56
|
accessId: number;
|
|
57
|
+
/**
|
|
58
|
+
* User ID associated with the access control.
|
|
59
|
+
*/
|
|
8
60
|
accessUserId: number;
|
|
61
|
+
/**
|
|
62
|
+
* Session identifier tracking when this text was accessed.
|
|
63
|
+
*/
|
|
9
64
|
sessionId: number;
|
|
65
|
+
/**
|
|
66
|
+
* User ID associated with the session.
|
|
67
|
+
*/
|
|
10
68
|
sessionUserId: number;
|
|
69
|
+
/**
|
|
70
|
+
* ISO 8601 timestamp indicating when this text entry was created or modified.
|
|
71
|
+
*/
|
|
11
72
|
entryTimestamp: string;
|
|
73
|
+
/**
|
|
74
|
+
* Flag indicating whether this is a newly created text entry.
|
|
75
|
+
*/
|
|
12
76
|
isNew: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Creates a new TheTexts instance.
|
|
79
|
+
*
|
|
80
|
+
* @param userId - The ID of the user who owns this text
|
|
81
|
+
* @param data - The text content
|
|
82
|
+
* @param securityId - Security level or context identifier
|
|
83
|
+
* @param securityUserId - User ID for the security context
|
|
84
|
+
* @param accessId - Access control identifier
|
|
85
|
+
* @param accessUserId - User ID for access control
|
|
86
|
+
* @param sessionId - Session tracking identifier
|
|
87
|
+
* @param sessionUserId - User ID for the session
|
|
88
|
+
* @param entryTimestamp - ISO 8601 timestamp when the text was created/entered
|
|
89
|
+
* @param isNew - Whether this is a newly created text entry
|
|
90
|
+
*
|
|
91
|
+
* @remarks
|
|
92
|
+
* Unlike TheCharacter, this constructor stores the entryTimestamp property,
|
|
93
|
+
* making it suitable for temporal tracking and audit trails.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* const text = new TheTexts(
|
|
98
|
+
* 1, "Sample text", 100, 1, 200, 1, 300, 1,
|
|
99
|
+
* new Date().toISOString(), true
|
|
100
|
+
* );
|
|
101
|
+
* console.log(text.data); // "Sample text"
|
|
102
|
+
* console.log(text.entryTimestamp); // "2025-10-30T12:00:00.000Z"
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
13
105
|
constructor(userId: number, data: string, securityId: number, securityUserId: number, accessId: number, accessUserId: number, sessionId: number, sessionUserId: number, entryTimestamp: string, isNew: boolean);
|
|
14
106
|
}
|
|
@@ -1,30 +1,320 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Defines the Transaction class for managing transactional operations.
|
|
3
|
+
* @module DataStructures/Transaction/Transaction
|
|
4
|
+
*/
|
|
1
5
|
import { Concept } from "../Concept";
|
|
2
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
|
+
*/
|
|
3
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
|
+
*/
|
|
4
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
|
+
*/
|
|
5
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
|
+
*/
|
|
6
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
|
+
*/
|
|
7
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
|
+
*/
|
|
8
99
|
initialize(): Promise<void>;
|
|
9
100
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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.
|
|
12
111
|
*/
|
|
13
112
|
protected markAction(): Promise<void>;
|
|
14
113
|
/**
|
|
15
|
-
*
|
|
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
|
+
* ```
|
|
16
131
|
*/
|
|
17
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
|
+
*/
|
|
18
156
|
commitTransaction(): Promise<void>;
|
|
19
157
|
/**
|
|
20
|
-
*
|
|
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
|
+
* ```
|
|
21
192
|
*/
|
|
22
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
|
+
*/
|
|
23
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
|
+
*/
|
|
24
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
|
+
*/
|
|
25
292
|
CreateTheConnectionGeneral(ofTheConceptId: number, ofTheConceptUserId: number, toTheConceptId: number, toTheConceptUserId: number, typeId: number, sessionInformationId: number, sessionInformationUserId: number, orderId?: number, accessId?: number, passedUserId?: number): Promise<Connection>;
|
|
26
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
|
+
*/
|
|
27
309
|
export interface InnerActions {
|
|
310
|
+
/**
|
|
311
|
+
* Array of concepts created or modified in the transaction.
|
|
312
|
+
* @type {Concept[]}
|
|
313
|
+
*/
|
|
28
314
|
concepts: Concept[];
|
|
315
|
+
/**
|
|
316
|
+
* Array of connections created or modified in the transaction.
|
|
317
|
+
* @type {Connection[]}
|
|
318
|
+
*/
|
|
29
319
|
connections: Connection[];
|
|
30
320
|
}
|
|
@@ -1,15 +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
|
+
*/
|
|
1
6
|
import { LConcept } from "../../DataStructures/Local/LConcept";
|
|
2
7
|
import { UserNode } from "./UserNode";
|
|
3
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
|
+
*/
|
|
4
24
|
export declare class UserBinaryTree {
|
|
25
|
+
/**
|
|
26
|
+
* The root node of the user data binary tree.
|
|
27
|
+
* Null if the tree is empty.
|
|
28
|
+
*/
|
|
5
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
|
+
*/
|
|
6
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
|
+
*/
|
|
7
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
|
+
*/
|
|
8
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
|
+
*/
|
|
9
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
|
+
*/
|
|
10
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
|
+
*/
|
|
11
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
|
+
*/
|
|
12
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
|
+
*/
|
|
13
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
|
+
*/
|
|
14
131
|
static countNumberOfNodes(): number;
|
|
15
132
|
}
|