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.
Files changed (188) hide show
  1. package/README.md +1148 -11
  2. package/dist/bundle.js +1 -0
  3. package/dist/types/Api/Create/CreateTheCharacter.d.ts +45 -0
  4. package/dist/types/Api/Create/CreateTheConceptApi.d.ts +52 -0
  5. package/dist/types/Api/Create/CreateTheConnectionApi.d.ts +53 -0
  6. package/dist/types/Api/Create/CreateTheTextData.d.ts +58 -0
  7. package/dist/types/Api/Delete/DeleteConceptInBackend.d.ts +44 -0
  8. package/dist/types/Api/DeleteConnectionApiBulk.d.ts +56 -0
  9. package/dist/types/Api/DeleteTheConcept.d.ts +65 -0
  10. package/dist/types/Api/DeleteTheConnection.d.ts +77 -0
  11. package/dist/types/Api/GetAiData.d.ts +37 -0
  12. package/dist/types/Api/GetAllConcepts.d.ts +43 -0
  13. package/dist/types/Api/GetAllConceptsByType.d.ts +46 -0
  14. package/dist/types/Api/GetAllConnections.d.ts +49 -0
  15. package/dist/types/Api/GetAllConnectionsOfComposition.d.ts +82 -0
  16. package/dist/types/Api/GetAllConnectionsOfCompositionBulk.d.ts +93 -0
  17. package/dist/types/Api/GetAllLinkerConnectionsFromTheConcept.d.ts +54 -0
  18. package/dist/types/Api/GetAllLinkerConnectionsToTheConcept.d.ts +63 -0
  19. package/dist/types/Api/GetAllPrefetchConnections.d.ts +52 -0
  20. package/dist/types/Api/GetCharacterDataByCharacter.d.ts +33 -0
  21. package/dist/types/Api/GetCompositionConnectionsBetweenTwoConcepts.d.ts +41 -0
  22. package/dist/types/Api/GetConcept.d.ts +49 -0
  23. package/dist/types/Api/GetConceptBulk.d.ts +71 -0
  24. package/dist/types/Api/GetConceptByCharacterAndType.d.ts +78 -0
  25. package/dist/types/Api/GetConceptByCharacterValue.d.ts +49 -0
  26. package/dist/types/Api/GetConnection.d.ts +51 -0
  27. package/dist/types/Api/GetConnectionBulk.d.ts +48 -0
  28. package/dist/types/Api/GetConnectionOfTheConcept.d.ts +52 -0
  29. package/dist/types/Api/GetConnectionToTheConcept.d.ts +58 -0
  30. package/dist/types/Api/GetReservedConnectionIds.d.ts +37 -0
  31. package/dist/types/Api/GetReservedIds.d.ts +38 -0
  32. package/dist/types/Api/Login.d.ts +39 -0
  33. package/dist/types/Api/MakeTheNameInBackend.d.ts +40 -0
  34. package/dist/types/Api/MakeTheTypeConceptApi.d.ts +42 -0
  35. package/dist/types/Api/RecursiveSearch.d.ts +44 -0
  36. package/dist/types/Api/Search/FreeschemaQueryApi.d.ts +48 -0
  37. package/dist/types/Api/Search/Search.d.ts +68 -0
  38. package/dist/types/Api/Search/SearchInternalApi.d.ts +71 -0
  39. package/dist/types/Api/Search/SearchLinkMultipleApi.d.ts +92 -0
  40. package/dist/types/Api/Search/SearchWithLinker.d.ts +99 -0
  41. package/dist/types/Api/SearchConcept/GetConceptByCharacterAndCategoryApi.d.ts +41 -0
  42. package/dist/types/Api/SearchConcept/GetConceptByCharacterAndCategoryDirect.d.ts +49 -0
  43. package/dist/types/Api/Session/CreateSession.d.ts +47 -0
  44. package/dist/types/Api/Session/CreateSessionVisit.d.ts +44 -0
  45. package/dist/types/Api/Signin.d.ts +51 -0
  46. package/dist/types/Api/Signup.d.ts +47 -0
  47. package/dist/types/Api/View/ViewInternalDataApi.d.ts +51 -0
  48. package/dist/types/Constants/ApiConstants.d.ts +249 -0
  49. package/dist/types/Constants/FormatConstants.d.ts +87 -0
  50. package/dist/types/DataStructures/BaseUrl.d.ts +262 -0
  51. package/dist/types/DataStructures/BinaryCharacterTree.d.ts +227 -0
  52. package/dist/types/DataStructures/BinaryTree.d.ts +151 -0
  53. package/dist/types/DataStructures/BinaryTypeTree.d.ts +211 -0
  54. package/dist/types/DataStructures/CharacterRepository.d.ts +117 -0
  55. package/dist/types/DataStructures/Composition/Composition.d.ts +117 -0
  56. package/dist/types/DataStructures/Composition/CompositionBinaryTree.d.ts +114 -0
  57. package/dist/types/DataStructures/Composition/CompositionNode.d.ts +223 -0
  58. package/dist/types/DataStructures/Concept.d.ts +139 -0
  59. package/dist/types/DataStructures/ConceptData.d.ts +317 -0
  60. package/dist/types/DataStructures/ConceptsToDraw.d.ts +179 -0
  61. package/dist/types/DataStructures/Connection.d.ts +103 -0
  62. package/dist/types/DataStructures/ConnectionBinaryTree/ConnectionBinaryTree.d.ts +126 -0
  63. package/dist/types/DataStructures/ConnectionBinaryTree/ConnectionNode.d.ts +193 -0
  64. package/dist/types/DataStructures/ConnectionBinaryTree/ConnectionTypeTree.d.ts +95 -0
  65. package/dist/types/DataStructures/ConnectionData.d.ts +209 -0
  66. package/dist/types/DataStructures/Count/CountInfo.d.ts +79 -0
  67. package/dist/types/DataStructures/FilterSearch.d.ts +93 -0
  68. package/dist/types/DataStructures/IdentifierFlags.d.ts +45 -0
  69. package/dist/types/DataStructures/Local/LConcept.d.ts +126 -0
  70. package/dist/types/DataStructures/Local/LConnection.d.ts +101 -0
  71. package/dist/types/DataStructures/Local/LNode.d.ts +217 -0
  72. package/dist/types/DataStructures/Local/LocalBinaryCharacterTree.d.ts +145 -0
  73. package/dist/types/DataStructures/Local/LocalBinaryTree.d.ts +147 -0
  74. package/dist/types/DataStructures/Local/LocalBinaryTypeTree.d.ts +160 -0
  75. package/dist/types/DataStructures/Local/LocalConceptData.d.ts +114 -0
  76. package/dist/types/DataStructures/Local/LocalConnectionData.d.ts +125 -0
  77. package/dist/types/DataStructures/Local/LocalSyncData.d.ts +103 -0
  78. package/dist/types/DataStructures/Node.d.ts +29 -0
  79. package/dist/types/DataStructures/PatcherStructure.d.ts +94 -0
  80. package/dist/types/DataStructures/ReferentInfo.d.ts +75 -0
  81. package/dist/types/DataStructures/ReservedIds.d.ts +111 -0
  82. package/dist/types/DataStructures/Responses/ErrorResponse.d.ts +236 -0
  83. package/dist/types/DataStructures/Responses/StandardResponses.d.ts +71 -0
  84. package/dist/types/DataStructures/Returner.d.ts +66 -0
  85. package/dist/types/DataStructures/Search/FreeschemaQuery.d.ts +187 -0
  86. package/dist/types/DataStructures/Search/SearchStructure.d.ts +78 -0
  87. package/dist/types/DataStructures/SearchQuery.d.ts +146 -0
  88. package/dist/types/DataStructures/Security/TokenStorage.d.ts +51 -0
  89. package/dist/types/DataStructures/Session/SessionData.d.ts +131 -0
  90. package/dist/types/DataStructures/SettingData.d.ts +37 -0
  91. package/dist/types/DataStructures/Settings.d.ts +31 -0
  92. package/dist/types/DataStructures/SigninModel.d.ts +54 -0
  93. package/dist/types/DataStructures/SignupModel.d.ts +54 -0
  94. package/dist/types/DataStructures/SyncData.d.ts +232 -0
  95. package/dist/types/DataStructures/TheCharacter.d.ts +100 -0
  96. package/dist/types/DataStructures/TheTexts.d.ts +106 -0
  97. package/dist/types/DataStructures/Transaction/Transaction.d.ts +320 -0
  98. package/dist/types/DataStructures/User/UserBinaryTree.d.ts +132 -0
  99. package/dist/types/DataStructures/User/UserNode.d.ts +150 -0
  100. package/dist/types/Database/GetConceptFromIndexDb.d.ts +9 -0
  101. package/dist/types/Database/NoIndexDb.d.ts +178 -0
  102. package/dist/types/Database/indexdblocal.d.ts +45 -0
  103. package/dist/types/Database/indexeddb.d.ts +46 -0
  104. package/dist/types/Drawing/ConceptDraw.d.ts +29 -0
  105. package/dist/types/Drawing/ConceptEvents.d.ts +47 -0
  106. package/dist/types/Helpers/CheckIfExists.d.ts +169 -0
  107. package/dist/types/Helpers/RemoveFromArray.d.ts +72 -0
  108. package/dist/types/Helpers/UniqueInsert.d.ts +29 -0
  109. package/dist/types/Services/CheckForConnectionDeletion.d.ts +193 -0
  110. package/dist/types/Services/Common/DecodeCountInfo.d.ts +57 -0
  111. package/dist/types/Services/Common/ErrorPosting.d.ts +51 -0
  112. package/dist/types/Services/Common/RegexFunction.d.ts +29 -0
  113. package/dist/types/Services/Composition/BuildComposition.d.ts +40 -0
  114. package/dist/types/Services/Composition/CompositionCache.d.ts +93 -0
  115. package/dist/types/Services/Composition/CreateCompositionCache.d.ts +46 -0
  116. package/dist/types/Services/ConceptFinding/GetConceptByCharacterAndCategory.d.ts +5 -0
  117. package/dist/types/Services/Conversion/ConvertConcepts.d.ts +90 -0
  118. package/dist/types/Services/CreateBinaryTreeFromData.d.ts +39 -0
  119. package/dist/types/Services/CreateCharacterBinaryTreeFromData.d.ts +43 -0
  120. package/dist/types/Services/CreateConnectionBetweenTwoConcepts.d.ts +211 -0
  121. package/dist/types/Services/CreateDefaultConcept.d.ts +117 -0
  122. package/dist/types/Services/CreateTheComposition.d.ts +103 -0
  123. package/dist/types/Services/CreateTheConcept.d.ts +184 -0
  124. package/dist/types/Services/CreateTheConnection.d.ts +61 -0
  125. package/dist/types/Services/CreateTheConnectionGeneral.d.ts +132 -0
  126. package/dist/types/Services/CreateTypeTreeFromData.d.ts +44 -0
  127. package/dist/types/Services/Delete/DeleteConnectionByType.d.ts +60 -0
  128. package/dist/types/Services/Delete/GetAllConnectionByType.d.ts +64 -0
  129. package/dist/types/Services/DeleteConcept.d.ts +137 -0
  130. package/dist/types/Services/DeleteConnection.d.ts +196 -0
  131. package/dist/types/Services/FindConeceptsFromConnection.d.ts +181 -0
  132. package/dist/types/Services/FindConnectionsOfCompositionBulkInMemory.d.ts +159 -0
  133. package/dist/types/Services/GenerateHexNumber.d.ts +65 -0
  134. package/dist/types/Services/GetAccessIdOfUser.d.ts +0 -0
  135. package/dist/types/Services/GetComposition.d.ts +342 -0
  136. package/dist/types/Services/GetCompositionBulk.d.ts +259 -0
  137. package/dist/types/Services/GetCompositionList.d.ts +132 -0
  138. package/dist/types/Services/GetConceptByCharacter.d.ts +87 -0
  139. package/dist/types/Services/GetConnections.d.ts +74 -0
  140. package/dist/types/Services/GetDataFromIndexDb.d.ts +81 -0
  141. package/dist/types/Services/GetLink.d.ts +107 -0
  142. package/dist/types/Services/GetLinkerConnectionFromConcept.d.ts +102 -0
  143. package/dist/types/Services/GetMaximumConnectionSyncTime.d.ts +59 -0
  144. package/dist/types/Services/GetRelation.d.ts +167 -0
  145. package/dist/types/Services/GetTheConcept.d.ts +73 -0
  146. package/dist/types/Services/GetTheReferent.d.ts +76 -0
  147. package/dist/types/Services/InitializeSystem.d.ts +121 -0
  148. package/dist/types/Services/Local/CreateConnectionListFromDatat.d.ts +0 -0
  149. package/dist/types/Services/Local/CreateDefaultLConcept.d.ts +50 -0
  150. package/dist/types/Services/Local/CreateLocalBinaryTreeFromData.d.ts +50 -0
  151. package/dist/types/Services/Local/CreateLocalBinaryTypeTreeFromData.d.ts +55 -0
  152. package/dist/types/Services/Local/CreateLocalCharacterBinaryTree.d.ts +61 -0
  153. package/dist/types/Services/Local/CreateTheCompositionLocal.d.ts +72 -0
  154. package/dist/types/Services/Local/CreateTheConceptLocal.d.ts +60 -0
  155. package/dist/types/Services/Local/CreateTheConnectionLocal.d.ts +58 -0
  156. package/dist/types/Services/Local/GetCompositionListLocal.d.ts +105 -0
  157. package/dist/types/Services/Local/GetCompositionLocal.d.ts +98 -0
  158. package/dist/types/Services/Local/GetConceptByCharacterLocal.d.ts +58 -0
  159. package/dist/types/Services/Local/MakeTheConceptLocal.d.ts +73 -0
  160. package/dist/types/Services/Local/MakeTheInstanceConceptLocal.d.ts +91 -0
  161. package/dist/types/Services/Local/MakeTheTypeLocal.d.ts +73 -0
  162. package/dist/types/Services/Local/UpdateCompositionLocal.d.ts +103 -0
  163. package/dist/types/Services/MakeTheCharacter.d.ts +76 -0
  164. package/dist/types/Services/MakeTheCharacterData.d.ts +67 -0
  165. package/dist/types/Services/MakeTheConcept.d.ts +2 -0
  166. package/dist/types/Services/MakeTheInstanceConcept.d.ts +78 -0
  167. package/dist/types/Services/MakeTheLocalConcept.d.ts +0 -0
  168. package/dist/types/Services/MakeTheName.d.ts +83 -0
  169. package/dist/types/Services/MakeTheTimestamp.d.ts +70 -0
  170. package/dist/types/Services/MakeTheTypeConcept.d.ts +71 -0
  171. package/dist/types/Services/Mqtt/publishMessage.d.ts +28 -0
  172. package/dist/types/Services/Mqtt/subscribeMessage.d.ts +23 -0
  173. package/dist/types/Services/PatchComposition.d.ts +107 -0
  174. package/dist/types/Services/Search/DataIdFormat.d.ts +104 -0
  175. package/dist/types/Services/Search/FormatData.d.ts +101 -0
  176. package/dist/types/Services/Search/JustIdFormat.d.ts +98 -0
  177. package/dist/types/Services/Search/SearchLinkInternal.d.ts +30 -0
  178. package/dist/types/Services/Search/SearchLinkMultiple.d.ts +61 -0
  179. package/dist/types/Services/Search/SearchWithTypeAndLinker.d.ts +101 -0
  180. package/dist/types/Services/Search/orderingConnections.d.ts +36 -0
  181. package/dist/types/Services/Security/GetRequestHeader.d.ts +10 -0
  182. package/dist/types/Services/SplitStrings.d.ts +51 -0
  183. package/dist/types/Services/UpdateComposition.d.ts +125 -0
  184. package/dist/types/Services/User/UserTranslation.d.ts +108 -0
  185. package/dist/types/Services/View/ViewInternalData.d.ts +33 -0
  186. package/dist/types/WrapperFunctions/SchemaQueryObservable.d.ts +159 -0
  187. package/dist/types/app.d.ts +162 -0
  188. package/package.json +1 -1
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Character-Based Binary Tree Data Loading Service
3
+ *
4
+ * This module provides functionality for creating and populating a character-based binary tree
5
+ * data structure from persisted concept data. The tree is organized by character values,
6
+ * allowing for efficient character-based searching and retrieval of concepts.
7
+ *
8
+ * @module CreateCharacterBinaryTreeFromData
9
+ */
10
+ /**
11
+ * Creates and populates a character-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 character values. Each concept is wrapped in a Node
15
+ * with its characterValue as the key, enabling efficient character-based lookups and searches.
16
+ *
17
+ * The BinaryCharacterTree allows for alphabetical or character-based organization of concepts,
18
+ * which is useful for features like autocomplete, search suggestions, or character-based
19
+ * filtering of concept data.
20
+ *
21
+ * @returns A promise that resolves when the character binary tree has been fully populated
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * // Build the character-based binary tree from database
26
+ * await CreateCharacterBinaryTreeFromData();
27
+ *
28
+ * // The tree can now be used for character-based searches
29
+ * const results = BinaryCharacterTree.search('a');
30
+ * console.log('Concepts starting with "a":', results);
31
+ * ```
32
+ *
33
+ * @remarks
34
+ * - Creates a new BinaryCharacterTree instance at the start of execution
35
+ * - Each concept is converted to a Node using its characterValue property as the key
36
+ * - The tree is built incrementally by adding one node at a time
37
+ * - Character values determine the position in the binary tree for O(log n) search performance
38
+ *
39
+ * @see {@link BinaryCharacterTree.addNodeToTree} for how nodes are inserted into the tree
40
+ * @see {@link Node} for the node data structure used in the tree
41
+ * @see {@link getFromDatabaseWithTypeOld} for database retrieval implementation
42
+ */
43
+ export declare function CreateCharacterBinaryTreeFromData(): Promise<void>;
@@ -0,0 +1,211 @@
1
+ /**
2
+ * Typed Connection Creation Between Concepts
3
+ *
4
+ * This module provides specialized functions for creating semantic, bidirectional, and
5
+ * counted connections between concepts. It implements a sophisticated connection naming
6
+ * scheme that incorporates concept types and relationship semantics, enabling queries
7
+ * like "show all books_s_authored_s_by author" in the system.
8
+ *
9
+ * The module supports:
10
+ * - Forward and backward (bidirectional) connections
11
+ * - Automatic relationship counting
12
+ * - Type-aware connection naming patterns
13
+ *
14
+ * @module CreateConnectionBetweenTwoConcepts
15
+ */
16
+ import { Concept } from "../DataStructures/Concept";
17
+ import { Connection } from "../DataStructures/Connection";
18
+ /**
19
+ * Creates a typed connection between two concepts with optional bidirectionality and counting.
20
+ *
21
+ * This function establishes semantic connections using a naming pattern that includes the
22
+ * concept types. For example, connecting a "book" to an "author" with linker "authored"
23
+ * creates a connection of type "books_s_authored_s". This enables type-aware querying and
24
+ * relationship navigation in the system.
25
+ *
26
+ * The function can optionally create bidirectional connections (both directions) and
27
+ * maintain relationship counts, which is useful for analytics and relationship tracking.
28
+ *
29
+ * @param ofTheConcept - The source concept from which the connection originates
30
+ * @param toTheConcept - The target concept to which the connection points
31
+ * @param linker - The semantic relationship name (e.g., "authored", "contains", "belongs_to")
32
+ * @param both - If true, creates connections in both directions (default: false)
33
+ * @param count - If true, maintains a count of relationships for this linker type (default: false)
34
+ *
35
+ * @returns A promise that resolves to the created forward Connection object
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * // Create a one-way "authored" connection
40
+ * const authorConcept = await GetTheConcept(123); // type: "author"
41
+ * const bookConcept = await GetTheConcept(456); // type: "book"
42
+ *
43
+ * const connection = await CreateConnectionBetweenTwoConcepts(
44
+ * authorConcept,
45
+ * bookConcept,
46
+ * "authored",
47
+ * false,
48
+ * false
49
+ * );
50
+ * // Creates connection type: "authors_s_authored_s"
51
+ * ```
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * // Create bidirectional "friends_with" connections with counting
56
+ * const userConcept1 = await GetTheConcept(789);
57
+ * const userConcept2 = await GetTheConcept(101);
58
+ *
59
+ * await CreateConnectionBetweenTwoConcepts(
60
+ * userConcept1,
61
+ * userConcept2,
62
+ * "friends_with",
63
+ * true, // Create both directions
64
+ * true // Enable counting
65
+ * );
66
+ * // Creates: "users_s_friends_with_s" and "users_s_friends_with_by"
67
+ * // Maintains count concepts for relationship tracking
68
+ * ```
69
+ *
70
+ * @remarks
71
+ * - Forward connection type pattern: `{sourceType}_s_{linker}_s`
72
+ * - Backward connection type pattern: `{targetType}_s_{linker}_by`
73
+ * - Count concept pattern: `{type}_s_{linker}_count`
74
+ * - Uses session information ID 999 and access level 4 as defaults
75
+ * - Counting creates/updates a separate count concept for relationship analytics
76
+ * - The backward connection is created first if both=true
77
+ *
78
+ * @see {@link CreateConnectionBetweenTwoConceptsGeneral} for the version using reserved IDs
79
+ * @see {@link CountRelationship} for understanding how relationship counting works
80
+ * @see {@link MakeTheInstanceConcept} for connection type concept creation
81
+ */
82
+ export declare function CreateConnectionBetweenTwoConcepts(ofTheConcept: Concept, toTheConcept: Concept, linker: string, both?: boolean, count?: boolean): Promise<Connection>;
83
+ /**
84
+ * Maintains a count of relationships for a specific connection type on a concept.
85
+ *
86
+ * This function implements a counting mechanism that tracks how many times a particular
87
+ * relationship type has been used with a concept. It retrieves any existing count,
88
+ * increments it, creates a new count concept, and connects it to the source concept.
89
+ *
90
+ * The counting system works by:
91
+ * 1. Looking for existing count connections using a special count connection type
92
+ * 2. Retrieving the current count value from the connected count concept
93
+ * 3. Incrementing the count
94
+ * 4. Deleting old count connections
95
+ * 5. Creating a new count concept with the updated value
96
+ * 6. Connecting the new count concept back to the source
97
+ *
98
+ * This enables analytics like "how many books has this author authored?" or
99
+ * "how many followers does this user have?"
100
+ *
101
+ * @param linker - The relationship name being counted (e.g., "authored_s", "follows_s")
102
+ * @param concept - The concept for which relationships are being counted
103
+ * @param passedUserId - Optional user ID to use instead of the concept's userId (default: null, uses concept.userId)
104
+ *
105
+ * @returns A promise that resolves when the count has been updated
106
+ *
107
+ * @example
108
+ * ```typescript
109
+ * // Count how many times an author has "authored" something
110
+ * const authorConcept = await GetTheConcept(123);
111
+ * await CountRelationship("authored_s", authorConcept);
112
+ *
113
+ * // Later, retrieve the count
114
+ * const countConnectionType = await GetConceptByCharacter("authors_s_authored_s_count");
115
+ * const countConnections = await GetConnectionOfTheConcept(
116
+ * countConnectionType.id,
117
+ * authorConcept.id,
118
+ * authorConcept.userId
119
+ * );
120
+ * const countConcept = await GetTheConcept(countConnections[0].toTheConceptId);
121
+ * console.log("Author has written", countConcept.characterValue, "books");
122
+ * ```
123
+ *
124
+ * @example
125
+ * ```typescript
126
+ * // Count relationships with a specific user ID
127
+ * const userConcept = await GetTheConcept(456);
128
+ * await CountRelationship("follows_s", userConcept, 999);
129
+ * ```
130
+ *
131
+ * @remarks
132
+ * - Count connection type pattern: `{conceptType}_s_{linker}_count`
133
+ * - Creates a new "count" type concept with the numeric value as characterValue
134
+ * - Deletes all previous count connections before creating the new one
135
+ * - If no existing count is found, starts from 1
136
+ * - If parsing the count value fails, defaults to 0 and increments to 1
137
+ * - Uses session information ID 999, access level 4, and security ID 999
138
+ * - The count concept itself is of type "count"
139
+ *
140
+ * @see {@link CreateConnectionBetweenTwoConcepts} for functions that use counting
141
+ * @see {@link GetConnectionOfTheConcept} for retrieving count connections
142
+ * @see {@link MakeTheInstanceConcept} for creating count concepts
143
+ */
144
+ export declare function CountRelationship(linker: string, concept: Concept, passedUserId?: number | null): Promise<void>;
145
+ /**
146
+ * Creates a typed connection with reserved IDs between two concepts.
147
+ *
148
+ * This is the production-ready version of CreateConnectionBetweenTwoConcepts that uses
149
+ * reserved IDs and the CreateTheConnectionGeneral function. It provides the same
150
+ * semantic connection naming and bidirectional support, but ensures connections are
151
+ * properly persisted with system-reserved IDs.
152
+ *
153
+ * Unlike the basic version, this function uses CreateTheConnectionGeneral instead of
154
+ * directly creating Connection objects, which means connections get proper ID reservation,
155
+ * update flags, and transaction tracking.
156
+ *
157
+ * @param ofTheConcept - The source concept from which the connection originates
158
+ * @param toTheConcept - The target concept to which the connection points
159
+ * @param linker - The semantic relationship name (e.g., "authored", "contains", "belongs_to")
160
+ * @param both - If true, creates connections in both directions (default: false)
161
+ * @param count - If true, maintains a count of relationships for this linker type (default: false)
162
+ *
163
+ * @returns A promise that resolves to the created forward Connection object with reserved ID
164
+ *
165
+ * @example
166
+ * ```typescript
167
+ * // Create a production-grade bidirectional "collaborates_with" connection
168
+ * const researcher1 = await GetTheConcept(123);
169
+ * const researcher2 = await GetTheConcept(456);
170
+ *
171
+ * const connection = await CreateConnectionBetweenTwoConceptsGeneral(
172
+ * researcher1,
173
+ * researcher2,
174
+ * "collaborates_with",
175
+ * true, // Bidirectional
176
+ * true // Track counts
177
+ * );
178
+ *
179
+ * console.log("Connection ID:", connection.id);
180
+ * // Both researchers now have collaboration connections and counts
181
+ * ```
182
+ *
183
+ * @example
184
+ * ```typescript
185
+ * // Create a one-way "belongs_to" connection with reserved ID
186
+ * const itemConcept = await GetTheConcept(789);
187
+ * const categoryConcept = await GetTheConcept(101);
188
+ *
189
+ * await CreateConnectionBetweenTwoConceptsGeneral(
190
+ * itemConcept,
191
+ * categoryConcept,
192
+ * "belongs_to",
193
+ * false,
194
+ * false
195
+ * );
196
+ * ```
197
+ *
198
+ * @remarks
199
+ * - Uses CreateTheConnectionGeneral for proper ID reservation and persistence
200
+ * - Forward connection type pattern: `{sourceType}_s_{linker}_s`
201
+ * - Backward connection type pattern: `{targetType}_s_{linker}_by`
202
+ * - Backward connections still use basic Connection creation (not CreateTheConnectionGeneral)
203
+ * - Uses session information ID 999, order 1000, and access level 4
204
+ * - Connection is marked for update (toUpdate = true) via CreateTheConnectionGeneral
205
+ * - Recommended for production use over CreateConnectionBetweenTwoConcepts
206
+ *
207
+ * @see {@link CreateConnectionBetweenTwoConcepts} for the temporary version
208
+ * @see {@link CreateTheConnectionGeneral} for the underlying connection creation
209
+ * @see {@link CountRelationship} for relationship counting implementation
210
+ */
211
+ export declare function CreateConnectionBetweenTwoConceptsGeneral(ofTheConcept: Concept, toTheConcept: Concept, linker: string, both?: boolean, count?: boolean): Promise<Connection>;
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Default Concept Factory
3
+ *
4
+ * This module provides utility functions for creating default/empty concept instances
5
+ * and formatting date values. These utilities are used throughout the system when
6
+ * initializing concepts or handling date operations.
7
+ *
8
+ * @module CreateDefaultConcept
9
+ */
10
+ import { Concept } from "../DataStructures/Concept";
11
+ /**
12
+ * Creates a default concept with zero/empty values and current timestamps.
13
+ *
14
+ * This factory function is used throughout the system when a concept instance is needed
15
+ * but not yet populated with real data. It's particularly useful as a placeholder during
16
+ * concept retrieval operations, initialization, or when a null-safe concept object is required.
17
+ *
18
+ * The created concept has all numeric fields set to 0, characterValue set to "0",
19
+ * isComposition set to false, and timestamps set to the current date/time.
20
+ *
21
+ * @returns A new Concept instance with default values
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * // Use as a placeholder during concept retrieval
26
+ * let concept = CreateDefaultConcept();
27
+ *
28
+ * try {
29
+ * concept = await GetTheConcept(123);
30
+ * } catch (error) {
31
+ * console.log("Using default concept due to error");
32
+ * }
33
+ *
34
+ * if (concept.id === 0) {
35
+ * console.log("Concept not found, using default");
36
+ * }
37
+ * ```
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * // Initialize a concept variable before conditional assignment
42
+ * let resultConcept = CreateDefaultConcept();
43
+ *
44
+ * if (useCache) {
45
+ * resultConcept = await ConceptsData.GetConcept(id);
46
+ * } else {
47
+ * resultConcept = await GetConcept(id);
48
+ * }
49
+ * ```
50
+ *
51
+ * @remarks
52
+ * - All ID fields (id, typeId, userId, etc.) are set to 0
53
+ * - characterValue is set to "0" string
54
+ * - isComposition is set to false
55
+ * - created_on and updated_on are set to current date/time using formatDate()
56
+ * - The concept is not added to any data store; it's just an instance
57
+ * - Commonly used as a null-safe alternative when concept retrieval might fail
58
+ *
59
+ * @see {@link formatDate} for the date formatting function used
60
+ * @see {@link Concept} for the concept data structure
61
+ */
62
+ export declare function CreateDefaultConcept(): Concept;
63
+ /**
64
+ * Formats a Date object into a human-readable string with 12-hour time format.
65
+ *
66
+ * This utility function converts JavaScript Date objects into a consistent string
67
+ * format used throughout the CCS system for timestamps. The format includes the date
68
+ * in MM/DD/YYYY format and time in 12-hour format with AM/PM indicator.
69
+ *
70
+ * The function is primarily used for setting created_on and updated_on timestamps
71
+ * on concepts and connections.
72
+ *
73
+ * @param date - The Date object to format
74
+ *
75
+ * @returns A formatted date string in the pattern "M/D/YYYY h:mm:ss AM/PM"
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * // Format current date
80
+ * const now = new Date();
81
+ * const formatted = formatDate(now);
82
+ * console.log(formatted); // "1/15/2024 3:45:30 PM"
83
+ * ```
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * // Use when creating a concept
88
+ * const concept = new Concept(
89
+ * 123,
90
+ * 456,
91
+ * 999,
92
+ * // ... other fields
93
+ * formatDate(new Date()), // created_on
94
+ * formatDate(new Date()) // updated_on
95
+ * );
96
+ * ```
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * // Format a specific date
101
+ * const specificDate = new Date(2024, 0, 15, 15, 30, 45);
102
+ * console.log(formatDate(specificDate)); // "1/15/2024 3:30:45 PM"
103
+ * ```
104
+ *
105
+ * @remarks
106
+ * - Months are 1-indexed in output (January = 1) but 0-indexed in JavaScript Date
107
+ * - Uses 12-hour time format with AM/PM
108
+ * - Minutes and seconds are zero-padded to 2 digits
109
+ * - Hours are NOT zero-padded (e.g., "3:05 PM" not "03:05 PM")
110
+ * - Date components are NOT zero-padded (e.g., "1/5/2024" not "01/05/2024")
111
+ * - Output format: "M/D/YYYY h:mm:ss AM/PM"
112
+ * - Midnight (00:00) is represented as "12:00 AM"
113
+ * - Noon (12:00) is represented as "12:00 PM"
114
+ *
115
+ * @see {@link CreateDefaultConcept} which uses this function for timestamps
116
+ */
117
+ export declare function formatDate(date: Date): string;
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Composition Creation Service
3
+ *
4
+ * This module provides functionality for converting JSON objects into interconnected
5
+ * concept structures (compositions) in the Concept Connection System. It recursively
6
+ * traverses JSON structures and creates corresponding concepts and connections,
7
+ * effectively serializing complex data structures into the graph database.
8
+ *
9
+ * This enables storing and retrieving structured data like user profiles, documents,
10
+ * or any hierarchical data within the CCS framework.
11
+ *
12
+ * @module CreateTheComposition
13
+ */
14
+ import { Concept } from "../DataStructures/Concept";
15
+ /**
16
+ * Recursively converts a JSON object into a composition of interconnected concepts.
17
+ *
18
+ * This function is the core serialization mechanism for storing structured data in CCS.
19
+ * It traverses a JSON object recursively, creating concepts for each key-value pair and
20
+ * establishing connections between them to preserve the hierarchical structure.
21
+ *
22
+ * The function handles both object structures (which become nested compositions) and
23
+ * primitive values (which become leaf concepts with character values). The resulting
24
+ * structure can be later reconstructed using GetComposition functions.
25
+ *
26
+ * The recursion works as follows:
27
+ * - Object/nested structures: Create a concept for the key, recurse into the value
28
+ * - Primitive values (string/number): Create a concept with the key as type and value as characterValue
29
+ * - Root level: If no parent concept is provided, creates a new root concept
30
+ *
31
+ * @param json - The JSON object to convert into a composition
32
+ * @param ofTheConceptId - The ID of the parent concept to connect to (null for root level)
33
+ * @param ofTheConceptUserId - The user ID of the parent concept (null for root level)
34
+ * @param mainKey - The ID of the root concept, used as connection type throughout the composition
35
+ * @param userId - The user ID to assign to all created concepts (default: 999)
36
+ * @param accessId - The access level for created concepts (default: 4)
37
+ * @param sessionInformationId - The session ID for tracking this operation (default: 999)
38
+ *
39
+ * @returns A promise that resolves to the main (root) Concept of the created composition
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * // Create a user profile composition
44
+ * const userProfile = {
45
+ * name: "Alice Johnson",
46
+ * age: 30,
47
+ * address: {
48
+ * street: "123 Main St",
49
+ * city: "Springfield",
50
+ * country: "USA"
51
+ * },
52
+ * hobbies: ["reading", "hiking", "photography"]
53
+ * };
54
+ *
55
+ * const rootConcept = await CreateTheComposition(
56
+ * userProfile,
57
+ * null, // No parent, this is root
58
+ * null,
59
+ * null,
60
+ * 999, // User ID
61
+ * 4, // Access level
62
+ * 999 // Session ID
63
+ * );
64
+ *
65
+ * console.log("Profile composition created:", rootConcept.id);
66
+ * // Can later retrieve with: GetComposition(rootConcept.id)
67
+ * ```
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * // Add a nested composition to an existing concept
72
+ * const parentConcept = await GetTheConcept(456);
73
+ * const metadata = {
74
+ * created: "2024-01-15",
75
+ * modified: "2024-01-20",
76
+ * version: 2
77
+ * };
78
+ *
79
+ * const metadataConcept = await CreateTheComposition(
80
+ * metadata,
81
+ * parentConcept.id,
82
+ * parentConcept.userId,
83
+ * parentConcept.id, // Use parent as mainKey
84
+ * parentConcept.userId
85
+ * );
86
+ * ```
87
+ *
88
+ * @remarks
89
+ * - Creates concepts for each JSON key, using the key as the concept's type
90
+ * - Primitive values (strings, numbers) are stored as characterValue in leaf concepts
91
+ * - Nested objects and arrays are recursively converted into sub-compositions
92
+ * - All concepts are connected using the mainKey (root concept ID) as the connection type
93
+ * - Uses temporary connections (via createTheConnection) with random IDs
94
+ * - Default values: userId=999, accessId=4, sessionInformationId=999
95
+ * - The function modifies SyncData by adding all created concepts and connections
96
+ * - Complex objects become type concepts with isComposition=true
97
+ * - Primitive values become instance concepts with isComposition=false
98
+ *
99
+ * @see {@link GetComposition} for reconstructing compositions back to JSON
100
+ * @see {@link MakeTheInstanceConcept} for individual concept creation
101
+ * @see {@link createTheConnection} for connection creation logic
102
+ */
103
+ export default function CreateTheComposition(json: any, ofTheConceptId?: number | null, ofTheConceptUserId?: number | null, mainKey?: number | null, userId?: number | null, accessId?: number | null, sessionInformationId?: number | null): Promise<Concept>;
@@ -0,0 +1,184 @@
1
+ /**
2
+ * Concept creation service module.
3
+ * Provides functions for creating concepts in different modes: normal, temporary, and immediate.
4
+ *
5
+ * @module Services/CreateTheConcept
6
+ * @see https://documentation.freeschema.com/#concept for concept documentation
7
+ */
8
+ import { Concept } from "../DataStructures/Concept";
9
+ import { InnerActions } from "../DataStructures/Transaction/Transaction";
10
+ /**
11
+ * Creates a new concept and adds it to the sync queue for backend synchronization.
12
+ * This is the standard way to create a concept that will be persisted to the backend.
13
+ * The concept is marked as new (isNew=true) and non-temporary (isTemp=false), and
14
+ * added to both SyncData (for backend sync) and the transaction actions list.
15
+ *
16
+ * @param referent - The character/string value representing the concept's content
17
+ * @param userId - The ID of the user creating this concept
18
+ * @param categoryId - The ID of the category concept this concept belongs to
19
+ * @param categoryUserId - The user ID of the category concept owner
20
+ * @param typeId - The ID of the type concept that defines this concept's type
21
+ * @param typeUserId - The user ID of the type concept owner
22
+ * @param referentId - The ID of the referent concept (what this concept refers to)
23
+ * @param referentUserId - The user ID of the referent concept owner
24
+ * @param securityId - The ID of the security concept controlling access
25
+ * @param securityUserId - The user ID of the security concept owner
26
+ * @param accessId - The ID of the access concept defining permissions
27
+ * @param accessUserId - The user ID of the access concept owner
28
+ * @param sessionInformationId - The ID of the session concept for tracking
29
+ * @param sessionInformationUserId - The user ID of the session concept owner
30
+ * @param actions - Transaction object to track all concepts and connections created in this operation
31
+ * @returns A Promise that resolves to the newly created Concept instance
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * // Create a new concept with all required metadata
36
+ * const concept = await CreateTheConcept(
37
+ * 'John Doe', // referent (the actual value)
38
+ * 1, // userId
39
+ * 10, 1, // categoryId, categoryUserId
40
+ * 20, 1, // typeId, typeUserId (e.g., "Person" type)
41
+ * 0, 0, // referentId, referentUserId (no referent)
42
+ * 30, 1, // securityId, securityUserId
43
+ * 40, 1, // accessId, accessUserId
44
+ * 50, 1, // sessionInformationId, sessionInformationUserId
45
+ * { concepts: [], connections: [] } // transaction actions
46
+ * );
47
+ *
48
+ * console.log(concept.id); // Auto-generated unique ID
49
+ * console.log(concept.isNew); // true - will be synced to backend
50
+ * console.log(concept.isTemp); // false - permanent concept
51
+ * ```
52
+ *
53
+ * @remarks
54
+ * - Automatically generates a unique ID using ReservedIds.getId()
55
+ * - Sets creation and update timestamps to current time
56
+ * - Marks concept as new (isNew=true) for backend synchronization
57
+ * - Marks concept as non-temporary (isTemp=false) for persistence
58
+ * - Adds concept to SyncData queue for eventual backend sync
59
+ * - Adds concept to transaction actions for tracking within a transaction context
60
+ * - Does NOT immediately call the backend API; sync happens separately
61
+ *
62
+ * @see CreateTheConceptTemporary for creating temporary concepts
63
+ * @see CreateTheConceptImmediate for creating concepts with immediate backend sync
64
+ * @see Concept for the concept data structure
65
+ * @see SyncData for sync queue management
66
+ * @see ReservedIds for ID generation
67
+ */
68
+ export default function CreateTheConcept(referent: string, userId: number, categoryId: number, categoryUserId: number, typeId: number, typeUserId: number, referentId: number, referentUserId: number, securityId: number, securityUserId: number, accessId: number, accessUserId: number, sessionInformationId: number, sessionInformationUserId: number, actions?: InnerActions): Promise<Concept>;
69
+ /**
70
+ * Creates a temporary concept that is NOT added to the sync queue or persisted to backend.
71
+ * Temporary concepts are useful for UI state management, draft operations, or transient data
72
+ * that doesn't need to be saved. The concept is marked as temporary (isTemp=true) and new (isNew=true).
73
+ *
74
+ * @param referent - The character/string value representing the concept's content
75
+ * @param userId - The ID of the user creating this concept
76
+ * @param categoryId - The ID of the category concept this concept belongs to
77
+ * @param categoryUserId - The user ID of the category concept owner
78
+ * @param typeId - The ID of the type concept that defines this concept's type
79
+ * @param typeUserId - The user ID of the type concept owner
80
+ * @param referentId - The ID of the referent concept (what this concept refers to)
81
+ * @param referentUserId - The user ID of the referent concept owner
82
+ * @param securityId - The ID of the security concept controlling access
83
+ * @param securityUserId - The user ID of the security concept owner
84
+ * @param accessId - The ID of the access concept defining permissions
85
+ * @param accessUserId - The user ID of the access concept owner
86
+ * @param sessionInformationId - The ID of the session concept for tracking
87
+ * @param sessionInformationUserId - The user ID of the session concept owner
88
+ * @returns A Promise that resolves to the newly created temporary Concept instance
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * // Create a temporary concept for UI draft state
93
+ * const draftConcept = await CreateTheConceptTemporary(
94
+ * 'Draft Note', // referent
95
+ * 1, // userId
96
+ * 10, 1, // categoryId, categoryUserId
97
+ * 20, 1, // typeId, typeUserId
98
+ * 0, 0, // referentId, referentUserId
99
+ * 30, 1, // securityId, securityUserId
100
+ * 40, 1, // accessId, accessUserId
101
+ * 50, 1 // sessionInformationId, sessionInformationUserId
102
+ * );
103
+ *
104
+ * console.log(draftConcept.isTemp); // true - won't be synced
105
+ * console.log(draftConcept.isNew); // true - marked as new
106
+ * // This concept will NOT be added to SyncData or saved to backend
107
+ * ```
108
+ *
109
+ * @remarks
110
+ * - Automatically generates a unique ID using ReservedIds.getId()
111
+ * - Sets creation and update timestamps to current time
112
+ * - Marks concept as new (isNew=true) but also temporary (isTemp=true)
113
+ * - Does NOT add concept to SyncData (no backend sync)
114
+ * - Does NOT add concept to transaction actions
115
+ * - Useful for draft states, temporary UI elements, or client-only data
116
+ * - The concept exists only in client memory until explicitly converted/saved
117
+ *
118
+ * @see CreateTheConcept for creating persistent concepts
119
+ * @see CreateTheConceptImmediate for creating concepts with immediate backend sync
120
+ * @see Concept for the concept data structure
121
+ */
122
+ export declare function CreateTheConceptTemporary(referent: string, userId: number, categoryId: number, categoryUserId: number, typeId: number, typeUserId: number, referentId: number, referentUserId: number, securityId: number, securityUserId: number, accessId: number, accessUserId: number, sessionInformationId: number, sessionInformationUserId: number): Promise<Concept>;
123
+ /**
124
+ * Creates a concept and immediately adds it to ConceptsData for instant availability in queries.
125
+ * Unlike CreateTheConcept, this function adds the concept to the in-memory ConceptsData store
126
+ * immediately (not just SyncData), making it instantly searchable. It also sets updateRecursion=true
127
+ * to enable recursive updates. The concept is marked as not new (isNew=false) and non-temporary.
128
+ *
129
+ * @param referent - The character/string value representing the concept's content
130
+ * @param userId - The ID of the user creating this concept
131
+ * @param categoryId - The ID of the category concept this concept belongs to
132
+ * @param categoryUserId - The user ID of the category concept owner
133
+ * @param typeId - The ID of the type concept that defines this concept's type
134
+ * @param typeUserId - The user ID of the type concept owner
135
+ * @param referentId - The ID of the referent concept (what this concept refers to)
136
+ * @param referentUserId - The user ID of the referent concept owner
137
+ * @param securityId - The ID of the security concept controlling access
138
+ * @param securityUserId - The user ID of the security concept owner
139
+ * @param accessId - The ID of the access concept defining permissions
140
+ * @param accessUserId - The user ID of the access concept owner
141
+ * @param sessionInformationId - The ID of the session concept for tracking
142
+ * @param sessionInformationUserId - The user ID of the session concept owner
143
+ * @param actions - Transaction object to track all concepts and connections created in this operation
144
+ * @returns A Promise that resolves to the newly created Concept instance
145
+ *
146
+ * @example
147
+ * ```typescript
148
+ * // Create a concept that's immediately available for queries
149
+ * const concept = await CreateTheConceptImmediate(
150
+ * 'Important User', // referent
151
+ * 1, // userId
152
+ * 10, 1, // categoryId, categoryUserId
153
+ * 20, 1, // typeId, typeUserId
154
+ * 0, 0, // referentId, referentUserId
155
+ * 30, 1, // securityId, securityUserId
156
+ * 40, 1, // accessId, accessUserId
157
+ * 50, 1, // sessionInformationId, sessionInformationUserId
158
+ * { concepts: [], connections: [] } // transaction actions
159
+ * );
160
+ *
161
+ * // Concept is immediately available in ConceptsData
162
+ * const found = ConceptsData.getConceptById(concept.id);
163
+ * console.log(found !== null); // true - immediately findable
164
+ * console.log(concept.isNew); // false - treated as existing
165
+ * console.log(concept.updateRecursion); // true - enables recursive updates
166
+ * ```
167
+ *
168
+ * @remarks
169
+ * - Automatically generates a unique ID using ReservedIds.getId()
170
+ * - Sets creation and update timestamps to current time
171
+ * - Marks concept as NOT new (isNew=false) - treated as existing concept
172
+ * - Marks concept as non-temporary (isTemp=false)
173
+ * - Adds concept to ConceptsData immediately for instant query availability
174
+ * - Sets updateRecursion=true to enable recursive composition updates
175
+ * - Adds concept to SyncData for backend synchronization
176
+ * - Adds concept to transaction actions for tracking
177
+ * - The commented-out line suggests this previously triggered immediate API sync
178
+ *
179
+ * @see CreateTheConcept for standard concept creation with delayed sync
180
+ * @see CreateTheConceptTemporary for creating temporary concepts
181
+ * @see ConceptsData for the in-memory concept store
182
+ * @see SyncData for sync queue management
183
+ */
184
+ export declare function CreateTheConceptImmediate(referent: string, userId: number, categoryId: number, categoryUserId: number, typeId: number, typeUserId: number, referentId: number, referentUserId: number, securityId: number, securityUserId: number, accessId: number, accessUserId: number, sessionInformationId: number, sessionInformationUserId: number, actions?: InnerActions): Promise<Concept>;