-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathglobals.d.ts
171 lines (157 loc) · 5.46 KB
/
globals.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
// Copyright (c) Fensak, LLC.
// SPDX-License-Identifier: MPL-2.0
declare var __projectroot: string;
declare var __dirname: string;
declare var __filename: string;
declare var console: Console;
declare var path: Path;
interface Console {
/**
* Logs a message to the console at the `TRACE` level with a newline. Multiple arguments can be passed.
*
* Each item that is passed will be JSON strigified and space separated before logging to console.
*
* ```js
* const code = 5;
* const foo = { msg: "hello world" };
* console.trace(foo, code);
* // Prints: TRACE: {"msg":"hello world"} 5
* ```
*/
trace(...args: any[]): void;
/**
* Logs a message to the console at the `DEBUG` level with a newline. Multiple arguments can be passed.
*
* Each item that is passed will be JSON strigified and space separated before logging to console.
*
* ```js
* const code = 5;
* const foo = { msg: "hello world" };
* console.debug(foo, code);
* // Prints: DEBUG: {"msg":"hello world"} 5
* ```
*/
debug(...args: any[]): void;
/**
* Logs a message to the console at the `INFO` level with a newline. Multiple arguments can be passed.
*
* Each item that is passed will be JSON strigified and space separated before logging to console.
*
* ```js
* const code = 5;
* const foo = { msg: "hello world" };
* console.info(foo, code);
* // Prints: INFO: {"msg":"hello world"} 5
* ```
*/
info(...args: any[]): void;
/**
* Logs a message to the console at the `WARN` level with a newline. Multiple arguments can be passed.
*
* Each item that is passed will be JSON strigified and space separated before logging to console.
*
* ```js
* const code = 5;
* const foo = { msg: "hello world" };
* console.warn(foo, code);
* // Prints: WARN: {"msg":"hello world"} 5
* ```
*/
warn(...args: any[]): void;
/**
* Logs a message to the console at the `ERROR` level with a newline. Multiple arguments can be passed.
*
* Each item that is passed will be JSON strigified and space separated before logging to console.
*
* ```js
* const code = 5;
* const foo = { msg: "hello world" };
* console.error(foo, code);
* // Prints: ERROR: {"msg":"hello world"} 5
* ```
*/
error(...args: any[]): void;
/**
* Alias for info.
*/
log(...args: any[]): void;
}
interface Path {
/**
* Returns the relative path from `base` to `p`. Joining the result to `base` will return `p`.
*
* ```js
* const base = "/home/senc/example"
* const p = "/home/senc/example/some/path/to/file.js"
* const r = path.rel(base, p)
* // r is "some/path/to/file.js"
* ```
*/
rel(base: string, p: string): string;
}
declare namespace senc {
/**
* Special class that indicates to senc that there is output metadata.
* This is useful to control the output behavior of the IaC objects, such as specifying the file format and extension.
*/
class OutData {
/**
* @params out_path The path of the output file, relative to the output dir. Only one of out_path or out_ext can be
* set.
* @params out_ext The extension of the output file, including the preceding `.` (e.g., `.json`).
* @params out_type The type of the output file. Either JSON or YAML.
* @params out_prefix An optional string to prepend to the file output. This is useful for adding comments such as a
* license header or a note about the file being autogenerated.
* @params schema_path An optional path to a schema file to use for validating the rendered data. The path is
* relative to the directory of the entrypoint. Currently only supports jsonschema.
* @params data The data to output to the output file. This can be any JSON/YAML serializable object.
*/
constructor(attrs: {
out_path?: string;
out_ext?: string;
out_type: "yaml" | "json";
out_prefix?: string;
schema_path?: string;
data: any;
});
/**
* A special marker function to indicate this is a senc OutData object to the runtime.
*/
__is_senc_out_data(): void;
}
/**
* A list of OutData objects. We use a class instead of a type so that we can bind a function that indicates this is
* an OutDataArray to the runtime.
*/
class OutDataArray extends Array {
constructor(...args: OutData[]);
push(...args: OutData[]): any;
__is_senc_out_data_array(): void;
}
/**
* Import the given file path as a JSON object. This equivalent to loading the file from disk and parsing it using
* JSON.parse.
*
* NOTE:
* - The provided path must be an absolute path. Use `__dirname` to construct the import path.
* - For security purposes, this only supports importing files in the project root as configured through the senc CLI.
*
* ```js
* const cfg = await import_json(`${__dirname}/someconfig.json`);
* ```
*/
function import_json(p: string): Promise<any>;
/**
* Import the given file path as a YAML object. This equivalent to loading the file from disk and parsing it using
* YAML.parse.
*
* NOTE:
* - The provided path must be an absolute path. Use `__dirname` to construct the import path.
* - For security purposes, this only supports importing files in the project root as configured through the senc CLI.
*
* ```js
* const cfg = await import_yaml(`${__dirname}/someconfig.yaml`);
* ```
*/
function import_yaml(p: string): Promise<any>;
}