@andrew_l/binlog 0.3.22 → 0.4.1

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/dist/index.d.mts CHANGED
@@ -1,51 +1,50 @@
1
- import { Structure } from '@andrew_l/tl-pack';
2
-
1
+ import { Structure } from "@andrew_l/tl-pack";
3
2
  /**
4
3
  * Options for configuring the KdbBinlog
5
4
  */
6
5
  interface BinlogOptions {
7
- /**
8
- * File location to store binlog files
9
- * @default './binlogs/log-{index}.bin'
10
- */
11
- path: string;
12
- /**
13
- * Maximum size of each binlog file before rotation (in bytes)
14
- * @default 104857600
15
- */
16
- maxFileSize: number;
17
- /**
18
- * Whether to enable log rotation
19
- * @default true
20
- */
21
- rotation: boolean;
22
- /**
23
- * Whether to sync writes to disk immediately
24
- * @default true
25
- */
26
- syncWrites: boolean;
27
- structures?: Structure.Constructor[];
6
+ /**
7
+ * File location to store binlog files
8
+ * @default './binlogs/log-{index}.bin'
9
+ */
10
+ path: string;
11
+ /**
12
+ * Maximum size of each binlog file before rotation (in bytes)
13
+ * @default 104857600
14
+ */
15
+ maxFileSize: number;
16
+ /**
17
+ * Whether to enable log rotation
18
+ * @default true
19
+ */
20
+ rotation: boolean;
21
+ /**
22
+ * Whether to sync writes to disk immediately
23
+ * @default true
24
+ */
25
+ syncWrites: boolean;
26
+ structures?: Structure.Constructor[];
28
27
  }
29
28
  /**
30
29
  * Represents a single binlog entry
31
30
  */
32
31
  interface BinlogEntry<TData = Buffer> {
33
- /**
34
- * Operation code defining the type of operation
35
- */
36
- opcode: number;
37
- /**
38
- * Unix timestamp when the entry was created
39
- */
40
- timestamp: number;
41
- /**
42
- * Binary data of the entry
43
- */
44
- data: TData | Buffer;
45
- /**
46
- * Position in the file where this entry starts
47
- */
48
- position: number;
32
+ /**
33
+ * Operation code defining the type of operation
34
+ */
35
+ opcode: number;
36
+ /**
37
+ * Unix timestamp when the entry was created
38
+ */
39
+ timestamp: number;
40
+ /**
41
+ * Binary data of the entry
42
+ */
43
+ data: TData | Buffer;
44
+ /**
45
+ * Position in the file where this entry starts
46
+ */
47
+ position: number;
49
48
  }
50
49
  /**
51
50
  * TypeScript implementation of binlog system
@@ -53,71 +52,70 @@ interface BinlogEntry<TData = Buffer> {
53
52
  * @group Main
54
53
  */
55
54
  declare class Binlog {
56
- #private;
57
- private _options;
58
- private _filePattern;
59
- private _directory;
60
- private _currentFile;
61
- private _currentFileDescriptor;
62
- private _currentFileSize;
63
- private _currentFileIndex;
64
- private _isOpen;
65
- private _log;
66
- private readonly BINLOG_MAGIC;
67
- private readonly BINLOG_VERSION;
68
- private readonly BINLOG_HEADER_SIZE;
69
- private readonly BINLOG_ENTRY_HEADER_SIZE;
70
- private readonly BINLOG_FLAG;
71
- constructor(options: BinlogOptions);
72
- /**
73
- * Initialize the binlog system, ensuring directory exists and pick most recent binlog file
74
- * @returns Promise resolving to true if successful, false otherwise
75
- */
76
- init(): Promise<void>;
77
- /**
78
- * Open the binlog for writing
79
- */
80
- open(): Promise<void>;
81
- /**
82
- * Close the current binlog file
83
- */
84
- close(): Promise<void>;
85
- /**
86
- * Write a binlog entry
87
- * @param opcode - Operation code
88
- * @param data - Data to write
89
- * @returns Promise resolving to true if successful, false otherwise
90
- */
91
- write(opcode: number, data: unknown): Promise<void>;
92
- /**
93
- * Rotate the binlog file
94
- */
95
- rotate(): Promise<void>;
96
- /**
97
- * Read and parse all entries from a binlog file
98
- * @param filename - Binlog file to read
99
- * @param unsafe - Ignore broken binlog records otherwise throws error
100
- * @returns Array of parsed entries
101
- */
102
- readEntries<TData = Buffer>(filename: string, unsafe?: boolean): Promise<BinlogEntry<TData>[]>;
103
- /**
104
- * Get the current binlog file index
105
- */
106
- get currentFileIndex(): number;
107
- /**
108
- * Get current binlog file name
109
- */
110
- get currentFileName(): string;
111
- /**
112
- * Get current binlog directory
113
- */
114
- get directory(): string;
55
+ #private;
56
+ private _options;
57
+ private _filePattern;
58
+ private _directory;
59
+ private _currentFile;
60
+ private _currentFileDescriptor;
61
+ private _currentFileSize;
62
+ private _currentFileIndex;
63
+ private _isOpen;
64
+ private _log;
65
+ private readonly BINLOG_MAGIC;
66
+ private readonly BINLOG_VERSION;
67
+ private readonly BINLOG_HEADER_SIZE;
68
+ private readonly BINLOG_ENTRY_HEADER_SIZE;
69
+ private readonly BINLOG_FLAG;
70
+ constructor(options: BinlogOptions);
71
+ /**
72
+ * Initialize the binlog system, ensuring directory exists and pick most recent binlog file
73
+ * @returns Promise resolving to true if successful, false otherwise
74
+ */
75
+ init(): Promise<void>;
76
+ /**
77
+ * Open the binlog for writing
78
+ */
79
+ open(): Promise<void>;
80
+ /**
81
+ * Close the current binlog file
82
+ */
83
+ close(): Promise<void>;
84
+ /**
85
+ * Write a binlog entry
86
+ * @param opcode - Operation code
87
+ * @param data - Data to write
88
+ * @returns Promise resolving to true if successful, false otherwise
89
+ */
90
+ write(opcode: number, data: unknown): Promise<void>;
91
+ /**
92
+ * Rotate the binlog file
93
+ */
94
+ rotate(): Promise<void>;
95
+ /**
96
+ * Read and parse all entries from a binlog file
97
+ * @param filename - Binlog file to read
98
+ * @param unsafe - Ignore broken binlog records otherwise throws error
99
+ * @returns Array of parsed entries
100
+ */
101
+ readEntries<TData = Buffer>(filename: string, unsafe?: boolean): Promise<BinlogEntry<TData>[]>;
102
+ /**
103
+ * Get the current binlog file index
104
+ */
105
+ get currentFileIndex(): number;
106
+ /**
107
+ * Get current binlog file name
108
+ */
109
+ get currentFileName(): string;
110
+ /**
111
+ * Get current binlog directory
112
+ */
113
+ get directory(): string;
115
114
  }
116
-
117
115
  /**
118
116
  * Create binlog instance
119
117
  * @group Main
120
118
  */
121
119
  declare function createBinlog(options: Partial<BinlogOptions>): Binlog;
122
-
123
- export { Binlog, type BinlogEntry, type BinlogOptions, createBinlog };
120
+ export { Binlog, BinlogEntry, BinlogOptions, createBinlog };
121
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":["path","maxFileSize","rotation","syncWrites","structures","Structure","Constructor","TData","Buffer","opcode","timestamp","data","position","private","_options","_filePattern","_directory","_currentFile","_currentFileDescriptor","_currentFileSize","_currentFileIndex","_isOpen","_log","BINLOG_MAGIC","BINLOG_VERSION","BINLOG_HEADER_SIZE","BINLOG_ENTRY_HEADER_SIZE","BINLOG_FLAG","constructor","BinlogOptions","options","init","Promise","open","close","write","rotate","readEntries","filename","unsafe","BinlogEntry","currentFileIndex","currentFileName","directory","Partial","BinlogOptions","options","Binlog"],"sources":["../src/Binlog.d.ts","../src/index.d.ts"],"mappings":";;AAIA;;UAAiB,aAAA;EAqBqB;;;;EAhBlCA,IAAAA;EAgBAI;;;;EAXAH,WAAAA;EAgBa;;;;EAXbC,QAAAA;EAuBc;;;;EAlBdC,UAAAA;EACAC,UAAAA,GAAa,SAAA,CAAU,WAAW;AAAA;;;;UAKrB,WAAA,SAAoB,MAAA;EAgBzB;AAAA;AAOZ;EAnBIK,MAAAA;EAmBuB;;;EAfvBC,SAAAA;EA4CS;;;EAxCTC,IAAAA,EAAM,KAAA,GAAQ,MAAA;EA0DuE;;;EAtDrFC,QAAAA;AAAAA;;;;;;cAOiB,MAAA;EAAA,CAChBC,OAAAA;EAAAA,QACOC,QAAAA;EAAAA,QACAC,YAAAA;EAAAA,QACAC,UAAAA;EAAAA,QACAC,YAAAA;EAAAA,QACAC,sBAAAA;EAAAA,QACAC,gBAAAA;EAAAA,QACAC,iBAAAA;EAAAA,QACAC,OAAAA;EAAAA,QACAC,IAAAA;EAAAA,iBACSC,YAAAA;EAAAA,iBACAC,cAAAA;EAAAA,iBACAC,kBAAAA;EAAAA,iBACAC,wBAAAA;EAAAA,iBACAC,WAAAA;EACjBC,WAAAA,CAAYE,OAAAA,EAAS,aAAA;EAarBI;;;;EARAH,IAAAA,IAAQ,OAAA;EAe8BC;;;EAXtCC,IAAAA,IAAQ,OAAA;EAsBI1B;;;EAlBZ2B,KAAAA,IAAS,OAAA;EAkBwDF;;;;;;EAXjEG,KAAAA,CAAM1B,MAAAA,UAAgBE,IAAAA,YAAgB,OAAA;EAuBzB;;AC1GjB;EDuFIyB,MAAAA,IAAU,OAAA;;;;;;;EAOVC,WAAAA,SAAoB,MAAA,EAAQC,QAAAA,UAAkBC,MAAAA,aAAmB,OAAA,CAAQ,WAAA,CAAY,KAAA;EC9FnCM;;;EAAAA,IDkG9CJ,gBAAAA;EClGqE;;;EAAA,IDsGrEC,eAAAA;;;;MAIAC,SAAAA;AAAAA;AA5GR;;;;AAAA,iBCEwB,YAAA,CAAaG,OAAAA,EAAS,OAAA,CAAQ,aAAA,IAAiB,MAAA"}