Skip to content

Commit 2fe91c2

Browse files
Slessimattberther
authored andcommitted
Reintroduce namespace and correct import/export (#247)
1 parent 21fa565 commit 2fe91c2

File tree

1 file changed

+84
-82
lines changed

1 file changed

+84
-82
lines changed

index.d.ts

Lines changed: 84 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import TransportStream from "winston-transport";
1+
import TransportStream = require("winston-transport");
22

33
// referenced from https://stackoverflow.com/questions/40510611/typescript-interface-require-one-of-two-properties-to-exist
44
type RequireOnlyOne<T, Keys extends keyof T = keyof T> =
@@ -12,95 +12,97 @@ type RequireOnlyOne<T, Keys extends keyof T = keyof T> =
1212
// merging into winston.transports
1313
declare module 'winston/lib/winston/transports' {
1414
interface Transports {
15-
DailyRotateFileTransport: typeof DailyRotateFileTransport;
16-
DailyRotateFileTransportOptions: DailyRotateFileTransportOptions;
15+
DailyRotateFileTransport: typeof DailyRotateFile;
16+
DailyRotateFileTransportOptions: DailyRotateFile.DailyRotateFileTransportOptions;
1717
}
1818
}
1919

20-
export type DailyRotateFileTransportOptions = RequireOnlyOne<GeneralDailyRotateFileTransportOptions, 'filename' | 'stream'>;
21-
22-
interface GeneralDailyRotateFileTransportOptions extends TransportStream.TransportStreamOptions {
23-
json?: boolean;
24-
eol?: string;
25-
26-
/**
27-
* A string representing the moment.js date format to be used for rotating. The meta characters used in this string will dictate the frequency of the file rotation. For example, if your datePattern is simply 'HH' you will end up with 24 log files that are picked up and appended to every day. (default 'YYYY-MM-DD')
28-
*/
29-
datePattern?: string;
30-
31-
/**
32-
* A boolean to define whether or not to gzip archived log files. (default 'false')
33-
*/
34-
zippedArchive?: boolean;
35-
36-
/**
37-
* Filename to be used to log to. This filename can include the %DATE% placeholder which will include the formatted datePattern at that point in the filename. (default: 'winston.log.%DATE%)
38-
*/
39-
filename?: string;
40-
41-
/**
42-
* The directory name to save log files to. (default: '.')
43-
*/
44-
dirname?: string;
45-
46-
/**
47-
* Write directly to a custom stream and bypass the rotation capabilities. (default: null)
48-
*/
49-
stream?: NodeJS.WritableStream;
50-
51-
/**
52-
* Maximum size of the file after which it will rotate. This can be a number of bytes, or units of kb, mb, and gb. If using the units, add 'k', 'm', or 'g' as the suffix. The units need to directly follow the number. (default: null)
53-
*/
54-
maxSize?: string | number;
55-
56-
/**
57-
* Maximum number of logs to keep. If not set, no logs will be removed. This can be a number of files or number of days. If using days, add 'd' as the suffix. (default: null)
58-
*/
59-
maxFiles?: string | number;
60-
61-
/**
62-
* An object resembling https://nodejs.org/api/fs.html#fs_fs_createwritestream_path_options indicating additional options that should be passed to the file stream. (default: `{ flags: 'a' }`)
63-
*/
64-
options?: string | object;
65-
66-
/**
67-
* A string representing the name of the name of the audit file. (default: './hash-audit.json')
68-
*/
69-
auditFile?: string;
70-
71-
/**
72-
* A string representing the frequency of rotation. (default: 'custom')
73-
*/
74-
frequency?: string;
75-
76-
/**
77-
* A boolean whether or not to generate file name from "datePattern" in UTC format. (default: false)
78-
*/
79-
utc?: boolean;
80-
81-
/**
82-
* A string representing an extension to be added to the filename, if not included in the filename property. (default: '')
83-
*/
84-
extension?: string;
85-
86-
/**
87-
* Create a tailable symlink to the current active log file. (default: false)
88-
*/
89-
createSymlink?: boolean;
90-
91-
/**
92-
* The name of the tailable symlink. (default: 'current.log')
93-
*/
94-
symlinkName?: string;
20+
declare namespace DailyRotateFile {
21+
type DailyRotateFileTransportOptions = RequireOnlyOne<GeneralDailyRotateFileTransportOptions, 'filename' | 'stream'>;
22+
23+
interface GeneralDailyRotateFileTransportOptions extends TransportStream.TransportStreamOptions {
24+
json?: boolean;
25+
eol?: string;
26+
27+
/**
28+
* A string representing the moment.js date format to be used for rotating. The meta characters used in this string will dictate the frequency of the file rotation. For example, if your datePattern is simply 'HH' you will end up with 24 log files that are picked up and appended to every day. (default 'YYYY-MM-DD')
29+
*/
30+
datePattern?: string;
31+
32+
/**
33+
* A boolean to define whether or not to gzip archived log files. (default 'false')
34+
*/
35+
zippedArchive?: boolean;
36+
37+
/**
38+
* Filename to be used to log to. This filename can include the %DATE% placeholder which will include the formatted datePattern at that point in the filename. (default: 'winston.log.%DATE%)
39+
*/
40+
filename?: string;
41+
42+
/**
43+
* The directory name to save log files to. (default: '.')
44+
*/
45+
dirname?: string;
46+
47+
/**
48+
* Write directly to a custom stream and bypass the rotation capabilities. (default: null)
49+
*/
50+
stream?: NodeJS.WritableStream;
51+
52+
/**
53+
* Maximum size of the file after which it will rotate. This can be a number of bytes, or units of kb, mb, and gb. If using the units, add 'k', 'm', or 'g' as the suffix. The units need to directly follow the number. (default: null)
54+
*/
55+
maxSize?: string | number;
56+
57+
/**
58+
* Maximum number of logs to keep. If not set, no logs will be removed. This can be a number of files or number of days. If using days, add 'd' as the suffix. (default: null)
59+
*/
60+
maxFiles?: string | number;
61+
62+
/**
63+
* An object resembling https://nodejs.org/api/fs.html#fs_fs_createwritestream_path_options indicating additional options that should be passed to the file stream. (default: `{ flags: 'a' }`)
64+
*/
65+
options?: string | object;
66+
67+
/**
68+
* A string representing the name of the name of the audit file. (default: './hash-audit.json')
69+
*/
70+
auditFile?: string;
71+
72+
/**
73+
* A string representing the frequency of rotation. (default: 'custom')
74+
*/
75+
frequency?: string;
76+
77+
/**
78+
* A boolean whether or not to generate file name from "datePattern" in UTC format. (default: false)
79+
*/
80+
utc?: boolean;
81+
82+
/**
83+
* A string representing an extension to be added to the filename, if not included in the filename property. (default: '')
84+
*/
85+
extension?: string;
86+
87+
/**
88+
* Create a tailable symlink to the current active log file. (default: false)
89+
*/
90+
createSymlink?: boolean;
91+
92+
/**
93+
* The name of the tailable symlink. (default: 'current.log')
94+
*/
95+
symlinkName?: string;
96+
}
9597
}
9698

97-
declare class DailyRotateFileTransport extends TransportStream {
99+
declare class DailyRotateFile extends TransportStream {
98100
filename: string;
99101
dirname: string;
100102
logStream: NodeJS.WritableStream;
101-
options: DailyRotateFileTransportOptions;
103+
options: DailyRotateFile.DailyRotateFileTransportOptions;
102104

103-
constructor(options: DailyRotateFileTransportOptions);
105+
constructor(options?: DailyRotateFile.DailyRotateFileTransportOptions);
104106
}
105107

106-
export default DailyRotateFileTransport;
108+
export = DailyRotateFile;

0 commit comments

Comments
 (0)