1 | import { IResolvable, IResolveContext } from './resolvable';
|
2 | /**
|
3 | * Interface for lazy string producers
|
4 | */
|
5 | export interface IStringProducer {
|
6 | /**
|
7 | * Produce the string value
|
8 | */
|
9 | produce(context: IResolveContext): string | undefined;
|
10 | }
|
11 | /**
|
12 | * Interface for (stable) lazy string producers
|
13 | */
|
14 | export interface IStableStringProducer {
|
15 | /**
|
16 | * Produce the string value
|
17 | */
|
18 | produce(): string | undefined;
|
19 | }
|
20 | /**
|
21 | * Interface for lazy list producers
|
22 | */
|
23 | export interface IListProducer {
|
24 | /**
|
25 | * Produce the list value
|
26 | */
|
27 | produce(context: IResolveContext): string[] | undefined;
|
28 | }
|
29 | /**
|
30 | * Interface for (stable) lazy list producers
|
31 | */
|
32 | export interface IStableListProducer {
|
33 | /**
|
34 | * Produce the list value
|
35 | */
|
36 | produce(): string[] | undefined;
|
37 | }
|
38 | /**
|
39 | * Interface for lazy number producers
|
40 | */
|
41 | export interface INumberProducer {
|
42 | /**
|
43 | * Produce the number value
|
44 | */
|
45 | produce(context: IResolveContext): number | undefined;
|
46 | }
|
47 | /**
|
48 | * Interface for (stable) lazy number producers
|
49 | */
|
50 | export interface IStableNumberProducer {
|
51 | /**
|
52 | * Produce the number value
|
53 | */
|
54 | produce(): number | undefined;
|
55 | }
|
56 | /**
|
57 | * Interface for lazy untyped value producers
|
58 | */
|
59 | export interface IAnyProducer {
|
60 | /**
|
61 | * Produce the value
|
62 | */
|
63 | produce(context: IResolveContext): any;
|
64 | }
|
65 | /**
|
66 | * Interface for (stable) lazy untyped value producers
|
67 | */
|
68 | export interface IStableAnyProducer {
|
69 | /**
|
70 | * Produce the value
|
71 | */
|
72 | produce(): any;
|
73 | }
|
74 | /**
|
75 | * Options for creating a lazy string token
|
76 | */
|
77 | export interface LazyStringValueOptions {
|
78 | /**
|
79 | * Use the given name as a display hint
|
80 | *
|
81 | * @default - No hint
|
82 | */
|
83 | readonly displayHint?: string;
|
84 | }
|
85 | /**
|
86 | * Options for creating a lazy list token
|
87 | */
|
88 | export interface LazyListValueOptions {
|
89 | /**
|
90 | * Use the given name as a display hint
|
91 | *
|
92 | * @default - No hint
|
93 | */
|
94 | readonly displayHint?: string;
|
95 | /**
|
96 | * If the produced list is empty, return 'undefined' instead
|
97 | *
|
98 | * @default false
|
99 | */
|
100 | readonly omitEmpty?: boolean;
|
101 | }
|
102 | /**
|
103 | * Options for creating lazy untyped tokens
|
104 | */
|
105 | export interface LazyAnyValueOptions {
|
106 | /**
|
107 | * Use the given name as a display hint
|
108 | *
|
109 | * @default - No hint
|
110 | */
|
111 | readonly displayHint?: string;
|
112 | /**
|
113 | * If the produced value is an array and it is empty, return 'undefined' instead
|
114 | *
|
115 | * @default false
|
116 | */
|
117 | readonly omitEmptyArray?: boolean;
|
118 | }
|
119 | /**
|
120 | * Lazily produce a value
|
121 | *
|
122 | * Can be used to return a string, list or numeric value whose actual value
|
123 | * will only be calculated later, during synthesis.
|
124 | */
|
125 | export declare class Lazy {
|
126 | /**
|
127 | * Defer the calculation of a string value to synthesis time
|
128 | *
|
129 | * Use this if you want to render a string to a template whose actual value depends on
|
130 | * some state mutation that may happen after the construct has been created.
|
131 | *
|
132 | * If you are simply looking to force a value to a `string` type and don't need
|
133 | * the calculation to be deferred, use `Token.asString()` instead.
|
134 | *
|
135 | * @deprecated Use `Lazy.string()` or `Lazy.uncachedString()` instead.
|
136 | */
|
137 | static stringValue(producer: IStringProducer, options?: LazyStringValueOptions): string;
|
138 | /**
|
139 | * Defer the one-time calculation of a string value to synthesis time
|
140 | *
|
141 | * Use this if you want to render a string to a template whose actual value depends on
|
142 | * some state mutation that may happen after the construct has been created.
|
143 | *
|
144 | * If you are simply looking to force a value to a `string` type and don't need
|
145 | * the calculation to be deferred, use `Token.asString()` instead.
|
146 | *
|
147 | * The inner function will only be invoked once, and the resolved value
|
148 | * cannot depend on the Stack the Token is used in.
|
149 | */
|
150 | static string(producer: IStableStringProducer, options?: LazyStringValueOptions): string;
|
151 | /**
|
152 | * Defer the calculation of a string value to synthesis time
|
153 | *
|
154 | * Use of this function is not recommended; unless you know you need it for sure, you
|
155 | * probably don't. Use `Lazy.string()` instead.
|
156 | *
|
157 | * The inner function may be invoked multiple times during synthesis. You
|
158 | * should only use this method if the returned value depends on variables
|
159 | * that may change during the Aspect application phase of synthesis, or if
|
160 | * the value depends on the Stack the value is being used in. Both of these
|
161 | * cases are rare, and only ever occur for AWS Construct Library authors.
|
162 | */
|
163 | static uncachedString(producer: IStringProducer, options?: LazyStringValueOptions): string;
|
164 | /**
|
165 | * Defer the one-time calculation of a number value to synthesis time
|
166 | *
|
167 | * Use this if you want to render a number to a template whose actual value depends on
|
168 | * some state mutation that may happen after the construct has been created.
|
169 | *
|
170 | * If you are simply looking to force a value to a `number` type and don't need
|
171 | * the calculation to be deferred, use `Token.asNumber()` instead.
|
172 | *
|
173 | * @deprecated Use `Lazy.number()` or `Lazy.uncachedNumber()` instead.
|
174 | */
|
175 | static numberValue(producer: INumberProducer): number;
|
176 | /**
|
177 | * Defer the one-time calculation of a number value to synthesis time
|
178 | *
|
179 | * Use this if you want to render a number to a template whose actual value depends on
|
180 | * some state mutation that may happen after the construct has been created.
|
181 | *
|
182 | * If you are simply looking to force a value to a `number` type and don't need
|
183 | * the calculation to be deferred, use `Token.asNumber()` instead.
|
184 | *
|
185 | * The inner function will only be invoked once, and the resolved value
|
186 | * cannot depend on the Stack the Token is used in.
|
187 | */
|
188 | static number(producer: IStableNumberProducer): number;
|
189 | /**
|
190 | * Defer the calculation of a number value to synthesis time
|
191 | *
|
192 | * Use of this function is not recommended; unless you know you need it for sure, you
|
193 | * probably don't. Use `Lazy.number()` instead.
|
194 | *
|
195 | * The inner function may be invoked multiple times during synthesis. You
|
196 | * should only use this method if the returned value depends on variables
|
197 | * that may change during the Aspect application phase of synthesis, or if
|
198 | * the value depends on the Stack the value is being used in. Both of these
|
199 | * cases are rare, and only ever occur for AWS Construct Library authors.
|
200 | */
|
201 | static uncachedNumber(producer: INumberProducer): number;
|
202 | /**
|
203 | * Defer the one-time calculation of a list value to synthesis time
|
204 | *
|
205 | * Use this if you want to render a list to a template whose actual value depends on
|
206 | * some state mutation that may happen after the construct has been created.
|
207 | *
|
208 | * If you are simply looking to force a value to a `string[]` type and don't need
|
209 | * the calculation to be deferred, use `Token.asList()` instead.
|
210 | *
|
211 | * @deprecated Use `Lazy.list()` or `Lazy.uncachedList()` instead.
|
212 | */
|
213 | static listValue(producer: IListProducer, options?: LazyListValueOptions): string[];
|
214 | /**
|
215 | * Defer the calculation of a list value to synthesis time
|
216 | *
|
217 | * Use of this function is not recommended; unless you know you need it for sure, you
|
218 | * probably don't. Use `Lazy.list()` instead.
|
219 | *
|
220 | * The inner function may be invoked multiple times during synthesis. You
|
221 | * should only use this method if the returned value depends on variables
|
222 | * that may change during the Aspect application phase of synthesis, or if
|
223 | * the value depends on the Stack the value is being used in. Both of these
|
224 | * cases are rare, and only ever occur for AWS Construct Library authors.
|
225 | */
|
226 | static uncachedList(producer: IListProducer, options?: LazyListValueOptions): string[];
|
227 | /**
|
228 | * Defer the one-time calculation of a list value to synthesis time
|
229 | *
|
230 | * Use this if you want to render a list to a template whose actual value depends on
|
231 | * some state mutation that may happen after the construct has been created.
|
232 | *
|
233 | * If you are simply looking to force a value to a `string[]` type and don't need
|
234 | * the calculation to be deferred, use `Token.asList()` instead.
|
235 | *
|
236 | * The inner function will only be invoked once, and the resolved value
|
237 | * cannot depend on the Stack the Token is used in.
|
238 | */
|
239 | static list(producer: IStableListProducer, options?: LazyListValueOptions): string[];
|
240 | /**
|
241 | * Defer the one-time calculation of an arbitrarily typed value to synthesis time
|
242 | *
|
243 | * Use this if you want to render an object to a template whose actual value depends on
|
244 | * some state mutation that may happen after the construct has been created.
|
245 | *
|
246 | * @deprecated Use `Lazy.any()` or `Lazy.uncachedAny()` instead.
|
247 | */
|
248 | static anyValue(producer: IAnyProducer, options?: LazyAnyValueOptions): IResolvable;
|
249 | /**
|
250 | * Defer the one-time calculation of an arbitrarily typed value to synthesis time
|
251 | *
|
252 | * Use this if you want to render an object to a template whose actual value depends on
|
253 | * some state mutation that may happen after the construct has been created.
|
254 | *
|
255 | * The inner function will only be invoked one time and cannot depend on
|
256 | * resolution context.
|
257 | */
|
258 | static any(producer: IStableAnyProducer, options?: LazyAnyValueOptions): IResolvable;
|
259 | /**
|
260 | * Defer the calculation of an untyped value to synthesis time
|
261 | *
|
262 | * Use of this function is not recommended; unless you know you need it for sure, you
|
263 | * probably don't. Use `Lazy.any()` instead.
|
264 | *
|
265 | * The inner function may be invoked multiple times during synthesis. You
|
266 | * should only use this method if the returned value depends on variables
|
267 | * that may change during the Aspect application phase of synthesis, or if
|
268 | * the value depends on the Stack the value is being used in. Both of these
|
269 | * cases are rare, and only ever occur for AWS Construct Library authors.
|
270 | */
|
271 | static uncachedAny(producer: IAnyProducer, options?: LazyAnyValueOptions): IResolvable;
|
272 | private constructor();
|
273 | }
|