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,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connection Creation Service
|
|
3
|
+
*
|
|
4
|
+
* This module provides functionality for creating temporary connections between concepts
|
|
5
|
+
* in the Concept Connection System. It handles basic connection creation with default
|
|
6
|
+
* security and access settings.
|
|
7
|
+
*
|
|
8
|
+
* @module CreateTheConnection
|
|
9
|
+
*/
|
|
10
|
+
import { Connection } from "../DataStructures/Connection";
|
|
11
|
+
/**
|
|
12
|
+
* Creates a temporary connection between two concepts with default settings.
|
|
13
|
+
*
|
|
14
|
+
* This function establishes a basic connection relationship between a source concept
|
|
15
|
+
* (ofTheConcept) and a target concept (toTheConcept). The created connection is marked
|
|
16
|
+
* as temporary (isTemp = true) and assigned a random ID. It automatically handles the
|
|
17
|
+
* special case where a concept connects to itself by setting predefined IDs.
|
|
18
|
+
*
|
|
19
|
+
* The function uses default values for security (0), access level (4), and order (1),
|
|
20
|
+
* making it suitable for quick connection creation during prototyping or when advanced
|
|
21
|
+
* configuration is not required.
|
|
22
|
+
*
|
|
23
|
+
* @param ofTheConceptId - The ID of the source concept from which the connection originates
|
|
24
|
+
* @param ofTheConceptUserId - The user ID who owns the source concept
|
|
25
|
+
* @param toTheConceptId - The ID of the target concept to which the connection points
|
|
26
|
+
* @param toTheConceptUserId - The user ID who owns the target concept
|
|
27
|
+
* @param typeId - The ID of the concept that defines the type/nature of this connection
|
|
28
|
+
* @param sessionInformationId - The ID of the session in which this connection is created
|
|
29
|
+
* @param sessionInformationUserId - The user ID associated with the session information
|
|
30
|
+
*
|
|
31
|
+
* @returns A new Connection object that has been added to SyncData for synchronization
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* // Create a simple "likes" connection between user's concepts
|
|
36
|
+
* const likesConcept = await GetConceptByCharacter("likes");
|
|
37
|
+
* const connection = createTheConnection(
|
|
38
|
+
* userConcept.id,
|
|
39
|
+
* userConcept.userId,
|
|
40
|
+
* postConcept.id,
|
|
41
|
+
* postConcept.userId,
|
|
42
|
+
* likesConcept.id,
|
|
43
|
+
* 999,
|
|
44
|
+
* 999
|
|
45
|
+
* );
|
|
46
|
+
* console.log("Connection created:", connection.id);
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @remarks
|
|
50
|
+
* - The connection is marked as temporary (isTemp = true) and assigned a random ID
|
|
51
|
+
* - Self-referencing connections (where ofTheConceptId equals toTheConceptId) are handled
|
|
52
|
+
* specially by setting ofTheConceptId to 0 and toTheConceptId to 1
|
|
53
|
+
* - Default security level is set to 0 and access level to 4
|
|
54
|
+
* - The connection is automatically added to SyncData for later synchronization
|
|
55
|
+
* - For production use with reserved IDs and more control, consider using CreateTheConnectionGeneral
|
|
56
|
+
*
|
|
57
|
+
* @see {@link CreateTheConnectionGeneral} for creating connections with more configuration options
|
|
58
|
+
* @see {@link Connection} for the connection data structure
|
|
59
|
+
* @see {@link SyncData.AddConnection} for how connections are queued for sync
|
|
60
|
+
*/
|
|
61
|
+
export declare function createTheConnection(ofTheConceptId: number, ofTheConceptUserId: number, toTheConceptId: number, toTheConceptUserId: number, typeId: number, sessionInformationId: number, sessionInformationUserId: number): Connection;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* General Connection Creation Service
|
|
3
|
+
*
|
|
4
|
+
* This module provides advanced functionality for creating permanent connections between
|
|
5
|
+
* concepts with reserved IDs and configurable settings. It supports transaction tracking
|
|
6
|
+
* and is designed for production use where connections need to be persisted and updated.
|
|
7
|
+
*
|
|
8
|
+
* @module CreateTheConnectionGeneral
|
|
9
|
+
*/
|
|
10
|
+
import { Concept } from "../app";
|
|
11
|
+
import { Connection } from "../DataStructures/Connection";
|
|
12
|
+
import { InnerActions } from "../DataStructures/Transaction/Transaction";
|
|
13
|
+
/**
|
|
14
|
+
* Creates a permanent connection between two concepts with reserved ID and full configuration.
|
|
15
|
+
*
|
|
16
|
+
* This is the production-ready version of connection creation that uses reserved IDs from
|
|
17
|
+
* the system's ID reservation pool. Unlike the basic createTheConnection, this function
|
|
18
|
+
* marks connections as non-temporary (isTemp = false) and sets them to update mode
|
|
19
|
+
* (toUpdate = true), ensuring they persist properly in the database.
|
|
20
|
+
*
|
|
21
|
+
* The function provides extensive configurability including custom order, access levels,
|
|
22
|
+
* and user assignment. It also supports transaction tracking by accepting an actions
|
|
23
|
+
* object where created connections are logged.
|
|
24
|
+
*
|
|
25
|
+
* @param ofTheConceptId - The ID of the source concept from which the connection originates
|
|
26
|
+
* @param ofTheConceptUserId - The user ID who owns the source concept
|
|
27
|
+
* @param toTheConceptId - The ID of the target concept to which the connection points
|
|
28
|
+
* @param toTheConceptUserId - The user ID who owns the target concept
|
|
29
|
+
* @param typeId - The ID of the concept that defines the type/nature of this connection
|
|
30
|
+
* @param sessionInformationId - The ID of the session in which this connection is created
|
|
31
|
+
* @param sessionInformationUserId - The user ID associated with the session information
|
|
32
|
+
* @param orderId - Optional ordering value for the connection (default: 1)
|
|
33
|
+
* @param accessId - Optional access level for the connection (default: 4)
|
|
34
|
+
* @param passedUserId - Optional specific user ID to assign to the connection (default: 999, uses ofTheConceptUserId if not provided)
|
|
35
|
+
* @param actions - Optional transaction tracking object to log created connections (default: empty actions)
|
|
36
|
+
*
|
|
37
|
+
* @returns A promise that resolves to the created Connection object with a reserved ID
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* // Create a production connection with transaction tracking
|
|
42
|
+
* const actions: InnerActions = { concepts: [], connections: [] };
|
|
43
|
+
* const connection = await CreateTheConnectionGeneral(
|
|
44
|
+
* authorConcept.id,
|
|
45
|
+
* authorConcept.userId,
|
|
46
|
+
* bookConcept.id,
|
|
47
|
+
* bookConcept.userId,
|
|
48
|
+
* wroteTypeConcept.id,
|
|
49
|
+
* 999,
|
|
50
|
+
* 999,
|
|
51
|
+
* 1,
|
|
52
|
+
* 4,
|
|
53
|
+
* authorConcept.userId,
|
|
54
|
+
* actions
|
|
55
|
+
* );
|
|
56
|
+
* console.log("Connection ID:", connection.id);
|
|
57
|
+
* console.log("Tracked connections:", actions.connections.length);
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @remarks
|
|
61
|
+
* - Uses reserved IDs from ReservedConnectionIds for guaranteed uniqueness
|
|
62
|
+
* - Connection is marked as non-temporary (isTemp = false) for persistence
|
|
63
|
+
* - Sets toUpdate = true to ensure database synchronization
|
|
64
|
+
* - Self-referencing connections are handled by setting ofTheConceptId to 0 and toTheConceptId to 1
|
|
65
|
+
* - The connection is added to both SyncData and the provided actions object
|
|
66
|
+
* - If passedUserId is 999, the function defaults to using ofTheConceptUserId
|
|
67
|
+
*
|
|
68
|
+
* @see {@link createTheConnection} for creating temporary connections
|
|
69
|
+
* @see {@link CreateConnection} for a simplified high-level connection API
|
|
70
|
+
* @see {@link ReservedConnectionIds.getId} for ID reservation mechanism
|
|
71
|
+
*/
|
|
72
|
+
export declare function CreateTheConnectionGeneral(ofTheConceptId: number, ofTheConceptUserId: number, toTheConceptId: number, toTheConceptUserId: number, typeId: number, sessionInformationId: number, sessionInformationUserId: number, orderId?: number, accessId?: number, passedUserId?: number, actions?: InnerActions): Promise<Connection>;
|
|
73
|
+
/**
|
|
74
|
+
* Creates a connection between two concepts using a type string identifier.
|
|
75
|
+
*
|
|
76
|
+
* This is a high-level convenience function that simplifies connection creation by
|
|
77
|
+
* accepting concept objects directly and a string for the connection type. It automatically
|
|
78
|
+
* handles the creation or retrieval of the connection type concept and delegates to
|
|
79
|
+
* CreateTheConnectionGeneral for the actual connection creation.
|
|
80
|
+
*
|
|
81
|
+
* This function is ideal for application-level code where you want to create connections
|
|
82
|
+
* using semantic type names (like "contains", "authored", "belongs_to") rather than
|
|
83
|
+
* managing type concept IDs manually.
|
|
84
|
+
*
|
|
85
|
+
* @param ofTheConcept - The source Concept object from which the connection originates
|
|
86
|
+
* @param toTheConcept - The target Concept object to which the connection points
|
|
87
|
+
* @param connectionTypeString - A string describing the connection type (e.g., "contains", "references")
|
|
88
|
+
* @param actions - Optional transaction tracking object to log created connections (default: empty actions)
|
|
89
|
+
*
|
|
90
|
+
* @returns A promise that resolves to the created Connection object
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* // Create a "contains" connection between a folder and a file
|
|
95
|
+
* const folderConcept = await GetTheConcept(123);
|
|
96
|
+
* const fileConcept = await GetTheConcept(456);
|
|
97
|
+
* const actions: InnerActions = { concepts: [], connections: [] };
|
|
98
|
+
*
|
|
99
|
+
* const connection = await CreateConnection(
|
|
100
|
+
* folderConcept,
|
|
101
|
+
* fileConcept,
|
|
102
|
+
* "contains",
|
|
103
|
+
* actions
|
|
104
|
+
* );
|
|
105
|
+
*
|
|
106
|
+
* console.log(`Created ${connectionTypeString} connection:`, connection.id);
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* // Create an "authored" connection between author and book
|
|
112
|
+
* const authorConcept = await GetTheConcept(789);
|
|
113
|
+
* const bookConcept = await GetTheConcept(101);
|
|
114
|
+
*
|
|
115
|
+
* const connection = await CreateConnection(
|
|
116
|
+
* authorConcept,
|
|
117
|
+
* bookConcept,
|
|
118
|
+
* "authored"
|
|
119
|
+
* );
|
|
120
|
+
* ```
|
|
121
|
+
*
|
|
122
|
+
* @remarks
|
|
123
|
+
* - Automatically creates or retrieves a type concept for the connectionTypeString
|
|
124
|
+
* - Uses default session information ID (999) and order (1000)
|
|
125
|
+
* - Access level is set to 4 (standard access)
|
|
126
|
+
* - The userId from ofTheConcept is used for the connection
|
|
127
|
+
* - The connection is tracked in the provided actions object for transaction management
|
|
128
|
+
*
|
|
129
|
+
* @see {@link CreateTheConnectionGeneral} for the underlying connection creation logic
|
|
130
|
+
* @see {@link MakeTheTypeConceptApi} for how type concepts are created/retrieved
|
|
131
|
+
*/
|
|
132
|
+
export declare function CreateConnection(ofTheConcept: Concept, toTheConcept: Concept, connectionTypeString: string, actions?: InnerActions): Promise<Connection>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type-Based Binary Tree Data Loading Service
|
|
3
|
+
*
|
|
4
|
+
* This module provides functionality for creating and populating a type-based binary tree
|
|
5
|
+
* data structure from persisted concept data. The tree is organized by type identifiers,
|
|
6
|
+
* enabling efficient type-based categorization, filtering, and retrieval of concepts.
|
|
7
|
+
*
|
|
8
|
+
* @module CreateTypeTreeFromData
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Creates and populates a type-based binary tree from concept data stored in the database.
|
|
12
|
+
*
|
|
13
|
+
* This function retrieves all concept records from IndexedDB and constructs a binary tree
|
|
14
|
+
* where nodes are organized by their type identifiers (typeId). This organization enables
|
|
15
|
+
* efficient grouping and retrieval of concepts by their type classification.
|
|
16
|
+
*
|
|
17
|
+
* The BinaryTypeTree structure is essential for type-based queries and operations, allowing
|
|
18
|
+
* the system to quickly find all concepts of a particular type without scanning the entire
|
|
19
|
+
* dataset. Performance metrics are tracked to monitor loading times.
|
|
20
|
+
*
|
|
21
|
+
* @returns A promise that resolves when the type binary tree has been fully populated
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* // Build the type-based binary tree from database
|
|
26
|
+
* await CreateTypeTreeFromData();
|
|
27
|
+
*
|
|
28
|
+
* // The tree can now be used for type-based queries
|
|
29
|
+
* const conceptsOfType = BinaryTypeTree.getByType(42);
|
|
30
|
+
* console.log('All concepts of type 42:', conceptsOfType);
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* - Tracks execution time for performance monitoring (startTime, endTime, time variables)
|
|
35
|
+
* - Each concept is wrapped in a Node using its typeId property as the organizational key
|
|
36
|
+
* - The tree is built sequentially by iterating through all retrieved concepts
|
|
37
|
+
* - Type identifiers determine node placement in the binary tree structure
|
|
38
|
+
* - Time measurements are calculated but not currently returned or logged
|
|
39
|
+
*
|
|
40
|
+
* @see {@link BinaryTypeTree.addNodeToTree} for how nodes are inserted into the tree
|
|
41
|
+
* @see {@link Node} for the node data structure used in the tree
|
|
42
|
+
* @see {@link getFromDatabaseWithTypeOld} for database retrieval implementation
|
|
43
|
+
*/
|
|
44
|
+
export declare function CreateTypeTreeFromData(): Promise<void>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module DeleteConnectionByType
|
|
3
|
+
* @description Provides functions to delete and retrieve connections by their type
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Deletes all connections of specified types from a concept.
|
|
7
|
+
* Finds connections matching the given linker types and deletes them.
|
|
8
|
+
*
|
|
9
|
+
* @async
|
|
10
|
+
* @param {number} id - The concept ID whose connections should be deleted
|
|
11
|
+
* @param {string[]} linkers - Array of connection type names to delete
|
|
12
|
+
* @returns {Promise<boolean>} A promise that resolves to true if all deletions successful, false otherwise
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const conceptId = 123;
|
|
17
|
+
* const linkersToDelete = ["follows", "likes", "shares"];
|
|
18
|
+
* const success = await DeleteConnectionByTypeBulk(conceptId, linkersToDelete);
|
|
19
|
+
* if (success) {
|
|
20
|
+
* console.log("All connections deleted successfully");
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* This function:
|
|
26
|
+
* - Fetches all linker connections from the concept
|
|
27
|
+
* - Gets concept objects for the specified linker type names
|
|
28
|
+
* - Matches connections by typeId with linker concept IDs
|
|
29
|
+
* - Deletes each matching connection
|
|
30
|
+
* - Returns false if any deletion fails
|
|
31
|
+
* - Uses bulk operations for efficiency
|
|
32
|
+
*/
|
|
33
|
+
export declare function DeleteConnectionByTypeBulk(id: number, linkers: string[]): Promise<boolean>;
|
|
34
|
+
/**
|
|
35
|
+
* Retrieves all connection IDs of specified types from a concept without deleting them.
|
|
36
|
+
* Useful for querying which connections exist before performing operations.
|
|
37
|
+
*
|
|
38
|
+
* @async
|
|
39
|
+
* @param {number} id - The concept ID whose connections should be retrieved
|
|
40
|
+
* @param {string[]} linkers - Array of connection type names to find
|
|
41
|
+
* @returns {Promise<number[]>} A promise that resolves to array of matching connection IDs
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const conceptId = 123;
|
|
46
|
+
* const linkersToFind = ["follows", "likes"];
|
|
47
|
+
* const connectionIds = await GetConnectionByTypeBulk(conceptId, linkersToFind);
|
|
48
|
+
* // connectionIds = [101, 102, 103, 104]
|
|
49
|
+
* console.log(`Found ${connectionIds.length} connections`);
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @remarks
|
|
53
|
+
* This function:
|
|
54
|
+
* - Similar to DeleteConnectionByTypeBulk but only retrieves IDs
|
|
55
|
+
* - Does not modify any data
|
|
56
|
+
* - Returns empty array if no matching connections found
|
|
57
|
+
* - Useful for counting or inspecting connections before deletion
|
|
58
|
+
* - Can be used to check connection existence
|
|
59
|
+
*/
|
|
60
|
+
export declare function GetConnectionByTypeBulk(id: number, linkers: string[]): Promise<number[]>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module GetAllConnectionByType
|
|
3
|
+
* @description Provides functions to retrieve connections filtered by type and direction
|
|
4
|
+
*/
|
|
5
|
+
import { Connection } from "../../app";
|
|
6
|
+
/**
|
|
7
|
+
* Retrieves all connections of a specific type from or to a concept.
|
|
8
|
+
* Supports both forward (from concept) and reverse (to concept) direction.
|
|
9
|
+
*
|
|
10
|
+
* @async
|
|
11
|
+
* @param {number} id - The concept ID to query connections for
|
|
12
|
+
* @param {string} linker - The connection type name to filter by
|
|
13
|
+
* @param {boolean} [reverse=false] - If true, returns connections TO the concept; if false, returns connections FROM the concept
|
|
14
|
+
* @returns {Promise<Connection[]>} A promise that resolves to array of matching Connection objects
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* // Get all "follows" connections FROM concept 123
|
|
19
|
+
* const followsFrom = await GetAllTheConnectionsByTypeAndOfTheConcept(123, "follows", false);
|
|
20
|
+
*
|
|
21
|
+
* // Get all "follows" connections TO concept 123 (reverse)
|
|
22
|
+
* const followsTo = await GetAllTheConnectionsByTypeAndOfTheConcept(123, "follows", true);
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @remarks
|
|
26
|
+
* This function:
|
|
27
|
+
* - Forward direction (reverse=false): Returns connections where concept is ofTheConceptId
|
|
28
|
+
* - Reverse direction (reverse=true): Returns connections where concept is toTheConceptId
|
|
29
|
+
* - Creates or retrieves the linker concept by type name
|
|
30
|
+
* - Filters connections by matching typeId
|
|
31
|
+
* - Caches forward connections in ConnectionData
|
|
32
|
+
* - Returns empty array if no matching connections found
|
|
33
|
+
*/
|
|
34
|
+
export declare function GetAllTheConnectionsByTypeAndOfTheConcept(id: number, linker: string, reverse?: boolean): Promise<Connection[]>;
|
|
35
|
+
/**
|
|
36
|
+
* Retrieves specific connections between two concepts with a given linker type.
|
|
37
|
+
* Filters connections to match both the source, destination, and type.
|
|
38
|
+
*
|
|
39
|
+
* @async
|
|
40
|
+
* @param {number} ofTheConceptId - The source concept ID
|
|
41
|
+
* @param {number} toTheConceptId - The destination concept ID
|
|
42
|
+
* @param {string} linker - The connection type name
|
|
43
|
+
* @param {boolean} [reverse=false] - If true, swaps the direction (queries from toTheConceptId)
|
|
44
|
+
* @returns {Promise<Connection[]>} A promise that resolves to array of matching connections
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* // Find all "follows" connections from concept 123 to concept 456
|
|
49
|
+
* const connections = await GiveConnection(123, 456, "follows", false);
|
|
50
|
+
*
|
|
51
|
+
* // Find all "follows" connections from 456 to 123 (reverse direction)
|
|
52
|
+
* const reverseConnections = await GiveConnection(123, 456, "follows", true);
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* This function:
|
|
57
|
+
* - First uses GetAllTheConnectionsByTypeAndOfTheConcept to get typed connections
|
|
58
|
+
* - Then filters by the destination concept ID
|
|
59
|
+
* - Forward (reverse=false): Returns connections from ofTheConceptId to toTheConceptId
|
|
60
|
+
* - Reverse (reverse=true): Returns connections from toTheConceptId to ofTheConceptId
|
|
61
|
+
* - Useful for finding specific connection instances between two concepts
|
|
62
|
+
* - Returns empty array if no matching connections exist
|
|
63
|
+
*/
|
|
64
|
+
export declare function GiveConnection(ofTheConceptId: number, toTheConceptId: number, linker: string, reverse?: boolean): Promise<Connection[]>;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Concept deletion service for the CCS-JS system.
|
|
3
|
+
* This module provides comprehensive functionality for deleting concepts from the system,
|
|
4
|
+
* including removal from all cache structures (binary trees, type trees, character trees),
|
|
5
|
+
* local database cleanup, and backend synchronization.
|
|
6
|
+
* @module Services/DeleteConcept
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Deletes a concept from the entire CCS-JS system, including all caches and the backend.
|
|
10
|
+
*
|
|
11
|
+
* This function performs a comprehensive deletion of a concept by removing it from multiple
|
|
12
|
+
* data structures and storage layers:
|
|
13
|
+
* 1. Retrieves the concept to get its metadata (typeId, characterValue)
|
|
14
|
+
* 2. Removes the concept from the main BinaryTree index
|
|
15
|
+
* 3. Removes it from the BinaryTypeTree (type-based indexing)
|
|
16
|
+
* 4. Removes it from the BinaryCharacterTree (character-based indexing)
|
|
17
|
+
* 5. Removes it from the local IndexedDB database
|
|
18
|
+
* 6. Deletes it from the backend server
|
|
19
|
+
*
|
|
20
|
+
* This ensures complete cleanup across all layers of the application, maintaining data
|
|
21
|
+
* consistency and preventing orphaned references. The deletion is performed in a specific
|
|
22
|
+
* order to ensure safe removal from all dependent structures.
|
|
23
|
+
*
|
|
24
|
+
* @param id - The unique identifier of the concept to delete
|
|
25
|
+
* @param token - Optional authentication token for backend deletion. If not provided,
|
|
26
|
+
* the function will attempt deletion without authentication
|
|
27
|
+
* @returns A promise that resolves to a boolean indicating whether the backend deletion was successful
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* // Delete a concept with authentication
|
|
32
|
+
* import { DeleteConceptById } from './DeleteConcept';
|
|
33
|
+
*
|
|
34
|
+
* const conceptId = 12345;
|
|
35
|
+
* const authToken = "user-auth-token-xyz";
|
|
36
|
+
*
|
|
37
|
+
* const isDeleted = await DeleteConceptById(conceptId, authToken);
|
|
38
|
+
* if (isDeleted) {
|
|
39
|
+
* console.log("Concept successfully deleted from all systems");
|
|
40
|
+
* } else {
|
|
41
|
+
* console.log("Backend deletion failed, but local caches cleared");
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* // Delete a concept without authentication token
|
|
48
|
+
* const conceptId = 67890;
|
|
49
|
+
* const result = await DeleteConceptById(conceptId);
|
|
50
|
+
* console.log(`Deletion status: ${result}`);
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* // Delete multiple concepts in sequence
|
|
56
|
+
* const conceptIds = [123, 456, 789];
|
|
57
|
+
* const authToken = "user-token";
|
|
58
|
+
*
|
|
59
|
+
* for (const id of conceptIds) {
|
|
60
|
+
* const deleted = await DeleteConceptById(id, authToken);
|
|
61
|
+
* if (!deleted) {
|
|
62
|
+
* console.error(`Failed to delete concept ${id}`);
|
|
63
|
+
* }
|
|
64
|
+
* }
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* // Delete concept with error handling
|
|
70
|
+
* try {
|
|
71
|
+
* const conceptId = 999;
|
|
72
|
+
* const isDeleted = await DeleteConceptById(conceptId, "auth-token");
|
|
73
|
+
*
|
|
74
|
+
* if (isDeleted) {
|
|
75
|
+
* // Update UI to reflect deletion
|
|
76
|
+
* updateConceptList();
|
|
77
|
+
* }
|
|
78
|
+
* } catch (error) {
|
|
79
|
+
* console.error("Error during concept deletion:", error);
|
|
80
|
+
* }
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @remarks
|
|
84
|
+
* Important implementation details and considerations:
|
|
85
|
+
*
|
|
86
|
+
* **Deletion Order:**
|
|
87
|
+
* The function follows a specific deletion sequence:
|
|
88
|
+
* 1. First retrieves concept data (needed for type and character indices)
|
|
89
|
+
* 2. Removes from main binary tree (ID-based index)
|
|
90
|
+
* 3. Removes from type tree (type-based index)
|
|
91
|
+
* 4. Removes from character tree (character-based index)
|
|
92
|
+
* 5. Removes from local database (IndexedDB)
|
|
93
|
+
* 6. Finally deletes from backend server
|
|
94
|
+
*
|
|
95
|
+
* **Cache Consistency:**
|
|
96
|
+
* - Removes the concept from all three binary tree structures
|
|
97
|
+
* - BinaryTree: Main ID-based concept index
|
|
98
|
+
* - BinaryTypeTree: Type-categorized concept index
|
|
99
|
+
* - BinaryCharacterTree: Character/name-based concept index
|
|
100
|
+
* - This ensures no dangling references remain in any cache
|
|
101
|
+
*
|
|
102
|
+
* **Local Database:**
|
|
103
|
+
* - Uses removeFromDatabase to clear from IndexedDB
|
|
104
|
+
* - This is synchronous local storage cleanup
|
|
105
|
+
* - Ensures offline-first capability remains consistent
|
|
106
|
+
*
|
|
107
|
+
* **Backend Synchronization:**
|
|
108
|
+
* - Calls DeleteTheConcept API to remove from server
|
|
109
|
+
* - Uses optional authentication token
|
|
110
|
+
* - Returns backend deletion status
|
|
111
|
+
* - Local cleanup happens regardless of backend success
|
|
112
|
+
*
|
|
113
|
+
* **Error Handling:**
|
|
114
|
+
* - If GetTheConcept fails, the function will throw
|
|
115
|
+
* - Tree removal operations are awaited but may not throw
|
|
116
|
+
* - Backend deletion status is returned but doesn't affect local cleanup
|
|
117
|
+
* - Consider wrapping in try-catch for production use
|
|
118
|
+
*
|
|
119
|
+
* **Side Effects:**
|
|
120
|
+
* - Permanently removes concept from all storage layers
|
|
121
|
+
* - Cannot be undone without re-creating the concept
|
|
122
|
+
* - May orphan connections that reference this concept
|
|
123
|
+
* - Consider deleting associated connections first
|
|
124
|
+
*
|
|
125
|
+
* **Performance:**
|
|
126
|
+
* - Multiple async operations performed sequentially
|
|
127
|
+
* - May take longer for concepts with complex relationships
|
|
128
|
+
* - Consider using connection cleanup functions before deletion
|
|
129
|
+
*
|
|
130
|
+
* @see {@link DeleteTheConcept} for backend deletion API
|
|
131
|
+
* @see {@link GetTheConcept} for concept retrieval
|
|
132
|
+
* @see {@link BinaryTree} for main concept indexing
|
|
133
|
+
* @see {@link BinaryTypeTree} for type-based indexing
|
|
134
|
+
* @see {@link BinaryCharacterTree} for character-based indexing
|
|
135
|
+
* @see {@link DeleteConnectionById} for deleting associated connections
|
|
136
|
+
*/
|
|
137
|
+
export declare function DeleteConceptById(id: number, token?: string): Promise<boolean>;
|