@resconet/qp-bridge 1.4.1-alpha.9 → 1.5.0-alpha.12
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 +311 -299
- package/index.js +1 -1
- package/index.mjs +974 -789
- package/lib/qp-bridge-types.d.ts +218 -22
- package/lib/qp-bridge.d.ts +43 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -56,6 +56,9 @@ await setAnswer("numericQuestion", 42);
|
|
|
56
56
|
- [initOnSaveMessageHandler](#initonsavemessagehandler)
|
|
57
57
|
- [removeOnSaveMessageHandler](#removeonsavemessagehandler)
|
|
58
58
|
- [getQuestionnaire](#getquestionnaire)
|
|
59
|
+
- [traverseQuestionnaireItems](#traversequestionnaireitems)
|
|
60
|
+
- [flattenQuestionnaireItems](#flattenquestionnaireitems)
|
|
61
|
+
- [flattenQuestions](#flattenquestions)
|
|
59
62
|
- [setAnswer](#setanswer)
|
|
60
63
|
- [getQuestion](#getquestion)
|
|
61
64
|
- [setQuestion](#setquestion)
|
|
@@ -69,6 +72,7 @@ await setAnswer("numericQuestion", 42);
|
|
|
69
72
|
- [onQuestionnaireLoaded](#onquestionnaireloaded)
|
|
70
73
|
- [onCommandExecuted](#oncommandexecuted)
|
|
71
74
|
- [onSave](#onsave)
|
|
75
|
+
- [onPostSave](#onpostsave)
|
|
72
76
|
- [fetchEntities](#fetchentities)
|
|
73
77
|
- [getEntityById](#getentitybyid)
|
|
74
78
|
- [createNewEntity](#createnewentity)
|
|
@@ -81,26 +85,25 @@ await setAnswer("numericQuestion", 42);
|
|
|
81
85
|
|
|
82
86
|
Creates a MediaItem from the provided parameters and content.
|
|
83
87
|
|
|
84
|
-
| Function
|
|
85
|
-
|
|
|
88
|
+
| Function | Type |
|
|
89
|
+
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
86
90
|
| `createMediaItem` | `{ (name: string, mimeType: string, content: File): { id: string; name: string; mimeType: string; blobUrl: string; }; (name: string, mimeType: string, content: Blob): { id: string; name: string; mimeType: string; blobUrl: string; }; (name: string, mimeType: string, content: string): { ...; }; (name: string, mimeType:...` |
|
|
87
91
|
|
|
88
92
|
Parameters:
|
|
89
93
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
94
|
+
- `name`: - Name of the media item.
|
|
95
|
+
- `mimeType`: - MIME type of the media item.
|
|
96
|
+
- `content`: - Content as File, Blob, base64 string, or ArrayBuffer.
|
|
97
|
+
- `id`: - Optional id for the media item. If not provided, a UUID will be generated.
|
|
98
|
+
- `name`: - Name of the media item.
|
|
99
|
+
- `mimeType`: - MIME type of the media item.
|
|
100
|
+
- `content`: - Content as Blob.
|
|
101
|
+
- `name`: - Name of the media item.
|
|
102
|
+
- `mimeType`: - MIME type of the media item.
|
|
103
|
+
- `content`: - Content as base64 string or binary string.
|
|
104
|
+
- `name`: - Name of the media item.
|
|
105
|
+
- `mimeType`: - MIME type of the media item.
|
|
106
|
+
- `content`: - Content as ArrayBuffer.
|
|
104
107
|
|
|
105
108
|
Returns:
|
|
106
109
|
|
|
@@ -110,26 +113,25 @@ MediaItem object with blobUrl generated from the content.
|
|
|
110
113
|
|
|
111
114
|
Creates a MediaItem from the provided parameters and content.
|
|
112
115
|
|
|
113
|
-
| Function
|
|
114
|
-
|
|
|
116
|
+
| Function | Type |
|
|
117
|
+
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
115
118
|
| `createMediaItem` | `{ (name: string, mimeType: string, content: File): { id: string; name: string; mimeType: string; blobUrl: string; }; (name: string, mimeType: string, content: Blob): { id: string; name: string; mimeType: string; blobUrl: string; }; (name: string, mimeType: string, content: string): { ...; }; (name: string, mimeType:...` |
|
|
116
119
|
|
|
117
120
|
Parameters:
|
|
118
121
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
122
|
+
- `name`: - Name of the media item.
|
|
123
|
+
- `mimeType`: - MIME type of the media item.
|
|
124
|
+
- `content`: - Content as File, Blob, base64 string, or ArrayBuffer.
|
|
125
|
+
- `id`: - Optional id for the media item. If not provided, a UUID will be generated.
|
|
126
|
+
- `name`: - Name of the media item.
|
|
127
|
+
- `mimeType`: - MIME type of the media item.
|
|
128
|
+
- `content`: - Content as Blob.
|
|
129
|
+
- `name`: - Name of the media item.
|
|
130
|
+
- `mimeType`: - MIME type of the media item.
|
|
131
|
+
- `content`: - Content as base64 string or binary string.
|
|
132
|
+
- `name`: - Name of the media item.
|
|
133
|
+
- `mimeType`: - MIME type of the media item.
|
|
134
|
+
- `content`: - Content as ArrayBuffer.
|
|
133
135
|
|
|
134
136
|
Returns:
|
|
135
137
|
|
|
@@ -139,26 +141,25 @@ MediaItem object with blobUrl generated from the content.
|
|
|
139
141
|
|
|
140
142
|
Creates a MediaItem from the provided parameters and content.
|
|
141
143
|
|
|
142
|
-
| Function
|
|
143
|
-
|
|
|
144
|
+
| Function | Type |
|
|
145
|
+
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
144
146
|
| `createMediaItem` | `{ (name: string, mimeType: string, content: File): { id: string; name: string; mimeType: string; blobUrl: string; }; (name: string, mimeType: string, content: Blob): { id: string; name: string; mimeType: string; blobUrl: string; }; (name: string, mimeType: string, content: string): { ...; }; (name: string, mimeType:...` |
|
|
145
147
|
|
|
146
148
|
Parameters:
|
|
147
149
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
150
|
+
- `name`: - Name of the media item.
|
|
151
|
+
- `mimeType`: - MIME type of the media item.
|
|
152
|
+
- `content`: - Content as File, Blob, base64 string, or ArrayBuffer.
|
|
153
|
+
- `id`: - Optional id for the media item. If not provided, a UUID will be generated.
|
|
154
|
+
- `name`: - Name of the media item.
|
|
155
|
+
- `mimeType`: - MIME type of the media item.
|
|
156
|
+
- `content`: - Content as Blob.
|
|
157
|
+
- `name`: - Name of the media item.
|
|
158
|
+
- `mimeType`: - MIME type of the media item.
|
|
159
|
+
- `content`: - Content as base64 string or binary string.
|
|
160
|
+
- `name`: - Name of the media item.
|
|
161
|
+
- `mimeType`: - MIME type of the media item.
|
|
162
|
+
- `content`: - Content as ArrayBuffer.
|
|
162
163
|
|
|
163
164
|
Returns:
|
|
164
165
|
|
|
@@ -168,26 +169,25 @@ MediaItem object with blobUrl generated from the content.
|
|
|
168
169
|
|
|
169
170
|
Creates a MediaItem from the provided parameters and content.
|
|
170
171
|
|
|
171
|
-
| Function
|
|
172
|
-
|
|
|
172
|
+
| Function | Type |
|
|
173
|
+
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
173
174
|
| `createMediaItem` | `{ (name: string, mimeType: string, content: File): { id: string; name: string; mimeType: string; blobUrl: string; }; (name: string, mimeType: string, content: Blob): { id: string; name: string; mimeType: string; blobUrl: string; }; (name: string, mimeType: string, content: string): { ...; }; (name: string, mimeType:...` |
|
|
174
175
|
|
|
175
176
|
Parameters:
|
|
176
177
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
178
|
+
- `name`: - Name of the media item.
|
|
179
|
+
- `mimeType`: - MIME type of the media item.
|
|
180
|
+
- `content`: - Content as File, Blob, base64 string, or ArrayBuffer.
|
|
181
|
+
- `id`: - Optional id for the media item. If not provided, a UUID will be generated.
|
|
182
|
+
- `name`: - Name of the media item.
|
|
183
|
+
- `mimeType`: - MIME type of the media item.
|
|
184
|
+
- `content`: - Content as Blob.
|
|
185
|
+
- `name`: - Name of the media item.
|
|
186
|
+
- `mimeType`: - MIME type of the media item.
|
|
187
|
+
- `content`: - Content as base64 string or binary string.
|
|
188
|
+
- `name`: - Name of the media item.
|
|
189
|
+
- `mimeType`: - MIME type of the media item.
|
|
190
|
+
- `content`: - Content as ArrayBuffer.
|
|
191
191
|
|
|
192
192
|
Returns:
|
|
193
193
|
|
|
@@ -197,26 +197,25 @@ MediaItem object with blobUrl generated from the content.
|
|
|
197
197
|
|
|
198
198
|
Creates a MediaItem from the provided parameters and content.
|
|
199
199
|
|
|
200
|
-
| Function
|
|
201
|
-
|
|
|
200
|
+
| Function | Type |
|
|
201
|
+
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
202
202
|
| `createMediaItem` | `{ (name: string, mimeType: string, content: File): { id: string; name: string; mimeType: string; blobUrl: string; }; (name: string, mimeType: string, content: Blob): { id: string; name: string; mimeType: string; blobUrl: string; }; (name: string, mimeType: string, content: string): { ...; }; (name: string, mimeType:...` |
|
|
203
203
|
|
|
204
204
|
Parameters:
|
|
205
205
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
206
|
+
- `name`: - Name of the media item.
|
|
207
|
+
- `mimeType`: - MIME type of the media item.
|
|
208
|
+
- `content`: - Content as File, Blob, base64 string, or ArrayBuffer.
|
|
209
|
+
- `id`: - Optional id for the media item. If not provided, a UUID will be generated.
|
|
210
|
+
- `name`: - Name of the media item.
|
|
211
|
+
- `mimeType`: - MIME type of the media item.
|
|
212
|
+
- `content`: - Content as Blob.
|
|
213
|
+
- `name`: - Name of the media item.
|
|
214
|
+
- `mimeType`: - MIME type of the media item.
|
|
215
|
+
- `content`: - Content as base64 string or binary string.
|
|
216
|
+
- `name`: - Name of the media item.
|
|
217
|
+
- `mimeType`: - MIME type of the media item.
|
|
218
|
+
- `content`: - Content as ArrayBuffer.
|
|
220
219
|
|
|
221
220
|
Returns:
|
|
222
221
|
|
|
@@ -226,26 +225,25 @@ MediaItem object with blobUrl generated from the content.
|
|
|
226
225
|
|
|
227
226
|
Creates a MediaItem from the provided parameters and content.
|
|
228
227
|
|
|
229
|
-
| Function
|
|
230
|
-
|
|
|
228
|
+
| Function | Type |
|
|
229
|
+
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
231
230
|
| `createMediaItem` | `{ (name: string, mimeType: string, content: File): { id: string; name: string; mimeType: string; blobUrl: string; }; (name: string, mimeType: string, content: Blob): { id: string; name: string; mimeType: string; blobUrl: string; }; (name: string, mimeType: string, content: string): { ...; }; (name: string, mimeType:...` |
|
|
232
231
|
|
|
233
232
|
Parameters:
|
|
234
233
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
234
|
+
- `name`: - Name of the media item.
|
|
235
|
+
- `mimeType`: - MIME type of the media item.
|
|
236
|
+
- `content`: - Content as File, Blob, base64 string, or ArrayBuffer.
|
|
237
|
+
- `id`: - Optional id for the media item. If not provided, a UUID will be generated.
|
|
238
|
+
- `name`: - Name of the media item.
|
|
239
|
+
- `mimeType`: - MIME type of the media item.
|
|
240
|
+
- `content`: - Content as Blob.
|
|
241
|
+
- `name`: - Name of the media item.
|
|
242
|
+
- `mimeType`: - MIME type of the media item.
|
|
243
|
+
- `content`: - Content as base64 string or binary string.
|
|
244
|
+
- `name`: - Name of the media item.
|
|
245
|
+
- `mimeType`: - MIME type of the media item.
|
|
246
|
+
- `content`: - Content as ArrayBuffer.
|
|
249
247
|
|
|
250
248
|
Returns:
|
|
251
249
|
|
|
@@ -255,21 +253,20 @@ MediaItem object with blobUrl generated from the content.
|
|
|
255
253
|
|
|
256
254
|
Updates a MediaItem with the provided changes.
|
|
257
255
|
|
|
258
|
-
| Function
|
|
259
|
-
|
|
|
256
|
+
| Function | Type |
|
|
257
|
+
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
260
258
|
| `updateMediaItem` | `{ (mediaItem: { id: string; name: string; mimeType: string; blobUrl: string; }, updates: { content: File; }): { id: string; name: string; mimeType: string; blobUrl: string; }; (mediaItem: { id: string; name: string; mimeType: string; blobUrl: string; }, updates: { ...; }): { ...; }; (mediaItem: { ...; }, updates: { ...` |
|
|
261
259
|
|
|
262
260
|
Parameters:
|
|
263
261
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
262
|
+
- `mediaItem`: - The original MediaItem to update.
|
|
263
|
+
- `updates`: - Object containing properties to update (name, mimeType, content).
|
|
264
|
+
- `mediaItem`: - The original MediaItem to update.
|
|
265
|
+
- `updates`: - Object containing content as Blob.
|
|
266
|
+
- `mediaItem`: - The original MediaItem to update.
|
|
267
|
+
- `updates`: - Object containing content as base64 string or binary string.
|
|
268
|
+
- `mediaItem`: - The original MediaItem to update.
|
|
269
|
+
- `updates`: - Object containing content as ArrayBuffer.
|
|
273
270
|
|
|
274
271
|
Returns:
|
|
275
272
|
|
|
@@ -279,21 +276,20 @@ Updated MediaItem object.
|
|
|
279
276
|
|
|
280
277
|
Updates a MediaItem with the provided changes.
|
|
281
278
|
|
|
282
|
-
| Function
|
|
283
|
-
|
|
|
279
|
+
| Function | Type |
|
|
280
|
+
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
284
281
|
| `updateMediaItem` | `{ (mediaItem: { id: string; name: string; mimeType: string; blobUrl: string; }, updates: { content: File; }): { id: string; name: string; mimeType: string; blobUrl: string; }; (mediaItem: { id: string; name: string; mimeType: string; blobUrl: string; }, updates: { ...; }): { ...; }; (mediaItem: { ...; }, updates: { ...` |
|
|
285
282
|
|
|
286
283
|
Parameters:
|
|
287
284
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
285
|
+
- `mediaItem`: - The original MediaItem to update.
|
|
286
|
+
- `updates`: - Object containing properties to update (name, mimeType, content).
|
|
287
|
+
- `mediaItem`: - The original MediaItem to update.
|
|
288
|
+
- `updates`: - Object containing content as Blob.
|
|
289
|
+
- `mediaItem`: - The original MediaItem to update.
|
|
290
|
+
- `updates`: - Object containing content as base64 string or binary string.
|
|
291
|
+
- `mediaItem`: - The original MediaItem to update.
|
|
292
|
+
- `updates`: - Object containing content as ArrayBuffer.
|
|
297
293
|
|
|
298
294
|
Returns:
|
|
299
295
|
|
|
@@ -303,21 +299,20 @@ Updated MediaItem object.
|
|
|
303
299
|
|
|
304
300
|
Updates a MediaItem with the provided changes.
|
|
305
301
|
|
|
306
|
-
| Function
|
|
307
|
-
|
|
|
302
|
+
| Function | Type |
|
|
303
|
+
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
308
304
|
| `updateMediaItem` | `{ (mediaItem: { id: string; name: string; mimeType: string; blobUrl: string; }, updates: { content: File; }): { id: string; name: string; mimeType: string; blobUrl: string; }; (mediaItem: { id: string; name: string; mimeType: string; blobUrl: string; }, updates: { ...; }): { ...; }; (mediaItem: { ...; }, updates: { ...` |
|
|
309
305
|
|
|
310
306
|
Parameters:
|
|
311
307
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
308
|
+
- `mediaItem`: - The original MediaItem to update.
|
|
309
|
+
- `updates`: - Object containing properties to update (name, mimeType, content).
|
|
310
|
+
- `mediaItem`: - The original MediaItem to update.
|
|
311
|
+
- `updates`: - Object containing content as Blob.
|
|
312
|
+
- `mediaItem`: - The original MediaItem to update.
|
|
313
|
+
- `updates`: - Object containing content as base64 string or binary string.
|
|
314
|
+
- `mediaItem`: - The original MediaItem to update.
|
|
315
|
+
- `updates`: - Object containing content as ArrayBuffer.
|
|
321
316
|
|
|
322
317
|
Returns:
|
|
323
318
|
|
|
@@ -327,21 +322,20 @@ Updated MediaItem object.
|
|
|
327
322
|
|
|
328
323
|
Updates a MediaItem with the provided changes.
|
|
329
324
|
|
|
330
|
-
| Function
|
|
331
|
-
|
|
|
325
|
+
| Function | Type |
|
|
326
|
+
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
332
327
|
| `updateMediaItem` | `{ (mediaItem: { id: string; name: string; mimeType: string; blobUrl: string; }, updates: { content: File; }): { id: string; name: string; mimeType: string; blobUrl: string; }; (mediaItem: { id: string; name: string; mimeType: string; blobUrl: string; }, updates: { ...; }): { ...; }; (mediaItem: { ...; }, updates: { ...` |
|
|
333
328
|
|
|
334
329
|
Parameters:
|
|
335
330
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
331
|
+
- `mediaItem`: - The original MediaItem to update.
|
|
332
|
+
- `updates`: - Object containing properties to update (name, mimeType, content).
|
|
333
|
+
- `mediaItem`: - The original MediaItem to update.
|
|
334
|
+
- `updates`: - Object containing content as Blob.
|
|
335
|
+
- `mediaItem`: - The original MediaItem to update.
|
|
336
|
+
- `updates`: - Object containing content as base64 string or binary string.
|
|
337
|
+
- `mediaItem`: - The original MediaItem to update.
|
|
338
|
+
- `updates`: - Object containing content as ArrayBuffer.
|
|
345
339
|
|
|
346
340
|
Returns:
|
|
347
341
|
|
|
@@ -351,21 +345,20 @@ Updated MediaItem object.
|
|
|
351
345
|
|
|
352
346
|
Updates a MediaItem with the provided changes.
|
|
353
347
|
|
|
354
|
-
| Function
|
|
355
|
-
|
|
|
348
|
+
| Function | Type |
|
|
349
|
+
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
356
350
|
| `updateMediaItem` | `{ (mediaItem: { id: string; name: string; mimeType: string; blobUrl: string; }, updates: { content: File; }): { id: string; name: string; mimeType: string; blobUrl: string; }; (mediaItem: { id: string; name: string; mimeType: string; blobUrl: string; }, updates: { ...; }): { ...; }; (mediaItem: { ...; }, updates: { ...` |
|
|
357
351
|
|
|
358
352
|
Parameters:
|
|
359
353
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
354
|
+
- `mediaItem`: - The original MediaItem to update.
|
|
355
|
+
- `updates`: - Object containing properties to update (name, mimeType, content).
|
|
356
|
+
- `mediaItem`: - The original MediaItem to update.
|
|
357
|
+
- `updates`: - Object containing content as Blob.
|
|
358
|
+
- `mediaItem`: - The original MediaItem to update.
|
|
359
|
+
- `updates`: - Object containing content as base64 string or binary string.
|
|
360
|
+
- `mediaItem`: - The original MediaItem to update.
|
|
361
|
+
- `updates`: - Object containing content as ArrayBuffer.
|
|
369
362
|
|
|
370
363
|
Returns:
|
|
371
364
|
|
|
@@ -375,21 +368,20 @@ Updated MediaItem object.
|
|
|
375
368
|
|
|
376
369
|
Updates a MediaItem with the provided changes.
|
|
377
370
|
|
|
378
|
-
| Function
|
|
379
|
-
|
|
|
371
|
+
| Function | Type |
|
|
372
|
+
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
380
373
|
| `updateMediaItem` | `{ (mediaItem: { id: string; name: string; mimeType: string; blobUrl: string; }, updates: { content: File; }): { id: string; name: string; mimeType: string; blobUrl: string; }; (mediaItem: { id: string; name: string; mimeType: string; blobUrl: string; }, updates: { ...; }): { ...; }; (mediaItem: { ...; }, updates: { ...` |
|
|
381
374
|
|
|
382
375
|
Parameters:
|
|
383
376
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
377
|
+
- `mediaItem`: - The original MediaItem to update.
|
|
378
|
+
- `updates`: - Object containing properties to update (name, mimeType, content).
|
|
379
|
+
- `mediaItem`: - The original MediaItem to update.
|
|
380
|
+
- `updates`: - Object containing content as Blob.
|
|
381
|
+
- `mediaItem`: - The original MediaItem to update.
|
|
382
|
+
- `updates`: - Object containing content as base64 string or binary string.
|
|
383
|
+
- `mediaItem`: - The original MediaItem to update.
|
|
384
|
+
- `updates`: - Object containing content as ArrayBuffer.
|
|
393
385
|
|
|
394
386
|
Returns:
|
|
395
387
|
|
|
@@ -397,57 +389,85 @@ Updated MediaItem object.
|
|
|
397
389
|
|
|
398
390
|
### initOnSaveMessageHandler
|
|
399
391
|
|
|
400
|
-
| Function
|
|
401
|
-
|
|
|
392
|
+
| Function | Type |
|
|
393
|
+
| -------------------------- | ------------ |
|
|
402
394
|
| `initOnSaveMessageHandler` | `() => void` |
|
|
403
395
|
|
|
404
396
|
### removeOnSaveMessageHandler
|
|
405
397
|
|
|
406
|
-
| Function
|
|
407
|
-
|
|
|
398
|
+
| Function | Type |
|
|
399
|
+
| ---------------------------- | ------------ |
|
|
408
400
|
| `removeOnSaveMessageHandler` | `() => void` |
|
|
409
401
|
|
|
410
402
|
### getQuestionnaire
|
|
411
403
|
|
|
412
404
|
Retrieves a questionnaire on which the user is currently working.
|
|
413
405
|
|
|
414
|
-
| Function
|
|
415
|
-
|
|
|
416
|
-
| `getQuestionnaire` | `(options?: QpBridgeOptions or undefined) => Promise<{ id: string; isNew: boolean; label: string; description?: string or undefined; regarding?: {
|
|
406
|
+
| Function | Type |
|
|
407
|
+
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
408
|
+
| `getQuestionnaire` | `(options?: QpBridgeOptions or undefined) => Promise<{ id: string; name: string; isNew: boolean; label: string; items: QuestionnaireItem[]; description?: string or undefined; regarding?: { ...; } or undefined; }>` |
|
|
417
409
|
|
|
418
410
|
Returns:
|
|
419
411
|
|
|
420
412
|
A promise that resolves to the questionnaire object.
|
|
421
413
|
|
|
422
414
|
The resolved `Questionnaire` object has the following properties:
|
|
415
|
+
|
|
423
416
|
- `isNew` — Whether the questionnaire is a new (unsaved) record.
|
|
424
417
|
- `id` — Unique identifier (UUID) of the questionnaire record.
|
|
425
|
-
- `
|
|
418
|
+
- `name` — Logical questionnaire name.
|
|
419
|
+
- `label` — Display name of the questionnaire. Kept as an alias for existing bridge consumers.
|
|
426
420
|
- `description` _(optional)_ — Description or notes for the questionnaire.
|
|
427
421
|
- `regarding` _(optional)_ — Reference to the related entity this questionnaire is associated with (`entityName`, `id`, `name`).
|
|
422
|
+
- `items` — Questionnaire item tree in domain-model order. Items can be questions, groups, repeatable groups, or static components.
|
|
428
423
|
|
|
429
424
|
Examples:
|
|
430
425
|
|
|
431
426
|
```typescript
|
|
432
427
|
const questionnaire = await getQuestionnaire();
|
|
433
|
-
console.log(questionnaire.id);
|
|
434
|
-
console.log(questionnaire.
|
|
428
|
+
console.log(questionnaire.id);
|
|
429
|
+
console.log(questionnaire.items.map(item => item.name));
|
|
430
|
+
console.log(flattenQuestions(questionnaire).map(question => question.name));
|
|
435
431
|
```
|
|
436
432
|
|
|
433
|
+
### traverseQuestionnaireItems
|
|
434
|
+
|
|
435
|
+
Traverses the questionnaire item tree in pre-order and passes parent context to the visitor.
|
|
436
|
+
|
|
437
|
+
Repeatable groups are visited before their group instances.
|
|
438
|
+
|
|
439
|
+
| Function | Type |
|
|
440
|
+
| ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
441
|
+
| `traverseQuestionnaireItems` | `(questionnaire: { id: string; name: string; isNew: boolean; label: string; items: QuestionnaireItem[]; description?: string or undefined; regarding?: { id: string; name: string; entityName: string; } or undefined; }, visitor: QuestionnaireItemVisitor) => void` |
|
|
442
|
+
|
|
443
|
+
### flattenQuestionnaireItems
|
|
444
|
+
|
|
445
|
+
Returns every questionnaire item in tree order.
|
|
446
|
+
|
|
447
|
+
| Function | Type |
|
|
448
|
+
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
449
|
+
| `flattenQuestionnaireItems` | `(questionnaire: { id: string; name: string; isNew: boolean; label: string; items: QuestionnaireItem[]; description?: string or undefined; regarding?: { id: string; name: string; entityName: string; } or undefined; }) => QuestionnaireItem[]` |
|
|
450
|
+
|
|
451
|
+
### flattenQuestions
|
|
452
|
+
|
|
453
|
+
Returns every question from the questionnaire item tree in tree order.
|
|
454
|
+
|
|
455
|
+
| Function | Type |
|
|
456
|
+
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
457
|
+
| `flattenQuestions` | `(questionnaire: { id: string; name: string; isNew: boolean; label: string; items: QuestionnaireItem[]; description?: string or undefined; regarding?: { id: string; name: string; entityName: string; } or undefined; }) => { ...; }[]` |
|
|
437
458
|
|
|
438
459
|
### setAnswer
|
|
439
460
|
|
|
440
461
|
Sets the answer for a specific question in the questionnaire.
|
|
441
462
|
|
|
442
|
-
| Function
|
|
443
|
-
|
|
|
463
|
+
| Function | Type |
|
|
464
|
+
| ----------- | -------------------------------------------------------------------------------------------------- |
|
|
444
465
|
| `setAnswer` | `(questionName: string, answer: unknown, options?: QpBridgeOptions or undefined) => Promise<void>` |
|
|
445
466
|
|
|
446
467
|
Parameters:
|
|
447
468
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
469
|
+
- `questionName`: - Name of the question for which the answer is being set.
|
|
470
|
+
- `answer`: - The answer to set for the question. Can be any type.
|
|
451
471
|
|
|
452
472
|
Returns:
|
|
453
473
|
|
|
@@ -455,28 +475,25 @@ A promise that resolves when the answer has been successfully set.
|
|
|
455
475
|
|
|
456
476
|
References:
|
|
457
477
|
|
|
458
|
-
|
|
459
|
-
|
|
478
|
+
- onAnswerChange
|
|
460
479
|
|
|
461
480
|
Examples:
|
|
462
481
|
|
|
463
482
|
```typescript
|
|
464
|
-
await setAnswer(
|
|
483
|
+
await setAnswer("favoriteColor", "blue");
|
|
465
484
|
```
|
|
466
485
|
|
|
467
|
-
|
|
468
486
|
### getQuestion
|
|
469
487
|
|
|
470
488
|
Retrieves a question by its name from the questionnaire.
|
|
471
489
|
|
|
472
|
-
| Function
|
|
473
|
-
|
|
|
490
|
+
| Function | Type |
|
|
491
|
+
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
474
492
|
| `getQuestion` | `(name: string, options?: QpBridgeOptions or undefined) => Promise<{ label: string; description: string; disabled: boolean; required: boolean; hidden: boolean; semanticColor?: string or undefined; errorMessage?: string or undefined; answer?: unknown; }>` |
|
|
475
493
|
|
|
476
494
|
Parameters:
|
|
477
495
|
|
|
478
|
-
|
|
479
|
-
|
|
496
|
+
- `name`: - The name of the question to retrieve.
|
|
480
497
|
|
|
481
498
|
Returns:
|
|
482
499
|
|
|
@@ -485,24 +502,22 @@ A promise that resolves to the question object.
|
|
|
485
502
|
Examples:
|
|
486
503
|
|
|
487
504
|
```typescript
|
|
488
|
-
const question = await getQuestion(
|
|
505
|
+
const question = await getQuestion("favoriteColor");
|
|
489
506
|
console.log(question.label); // Outputs the label of the question
|
|
490
507
|
```
|
|
491
508
|
|
|
492
|
-
|
|
493
509
|
### setQuestion
|
|
494
510
|
|
|
495
511
|
Updates a question in the questionnaire.
|
|
496
512
|
|
|
497
|
-
| Function
|
|
498
|
-
|
|
|
513
|
+
| Function | Type |
|
|
514
|
+
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
499
515
|
| `setQuestion` | `(name: string, questionData: { label?: string or undefined; description?: string or undefined; semanticColor?: string or undefined; disabled?: boolean or undefined; required?: boolean or undefined; hidden?: boolean or undefined; errorMessage?: string or undefined; answer?: unknown; }, options?: QpBridgeOptions or undefined)...` |
|
|
500
516
|
|
|
501
517
|
Parameters:
|
|
502
518
|
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
519
|
+
- `name`: - The name of the question to update. This is a unique identifier and cannot be changed.
|
|
520
|
+
- `questionData`: - The updated question data excluding the name property.
|
|
506
521
|
|
|
507
522
|
Returns:
|
|
508
523
|
|
|
@@ -511,22 +526,20 @@ A promise that resolves when the question has been successfully updated.
|
|
|
511
526
|
Examples:
|
|
512
527
|
|
|
513
528
|
```typescript
|
|
514
|
-
await setQuestion(
|
|
529
|
+
await setQuestion("favoriteColor", { label: "What is your favorite color?" });
|
|
515
530
|
```
|
|
516
531
|
|
|
517
|
-
|
|
518
532
|
### getGroup
|
|
519
533
|
|
|
520
534
|
Retrieves a group by its name from the questionnaire.
|
|
521
535
|
|
|
522
|
-
| Function
|
|
523
|
-
| ---------- |
|
|
536
|
+
| Function | Type |
|
|
537
|
+
| ---------- | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
524
538
|
| `getGroup` | `(name: string, options?: QpBridgeOptions or undefined) => Promise<{ label: string; hidden: boolean; collapsed: boolean; }>` |
|
|
525
539
|
|
|
526
540
|
Parameters:
|
|
527
541
|
|
|
528
|
-
|
|
529
|
-
|
|
542
|
+
- `name`: - The name of the group to retrieve.
|
|
530
543
|
|
|
531
544
|
Returns:
|
|
532
545
|
|
|
@@ -535,26 +548,24 @@ A promise that resolves to the group object.
|
|
|
535
548
|
Examples:
|
|
536
549
|
|
|
537
550
|
```typescript
|
|
538
|
-
const group = await getGroup(
|
|
551
|
+
const group = await getGroup("personalInfo");
|
|
539
552
|
console.log(group.label); // Outputs the label of the group
|
|
540
553
|
console.log(group.hidden); // Outputs whether the group is hidden
|
|
541
554
|
console.log(group.collapsed); // Outputs whether the group is collapsed
|
|
542
555
|
```
|
|
543
556
|
|
|
544
|
-
|
|
545
557
|
### setGroup
|
|
546
558
|
|
|
547
559
|
Updates a group in the questionnaire.
|
|
548
560
|
|
|
549
|
-
| Function
|
|
550
|
-
| ---------- |
|
|
561
|
+
| Function | Type |
|
|
562
|
+
| ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
551
563
|
| `setGroup` | `(name: string, groupData: { label?: string or undefined; hidden?: boolean or undefined; collapsed?: boolean or undefined; }, options?: QpBridgeOptions or undefined) => Promise<...>` |
|
|
552
564
|
|
|
553
565
|
Parameters:
|
|
554
566
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
567
|
+
- `name`: - The name of the group to update. This is a unique identifier and cannot be changed.
|
|
568
|
+
- `groupData`: - The updated group data excluding the name property.
|
|
558
569
|
|
|
559
570
|
Returns:
|
|
560
571
|
|
|
@@ -563,51 +574,47 @@ A promise that resolves when the group has been successfully updated.
|
|
|
563
574
|
Examples:
|
|
564
575
|
|
|
565
576
|
```typescript
|
|
566
|
-
await setGroup(
|
|
577
|
+
await setGroup("personalInfo", { label: "Personal Information", hidden: false, collapsed: true });
|
|
567
578
|
```
|
|
568
579
|
|
|
569
|
-
|
|
570
580
|
### onAnswerChange
|
|
571
581
|
|
|
572
582
|
Subscribes to changes in answers for questions.
|
|
573
583
|
Calls the provided listener whenever an answer changes in the questionnaire.
|
|
574
584
|
|
|
575
|
-
| Function
|
|
576
|
-
|
|
|
585
|
+
| Function | Type |
|
|
586
|
+
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
|
|
577
587
|
| `onAnswerChange` | `(listener: (question: string, answer: unknown) => void, options?: QpBridgeOptions or undefined) => { cancelSubscription: () => void; }` |
|
|
578
588
|
|
|
579
589
|
Parameters:
|
|
580
590
|
|
|
581
|
-
|
|
582
|
-
|
|
591
|
+
- `listener`: - A function that will be called with the question name and the new answer whenever an answer changes.
|
|
583
592
|
|
|
584
593
|
Examples:
|
|
585
594
|
|
|
586
595
|
```typescript
|
|
587
|
-
import { onAnswerChange } from
|
|
596
|
+
import { onAnswerChange } from "qp-bridge";
|
|
588
597
|
const { cancelSubscription } = onAnswerChange((question, answer) => {
|
|
589
|
-
|
|
590
|
-
|
|
598
|
+
console.log(`Answer for ${question} changed to:`, answer);
|
|
599
|
+
});
|
|
591
600
|
|
|
592
601
|
// To stop listening for changes:
|
|
593
602
|
cancelSubscription();
|
|
594
603
|
```
|
|
595
604
|
|
|
596
|
-
|
|
597
605
|
### withBusyIndicator
|
|
598
606
|
|
|
599
607
|
Wraps an asynchronous action with a busy indicator in the host application.
|
|
600
608
|
Shows a loading indicator during the execution of the provided action,
|
|
601
609
|
ensuring the UI reflects the busy state appropriately.
|
|
602
610
|
|
|
603
|
-
| Function
|
|
604
|
-
|
|
|
611
|
+
| Function | Type |
|
|
612
|
+
| ------------------- | ------------------------------------------------------------------------------------- |
|
|
605
613
|
| `withBusyIndicator` | `<T>(action: () => Promise<T>, options?: QpBridgeOptions or undefined) => Promise<T>` |
|
|
606
614
|
|
|
607
615
|
Parameters:
|
|
608
616
|
|
|
609
|
-
|
|
610
|
-
|
|
617
|
+
- `action`: - A function returning a promise whose execution should be wrapped.
|
|
611
618
|
|
|
612
619
|
Returns:
|
|
613
620
|
|
|
@@ -617,20 +624,19 @@ Examples:
|
|
|
617
624
|
|
|
618
625
|
```typescript
|
|
619
626
|
const result = await withBusyIndicator(async () => {
|
|
620
|
-
await setAnswer(
|
|
621
|
-
return
|
|
627
|
+
await setAnswer("favoriteColor", "blue");
|
|
628
|
+
return "done";
|
|
622
629
|
});
|
|
623
630
|
console.log(result); // 'done'
|
|
624
631
|
```
|
|
625
632
|
|
|
626
|
-
|
|
627
633
|
### saveQuestionnaire
|
|
628
634
|
|
|
629
635
|
Saves the current questionnaire state.
|
|
630
636
|
Triggers a save operation for the questionnaire data.
|
|
631
637
|
|
|
632
|
-
| Function
|
|
633
|
-
|
|
|
638
|
+
| Function | Type |
|
|
639
|
+
| ------------------- | ----------------------------------------------------------- |
|
|
634
640
|
| `saveQuestionnaire` | `(options?: QpBridgeOptions or undefined) => Promise<void>` |
|
|
635
641
|
|
|
636
642
|
Returns:
|
|
@@ -641,17 +647,16 @@ Examples:
|
|
|
641
647
|
|
|
642
648
|
```typescript
|
|
643
649
|
await saveQuestionnaire();
|
|
644
|
-
console.log(
|
|
650
|
+
console.log("Questionnaire saved successfully");
|
|
645
651
|
```
|
|
646
652
|
|
|
647
|
-
|
|
648
653
|
### completeAndCloseQuestionnaire
|
|
649
654
|
|
|
650
655
|
Completes and closes the current questionnaire.
|
|
651
656
|
Triggers the complete and close operation for the questionnaire.
|
|
652
657
|
|
|
653
|
-
| Function
|
|
654
|
-
|
|
|
658
|
+
| Function | Type |
|
|
659
|
+
| ------------------------------- | ----------------------------------------------------------- |
|
|
655
660
|
| `completeAndCloseQuestionnaire` | `(options?: QpBridgeOptions or undefined) => Promise<void>` |
|
|
656
661
|
|
|
657
662
|
Returns:
|
|
@@ -662,23 +667,21 @@ Examples:
|
|
|
662
667
|
|
|
663
668
|
```typescript
|
|
664
669
|
await completeAndCloseQuestionnaire();
|
|
665
|
-
console.log(
|
|
670
|
+
console.log("Questionnaire completed and closed successfully");
|
|
666
671
|
```
|
|
667
672
|
|
|
668
|
-
|
|
669
673
|
### executeCustomCommand
|
|
670
674
|
|
|
671
675
|
Executes a custom command by its name.
|
|
672
676
|
Triggers the execution of any user-defined command in the questionnaire.
|
|
673
677
|
|
|
674
|
-
| Function
|
|
675
|
-
|
|
|
678
|
+
| Function | Type |
|
|
679
|
+
| ---------------------- | -------------------------------------------------------------------------------- |
|
|
676
680
|
| `executeCustomCommand` | `(commandName: string, options?: QpBridgeOptions or undefined) => Promise<void>` |
|
|
677
681
|
|
|
678
682
|
Parameters:
|
|
679
683
|
|
|
680
|
-
|
|
681
|
-
|
|
684
|
+
- `commandName`: - The name of the command to execute.
|
|
682
685
|
|
|
683
686
|
Returns:
|
|
684
687
|
|
|
@@ -687,24 +690,22 @@ A promise that resolves when the command has been successfully executed.
|
|
|
687
690
|
Examples:
|
|
688
691
|
|
|
689
692
|
```typescript
|
|
690
|
-
await executeCustomCommand(
|
|
691
|
-
console.log(
|
|
693
|
+
await executeCustomCommand("MyCustomCommand");
|
|
694
|
+
console.log("Custom command executed successfully");
|
|
692
695
|
```
|
|
693
696
|
|
|
694
|
-
|
|
695
697
|
### onQuestionnaireLoaded
|
|
696
698
|
|
|
697
699
|
Registers a handler function to be called when the questionnaire is fully loaded.
|
|
698
700
|
Useful for performing actions that depend on the questionnaire being ready.
|
|
699
701
|
|
|
700
|
-
| Function
|
|
701
|
-
|
|
|
702
|
+
| Function | Type |
|
|
703
|
+
| ----------------------- | ------------------------------------------------------------------------------------------------------ |
|
|
702
704
|
| `onQuestionnaireLoaded` | `(handler: () => void, options?: QpBridgeOptions or undefined) => { cancelSubscription: () => void; }` |
|
|
703
705
|
|
|
704
706
|
Parameters:
|
|
705
707
|
|
|
706
|
-
|
|
707
|
-
|
|
708
|
+
- `handler`: - A function to be called when the questionnaire is loaded.
|
|
708
709
|
|
|
709
710
|
Returns:
|
|
710
711
|
|
|
@@ -713,29 +714,27 @@ An object with a `cancelSubscription` method to unregister the handler.
|
|
|
713
714
|
Examples:
|
|
714
715
|
|
|
715
716
|
```typescript
|
|
716
|
-
import { onQuestionnaireLoaded } from
|
|
717
|
+
import { onQuestionnaireLoaded } from "qp-bridge";
|
|
717
718
|
const { cancelSubscription } = onQuestionnaireLoaded(() => {
|
|
718
|
-
console.log(
|
|
719
|
+
console.log("Questionnaire is fully loaded");
|
|
719
720
|
});
|
|
720
721
|
|
|
721
722
|
// To stop listening for questionnaire load events:
|
|
722
723
|
cancelSubscription();
|
|
723
724
|
```
|
|
724
725
|
|
|
725
|
-
|
|
726
726
|
### onCommandExecuted
|
|
727
727
|
|
|
728
728
|
Registers a handler function to be called when a command is executed.
|
|
729
729
|
Useful for reacting to custom command executions within the questionnaire.
|
|
730
730
|
|
|
731
|
-
| Function
|
|
732
|
-
|
|
|
731
|
+
| Function | Type |
|
|
732
|
+
| ------------------- | ------------------------------------------------------------------------------------------------------------------------- |
|
|
733
733
|
| `onCommandExecuted` | `(handler: (commandName: string) => void, options?: QpBridgeOptions or undefined) => { cancelSubscription: () => void; }` |
|
|
734
734
|
|
|
735
735
|
Parameters:
|
|
736
736
|
|
|
737
|
-
|
|
738
|
-
|
|
737
|
+
- `handler`: - A function that receives the name of the executed command.
|
|
739
738
|
|
|
740
739
|
Returns:
|
|
741
740
|
|
|
@@ -744,8 +743,8 @@ An object with a `cancelSubscription` method to unregister the handler.
|
|
|
744
743
|
Examples:
|
|
745
744
|
|
|
746
745
|
```typescript
|
|
747
|
-
import { onCommandExecuted } from
|
|
748
|
-
const { cancelSubscription } = onCommandExecuted(
|
|
746
|
+
import { onCommandExecuted } from "qp-bridge";
|
|
747
|
+
const { cancelSubscription } = onCommandExecuted(commandName => {
|
|
749
748
|
console.log(`Command executed: ${commandName}`);
|
|
750
749
|
});
|
|
751
750
|
|
|
@@ -753,20 +752,18 @@ const { cancelSubscription } = onCommandExecuted((commandName) => {
|
|
|
753
752
|
cancelSubscription();
|
|
754
753
|
```
|
|
755
754
|
|
|
756
|
-
|
|
757
755
|
### onSave
|
|
758
756
|
|
|
759
757
|
Registers a validator function to be called when a save event occurs.
|
|
760
758
|
Useful for validating data before saving the questionnaire.
|
|
761
759
|
|
|
762
|
-
| Function | Type
|
|
763
|
-
|
|
|
760
|
+
| Function | Type |
|
|
761
|
+
| -------- | ------------------------------------------------------------------------------------------------------- |
|
|
764
762
|
| `onSave` | `(validator: Validator, options?: QpBridgeOptions or undefined) => { cancelSubscription: () => void; }` |
|
|
765
763
|
|
|
766
764
|
Parameters:
|
|
767
765
|
|
|
768
|
-
|
|
769
|
-
|
|
766
|
+
- `validator`: - A function returning a Promise resolving to a boolean indicating if the save is valid.
|
|
770
767
|
|
|
771
768
|
Returns:
|
|
772
769
|
|
|
@@ -775,7 +772,7 @@ An object with a `cancelSubscription` method to unregister the validator.
|
|
|
775
772
|
Examples:
|
|
776
773
|
|
|
777
774
|
```typescript
|
|
778
|
-
import { onSave } from
|
|
775
|
+
import { onSave } from "qp-bridge";
|
|
779
776
|
const { cancelSubscription } = onSave(async () => {
|
|
780
777
|
// perform validation logic
|
|
781
778
|
return true;
|
|
@@ -785,19 +782,46 @@ const { cancelSubscription } = onSave(async () => {
|
|
|
785
782
|
cancelSubscription();
|
|
786
783
|
```
|
|
787
784
|
|
|
785
|
+
### onPostSave
|
|
786
|
+
|
|
787
|
+
Registers a handler function to be called after the questionnaire is successfully saved.
|
|
788
|
+
The handler receives the saved answer ID and the save flow waits for all handlers to finish before continuing.
|
|
789
|
+
|
|
790
|
+
| Function | Type |
|
|
791
|
+
| ------------ | ----------------------------------------------------------------------------------------------------------- |
|
|
792
|
+
| `onPostSave` | `(handler: PostSaveHandler, options?: QpBridgeOptions or undefined) => { cancelSubscription: () => void; }` |
|
|
793
|
+
|
|
794
|
+
Parameters:
|
|
795
|
+
|
|
796
|
+
- `handler`: - A function called with the saved answer ID after save.
|
|
797
|
+
|
|
798
|
+
Returns:
|
|
799
|
+
|
|
800
|
+
An object with a `cancelSubscription` method to unregister the handler.
|
|
801
|
+
|
|
802
|
+
Examples:
|
|
803
|
+
|
|
804
|
+
```typescript
|
|
805
|
+
import { onPostSave } from "qp-bridge";
|
|
806
|
+
const { cancelSubscription } = onPostSave(async answerId => {
|
|
807
|
+
// create related records and set their regarding to answerId
|
|
808
|
+
});
|
|
809
|
+
|
|
810
|
+
// To stop listening for post-save events:
|
|
811
|
+
cancelSubscription();
|
|
812
|
+
```
|
|
788
813
|
|
|
789
814
|
### fetchEntities
|
|
790
815
|
|
|
791
816
|
Fetches entities from the CRM system using the provided FetchXML query.
|
|
792
817
|
|
|
793
|
-
| Function
|
|
794
|
-
|
|
|
818
|
+
| Function | Type |
|
|
819
|
+
| --------------- | -------------------------------------------------------------------------------------------------- |
|
|
795
820
|
| `fetchEntities` | `(fetchXml: string, options?: QpBridgeOptions or undefined) => Promise<Record<string, unknown>[]>` |
|
|
796
821
|
|
|
797
822
|
Parameters:
|
|
798
823
|
|
|
799
|
-
|
|
800
|
-
|
|
824
|
+
- `fetchXml`: - The FetchXML query string to execute.
|
|
801
825
|
|
|
802
826
|
Returns:
|
|
803
827
|
|
|
@@ -816,20 +840,18 @@ const entities = await fetchEntities(fetchXml);
|
|
|
816
840
|
console.log(entities); // Array of contact entities
|
|
817
841
|
```
|
|
818
842
|
|
|
819
|
-
|
|
820
843
|
### getEntityById
|
|
821
844
|
|
|
822
845
|
Retrieves a single entity by its name and ID from the CRM system.
|
|
823
846
|
|
|
824
|
-
| Function
|
|
825
|
-
|
|
|
847
|
+
| Function | Type |
|
|
848
|
+
| --------------- | -------------------------------------------------------------------------------------------------------------- |
|
|
826
849
|
| `getEntityById` | `(entityName: string, id: string, options?: QpBridgeOptions or undefined) => Promise<Record<string, unknown>>` |
|
|
827
850
|
|
|
828
851
|
Parameters:
|
|
829
852
|
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
853
|
+
- `entityName`: - The name of the entity to retrieve (e.g., "contact", "account").
|
|
854
|
+
- `id`: - The unique identifier of the entity.
|
|
833
855
|
|
|
834
856
|
Returns:
|
|
835
857
|
|
|
@@ -838,47 +860,44 @@ A promise that resolves to the entity object.
|
|
|
838
860
|
Examples:
|
|
839
861
|
|
|
840
862
|
```typescript
|
|
841
|
-
const contact = await getEntityById(
|
|
863
|
+
const contact = await getEntityById("contact", "12345678-1234-1234-1234-123456789abc");
|
|
842
864
|
console.log(contact.attributes.firstname); // Entity firstname attribute
|
|
843
865
|
```
|
|
844
866
|
|
|
845
|
-
|
|
846
867
|
### createNewEntity
|
|
847
868
|
|
|
848
869
|
Creates a new entity marker that can be enriched before saving.
|
|
849
870
|
The returned entity is flagged with `isNew` so the host can distinguish new records.
|
|
850
871
|
|
|
851
|
-
| Function
|
|
852
|
-
|
|
|
872
|
+
| Function | Type |
|
|
873
|
+
| ----------------- | ------------------------------- |
|
|
853
874
|
| `createNewEntity` | `() => Record<string, unknown>` |
|
|
854
875
|
|
|
855
876
|
### saveEntity
|
|
856
877
|
|
|
857
878
|
Persists an entity through the bridge. Supports both new and existing entities.
|
|
858
879
|
|
|
859
|
-
| Function
|
|
860
|
-
|
|
|
880
|
+
| Function | Type |
|
|
881
|
+
| ------------ | -------------------------------------------------------------------------------------------- |
|
|
861
882
|
| `saveEntity` | `(entity: Record<string, unknown>, options?: QpBridgeOptions or undefined) => Promise<void>` |
|
|
862
883
|
|
|
863
884
|
Parameters:
|
|
864
885
|
|
|
865
|
-
|
|
866
|
-
|
|
886
|
+
- `entity`: - Entity payload; include `isNew` for newly created entities.
|
|
867
887
|
|
|
868
888
|
### repeatGroup
|
|
869
889
|
|
|
870
890
|
Repeats a specific group within a repeatable group by creating a copy of the group at the specified index.
|
|
871
891
|
The parent group must be a repeatable group and the index must refer to an existing group instance.
|
|
872
892
|
|
|
873
|
-
| Function
|
|
874
|
-
|
|
|
893
|
+
| Function | Type |
|
|
894
|
+
| ------------- | ------------------------------------------------------------------------------------------------------------ |
|
|
875
895
|
| `repeatGroup` | `(repeatableGroupName: string, groupIndex: number, options?: QpBridgeOptions or undefined) => Promise<void>` |
|
|
876
896
|
|
|
877
897
|
Parameters:
|
|
878
898
|
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
899
|
+
- `repeatableGroupName`: - The name of the parent repeatable group.
|
|
900
|
+
- `groupIndex`: - The index (0-based) of the group instance to repeat.
|
|
882
901
|
|
|
883
902
|
Returns:
|
|
884
903
|
|
|
@@ -887,24 +906,22 @@ A promise that resolves when the group has been successfully repeated.
|
|
|
887
906
|
Examples:
|
|
888
907
|
|
|
889
908
|
```typescript
|
|
890
|
-
await repeatGroup(
|
|
891
|
-
console.log(
|
|
909
|
+
await repeatGroup("personalInfoRepeatable", 1);
|
|
910
|
+
console.log("Group repeated successfully");
|
|
892
911
|
```
|
|
893
912
|
|
|
894
|
-
|
|
895
913
|
### addNewGroup
|
|
896
914
|
|
|
897
915
|
Adds a new group instance to a repeatable group.
|
|
898
916
|
The specified name must refer to a repeatable group.
|
|
899
917
|
|
|
900
|
-
| Function
|
|
901
|
-
|
|
|
918
|
+
| Function | Type |
|
|
919
|
+
| ------------- | ---------------------------------------------------------------------------------------- |
|
|
902
920
|
| `addNewGroup` | `(repeatableGroupName: string, options?: QpBridgeOptions or undefined) => Promise<void>` |
|
|
903
921
|
|
|
904
922
|
Parameters:
|
|
905
923
|
|
|
906
|
-
|
|
907
|
-
|
|
924
|
+
- `repeatableGroupName`: - The name of the repeatable group to add a new instance to.
|
|
908
925
|
|
|
909
926
|
Returns:
|
|
910
927
|
|
|
@@ -913,25 +930,23 @@ A promise that resolves when the new group has been successfully added.
|
|
|
913
930
|
Examples:
|
|
914
931
|
|
|
915
932
|
```typescript
|
|
916
|
-
await addNewGroup(
|
|
917
|
-
console.log(
|
|
933
|
+
await addNewGroup("personalInfoRepeatable");
|
|
934
|
+
console.log("New group added successfully");
|
|
918
935
|
```
|
|
919
936
|
|
|
920
|
-
|
|
921
937
|
### deleteGroup
|
|
922
938
|
|
|
923
939
|
Deletes a specific group instance from a repeatable group by index.
|
|
924
940
|
The parent group must be a repeatable group and the index must refer to an existing group instance.
|
|
925
941
|
|
|
926
|
-
| Function
|
|
927
|
-
|
|
|
942
|
+
| Function | Type |
|
|
943
|
+
| ------------- | ------------------------------------------------------------------------------------------------------------ |
|
|
928
944
|
| `deleteGroup` | `(repeatableGroupName: string, groupIndex: number, options?: QpBridgeOptions or undefined) => Promise<void>` |
|
|
929
945
|
|
|
930
946
|
Parameters:
|
|
931
947
|
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
948
|
+
- `repeatableGroupName`: - The name of the parent repeatable group.
|
|
949
|
+
- `groupIndex`: - The index (0-based) of the group instance to delete.
|
|
935
950
|
|
|
936
951
|
Returns:
|
|
937
952
|
|
|
@@ -940,11 +955,8 @@ A promise that resolves when the group has been successfully deleted.
|
|
|
940
955
|
Examples:
|
|
941
956
|
|
|
942
957
|
```typescript
|
|
943
|
-
await deleteGroup(
|
|
944
|
-
console.log(
|
|
958
|
+
await deleteGroup("personalInfoRepeatable", 1);
|
|
959
|
+
console.log("Group deleted successfully");
|
|
945
960
|
```
|
|
946
961
|
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
962
|
<!-- TSDOC_END -->
|