@resconet/qp-bridge 0.0.1-alpha.10
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.
- package/README.md +182 -0
- package/index.d.ts +2 -0
- package/index.js +1 -0
- package/index.mjs +3067 -0
- package/lib/qp-bridge-types.d.ts +356 -0
- package/lib/qp-bridge.d.ts +76 -0
- package/package.json +11 -0
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const qpBridgeMessageSchema: z.ZodObject<{
|
|
3
|
+
type: z.ZodLiteral<"qp-bridge">;
|
|
4
|
+
id: z.ZodOptional<z.ZodString>;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
type: "qp-bridge";
|
|
7
|
+
id?: string | undefined;
|
|
8
|
+
}, {
|
|
9
|
+
type: "qp-bridge";
|
|
10
|
+
id?: string | undefined;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const onAnswerChangeMessageSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
13
|
+
type: z.ZodLiteral<"qp-bridge">;
|
|
14
|
+
id: z.ZodOptional<z.ZodString>;
|
|
15
|
+
}, {
|
|
16
|
+
status: z.ZodLiteral<"answerChanged">;
|
|
17
|
+
question: z.ZodString;
|
|
18
|
+
answer: z.ZodUnknown;
|
|
19
|
+
}>, "strip", z.ZodTypeAny, {
|
|
20
|
+
type: "qp-bridge";
|
|
21
|
+
status: "answerChanged";
|
|
22
|
+
question: string;
|
|
23
|
+
id?: string | undefined;
|
|
24
|
+
answer?: unknown;
|
|
25
|
+
}, {
|
|
26
|
+
type: "qp-bridge";
|
|
27
|
+
status: "answerChanged";
|
|
28
|
+
question: string;
|
|
29
|
+
id?: string | undefined;
|
|
30
|
+
answer?: unknown;
|
|
31
|
+
}>;
|
|
32
|
+
export declare const responseSuccessMessageSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
33
|
+
type: z.ZodLiteral<"qp-bridge">;
|
|
34
|
+
id: z.ZodOptional<z.ZodString>;
|
|
35
|
+
}, {
|
|
36
|
+
status: z.ZodLiteral<"success">;
|
|
37
|
+
}>, "strip", z.ZodTypeAny, {
|
|
38
|
+
type: "qp-bridge";
|
|
39
|
+
status: "success";
|
|
40
|
+
id?: string | undefined;
|
|
41
|
+
}, {
|
|
42
|
+
type: "qp-bridge";
|
|
43
|
+
status: "success";
|
|
44
|
+
id?: string | undefined;
|
|
45
|
+
}>;
|
|
46
|
+
export declare const responseErrorMessageSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
47
|
+
type: z.ZodLiteral<"qp-bridge">;
|
|
48
|
+
id: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, {
|
|
50
|
+
status: z.ZodLiteral<"error">;
|
|
51
|
+
message: z.ZodString;
|
|
52
|
+
}>, "strip", z.ZodTypeAny, {
|
|
53
|
+
type: "qp-bridge";
|
|
54
|
+
status: "error";
|
|
55
|
+
message: string;
|
|
56
|
+
id?: string | undefined;
|
|
57
|
+
}, {
|
|
58
|
+
type: "qp-bridge";
|
|
59
|
+
status: "error";
|
|
60
|
+
message: string;
|
|
61
|
+
id?: string | undefined;
|
|
62
|
+
}>;
|
|
63
|
+
export declare const questionSchema: z.ZodObject<{
|
|
64
|
+
semanticColor: z.ZodOptional<z.ZodString>;
|
|
65
|
+
label: z.ZodString;
|
|
66
|
+
description: z.ZodString;
|
|
67
|
+
disabled: z.ZodBoolean;
|
|
68
|
+
required: z.ZodBoolean;
|
|
69
|
+
hidden: z.ZodBoolean;
|
|
70
|
+
}, "strip", z.ZodTypeAny, {
|
|
71
|
+
label: string;
|
|
72
|
+
description: string;
|
|
73
|
+
disabled: boolean;
|
|
74
|
+
required: boolean;
|
|
75
|
+
hidden: boolean;
|
|
76
|
+
semanticColor?: string | undefined;
|
|
77
|
+
}, {
|
|
78
|
+
label: string;
|
|
79
|
+
description: string;
|
|
80
|
+
disabled: boolean;
|
|
81
|
+
required: boolean;
|
|
82
|
+
hidden: boolean;
|
|
83
|
+
semanticColor?: string | undefined;
|
|
84
|
+
}>;
|
|
85
|
+
export declare const questionOptionalScheme: z.ZodObject<{
|
|
86
|
+
semanticColor: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
87
|
+
label: z.ZodOptional<z.ZodString>;
|
|
88
|
+
description: z.ZodOptional<z.ZodString>;
|
|
89
|
+
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
90
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
91
|
+
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
92
|
+
}, "strip", z.ZodTypeAny, {
|
|
93
|
+
semanticColor?: string | undefined;
|
|
94
|
+
label?: string | undefined;
|
|
95
|
+
description?: string | undefined;
|
|
96
|
+
disabled?: boolean | undefined;
|
|
97
|
+
required?: boolean | undefined;
|
|
98
|
+
hidden?: boolean | undefined;
|
|
99
|
+
}, {
|
|
100
|
+
semanticColor?: string | undefined;
|
|
101
|
+
label?: string | undefined;
|
|
102
|
+
description?: string | undefined;
|
|
103
|
+
disabled?: boolean | undefined;
|
|
104
|
+
required?: boolean | undefined;
|
|
105
|
+
hidden?: boolean | undefined;
|
|
106
|
+
}>;
|
|
107
|
+
export declare const groupSchema: z.ZodObject<{
|
|
108
|
+
label: z.ZodString;
|
|
109
|
+
hidden: z.ZodBoolean;
|
|
110
|
+
collapsed: z.ZodBoolean;
|
|
111
|
+
}, "strip", z.ZodTypeAny, {
|
|
112
|
+
label: string;
|
|
113
|
+
hidden: boolean;
|
|
114
|
+
collapsed: boolean;
|
|
115
|
+
}, {
|
|
116
|
+
label: string;
|
|
117
|
+
hidden: boolean;
|
|
118
|
+
collapsed: boolean;
|
|
119
|
+
}>;
|
|
120
|
+
export declare const groupOptionalScheme: z.ZodObject<{
|
|
121
|
+
label: z.ZodOptional<z.ZodString>;
|
|
122
|
+
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
123
|
+
collapsed: z.ZodOptional<z.ZodBoolean>;
|
|
124
|
+
}, "strip", z.ZodTypeAny, {
|
|
125
|
+
label?: string | undefined;
|
|
126
|
+
hidden?: boolean | undefined;
|
|
127
|
+
collapsed?: boolean | undefined;
|
|
128
|
+
}, {
|
|
129
|
+
label?: string | undefined;
|
|
130
|
+
hidden?: boolean | undefined;
|
|
131
|
+
collapsed?: boolean | undefined;
|
|
132
|
+
}>;
|
|
133
|
+
export declare const getQuestionRequestMessageSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
134
|
+
type: z.ZodLiteral<"qp-bridge">;
|
|
135
|
+
id: z.ZodOptional<z.ZodString>;
|
|
136
|
+
}, {
|
|
137
|
+
action: z.ZodLiteral<"getQuestion">;
|
|
138
|
+
question: z.ZodString;
|
|
139
|
+
}>, "strip", z.ZodTypeAny, {
|
|
140
|
+
type: "qp-bridge";
|
|
141
|
+
question: string;
|
|
142
|
+
action: "getQuestion";
|
|
143
|
+
id?: string | undefined;
|
|
144
|
+
}, {
|
|
145
|
+
type: "qp-bridge";
|
|
146
|
+
question: string;
|
|
147
|
+
action: "getQuestion";
|
|
148
|
+
id?: string | undefined;
|
|
149
|
+
}>;
|
|
150
|
+
export declare const getQuestionSuccessResponseMessageSchema: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<{
|
|
151
|
+
type: z.ZodLiteral<"qp-bridge">;
|
|
152
|
+
id: z.ZodOptional<z.ZodString>;
|
|
153
|
+
}, {
|
|
154
|
+
status: z.ZodLiteral<"success">;
|
|
155
|
+
}>, {
|
|
156
|
+
question: z.ZodObject<{
|
|
157
|
+
semanticColor: z.ZodOptional<z.ZodString>;
|
|
158
|
+
label: z.ZodString;
|
|
159
|
+
description: z.ZodString;
|
|
160
|
+
disabled: z.ZodBoolean;
|
|
161
|
+
required: z.ZodBoolean;
|
|
162
|
+
hidden: z.ZodBoolean;
|
|
163
|
+
}, "strip", z.ZodTypeAny, {
|
|
164
|
+
label: string;
|
|
165
|
+
description: string;
|
|
166
|
+
disabled: boolean;
|
|
167
|
+
required: boolean;
|
|
168
|
+
hidden: boolean;
|
|
169
|
+
semanticColor?: string | undefined;
|
|
170
|
+
}, {
|
|
171
|
+
label: string;
|
|
172
|
+
description: string;
|
|
173
|
+
disabled: boolean;
|
|
174
|
+
required: boolean;
|
|
175
|
+
hidden: boolean;
|
|
176
|
+
semanticColor?: string | undefined;
|
|
177
|
+
}>;
|
|
178
|
+
}>, "strip", z.ZodTypeAny, {
|
|
179
|
+
type: "qp-bridge";
|
|
180
|
+
status: "success";
|
|
181
|
+
question: {
|
|
182
|
+
label: string;
|
|
183
|
+
description: string;
|
|
184
|
+
disabled: boolean;
|
|
185
|
+
required: boolean;
|
|
186
|
+
hidden: boolean;
|
|
187
|
+
semanticColor?: string | undefined;
|
|
188
|
+
};
|
|
189
|
+
id?: string | undefined;
|
|
190
|
+
}, {
|
|
191
|
+
type: "qp-bridge";
|
|
192
|
+
status: "success";
|
|
193
|
+
question: {
|
|
194
|
+
label: string;
|
|
195
|
+
description: string;
|
|
196
|
+
disabled: boolean;
|
|
197
|
+
required: boolean;
|
|
198
|
+
hidden: boolean;
|
|
199
|
+
semanticColor?: string | undefined;
|
|
200
|
+
};
|
|
201
|
+
id?: string | undefined;
|
|
202
|
+
}>;
|
|
203
|
+
export declare const setQuestionRequestMessageSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
204
|
+
type: z.ZodLiteral<"qp-bridge">;
|
|
205
|
+
id: z.ZodOptional<z.ZodString>;
|
|
206
|
+
}, {
|
|
207
|
+
action: z.ZodLiteral<"setQuestion">;
|
|
208
|
+
question: z.ZodString;
|
|
209
|
+
questionData: z.ZodObject<{
|
|
210
|
+
semanticColor: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
211
|
+
label: z.ZodOptional<z.ZodString>;
|
|
212
|
+
description: z.ZodOptional<z.ZodString>;
|
|
213
|
+
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
214
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
215
|
+
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
216
|
+
}, "strip", z.ZodTypeAny, {
|
|
217
|
+
semanticColor?: string | undefined;
|
|
218
|
+
label?: string | undefined;
|
|
219
|
+
description?: string | undefined;
|
|
220
|
+
disabled?: boolean | undefined;
|
|
221
|
+
required?: boolean | undefined;
|
|
222
|
+
hidden?: boolean | undefined;
|
|
223
|
+
}, {
|
|
224
|
+
semanticColor?: string | undefined;
|
|
225
|
+
label?: string | undefined;
|
|
226
|
+
description?: string | undefined;
|
|
227
|
+
disabled?: boolean | undefined;
|
|
228
|
+
required?: boolean | undefined;
|
|
229
|
+
hidden?: boolean | undefined;
|
|
230
|
+
}>;
|
|
231
|
+
}>, "strip", z.ZodTypeAny, {
|
|
232
|
+
type: "qp-bridge";
|
|
233
|
+
question: string;
|
|
234
|
+
action: "setQuestion";
|
|
235
|
+
questionData: {
|
|
236
|
+
semanticColor?: string | undefined;
|
|
237
|
+
label?: string | undefined;
|
|
238
|
+
description?: string | undefined;
|
|
239
|
+
disabled?: boolean | undefined;
|
|
240
|
+
required?: boolean | undefined;
|
|
241
|
+
hidden?: boolean | undefined;
|
|
242
|
+
};
|
|
243
|
+
id?: string | undefined;
|
|
244
|
+
}, {
|
|
245
|
+
type: "qp-bridge";
|
|
246
|
+
question: string;
|
|
247
|
+
action: "setQuestion";
|
|
248
|
+
questionData: {
|
|
249
|
+
semanticColor?: string | undefined;
|
|
250
|
+
label?: string | undefined;
|
|
251
|
+
description?: string | undefined;
|
|
252
|
+
disabled?: boolean | undefined;
|
|
253
|
+
required?: boolean | undefined;
|
|
254
|
+
hidden?: boolean | undefined;
|
|
255
|
+
};
|
|
256
|
+
id?: string | undefined;
|
|
257
|
+
}>;
|
|
258
|
+
export declare const getGroupRequestMessageSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
259
|
+
type: z.ZodLiteral<"qp-bridge">;
|
|
260
|
+
id: z.ZodOptional<z.ZodString>;
|
|
261
|
+
}, {
|
|
262
|
+
action: z.ZodLiteral<"getGroup">;
|
|
263
|
+
group: z.ZodString;
|
|
264
|
+
}>, "strip", z.ZodTypeAny, {
|
|
265
|
+
type: "qp-bridge";
|
|
266
|
+
action: "getGroup";
|
|
267
|
+
group: string;
|
|
268
|
+
id?: string | undefined;
|
|
269
|
+
}, {
|
|
270
|
+
type: "qp-bridge";
|
|
271
|
+
action: "getGroup";
|
|
272
|
+
group: string;
|
|
273
|
+
id?: string | undefined;
|
|
274
|
+
}>;
|
|
275
|
+
export declare const getGroupSuccessResponseMessageSchema: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<{
|
|
276
|
+
type: z.ZodLiteral<"qp-bridge">;
|
|
277
|
+
id: z.ZodOptional<z.ZodString>;
|
|
278
|
+
}, {
|
|
279
|
+
status: z.ZodLiteral<"success">;
|
|
280
|
+
}>, {
|
|
281
|
+
group: z.ZodObject<{
|
|
282
|
+
label: z.ZodString;
|
|
283
|
+
hidden: z.ZodBoolean;
|
|
284
|
+
collapsed: z.ZodBoolean;
|
|
285
|
+
}, "strip", z.ZodTypeAny, {
|
|
286
|
+
label: string;
|
|
287
|
+
hidden: boolean;
|
|
288
|
+
collapsed: boolean;
|
|
289
|
+
}, {
|
|
290
|
+
label: string;
|
|
291
|
+
hidden: boolean;
|
|
292
|
+
collapsed: boolean;
|
|
293
|
+
}>;
|
|
294
|
+
}>, "strip", z.ZodTypeAny, {
|
|
295
|
+
type: "qp-bridge";
|
|
296
|
+
status: "success";
|
|
297
|
+
group: {
|
|
298
|
+
label: string;
|
|
299
|
+
hidden: boolean;
|
|
300
|
+
collapsed: boolean;
|
|
301
|
+
};
|
|
302
|
+
id?: string | undefined;
|
|
303
|
+
}, {
|
|
304
|
+
type: "qp-bridge";
|
|
305
|
+
status: "success";
|
|
306
|
+
group: {
|
|
307
|
+
label: string;
|
|
308
|
+
hidden: boolean;
|
|
309
|
+
collapsed: boolean;
|
|
310
|
+
};
|
|
311
|
+
id?: string | undefined;
|
|
312
|
+
}>;
|
|
313
|
+
export declare const setAnswerRequestMessageSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
314
|
+
type: z.ZodLiteral<"qp-bridge">;
|
|
315
|
+
id: z.ZodOptional<z.ZodString>;
|
|
316
|
+
}, {
|
|
317
|
+
action: z.ZodLiteral<"setAnswer">;
|
|
318
|
+
question: z.ZodString;
|
|
319
|
+
answer: z.ZodUnknown;
|
|
320
|
+
}>, "strip", z.ZodTypeAny, {
|
|
321
|
+
type: "qp-bridge";
|
|
322
|
+
question: string;
|
|
323
|
+
action: "setAnswer";
|
|
324
|
+
id?: string | undefined;
|
|
325
|
+
answer?: unknown;
|
|
326
|
+
}, {
|
|
327
|
+
type: "qp-bridge";
|
|
328
|
+
question: string;
|
|
329
|
+
action: "setAnswer";
|
|
330
|
+
id?: string | undefined;
|
|
331
|
+
answer?: unknown;
|
|
332
|
+
}>;
|
|
333
|
+
export type QpBridgeMessage = z.infer<typeof qpBridgeMessageSchema>;
|
|
334
|
+
export type ResponseSuccessMessage = z.infer<typeof responseSuccessMessageSchema>;
|
|
335
|
+
export type ResponseErrorMessage = z.infer<typeof responseErrorMessageSchema>;
|
|
336
|
+
export type Question = z.infer<typeof questionSchema>;
|
|
337
|
+
export type QuestionOptional = z.infer<typeof questionOptionalScheme>;
|
|
338
|
+
export type Group = z.infer<typeof groupSchema>;
|
|
339
|
+
export type GroupOptional = z.infer<typeof groupOptionalScheme>;
|
|
340
|
+
export type OnAnswerChangeMessage = z.infer<typeof onAnswerChangeMessageSchema>;
|
|
341
|
+
export type GetQuestionSuccessResponseMessage = z.infer<typeof getQuestionSuccessResponseMessageSchema>;
|
|
342
|
+
export type GetGroupSuccessResponseMessage = z.infer<typeof getGroupSuccessResponseMessageSchema>;
|
|
343
|
+
export type SetAnswerRequestMessage = z.infer<typeof setAnswerRequestMessageSchema>;
|
|
344
|
+
export type GetQuestionRequestMessage = z.infer<typeof getQuestionRequestMessageSchema>;
|
|
345
|
+
export type GetGroupRequestMessage = z.infer<typeof getGroupRequestMessageSchema>;
|
|
346
|
+
export type SetQuestionRequestMessage = z.infer<typeof setQuestionRequestMessageSchema>;
|
|
347
|
+
export declare function isOnAnswerChangeMessage(data: unknown): data is OnAnswerChangeMessage;
|
|
348
|
+
export declare function isQpBridgeMessage(data: unknown): data is QpBridgeMessage;
|
|
349
|
+
export declare function isSuccessMessage(data: unknown): data is ResponseSuccessMessage;
|
|
350
|
+
export declare function isErrorMessage(data: unknown): data is ResponseErrorMessage;
|
|
351
|
+
export declare function isGetQuestionRequestMessage(data: unknown): data is GetQuestionRequestMessage;
|
|
352
|
+
export declare function isGetQuestionSuccessResponseMessage(data: unknown): data is GetQuestionSuccessResponseMessage;
|
|
353
|
+
export declare function isSetAnswerRequestMessage(data: unknown): data is SetAnswerRequestMessage;
|
|
354
|
+
export declare function isSetQuestionRequestMessage(data: unknown): data is SetQuestionRequestMessage;
|
|
355
|
+
export declare function isGetGroupRequestMessage(data: unknown): data is GetGroupRequestMessage;
|
|
356
|
+
export declare function isGetGroupSuccessResponseMessage(data: unknown): data is GetGroupSuccessResponseMessage;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Group, Question, QuestionOptional } from './qp-bridge-types';
|
|
2
|
+
/**
|
|
3
|
+
* Sets the answer for a specific question in the questionnaire.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} questionName - Name of the question for which the answer is being set.
|
|
6
|
+
* @param {*} answer - The answer to set for the question. Can be any type.
|
|
7
|
+
* @returns {Promise<void>} A promise that resolves when the answer has been successfully set.
|
|
8
|
+
* @throws {Error} Throws if the message from the parent window indicates a failure.
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* await setAnswer('favoriteColor', 'blue');
|
|
12
|
+
* ```
|
|
13
|
+
* @see onAnswerChange
|
|
14
|
+
*/
|
|
15
|
+
export declare function setAnswer(questionName: string, answer: unknown): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves a question by its name from the questionnaire.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} name - The name of the question to retrieve.
|
|
20
|
+
* @returns {Promise<Question>} A promise that resolves to the question object.
|
|
21
|
+
* @throws {Error} Throws if the message from the parent window indicates a failure.
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const question = await getQuestion('favoriteColor');
|
|
25
|
+
* console.log(question.label); // Outputs the label of the question
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function getQuestion(name: string): Promise<Question>;
|
|
29
|
+
/**
|
|
30
|
+
* Updates a question in the questionnaire.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} name - The name of the question to update. This is a unique identifier and cannot be changed.
|
|
33
|
+
* @param {QuestionOptional} questionData - The updated question data excluding the name property.
|
|
34
|
+
* @returns {Promise<void>} A promise that resolves when the question has been successfully updated.
|
|
35
|
+
* @throws {Error} Throws if the message from the parent window indicates a failure.
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* await setQuestion('favoriteColor', { label: 'What is your favorite color?' });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function setQuestion(name: string, questionData: QuestionOptional): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Retrieves a group by its name from the questionnaire.
|
|
44
|
+
*
|
|
45
|
+
* @param {string} name - The name of the group to retrieve.
|
|
46
|
+
* @returns {Promise<Group>} A promise that resolves to the group object.
|
|
47
|
+
* @throws {Error} Throws if the message from the parent window indicates a failure.
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const group = await getGroup('personalInfo');
|
|
51
|
+
* console.log(group.label); // Outputs the label of the group
|
|
52
|
+
* console.log(group.hidden); // Outputs whether the group is hidden
|
|
53
|
+
* console.log(group.collapsed); // Outputs whether the group is collapsed
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare function getGroup(name: string): Promise<Group>;
|
|
57
|
+
/**
|
|
58
|
+
* Subscribes to changes in answers for questions.
|
|
59
|
+
* This function listens for messages from the parent window
|
|
60
|
+
* and invokes the provided listener whenever an answer changes.
|
|
61
|
+
* @param listener - A function that will be called with the question name and the new answer whenever an answer changes.
|
|
62
|
+
* @return An object with a `cancelSubscription` method to stop listening for changes.
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* import { onAnswerChange } from 'qp-bridge';
|
|
66
|
+
* const { cancelSubsctiprion } = onAnswerChange((question, answer) => {
|
|
67
|
+
* console.log(`Answer for ${question} changed to:`, answer);
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* // To stop listening for changes:
|
|
71
|
+
* cancelSubscription();
|
|
72
|
+
* ```
|
|
73
|
+
**/
|
|
74
|
+
export declare function onAnswerChange(listener: (question: string, answer: unknown) => void): {
|
|
75
|
+
cancelSubscription: () => void;
|
|
76
|
+
};
|