This repository has been archived by the owner on Jan 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
97 lines (75 loc) · 2.35 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
declare module '@augu/dotenv' {
type Class<T> = {
new (...args: any[]): T;
}
interface UnpopulatedParseOptions<T extends object> {
populate: false;
/** Custom delimiter to split an Array */
delimiter?: string;
/** The custom readers to add */
readers?: (Class<TypeReader>)[];
/** The schema to follow */
schema?: {
[P in keyof T]: string | SchemaOptions;
}
/** The file to use (default: `<current directory>/.env`) */
file?: string;
}
interface PopulatedParseOptions<T extends object> {
populate: true;
/** Custom delimiter to split an Array */
delimiter?: string;
/** The custom readers to add */
readers?: (Class<TypeReader>)[];
/** The schema to follow */
schema?: {
[x in keyof T]: string | SchemaOptions;
}
/** The file to use (default: `<current directory>/.env`) */
file?: string;
}
interface SchemaOptions {
/** A default value if the property doesn't exist */
default?: any;
/** Chooses one of these values */
oneOf?: any[];
/** The minimum value to use (only used in `int` and `string` Type Readers) */
min?: number;
/** The maximum value to use (only used in `int` and `string` Type Readers) */
max?: number;
/** The type reader to use */
type: string;
}
export abstract class TypeReader<T = unknown> {
/** The type reader's ID */
public id: string;
/**
* Creates a new `TypeReader`
* @param id The ID
* @param aliases Any additional aliases to use to find this TypeReader
*/
constructor(id: string);
/**
* Validates the reader
* @param arg The raw value
*/
public abstract validate(arg: string): boolean;
/**
* Parses the reader
* @param arg The raw value
*/
public abstract parse(arg: string): T;
}
/** Returns the version of this library */
export const version: string;
/**
* Populates an `.env` file
* @param options The options to use
*/
export function parse<T extends object = {}>(options: PopulatedParseOptions<T>): void;
/**
* Returns the parsed results from the `.env` file
* @param options The options to use
*/
export function parse<T extends object = {}>(options: UnpopulatedParseOptions<T>): T;
}