@nan0web/ui 1.0.4 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/README.md +19 -14
  2. package/package.json +6 -4
  3. package/src/App/Command/DepsCommand.js +25 -0
  4. package/src/App/Core/CoreApp.js +18 -17
  5. package/src/App/Core/UI.js +12 -19
  6. package/src/App/Core/Widget.js +6 -10
  7. package/src/App/Core/index.js +3 -3
  8. package/src/App/Scenario.js +4 -4
  9. package/src/App/User/Command/Message.js +2 -29
  10. package/src/App/User/Command/index.js +3 -4
  11. package/src/App/User/UserApp.js +30 -23
  12. package/src/App/User/UserUI.js +2 -2
  13. package/src/App/User/index.js +2 -2
  14. package/src/App/index.js +5 -10
  15. package/src/Component/Process/Input.js +10 -17
  16. package/src/Component/Process/Process.js +3 -5
  17. package/src/Component/Process/index.js +2 -2
  18. package/src/Component/SortableList/SortableList.js +100 -0
  19. package/src/Component/SortableList/index.js +3 -0
  20. package/src/Component/Welcome/Input.js +2 -4
  21. package/src/Component/Welcome/Welcome.js +5 -9
  22. package/src/Component/Welcome/index.js +2 -2
  23. package/src/Component/index.js +5 -3
  24. package/src/Frame/Frame.js +163 -146
  25. package/src/Frame/Props.js +20 -20
  26. package/src/Locale.js +17 -18
  27. package/src/Model/User/User.js +3 -6
  28. package/src/Model/index.js +1 -1
  29. package/src/README.md.js +84 -94
  30. package/src/StdIn.js +8 -12
  31. package/src/StdOut.js +23 -27
  32. package/src/View/RenderOptions.js +1 -1
  33. package/src/View/View.js +42 -38
  34. package/src/core/Error/CancelError.js +2 -2
  35. package/src/core/Error/index.js +3 -5
  36. package/src/core/Flow.js +347 -0
  37. package/src/core/Form/Form.js +35 -33
  38. package/src/core/Form/Input.js +29 -14
  39. package/src/core/Form/Message.js +3 -6
  40. package/src/core/Form/index.js +4 -8
  41. package/src/core/InputAdapter.js +4 -6
  42. package/src/core/Message/Message.js +9 -12
  43. package/src/core/Message/OutputMessage.js +19 -17
  44. package/src/core/Message/index.js +2 -2
  45. package/src/core/OutputAdapter.js +12 -10
  46. package/src/core/Stream.js +4 -3
  47. package/src/core/StreamEntry.js +2 -2
  48. package/src/core/UiAdapter.js +57 -29
  49. package/src/core/index.js +38 -9
  50. package/src/functions.js +8 -15
  51. package/src/index.js +21 -32
  52. package/types/App/Command/DepsCommand.d.ts +16 -0
  53. package/types/App/Command/Options.d.ts +37 -40
  54. package/types/App/Command/index.d.ts +6 -6
  55. package/types/App/Core/CoreApp.d.ts +2 -2
  56. package/types/App/Core/UI.d.ts +6 -7
  57. package/types/App/Core/Widget.d.ts +4 -4
  58. package/types/App/Core/index.d.ts +3 -3
  59. package/types/App/Scenario.d.ts +1 -1
  60. package/types/App/User/Command/Message.d.ts +2 -16
  61. package/types/App/User/Command/Options.d.ts +29 -29
  62. package/types/App/User/Command/index.d.ts +2 -3
  63. package/types/App/User/UserApp.d.ts +5 -5
  64. package/types/App/User/index.d.ts +2 -2
  65. package/types/App/index.d.ts +4 -4
  66. package/types/Component/Process/Process.d.ts +2 -2
  67. package/types/Component/Process/index.d.ts +2 -2
  68. package/types/Component/SortableList/SortableList.d.ts +58 -0
  69. package/types/Component/SortableList/index.d.ts +2 -0
  70. package/types/Component/Welcome/Input.d.ts +1 -1
  71. package/types/Component/Welcome/Welcome.d.ts +1 -1
  72. package/types/Component/Welcome/index.d.ts +2 -2
  73. package/types/Component/index.d.ts +5 -3
  74. package/types/Frame/Frame.d.ts +1 -1
  75. package/types/Frame/Props.d.ts +1 -1
  76. package/types/Model/index.d.ts +1 -1
  77. package/types/StdIn.d.ts +2 -2
  78. package/types/StdOut.d.ts +1 -1
  79. package/types/View/View.d.ts +7 -7
  80. package/types/core/Error/index.d.ts +1 -1
  81. package/types/core/Flow.d.ts +320 -0
  82. package/types/core/Form/Form.d.ts +2 -2
  83. package/types/core/Form/Input.d.ts +15 -4
  84. package/types/core/Form/Message.d.ts +1 -1
  85. package/types/core/Form/index.d.ts +3 -3
  86. package/types/core/InputAdapter.d.ts +2 -2
  87. package/types/core/Intent.d.ts +65 -68
  88. package/types/core/Message/InputMessage.d.ts +65 -65
  89. package/types/core/Message/Message.d.ts +1 -1
  90. package/types/core/Message/OutputMessage.d.ts +1 -1
  91. package/types/core/Message/index.d.ts +2 -2
  92. package/types/core/Stream.d.ts +1 -2
  93. package/types/core/UiAdapter.d.ts +22 -4
  94. package/types/core/index.d.ts +5 -2
  95. package/types/index.d.ts +10 -10
@@ -0,0 +1,320 @@
1
+ /**
2
+ * Component types that can be yielded from a Flow.
3
+ *
4
+ * @typedef {'view' | 'prompt' | 'stream' | 'action' | 'flow'} ComponentType
5
+ */
6
+ /**
7
+ * Base interface for all UI components.
8
+ *
9
+ * @typedef {Object} FlowComponent
10
+ * @property {ComponentType} type - Component type discriminator.
11
+ * @property {string} [name] - Optional component name for debugging.
12
+ */
13
+ /**
14
+ * Static view component (no user input required).
15
+ * Examples: Alert, Badge, Toast, Table, Text
16
+ *
17
+ * @typedef {Object} ViewComponent
18
+ * @property {'view'} type - Always 'view'.
19
+ * @property {string} name - Component name (e.g., 'Alert', 'Toast').
20
+ * @property {Object} props - Component-specific properties.
21
+ */
22
+ /**
23
+ * Interactive prompt component (requires user input).
24
+ * Examples: Input, Select, Confirm, Multiselect, Mask
25
+ *
26
+ * @typedef {Object} PromptComponent
27
+ * @property {'prompt'} type - Always 'prompt'.
28
+ * @property {string} name - Component name (e.g., 'Select', 'Input').
29
+ * @property {Object} props - Component-specific properties.
30
+ * @property {string} [props.message] - Prompt message to display.
31
+ * @property {any[]} [props.choices] - Options for Select/Multiselect.
32
+ * @property {Function} [props.validate] - Validation function.
33
+ */
34
+ /**
35
+ * Streaming component for progress/async operations.
36
+ * Examples: Spinner, ProgressBar, StreamChunk
37
+ *
38
+ * @typedef {Object} StreamComponent
39
+ * @property {'stream'} type - Always 'stream'.
40
+ * @property {string} name - Component name (e.g., 'Spinner', 'Progress').
41
+ * @property {Object} props - Component-specific properties.
42
+ * @property {AsyncIterable} [iterable] - Async iterator for streaming content.
43
+ */
44
+ /**
45
+ * Action component for physical or side-effect operations.
46
+ * Examples: Move, Sound, Light, Notify
47
+ *
48
+ * @typedef {Object} ActionComponent
49
+ * @property {'action'} type - Always 'action'.
50
+ * @property {string} name - Component name (e.g., 'Move', 'Beep').
51
+ * @property {Object} props - Component-specific properties.
52
+ */
53
+ /**
54
+ * Result returned by prompt components.
55
+ *
56
+ * @typedef {Object} PromptResult
57
+ * @property {any} value - The value entered/selected by user.
58
+ * @property {boolean} [cancelled] - True if user cancelled the prompt.
59
+ */
60
+ /**
61
+ * Adapter interface that all platform adapters must implement.
62
+ *
63
+ * @typedef {Object} FlowAdapter
64
+ * @property {(component: ViewComponent) => void | Promise<void>} renderView
65
+ * Renders a static view component.
66
+ * @property {(component: PromptComponent) => Promise<PromptResult>} executePrompt
67
+ * Execute an interactive prompt and returns user input.
68
+ * @property {(component: StreamComponent) => AsyncIterable} streamProgress
69
+ * Handles streaming components.
70
+ * @property {(component: ActionComponent) => Promise<any>} [executeAction]
71
+ * Executes an action component (physical or side-effect).
72
+ */
73
+ /**
74
+ * Creates a View component.
75
+ *
76
+ * @param {string} name - Component name (e.g., 'Alert', 'Toast').
77
+ * @param {Object} props - Component properties.
78
+ * @returns {ViewComponent}
79
+ *
80
+ * @example
81
+ * yield View('Alert', { variant: 'success', message: 'Done!' })
82
+ */
83
+ export function View(name: string, props?: any): ViewComponent;
84
+ /**
85
+ * Creates a Prompt component.
86
+ *
87
+ * @param {string} name - Component name (e.g., 'Select', 'Input').
88
+ * @param {Object} props - Component properties.
89
+ * @returns {PromptComponent}
90
+ *
91
+ * @example
92
+ * const value = yield Prompt('Select', { message: 'Choose:', choices: ['a', 'b'] })
93
+ */
94
+ export function Prompt(name: string, props?: any): PromptComponent;
95
+ /**
96
+ * Creates a Stream component.
97
+ *
98
+ * @param {string} name - Component name (e.g., 'Spinner', 'Progress').
99
+ * @param {Object} props - Component properties.
100
+ * @returns {StreamComponent}
101
+ *
102
+ * @example
103
+ * yield* Stream('Progress', { total: 100, current: 50 })
104
+ */
105
+ export function Stream(name: string, props?: any): StreamComponent;
106
+ /**
107
+ * Creates an Action component.
108
+ *
109
+ * @param {string} name - Action name.
110
+ * @param {Object} props - Action properties.
111
+ * @returns {ActionComponent}
112
+ */
113
+ export function Action(name: string, props?: any): ActionComponent;
114
+ /**
115
+ * Runs a Flow (async generator) with the provided adapter.
116
+ *
117
+ * The Flow runner iterates through yielded components and dispatches them
118
+ * to the appropriate adapter method based on component type.
119
+ *
120
+ * @param {AsyncGenerator} flow - The flow generator to execute.
121
+ * @param {FlowAdapter} adapter - The platform-specific adapter.
122
+ * @param {Object} [options={}] - Additional options.
123
+ * @param {AbortSignal} [options.signal] - Abort signal for cancellation.
124
+ * @returns {Promise<any>} The final return value of the flow.
125
+ *
126
+ * @example
127
+ * async function* loginFlow() {
128
+ * yield Alert({ message: 'Welcome!' })
129
+ * const username = yield Input({ message: 'Username:' })
130
+ * const password = yield Password({ message: 'Password:' })
131
+ * return { username, password }
132
+ * }
133
+ *
134
+ * const result = await runFlow(loginFlow(), cliAdapter)
135
+ */
136
+ export function runFlow(flow: AsyncGenerator, adapter: FlowAdapter, options?: {
137
+ signal?: AbortSignal | undefined;
138
+ }): Promise<any>;
139
+ /**
140
+ * Wraps a nested flow for composition with yield*.
141
+ *
142
+ * @param {Function} flowFn - Flow generator function.
143
+ * @param {...any} args - Arguments to pass to the flow function.
144
+ * @returns {Object} A flow component.
145
+ *
146
+ * @example
147
+ * async function* mainFlow() {
148
+ * yield Alert({ message: 'Starting...' })
149
+ * const user = yield* flow(loginFlow)
150
+ * yield Alert({ message: `Welcome, ${user.name}!` })
151
+ * }
152
+ */
153
+ export function flow(flowFn: Function, ...args: any[]): any;
154
+ export function Alert(props: any): ViewComponent;
155
+ export function Toast(props: any): ViewComponent;
156
+ export function Badge(props: any): ViewComponent;
157
+ export function Text(props: any): ViewComponent;
158
+ export function Table(props: any): ViewComponent;
159
+ export function Input(props: any): PromptComponent;
160
+ export function Select(props: any): PromptComponent;
161
+ export function Confirm(props: any): PromptComponent;
162
+ export function Multiselect(props: any): PromptComponent;
163
+ export function Mask(props: any): PromptComponent;
164
+ export function Password(props: any): PromptComponent;
165
+ export function Spinner(props: any): StreamComponent;
166
+ export function Progress(props: any): StreamComponent;
167
+ export function Beep(props: any): ActionComponent;
168
+ export function Move(props: any): ActionComponent;
169
+ declare namespace _default {
170
+ export { runFlow };
171
+ export { flow };
172
+ export { View };
173
+ export { Prompt };
174
+ export { Stream };
175
+ export { Alert };
176
+ export { Toast };
177
+ export { Badge };
178
+ export { Text };
179
+ export { Table };
180
+ export { Input };
181
+ export { Select };
182
+ export { Confirm };
183
+ export { Multiselect };
184
+ export { Mask };
185
+ export { Password };
186
+ export { Spinner };
187
+ export { Progress };
188
+ }
189
+ export default _default;
190
+ /**
191
+ * Component types that can be yielded from a Flow.
192
+ */
193
+ export type ComponentType = "view" | "prompt" | "stream" | "action" | "flow";
194
+ /**
195
+ * Base interface for all UI components.
196
+ */
197
+ export type FlowComponent = {
198
+ /**
199
+ * - Component type discriminator.
200
+ */
201
+ type: ComponentType;
202
+ /**
203
+ * - Optional component name for debugging.
204
+ */
205
+ name?: string | undefined;
206
+ };
207
+ /**
208
+ * Static view component (no user input required).
209
+ * Examples: Alert, Badge, Toast, Table, Text
210
+ */
211
+ export type ViewComponent = {
212
+ /**
213
+ * - Always 'view'.
214
+ */
215
+ type: "view";
216
+ /**
217
+ * - Component name (e.g., 'Alert', 'Toast').
218
+ */
219
+ name: string;
220
+ /**
221
+ * - Component-specific properties.
222
+ */
223
+ props: any;
224
+ };
225
+ /**
226
+ * Interactive prompt component (requires user input).
227
+ * Examples: Input, Select, Confirm, Multiselect, Mask
228
+ */
229
+ export type PromptComponent = {
230
+ /**
231
+ * - Always 'prompt'.
232
+ */
233
+ type: "prompt";
234
+ /**
235
+ * - Component name (e.g., 'Select', 'Input').
236
+ */
237
+ name: string;
238
+ /**
239
+ * - Component-specific properties.
240
+ */
241
+ props: {
242
+ message?: string | undefined;
243
+ choices?: any[] | undefined;
244
+ validate?: Function | undefined;
245
+ };
246
+ };
247
+ /**
248
+ * Streaming component for progress/async operations.
249
+ * Examples: Spinner, ProgressBar, StreamChunk
250
+ */
251
+ export type StreamComponent = {
252
+ /**
253
+ * - Always 'stream'.
254
+ */
255
+ type: "stream";
256
+ /**
257
+ * - Component name (e.g., 'Spinner', 'Progress').
258
+ */
259
+ name: string;
260
+ /**
261
+ * - Component-specific properties.
262
+ */
263
+ props: any;
264
+ /**
265
+ * - Async iterator for streaming content.
266
+ */
267
+ iterable?: AsyncIterable<any> | undefined;
268
+ };
269
+ /**
270
+ * Action component for physical or side-effect operations.
271
+ * Examples: Move, Sound, Light, Notify
272
+ */
273
+ export type ActionComponent = {
274
+ /**
275
+ * - Always 'action'.
276
+ */
277
+ type: "action";
278
+ /**
279
+ * - Component name (e.g., 'Move', 'Beep').
280
+ */
281
+ name: string;
282
+ /**
283
+ * - Component-specific properties.
284
+ */
285
+ props: any;
286
+ };
287
+ /**
288
+ * Result returned by prompt components.
289
+ */
290
+ export type PromptResult = {
291
+ /**
292
+ * - The value entered/selected by user.
293
+ */
294
+ value: any;
295
+ /**
296
+ * - True if user cancelled the prompt.
297
+ */
298
+ cancelled?: boolean | undefined;
299
+ };
300
+ /**
301
+ * Adapter interface that all platform adapters must implement.
302
+ */
303
+ export type FlowAdapter = {
304
+ /**
305
+ * Renders a static view component.
306
+ */
307
+ renderView: (component: ViewComponent) => void | Promise<void>;
308
+ /**
309
+ * Execute an interactive prompt and returns user input.
310
+ */
311
+ executePrompt: (component: PromptComponent) => Promise<PromptResult>;
312
+ /**
313
+ * Handles streaming components.
314
+ */
315
+ streamProgress: (component: StreamComponent) => AsyncIterable<any>;
316
+ /**
317
+ * Executes an action component (physical or side-effect).
318
+ */
319
+ executeAction?: ((component: ActionComponent) => Promise<any>) | undefined;
320
+ };
@@ -122,5 +122,5 @@ export default class UIForm extends FormMessage {
122
122
  */
123
123
  toJSON(): any;
124
124
  }
125
- import FormMessage from "./Message.js";
126
- import FormInput from "./Input.js";
125
+ import FormMessage from './Message.js';
126
+ import FormInput from './Input.js';
@@ -14,8 +14,9 @@
14
14
  * @property {string} type - Input type (text, email, number, select, etc.).
15
15
  * @property {boolean} required - Whether the field is required.
16
16
  * @property {string} placeholder - Placeholder text.
17
- * @property {Array<string>} options - Select options (if type is 'select').
18
- * @property {Function|null} validation - Custom validation function.
17
+ * @property {InputOptions} options - Select options (if type is 'select').
18
+ * @property {Function} validation - Custom validation function.
19
+ * @property {string} mask - Mask pattern (e.g. '###-###').
19
20
  * @property {*} defaultValue - Default value.
20
21
  */
21
22
  export default class FormInput {
@@ -29,6 +30,13 @@ export default class FormInput {
29
30
  SELECT: string;
30
31
  CHECKBOX: string;
31
32
  TEXTAREA: string;
33
+ PASSWORD: string;
34
+ SECRET: string;
35
+ MASK: string;
36
+ CONFIRM: string;
37
+ TOGGLE: string;
38
+ MULTISELECT: string;
39
+ AUTOCOMPLETE: string;
32
40
  };
33
41
  /**
34
42
  * @param {*} input
@@ -45,7 +53,8 @@ export default class FormInput {
45
53
  * @param {boolean} [props.required=false] - Is required.
46
54
  * @param {string} [props.placeholder=''] - Placeholder.
47
55
  * @param {InputOptions} [props.options=[]] - Select options or async function to retrieve data with the search and page.
48
- * @param {Function} [props.validation=null] - Custom validation.
56
+ * @param {Function} [props.validation] - Custom validation.
57
+ * @param {string} [props.mask=''] - Mask pattern.
49
58
  * @param {*} [props.defaultValue=null] - Default value.
50
59
  */
51
60
  constructor(props: {
@@ -56,6 +65,7 @@ export default class FormInput {
56
65
  placeholder?: string | undefined;
57
66
  options?: InputOptions | undefined;
58
67
  validation?: Function | undefined;
68
+ mask?: string | undefined;
59
69
  defaultValue?: any;
60
70
  });
61
71
  /** @type {string} */ name: string;
@@ -64,7 +74,8 @@ export default class FormInput {
64
74
  /** @type {boolean} */ required: boolean;
65
75
  /** @type {string} */ placeholder: string;
66
76
  /** @type {InputOptions} */ options: InputOptions;
67
- /** @type {import("@nan0web/co").ValidateFn|null} */ validation: import("@nan0web/co").ValidateFn | null;
77
+ /** @type {Function} */ validation: Function;
78
+ /** @type {string} */ mask: string;
68
79
  /** @type {*} */ defaultValue: any;
69
80
  requireValidType(): void;
70
81
  /**
@@ -26,4 +26,4 @@ export default class FormMessage extends UiMessage {
26
26
  errors: any;
27
27
  };
28
28
  }
29
- import UiMessage from "../Message/Message.js";
29
+ import UiMessage from '../Message/Message.js';
@@ -1,5 +1,5 @@
1
1
  export default Form;
2
- import FormInput from "./Input.js";
3
- import FormMessage from "./Message.js";
4
- import Form from "./Form.js";
2
+ import FormInput from './Input.js';
3
+ import FormMessage from './Message.js';
4
+ import Form from './Form.js';
5
5
  export { FormInput, FormMessage, Form };
@@ -42,5 +42,5 @@ export default class InputAdapter extends Event {
42
42
  value: string | null;
43
43
  }>;
44
44
  }
45
- import Event from "@nan0web/event/oop";
46
- import CancelError from "./Error/CancelError.js";
45
+ import Event from '@nan0web/event/oop';
46
+ import CancelError from './Error/CancelError.js';
@@ -18,74 +18,71 @@
18
18
  * }
19
19
  */
20
20
  declare class Intent extends Message {
21
- /**
22
- * Create a new Intent.
23
- *
24
- * @param {object} input
25
- * @param {typeof Message} input.target - message class this intent wants to create
26
- * @param {any} [input.context] - execution context
27
- * @param {object} [body] - partial or complete data for the target message
28
- */
29
- constructor({ target, context, ...body }?: {
30
- target: typeof Message;
31
- context?: any;
32
- });
33
- /**
34
- * The target Message class this Intent aims to produce.
35
- * Must be a class with a static `.Body` schema.
36
- *
37
- * @type {typeof Message | null}
38
- */
39
- target: typeof Message | null;
40
- /**
41
- * Optional context for execution (session, locale, state, etc.).
42
- *
43
- * @type {any}
44
- */
45
- context: any;
46
- /**
47
- * Validates all fields in the Intent's body against the target's schema.
48
- *
49
- * Checks:
50
- * - Required fields presence and non-emptiness
51
- * - Pattern matching (RegExp)
52
- * - Value within allowed options (if defined)
53
- * - Custom validation logic (if `validate` function is defined)
54
- *
55
- * @returns {Map<string, string>} Map of field → error message, empty if valid
56
- */
57
- validateIntent(): Map<string, string>;
58
- /**
59
- * Executes the Intent by creating a valid instance of the target message.
60
- *
61
- * If the Intent is not ready (has validation errors), returns null.
62
- *
63
- * @returns {Message | null} the created message, or null if invalid
64
- */
65
- execute(): Message | null;
66
- /**
67
- * Checks if the Intent can be executed immediately, without user input.
68
- *
69
- * @returns {boolean} true if all required fields are valid
70
- */
71
- isReady(): boolean;
72
- /**
73
- * Converts the Intent to a plain object for logging or inspection.
74
- *
75
- * @returns {object} serializable object with intent, body, and context
76
- */
77
- toObject(): object;
21
+ /**
22
+ * Create a new Intent.
23
+ *
24
+ * @param {object} input
25
+ * @param {typeof Message} input.target - message class this intent wants to create
26
+ * @param {any} [input.context] - execution context
27
+ * @param {object} [body] - partial or complete data for the target message
28
+ */
29
+ constructor({ target, context, ...body }?: { target: typeof Message; context?: any })
30
+ /**
31
+ * The target Message class this Intent aims to produce.
32
+ * Must be a class with a static `.Body` schema.
33
+ *
34
+ * @type {typeof Message | null}
35
+ */
36
+ target: typeof Message | null
37
+ /**
38
+ * Optional context for execution (session, locale, state, etc.).
39
+ *
40
+ * @type {any}
41
+ */
42
+ context: any
43
+ /**
44
+ * Validates all fields in the Intent's body against the target's schema.
45
+ *
46
+ * Checks:
47
+ * - Required fields presence and non-emptiness
48
+ * - Pattern matching (RegExp)
49
+ * - Value within allowed options (if defined)
50
+ * - Custom validation logic (if `validate` function is defined)
51
+ *
52
+ * @returns {Map<string, string>} Map of field → error message, empty if valid
53
+ */
54
+ validateIntent(): Map<string, string>
55
+ /**
56
+ * Executes the Intent by creating a valid instance of the target message.
57
+ *
58
+ * If the Intent is not ready (has validation errors), returns null.
59
+ *
60
+ * @returns {Message | null} the created message, or null if invalid
61
+ */
62
+ execute(): Message | null
63
+ /**
64
+ * Checks if the Intent can be executed immediately, without user input.
65
+ *
66
+ * @returns {boolean} true if all required fields are valid
67
+ */
68
+ isReady(): boolean
69
+ /**
70
+ * Converts the Intent to a plain object for logging or inspection.
71
+ *
72
+ * @returns {object} serializable object with intent, body, and context
73
+ */
74
+ toObject(): object
78
75
  }
79
76
  declare namespace Intent {
80
- /**
81
- * Handles an Intent by fulfilling missing or invalid fields.
82
- *
83
- * @param {Intent} intent - the declared intent to handle
84
- * @param {object} inputAdapter - must have `.ask(prompt)`
85
- * @returns {Promise<Message | null>} resolved when intent is fulfilled
86
- * @throws {CancelError} if user cancels
87
- */
88
- function handleIntent(intent: Intent, inputAdapter: object): Promise<Message | null>;
77
+ /**
78
+ * Handles an Intent by fulfilling missing or invalid fields.
79
+ *
80
+ * @param {Intent} intent - the declared intent to handle
81
+ * @param {object} inputAdapter - must have `.ask(prompt)`
82
+ * @returns {Promise<Message | null>} resolved when intent is fulfilled
83
+ * @throws {CancelError} if user cancels
84
+ */
85
+ function handleIntent(intent: Intent, inputAdapter: object): Promise<Message | null>
89
86
  }
90
- export default Intent;
91
- import { Message } from "@nan0web/co";
87
+ export default Intent
88
+ import { Message } from '@nan0web/co'