mftsccs-node 0.2.23 → 0.2.24

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.
@@ -0,0 +1,8 @@
1
+ import { FetchConnection } from "../../DataStructures/FetchConnection";
2
+ /**
3
+ * Fetches connection IDs matching one or more connection queries.
4
+ *
5
+ * Each item is resolved independently by the backend and returned with
6
+ * connectionIds populated.
7
+ */
8
+ export declare function GetConnectionsBetweenApi(fetchConnections: FetchConnection[]): Promise<FetchConnection[]>;
@@ -34,4 +34,4 @@
34
34
  * @see ReservedConnectionIds for the storage data structure
35
35
  * @see GetReservedIds for fetching regular concept IDs
36
36
  */
37
- export declare function GetReservedConnectionIds(): Promise<void>;
37
+ export declare function GetReservedConnectionIds(count?: number): Promise<void>;
@@ -64,6 +64,11 @@ export declare class BaseUrl {
64
64
  * @returns {string} The user connections retrieval API endpoint
65
65
  */
66
66
  static GetAllConnectionsOfUserUrl(): string;
67
+ /**
68
+ * Returns the URL for retrieving connection IDs matching connection filters.
69
+ * @returns {string} The connection filtering API endpoint
70
+ */
71
+ static GetConnectionsBetweenUrl(): string;
67
72
  /**
68
73
  * Returns the URL for retrieving all connections of a composition.
69
74
  * @returns {string} The composition connections retrieval API endpoint
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Request/response shape for POST /api/get-connection-between.
3
+ *
4
+ * Use only the fields relevant to the query and leave the rest at their
5
+ * zero/empty defaults. The backend resolves typeId from type when typeId is 0.
6
+ */
7
+ export interface FetchConnection {
8
+ ofTheConceptId: number;
9
+ toTheConceptId: number;
10
+ typeId: number;
11
+ type: string;
12
+ oldType: string;
13
+ reverse: boolean;
14
+ isComposition: boolean;
15
+ connectionIds: number[];
16
+ }
17
+ export type FetchConnectionQuery = Omit<FetchConnection, 'connectionIds'>;
18
+ /**
19
+ * Builds a complete FetchConnection request object from a partial query.
20
+ */
21
+ export declare function buildFetchConnection(query: Partial<FetchConnectionQuery>): FetchConnection;
@@ -77,21 +77,13 @@ export declare class ReservedIds {
77
77
  export declare class ReservedConnectionIds {
78
78
  /** Pool of reserved connection IDs */
79
79
  static connectionIds: number[];
80
+ private static pendingFetch;
80
81
  /**
81
82
  * Gets the next available reserved connection ID from the pool.
82
- * Automatically refills the pool if it has fewer than 10 IDs.
83
+ * Triggers a background refill when the pool is low, and waits for a fetch
84
+ * if the pool is completely empty. Only one fetch is in-flight at a time.
83
85
  *
84
86
  * @returns {Promise<number>} A unique reserved connection ID
85
- *
86
- * @example
87
- * ```typescript
88
- * const id = await ReservedConnectionIds.getId();
89
- * const connection = new Connection(id, ...);
90
- * ```
91
- *
92
- * @remarks
93
- * Uses FIFO (first in, first out) to retrieve IDs.
94
- * Triggers a backend call to GetReservedConnectionIds when pool is low.
95
87
  */
96
88
  static getId(): Promise<number>;
97
89
  /**
@@ -99,13 +91,15 @@ export declare class ReservedConnectionIds {
99
91
  *
100
92
  * @param {number} id - The ID to add to the pool
101
93
  *
102
- * @example
103
- * ```typescript
104
- * ReservedConnectionIds.AddId(456);
105
- * ```
106
- *
107
94
  * @remarks
108
95
  * Prevents duplicate IDs from being added to the pool.
109
96
  */
110
97
  static AddId(id: number): void;
98
+ /**
99
+ * Pre-fills the pool with at least `needed` IDs in a single API call.
100
+ * Call this before a parallel batch so getId() never has to wait mid-flight.
101
+ *
102
+ * @param {number} needed - Total IDs required for the upcoming batch
103
+ */
104
+ static warmUp(needed: number): Promise<void>;
111
105
  }
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import { Concept } from "../Concept";
6
6
  import { Connection } from "../Connection";
7
+ import { FetchConnectionQuery } from "../FetchConnection";
7
8
  /**
8
9
  * Manages transactional operations for concepts and connections.
9
10
  * This class provides ACID-like transaction capabilities for creating and managing
@@ -69,6 +70,14 @@ export declare class Transaction {
69
70
  * @default true
70
71
  */
71
72
  protected success: boolean;
73
+ /**
74
+ * Connection IDs queued for deletion when the transaction commits.
75
+ * Rollback clears this list without touching the backend.
76
+ *
77
+ * @protected
78
+ * @type {number[]}
79
+ */
80
+ protected pendingConnectionDeletions: number[];
72
81
  /**
73
82
  * Creates a new Transaction instance.
74
83
  * Generates a unique transaction ID for tracking purposes.
@@ -154,6 +163,20 @@ export declare class Transaction {
154
163
  * ```
155
164
  */
156
165
  commitTransaction(): Promise<void>;
166
+ /**
167
+ * Queues connections matching one query for deletion on commit.
168
+ *
169
+ * Nothing is deleted until commitTransaction() is called. Calling
170
+ * rollbackTransaction() discards the queued IDs.
171
+ */
172
+ DeleteConnectionsBetween(query: Partial<FetchConnectionQuery>): Promise<number[]>;
173
+ /**
174
+ * Queues connections matching multiple queries for deletion on commit.
175
+ *
176
+ * The queries are resolved in one API call, then their connection IDs are
177
+ * merged into this transaction's pending deletion queue.
178
+ */
179
+ DeleteConnectionsBetweenBulk(queries: Partial<FetchConnectionQuery>[]): Promise<number[]>;
157
180
  /**
158
181
  * Creates a new instance concept within the transaction.
159
182
  * The concept represents a data instance of a specified type with associated metadata.
@@ -1,132 +1,14 @@
1
- /**
2
- * @fileoverview Binary tree for managing user-specific concepts and connections.
3
- * This module provides a composite-key based tree for efficient user and session-based data storage.
4
- * @module DataStructures/User/UserBinaryTree
5
- */
6
1
  import { LConcept } from "../../DataStructures/Local/LConcept";
7
2
  import { UserNode } from "./UserNode";
8
3
  import { LConnection } from "../Local/LConnection";
9
- /**
10
- * Binary tree data structure for managing user-specific data with composite keys.
11
- *
12
- * @remarks
13
- * This class implements an AVL tree that uses composite keys (userId + sessionId + randomizer)
14
- * to organize user-specific concepts and connections. The composite key enables efficient
15
- * organization and retrieval of data by user, session, and application context.
16
- *
17
- * @example
18
- * ```typescript
19
- * const concept = new LConcept(123, "example", 5);
20
- * UserBinaryTree.addConceptToTree(concept, 42, 999);
21
- * const node = await UserBinaryTree.getNodeFromTree(42, 999, 123);
22
- * ```
23
- */
24
4
  export declare class UserBinaryTree {
25
- /**
26
- * The root node of the user data binary tree.
27
- * Null if the tree is empty.
28
- */
29
- static root: UserNode | null;
30
- /**
31
- * Creates a composite key from user ID, session ID, and randomizer.
32
- *
33
- * @param userId - The user ID
34
- * @param sessionId - The session ID
35
- * @param randomizer - Additional identifier (defaults to 999)
36
- * @returns A 12-character hexadecimal composite key
37
- *
38
- * @remarks
39
- * The composite key is formed by concatenating three 4-digit hexadecimal values:
40
- * userHex (4 chars) + sessionHex (4 chars) + randomizerHex (4 chars) = 12 chars total.
41
- * This enables unique identification of data across users, sessions, and applications.
42
- *
43
- * @example
44
- * ```typescript
45
- * const key = UserBinaryTree.compositeKey(42, 999, 123);
46
- * // Returns something like "002A03E7007B"
47
- * ```
48
- */
5
+ static nodeMap: Map<string, UserNode>;
49
6
  static compositeKey(userId: number, sessionId: number, randomizer?: number): string;
50
- /**
51
- * Adds a user node to the binary tree.
52
- *
53
- * @param node - The UserNode to be added to the tree
54
- *
55
- * @remarks
56
- * If the tree is empty, the provided node becomes the root.
57
- * Otherwise, the node is inserted using the AVL tree balancing algorithm.
58
- */
59
- static addNodeToTree(node: UserNode): UserNode | undefined;
60
- /**
61
- * Waits for user data to be loaded into the tree.
62
- *
63
- * @returns A promise that resolves with "done" when data is loaded, or rejects with "not" after 25 seconds
64
- */
65
7
  static waitForDataToLoad(): Promise<unknown>;
66
- /**
67
- * Periodically checks if user data has been loaded.
68
- *
69
- * @param resolve - The promise resolve function to call when data is loaded
70
- */
71
8
  static checkFlag(resolve: any): any;
72
- /**
73
- * Creates a node from a concept and adds it to the user tree.
74
- *
75
- * @param concept - The LConcept object to be added
76
- * @param userId - The user ID
77
- * @param sessionId - The session ID (defaults to 999)
78
- *
79
- * @remarks
80
- * Uses the concept's applicationId as the randomizer in the composite key.
81
- */
82
9
  static addConceptToTree(concept: LConcept, userId: number, sessionId?: number): void;
83
- /**
84
- * Creates a node from a connection and adds it to the user tree.
85
- *
86
- * @param connection - The LConnection object to be added
87
- * @param userId - The user ID
88
- * @param sessionId - The session ID (defaults to 999)
89
- *
90
- * @remarks
91
- * Uses the connection's applicationId as the randomizer in the composite key.
92
- */
93
10
  static addConnectionToTree(connection: LConnection, userId: number, sessionId?: number): void;
94
- /**
95
- * Retrieves a node from the tree using composite key components.
96
- *
97
- * @param userId - The user ID
98
- * @param sessionId - The session ID
99
- * @param randomizer - Additional identifier (defaults to 999)
100
- * @returns The UserNode if found, null otherwise
101
- *
102
- * @remarks
103
- * Constructs a composite key from the parameters and performs a binary search.
104
- */
105
11
  static getNodeFromTree(userId: number, sessionId: number, randomizer?: number): Promise<UserNode | null>;
106
- /**
107
- * Removes a node from the tree using composite key components.
108
- *
109
- * @param userId - The user ID
110
- * @param sessionId - The session ID (defaults to 999)
111
- * @param randomizer - Additional identifier (defaults to 999)
112
- *
113
- * @remarks
114
- * Constructs a composite key and removes the matching node while maintaining AVL balance.
115
- */
116
12
  static removeNodeFromTree(userId: number, sessionId?: number, randomizer?: number): Promise<void>;
117
- /**
118
- * Counts the total number of nodes in the tree.
119
- *
120
- * @returns The total number of user nodes in the tree
121
- *
122
- * @remarks
123
- * Recursively traverses the entire tree to count all nodes. Returns 0 if the tree is empty.
124
- *
125
- * @example
126
- * ```typescript
127
- * const count = UserBinaryTree.countNumberOfNodes();
128
- * console.log(`Tree contains ${count} user data nodes`);
129
- * ```
130
- */
131
13
  static countNumberOfNodes(): number;
132
14
  }
@@ -1,150 +1,8 @@
1
- /**
2
- * @fileoverview Node implementation for the UserBinaryTree.
3
- * This module provides the UserNode class for storing user-specific concepts and connections.
4
- * @module DataStructures/User/UserNode
5
- */
6
1
  import { LConcept } from "../Local/LConcept";
7
2
  import { LConnection } from "../Local/LConnection";
8
- /**
9
- * Represents a node in the user binary tree that stores both concepts and connections.
10
- *
11
- * @remarks
12
- * UserNode implements an AVL tree node that can store multiple concepts and connections
13
- * for a given composite key (userId + sessionId + randomizer). This allows efficient
14
- * storage and retrieval of all user data associated with a specific key combination.
15
- *
16
- * @example
17
- * ```typescript
18
- * const concept = new LConcept(123, "example", 5);
19
- * const connection = new LConnection(456, 1, 2, 3, 4, 5);
20
- * const node = new UserNode("compositeKey", concept, connection, null, null);
21
- * ```
22
- */
23
3
  export declare class UserNode {
24
- /**
25
- * The composite key used for tree ordering.
26
- * Typically a hexadecimal string combining userId, sessionId, and randomizer.
27
- */
28
- key: any;
29
- /**
30
- * Array of connections stored in this node.
31
- * Multiple connections can be associated with the same key.
32
- */
33
- connectionValue: LConnection[];
34
- /**
35
- * Array of concepts stored in this node.
36
- * Multiple concepts can be associated with the same key.
37
- */
38
- value: LConcept[];
39
- /**
40
- * Reference to the left child node.
41
- */
42
- leftNode: UserNode | null;
43
- /**
44
- * Reference to the right child node.
45
- */
46
- rightNode: UserNode | null;
47
- /**
48
- * The height of this node in the tree.
49
- * Used for AVL tree balancing calculations.
50
- */
51
- height: number;
52
- /**
53
- * Creates a new UserNode.
54
- *
55
- * @param key - The composite key for tree ordering
56
- * @param value - The LConcept to store (added if ID > 0)
57
- * @param connectionValue - The LConnection to store (added if ID > 0)
58
- * @param leftNode - The left child node (or null)
59
- * @param rightNode - The right child node (or null)
60
- *
61
- * @remarks
62
- * Only adds concepts and connections with valid (> 0) IDs to their respective arrays.
63
- *
64
- * @example
65
- * ```typescript
66
- * const node = new UserNode("compositeKey", concept, connection, null, null);
67
- * ```
68
- */
69
- constructor(key: any, value: LConcept, connectionValue: LConnection, leftNode: UserNode | null, rightNode: UserNode | null);
70
- /**
71
- * Adds a new node to the tree with AVL balancing.
72
- *
73
- * @param passedNode - The node to be added
74
- * @param node - The current node being evaluated
75
- * @param height - The height of the current node
76
- * @returns The root node after insertion and balancing
77
- *
78
- * @remarks
79
- * Implements AVL tree insertion. When a node with the same key exists,
80
- * the new node's concepts and connections are added to the existing node's arrays.
81
- */
82
- addNode(passedNode: UserNode, node: UserNode | null, height: number): UserNode | null;
83
- /**
84
- * Performs a right rotation on the given node for AVL balancing.
85
- *
86
- * @param y - The node to rotate right
87
- * @returns The new root node after rotation
88
- */
89
- rightRotate(y: UserNode | null): UserNode | null;
90
- /**
91
- * Performs a left rotation on the given node for AVL balancing.
92
- *
93
- * @param x - The node to rotate left
94
- * @returns The new root node after rotation
95
- */
96
- leftRotate(x: UserNode | null): UserNode | null;
97
- /**
98
- * Gets the height of a node.
99
- *
100
- * @param node - The node to get the height from
101
- * @returns The height of the node, or 0 if null
102
- */
103
- getHeight(node: UserNode | null): number;
104
- /**
105
- * Calculates the balance factor of a node.
106
- *
107
- * @param N - The node to calculate the balance factor for
108
- * @returns The balance factor (difference between left and right heights)
109
- */
110
- getBalanceFactor(N: UserNode | null): number;
111
- /**
112
- * Retrieves a node from the tree by its composite key.
113
- *
114
- * @param id - The composite key string to search for
115
- * @param node - The current node being evaluated
116
- * @returns The matching UserNode if found, null otherwise
117
- */
118
- getFromNode(id: string, node: UserNode | null): UserNode | null;
119
- /**
120
- * Removes a node from the tree by its composite key.
121
- *
122
- * @param passedNode - The current node being evaluated
123
- * @param id - The composite key string to remove
124
- * @returns The root node after removal
125
- *
126
- * @remarks
127
- * Implements standard BST deletion with in-order successor replacement.
128
- */
129
- removeNode(passedNode: UserNode | null, id: string): UserNode | null;
130
- /**
131
- * Counts all nodes below and including the given node.
132
- *
133
- * @param root - The root node to start counting from
134
- * @returns The total number of nodes in the subtree
135
- *
136
- * @remarks
137
- * Recursively traverses the entire subtree to count all nodes.
138
- */
139
- countNodeBelow(root: UserNode | null): number;
140
- /**
141
- * Finds the in-order successor of a node.
142
- *
143
- * @param root - The node to find the successor from
144
- * @returns The in-order successor node (leftmost node in right subtree)
145
- *
146
- * @remarks
147
- * Used during node deletion to find the replacement node.
148
- */
149
- inOrderSuccessor(root: UserNode): UserNode;
4
+ key: string;
5
+ value: Map<number, LConcept>;
6
+ connectionValue: Map<number, LConnection>;
7
+ constructor(key: string, value: LConcept, connectionValue: LConnection);
150
8
  }
@@ -31,7 +31,7 @@ export { MakeTheTypeConcept } from './Services/MakeTheTypeConcept';
31
31
  export { MakeTheTypeConceptApi } from './Api/MakeTheTypeConceptApi';
32
32
  export { GetLinkerConnectionFromConcepts, GetLinkerConnectionToConcepts } from './Services/GetLinkerConnectionFromConcept';
33
33
  export { DeleteConceptById } from './Services/DeleteConcept';
34
- export { DeleteConnectionById } from './Services/DeleteConnection';
34
+ export { DeleteConnectionById, DeleteConnectionByIdBulk } from './Services/DeleteConnection';
35
35
  export { TrashTheConcept } from './Api/Delete/DeleteConceptInBackend';
36
36
  export { GetConnectionById } from './Services/GetConnections';
37
37
  export { MakeTheTimestamp } from './Services/MakeTheTimestamp';
@@ -99,10 +99,13 @@ export { TokenStorage } from './DataStructures/Security/TokenStorage';
99
99
  export { SchemaQueryListener } from './WrapperFunctions/SchemaQueryObservable';
100
100
  export { FreeschemaQuery } from './DataStructures/Search/FreeschemaQuery';
101
101
  export { GiveConnection, GetAllTheConnectionsByTypeAndOfTheConcept } from './Services/Delete/GetAllConnectionByType';
102
+ export { GetConnectionsBetweenApi } from './Api/GetConnections/GetConnectionsBetweenApi';
103
+ export { FetchConnection, FetchConnectionQuery, buildFetchConnection } from './DataStructures/FetchConnection';
102
104
  export { DATAID, NORMAL, JUSTDATA, ALLID, DATAIDDATE, RAW, LISTNORMAL, DATAV2 } from './Constants/FormatConstants';
103
105
  export { AccessControlService } from './Services/AccessControl/AccessControlService';
104
106
  export { PermissionSet } from './Services/AccessControl/PermissionSet';
105
- export { Transaction } from './DataStructures/Transaction/Transaction';
107
+ export { Transaction, InnerActions } from './DataStructures/Transaction/Transaction';
108
+ export { ReservedIds, ReservedConnectionIds } from './DataStructures/ReservedIds';
106
109
  /**
107
110
  * Updates the bearer access token used for authenticating API requests to the backend.
108
111
  * This token is stored globally and used by all API calls that require authentication.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mftsccs-node",
3
- "version": "0.2.23",
3
+ "version": "0.2.24",
4
4
  "environment": "production",
5
5
  "description": "Full Pack of concept and connection system",
6
6
  "main": "dist/bundle.js",