fixparser-common 9.2.2 → 9.2.3-175e9b8c
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/package.json +1 -1
- package/types/ILogTransporter.d.ts +35 -0
- package/types/IMessage.d.ts +4 -0
- package/types/IMessageStore.d.ts +95 -0
- package/types/IPlugin.d.ts +3 -0
- package/types/Level.d.ts +11 -0
- package/types/LogMessage.d.ts +7 -0
- package/types/MessageBuffer.d.ts +104 -0
- package/types/index.d.ts +8 -0
- package/types/uuidv4.d.ts +1 -0
package/package.json
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { LogMessage } from './LogMessage';
|
|
2
|
+
/**
|
|
3
|
+
* A LogTransporter interface for external log storage solutions.
|
|
4
|
+
* @example
|
|
5
|
+
* const consoleTransport = new ConsoleLogTransport({ format: 'console' as ConsoleFormat });
|
|
6
|
+
* const logger = new Logger({ name: 'TestLogger', level: 'info', transport: consoleTransport });
|
|
7
|
+
*
|
|
8
|
+
* const message: LogMessage = { level: 'info', message: 'This is an info message' };
|
|
9
|
+
* logger.log(message);
|
|
10
|
+
*/
|
|
11
|
+
export interface ILogTransporter {
|
|
12
|
+
/**
|
|
13
|
+
* Initializes the transporter with necessary configuration options.
|
|
14
|
+
* @param config The configuration object for the transporter (e.g. connection info, credentials).
|
|
15
|
+
*/
|
|
16
|
+
configure(config: Record<string, any>): void;
|
|
17
|
+
/**
|
|
18
|
+
* Sends a log message to the external service or storage.
|
|
19
|
+
* @param log The log message to be sent.
|
|
20
|
+
*/
|
|
21
|
+
send(log: LogMessage): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Flushes any pending log messages if the transporter uses buffering, and closes any open connections if needed.
|
|
24
|
+
*/
|
|
25
|
+
flush(): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Closes the transporter, cleaning up resources (e.g. closing connections).
|
|
28
|
+
*/
|
|
29
|
+
close(): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Returns the current status of the transporter (e.g., connected, closed, etc.).
|
|
32
|
+
* This can be useful for diagnostic purposes.
|
|
33
|
+
*/
|
|
34
|
+
status(): string;
|
|
35
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `IMessageStore` interface defines the contract for a generic message store.
|
|
3
|
+
* This store is used for storing, retrieving, updating, and removing items of type `T`.
|
|
4
|
+
* It provides methods to add, retrieve, update, and remove items, along with checking
|
|
5
|
+
* the store's size, capacity, and performing batch operations.
|
|
6
|
+
*
|
|
7
|
+
* @interface IMessageStore
|
|
8
|
+
*/
|
|
9
|
+
export interface IMessageStore<T> {
|
|
10
|
+
/**
|
|
11
|
+
* Adds an item of type `T` to the message store.
|
|
12
|
+
*
|
|
13
|
+
* @param {T} item - The item to add to the store.
|
|
14
|
+
*
|
|
15
|
+
* @returns {void}
|
|
16
|
+
*/
|
|
17
|
+
add(item: T): void;
|
|
18
|
+
/**
|
|
19
|
+
* Retrieves an item of type `T` from the store by its sequence number (or any other identifier).
|
|
20
|
+
*
|
|
21
|
+
* @param {number} msgSequence - The sequence number of the item to retrieve.
|
|
22
|
+
*
|
|
23
|
+
* @returns {T | undefined} - The item if found, otherwise `undefined`.
|
|
24
|
+
*/
|
|
25
|
+
getByMsgSequence(msgSequence: number): T | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Removes an item of type `T` from the store by its sequence number.
|
|
28
|
+
*
|
|
29
|
+
* @param {number} msgSequence - The sequence number of the item to remove.
|
|
30
|
+
*
|
|
31
|
+
* @returns {void}
|
|
32
|
+
*/
|
|
33
|
+
remove(msgSequence: number): void;
|
|
34
|
+
/**
|
|
35
|
+
* Updates an item of type `T` in the store.
|
|
36
|
+
*
|
|
37
|
+
* @param {number} msgSequence - The sequence number of the item to update.
|
|
38
|
+
* @param {T} item - The updated item.
|
|
39
|
+
*
|
|
40
|
+
* @returns {boolean} - Returns `true` if the item was updated successfully, `false` otherwise.
|
|
41
|
+
*/
|
|
42
|
+
update(msgSequence: number, item: T): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Retrieves all items of type `T` from the store.
|
|
45
|
+
*
|
|
46
|
+
* @returns {T[]} - An array of all items in the store.
|
|
47
|
+
*/
|
|
48
|
+
getAll(): T[];
|
|
49
|
+
/**
|
|
50
|
+
* Checks if an item with a given sequence number exists in the store.
|
|
51
|
+
*
|
|
52
|
+
* @param {number} msgSequence - The sequence number of the item to check.
|
|
53
|
+
* @returns {boolean} - `true` if the item exists, `false` otherwise.
|
|
54
|
+
*/
|
|
55
|
+
exists(msgSequence: number): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Returns the current number of items stored in the message store.
|
|
58
|
+
*
|
|
59
|
+
* @returns {number} - The number of items in the store.
|
|
60
|
+
*/
|
|
61
|
+
size(): number;
|
|
62
|
+
/**
|
|
63
|
+
* Resizes the message store's capacity.
|
|
64
|
+
*
|
|
65
|
+
* @param {number} newCapacity - The new maximum capacity for the store.
|
|
66
|
+
* @returns {void}
|
|
67
|
+
*/
|
|
68
|
+
resize(newCapacity: number): void;
|
|
69
|
+
/**
|
|
70
|
+
* Clears all items from the store, removing them permanently.
|
|
71
|
+
*
|
|
72
|
+
* @returns {void}
|
|
73
|
+
*/
|
|
74
|
+
clear(): void;
|
|
75
|
+
/**
|
|
76
|
+
* Returns the maximum capacity of the message store. This indicates how many items
|
|
77
|
+
* the store can hold before it reaches its limit.
|
|
78
|
+
*
|
|
79
|
+
* @returns {number} - The maximum capacity of the store.
|
|
80
|
+
*/
|
|
81
|
+
getCapacity(): number;
|
|
82
|
+
/**
|
|
83
|
+
* Set the next message sequence number.
|
|
84
|
+
*
|
|
85
|
+
* @param nextMsgSeqNum - The next message sequence number.
|
|
86
|
+
* @returns {number} - The next message sequence number.
|
|
87
|
+
*/
|
|
88
|
+
setNextMsgSeqNum(nextMsgSeqNum: number): number;
|
|
89
|
+
/**
|
|
90
|
+
* Get the next message sequence number.
|
|
91
|
+
*
|
|
92
|
+
* @returns {number} - The next message sequence number.
|
|
93
|
+
*/
|
|
94
|
+
getNextMsgSeqNum(): number;
|
|
95
|
+
}
|
package/types/Level.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger output level options.
|
|
3
|
+
*
|
|
4
|
+
* - 'info': General informational messages that highlight the progress or state of the application.
|
|
5
|
+
* - 'warn': Warnings about potential issues that don’t necessarily disrupt the program’s functionality.
|
|
6
|
+
* - 'error': Critical issues that indicate something has gone wrong and may require attention.
|
|
7
|
+
* - 'silent': No log messages are displayed or recorded, effectively suppressing all output.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export type Level = 'info' | 'warn' | 'error' | 'silent';
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { IMessageStore } from './IMessageStore';
|
|
2
|
+
/**
|
|
3
|
+
* A buffer that stores items of type `T` up to a specified maximum size.
|
|
4
|
+
* Implements the IMessageStore interface for generic types.
|
|
5
|
+
*/
|
|
6
|
+
export declare class MessageBuffer<T> implements IMessageStore<T> {
|
|
7
|
+
/**
|
|
8
|
+
* A number representing the next expected message sequence number.
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
private nextMsgSeqNum;
|
|
12
|
+
/**
|
|
13
|
+
* An array holding the items in the buffer.
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
16
|
+
private buffer;
|
|
17
|
+
/**
|
|
18
|
+
* The maximum capacity of the buffer.
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
private maxBufferSize;
|
|
22
|
+
constructor(maxBufferSize?: number);
|
|
23
|
+
/**
|
|
24
|
+
* Adds a new item to the buffer.
|
|
25
|
+
* If the buffer is full, the oldest item is removed to make space for the new one.
|
|
26
|
+
*
|
|
27
|
+
* @param {T} item - The item to add to the buffer.
|
|
28
|
+
* @returns {void}
|
|
29
|
+
*/
|
|
30
|
+
add(item: T): void;
|
|
31
|
+
/**
|
|
32
|
+
* Retrieves an item from the buffer by its sequence number (or any other identifier).
|
|
33
|
+
*
|
|
34
|
+
* @param {number} msgSequence - The sequence number of the item to retrieve.
|
|
35
|
+
* @returns {T | undefined} The item if found, or `undefined` if not found.
|
|
36
|
+
*/
|
|
37
|
+
getByMsgSequence(msgSequence: number): T | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Removes an item from the buffer by its sequence number.
|
|
40
|
+
*
|
|
41
|
+
* @param {number} msgSequence - The sequence number of the item to remove.
|
|
42
|
+
* @returns {void}
|
|
43
|
+
*/
|
|
44
|
+
remove(msgSequence: number): void;
|
|
45
|
+
/**
|
|
46
|
+
* Updates an item in the buffer.
|
|
47
|
+
*
|
|
48
|
+
* @param {number} msgSequence - The sequence number of the item to update.
|
|
49
|
+
* @param {T} item - The updated item.
|
|
50
|
+
* @returns {boolean} - Returns `true` if the item was updated successfully, `false` otherwise.
|
|
51
|
+
*/
|
|
52
|
+
update(msgSequence: number, item: T): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Retrieves all items from the buffer.
|
|
55
|
+
*
|
|
56
|
+
* @returns {T[]} - An array of all items in the buffer.
|
|
57
|
+
*/
|
|
58
|
+
getAll(): T[];
|
|
59
|
+
/**
|
|
60
|
+
* Checks if an item with a given sequence number exists in the buffer.
|
|
61
|
+
*
|
|
62
|
+
* @param {number} msgSequence - The sequence number of the item to check.
|
|
63
|
+
* @returns {boolean} - `true` if the item exists, `false` otherwise.
|
|
64
|
+
*/
|
|
65
|
+
exists(msgSequence: number): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Gets the current size of the buffer (the number of items it contains).
|
|
68
|
+
*
|
|
69
|
+
* @returns {number} The number of items currently in the buffer.
|
|
70
|
+
*/
|
|
71
|
+
size(): number;
|
|
72
|
+
/**
|
|
73
|
+
* Resizes the buffer's capacity.
|
|
74
|
+
*
|
|
75
|
+
* @param {number} newCapacity - The new maximum capacity for the buffer.
|
|
76
|
+
* @returns {void}
|
|
77
|
+
*/
|
|
78
|
+
resize(newCapacity: number): void;
|
|
79
|
+
/**
|
|
80
|
+
* Clears all items from the buffer.
|
|
81
|
+
*
|
|
82
|
+
* @returns {void}
|
|
83
|
+
*/
|
|
84
|
+
clear(): void;
|
|
85
|
+
/**
|
|
86
|
+
* Gets the maximum capacity of the buffer.
|
|
87
|
+
*
|
|
88
|
+
* @returns {number} The maximum number of items the buffer can hold.
|
|
89
|
+
*/
|
|
90
|
+
getCapacity(): number;
|
|
91
|
+
/**
|
|
92
|
+
* Set the next message sequence number.
|
|
93
|
+
*
|
|
94
|
+
* @param nextMsgSeqNum - The next message sequence number.
|
|
95
|
+
* @returns {number} - The next message sequence number.
|
|
96
|
+
*/
|
|
97
|
+
setNextMsgSeqNum(nextMsgSeqNum: number): number;
|
|
98
|
+
/**
|
|
99
|
+
* Get the next message sequence number.
|
|
100
|
+
*
|
|
101
|
+
* @returns {number} - The next message sequence number.
|
|
102
|
+
*/
|
|
103
|
+
getNextMsgSeqNum(): number;
|
|
104
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { ILogTransporter } from './ILogTransporter';
|
|
2
|
+
export type { IMessage } from './IMessage';
|
|
3
|
+
export type { IMessageStore } from './IMessageStore';
|
|
4
|
+
export type { IPlugin } from './IPlugin';
|
|
5
|
+
export { Level } from './Level';
|
|
6
|
+
export { LogMessage } from './LogMessage';
|
|
7
|
+
export { MessageBuffer } from './MessageBuffer';
|
|
8
|
+
export { uuidv4 } from './uuidv4';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const uuidv4: () => string;
|