@resconet/qp-bridge 0.0.1-alpha.5 → 0.0.1-alpha.7

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.
@@ -61,14 +61,74 @@ export declare const responseErrorMessageSchema: z.ZodObject<z.objectUtil.extend
61
61
  id?: string | undefined;
62
62
  }>;
63
63
  export declare const questionSchema: z.ZodObject<{
64
+ semanticColor: z.ZodOptional<z.ZodString>;
64
65
  label: z.ZodString;
65
- name: z.ZodString;
66
+ description: z.ZodString;
67
+ disabled: z.ZodBoolean;
68
+ required: z.ZodBoolean;
69
+ hidden: z.ZodBoolean;
66
70
  }, "strip", z.ZodTypeAny, {
67
71
  label: string;
68
- name: string;
72
+ description: string;
73
+ disabled: boolean;
74
+ required: boolean;
75
+ hidden: boolean;
76
+ semanticColor?: string | undefined;
69
77
  }, {
70
78
  label: string;
71
- name: 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;
72
132
  }>;
73
133
  export declare const getQuestionRequestMessageSchema: z.ZodObject<z.objectUtil.extendShape<{
74
134
  type: z.ZodLiteral<"qp-bridge">;
@@ -94,21 +154,37 @@ export declare const getQuestionSuccessResponseMessageSchema: z.ZodObject<z.obje
94
154
  status: z.ZodLiteral<"success">;
95
155
  }>, {
96
156
  question: z.ZodObject<{
157
+ semanticColor: z.ZodOptional<z.ZodString>;
97
158
  label: z.ZodString;
98
- name: z.ZodString;
159
+ description: z.ZodString;
160
+ disabled: z.ZodBoolean;
161
+ required: z.ZodBoolean;
162
+ hidden: z.ZodBoolean;
99
163
  }, "strip", z.ZodTypeAny, {
100
164
  label: string;
101
- name: string;
165
+ description: string;
166
+ disabled: boolean;
167
+ required: boolean;
168
+ hidden: boolean;
169
+ semanticColor?: string | undefined;
102
170
  }, {
103
171
  label: string;
104
- name: string;
172
+ description: string;
173
+ disabled: boolean;
174
+ required: boolean;
175
+ hidden: boolean;
176
+ semanticColor?: string | undefined;
105
177
  }>;
106
178
  }>, "strip", z.ZodTypeAny, {
107
179
  type: "qp-bridge";
108
180
  status: "success";
109
181
  question: {
110
182
  label: string;
111
- name: string;
183
+ description: string;
184
+ disabled: boolean;
185
+ required: boolean;
186
+ hidden: boolean;
187
+ semanticColor?: string | undefined;
112
188
  };
113
189
  id?: string | undefined;
114
190
  }, {
@@ -116,7 +192,121 @@ export declare const getQuestionSuccessResponseMessageSchema: z.ZodObject<z.obje
116
192
  status: "success";
117
193
  question: {
118
194
  label: string;
119
- name: 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;
120
310
  };
121
311
  id?: string | undefined;
122
312
  }>;
@@ -144,10 +334,16 @@ export type QpBridgeMessage = z.infer<typeof qpBridgeMessageSchema>;
144
334
  export type ResponseSuccessMessage = z.infer<typeof responseSuccessMessageSchema>;
145
335
  export type ResponseErrorMessage = z.infer<typeof responseErrorMessageSchema>;
146
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>;
147
340
  export type OnAnswerChangeMessage = z.infer<typeof onAnswerChangeMessageSchema>;
148
341
  export type GetQuestionSuccessResponseMessage = z.infer<typeof getQuestionSuccessResponseMessageSchema>;
342
+ export type GetGroupSuccessResponseMessage = z.infer<typeof getGroupSuccessResponseMessageSchema>;
149
343
  export type SetAnswerRequestMessage = z.infer<typeof setAnswerRequestMessageSchema>;
150
344
  export type GetQuestionRequestMessage = z.infer<typeof getQuestionRequestMessageSchema>;
345
+ export type GetGroupRequestMessage = z.infer<typeof getGroupRequestMessageSchema>;
346
+ export type SetQuestionRequestMessage = z.infer<typeof setQuestionRequestMessageSchema>;
151
347
  export declare function isOnAnswerChangeMessage(data: unknown): data is OnAnswerChangeMessage;
152
348
  export declare function isQpBridgeMessage(data: unknown): data is QpBridgeMessage;
153
349
  export declare function isSuccessMessage(data: unknown): data is ResponseSuccessMessage;
@@ -155,3 +351,6 @@ export declare function isErrorMessage(data: unknown): data is ResponseErrorMess
155
351
  export declare function isGetQuestionRequestMessage(data: unknown): data is GetQuestionRequestMessage;
156
352
  export declare function isGetQuestionSuccessResponseMessage(data: unknown): data is GetQuestionSuccessResponseMessage;
157
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;
@@ -1,4 +1,4 @@
1
- import { Question } from './qp-bridge-types';
1
+ import { Group, Question, QuestionOptional } from './qp-bridge-types';
2
2
  /**
3
3
  * Sets the answer for a specific question in the questionnaire.
4
4
  *
@@ -26,6 +26,34 @@ export declare function setAnswer(questionName: string, answer: unknown): Promis
26
26
  * ```
27
27
  */
28
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>;
29
57
  /**
30
58
  * Subscribes to changes in answers for questions.
31
59
  * This function listens for messages from the parent window
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@resconet/qp-bridge",
3
- "version": "0.0.1-alpha.5",
3
+ "version": "0.0.1-alpha.7",
4
4
  "dependencies": {
5
- "zod": "^3.23.8"
5
+ "zod": "^3.23.8",
6
+ "uuid": "^9.0.1"
6
7
  },
7
8
  "main": "./index.js",
8
9
  "module": "./index.mjs",