44 * This software may be modified and distributed under the terms
55 * of the MIT license. See the LICENSE file for details.
66 */
7+
78/** *********************************************************************
89 * SINGLE-VALUE COLLECTORS
910 */
@@ -15,10 +16,11 @@ export type SingleValueCollectorTypes =
1516 | 'PasswordCollector'
1617 | 'SingleValueCollector'
1718 | 'SingleSelectCollector'
19+ | 'SingleSelectObjectCollector'
1820 | 'TextCollector'
1921 | 'ValidatedTextCollector' ;
2022
21- interface SelectorOptions {
23+ interface SelectorOption {
2224 label : string ;
2325 value : string ;
2426}
@@ -90,7 +92,7 @@ export interface SingleSelectCollectorWithValue<T extends SingleValueCollectorTy
9092 label : string ;
9193 type : string ;
9294 value : string | number | boolean ;
93- options : SelectorOptions [ ] ;
95+ options : SelectorOption [ ] ;
9496 } ;
9597}
9698
@@ -127,7 +129,7 @@ export interface SingleSelectCollectorNoValue<T extends SingleValueCollectorType
127129 key : string ;
128130 label : string ;
129131 type : string ;
130- options : SelectorOptions [ ] ;
132+ options : SelectorOption [ ] ;
131133 } ;
132134}
133135
@@ -143,16 +145,18 @@ export type InferSingleValueCollectorType<T extends SingleValueCollectorTypes> =
143145 ? TextCollector
144146 : T extends 'SingleSelectCollector'
145147 ? SingleSelectCollector
146- : T extends 'PasswordCollector'
147- ? PasswordCollector
148- : /**
149- * At this point, we have not passed in a collector type
150- * or we have explicitly passed in 'SingleValueCollector'
151- * So we can return either a SingleValueCollector with value
152- * or without a value.
153- **/
154- | SingleValueCollectorWithValue < 'SingleValueCollector' >
155- | SingleValueCollectorNoValue < 'SingleValueCollector' > ;
148+ : T extends 'ValidatedTextCollector'
149+ ? ValidatedTextCollector
150+ : T extends 'PasswordCollector'
151+ ? PasswordCollector
152+ : /**
153+ * At this point, we have not passed in a collector type
154+ * or we have explicitly passed in 'SingleValueCollector'
155+ * So we can return either a SingleValueCollector with value
156+ * or without a value.
157+ **/
158+ | SingleValueCollectorWithValue < 'SingleValueCollector' >
159+ | SingleValueCollectorNoValue < 'SingleValueCollector' > ;
156160
157161/**
158162 * SINGLE-VALUE COLLECTOR TYPES
@@ -198,7 +202,7 @@ export interface MultiValueCollectorWithValue<T extends MultiValueCollectorTypes
198202 label : string ;
199203 type : string ;
200204 value : string [ ] ;
201- options : SelectorOptions [ ] ;
205+ options : SelectorOption [ ] ;
202206 } ;
203207}
204208
@@ -218,7 +222,7 @@ export interface MultiValueCollectorNoValue<T extends MultiValueCollectorTypes>
218222 label : string ;
219223 type : string ;
220224 value : string [ ] ;
221- options : SelectorOptions [ ] ;
225+ options : SelectorOption [ ] ;
222226 } ;
223227}
224228
@@ -246,6 +250,101 @@ export type MultiValueCollector<T extends MultiValueCollectorTypes> =
246250
247251export type MultiSelectCollector = MultiValueCollectorWithValue < 'MultiSelectCollector' > ;
248252
253+ /** *********************************************************************
254+ * OBJECT COLLECTORS
255+ */
256+
257+ export type ObjectValueCollectorTypes =
258+ | 'DeviceAuthenticationCollector'
259+ | 'DeviceRegistrationCollector'
260+ | 'ObjectValueCollector'
261+ | 'ObjectSelectCollector' ;
262+
263+ interface ObjectOptionWithValue {
264+ type : string ;
265+ label : string ;
266+ content : string ;
267+ default : boolean ;
268+ value : string ;
269+ key : string ;
270+ }
271+
272+ interface ObjectOptionNoValue {
273+ type : string ;
274+ label : string ;
275+ content : string ;
276+ value : string ;
277+ key : string ;
278+ }
279+
280+ interface ObjectValue {
281+ type : string ;
282+ id : string ;
283+ value : string ;
284+ }
285+
286+ export interface ObjectValueCollectorNoValue < T extends ObjectValueCollectorTypes > {
287+ category : 'ObjectValueCollector' ;
288+ error : string | null ;
289+ type : T ;
290+ id : string ;
291+ name : string ;
292+ input : {
293+ key : string ;
294+ value : string | null ;
295+ type : string ;
296+ } ;
297+ output : {
298+ key : string ;
299+ label : string ;
300+ type : string ;
301+ options : ObjectOptionNoValue [ ] ;
302+ } ;
303+ }
304+
305+ export interface ObjectValueCollectorWithValue < T extends ObjectValueCollectorTypes > {
306+ category : 'ObjectValueCollector' ;
307+ error : string | null ;
308+ type : T ;
309+ id : string ;
310+ name : string ;
311+ input : {
312+ key : string ;
313+ value : ObjectValue | null ;
314+ type : string ;
315+ } ;
316+ output : {
317+ key : string ;
318+ label : string ;
319+ type : string ;
320+ options : ObjectOptionWithValue [ ] ;
321+ } ;
322+ }
323+
324+ export type InferValueObjectCollectorType < T extends ObjectValueCollectorTypes > =
325+ T extends 'DeviceAuthenticationCollector'
326+ ? DeviceAuthenticationCollector
327+ : T extends 'DeviceRegistrationCollector'
328+ ? DeviceRegistrationCollector
329+ :
330+ | ObjectValueCollectorWithValue < 'ObjectValueCollector' >
331+ | ObjectValueCollectorNoValue < 'ObjectValueCollector' > ;
332+
333+ export type ObjectValueCollectors =
334+ | ObjectValueCollectorWithValue < 'DeviceAuthenticationCollector' >
335+ | ObjectValueCollectorNoValue < 'DeviceRegistrationCollector' >
336+ | ObjectValueCollectorWithValue < 'ObjectSelectCollector' >
337+ | ObjectValueCollectorNoValue < 'ObjectSelectCollector' > ;
338+
339+ export type ObjectValueCollector < T extends ObjectValueCollectorTypes > =
340+ | ObjectValueCollectorWithValue < T >
341+ | ObjectValueCollectorNoValue < T > ;
342+
343+ export type DeviceRegistrationCollector =
344+ ObjectValueCollectorNoValue < 'DeviceRegistrationCollector' > ;
345+ export type DeviceAuthenticationCollector =
346+ ObjectValueCollectorWithValue < 'DeviceAuthenticationCollector' > ;
347+
249348/** *********************************************************************
250349 * ACTION COLLECTORS
251350 */
0 commit comments