case-editor-tools 1.0.0-beta.16 → 1.0.0-beta.17

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 (113) hide show
  1. package/constants/key-definitions.d.ts +14 -0
  2. package/constants/key-definitions.js +34 -0
  3. package/constants/key-definitions.js.map +1 -0
  4. package/exporter/index.d.ts +2 -0
  5. package/exporter/index.js +99 -0
  6. package/exporter/index.js.map +1 -0
  7. package/expression-utils/expressionGen.d.ts +2 -0
  8. package/{src/expression-utils/expressionGen.ts → expression-utils/expressionGen.js} +29 -26
  9. package/expression-utils/expressionGen.js.map +1 -0
  10. package/expression-utils/studyEngineExpressions.d.ts +114 -0
  11. package/expression-utils/studyEngineExpressions.js +283 -0
  12. package/expression-utils/studyEngineExpressions.js.map +1 -0
  13. package/{CHANGELOG.md → index.d.ts} +0 -0
  14. package/index.js +3 -0
  15. package/index.js.map +1 -0
  16. package/item-editor-7f825952.js +522 -0
  17. package/item-editor-7f825952.js.map +1 -0
  18. package/{src/logger/index.ts → logger/index.d.ts} +1 -1
  19. package/logger/index.js +10 -0
  20. package/logger/index.js.map +1 -0
  21. package/logger/logger.d.ts +9 -0
  22. package/logger/logger.js +31 -0
  23. package/logger/logger.js.map +1 -0
  24. package/package.json +1 -1
  25. package/{src/surveys/index.ts → surveys/index.d.ts} +3 -3
  26. package/surveys/index.js +26 -0
  27. package/surveys/index.js.map +1 -0
  28. package/surveys/survey-editor/component-editor.d.ts +84 -0
  29. package/surveys/survey-editor/component-editor.js +112 -0
  30. package/surveys/survey-editor/component-editor.js.map +1 -0
  31. package/{src/surveys/survey-editor/data-types.ts → surveys/survey-editor/data-types.d.ts} +13 -18
  32. package/surveys/survey-editor/data-types.js +3 -0
  33. package/surveys/survey-editor/data-types.js.map +1 -0
  34. package/surveys/survey-editor/item-editor.d.ts +65 -0
  35. package/surveys/survey-editor/item-editor.js +13 -0
  36. package/surveys/survey-editor/item-editor.js.map +1 -0
  37. package/surveys/survey-editor/survey-editor.d.ts +43 -0
  38. package/surveys/survey-editor/survey-editor.js +231 -0
  39. package/surveys/survey-editor/survey-editor.js.map +1 -0
  40. package/surveys/survey-engine-expressions.d.ts +120 -0
  41. package/surveys/survey-engine-expressions.js +407 -0
  42. package/surveys/survey-engine-expressions.js.map +1 -0
  43. package/surveys/survey-items.d.ts +133 -0
  44. package/surveys/survey-items.js +1051 -0
  45. package/surveys/survey-items.js.map +1 -0
  46. package/surveys/types/group.d.ts +23 -0
  47. package/surveys/types/group.js +71 -0
  48. package/surveys/types/group.js.map +1 -0
  49. package/{src/surveys/types/index.ts → surveys/types/index.d.ts} +4 -4
  50. package/surveys/types/index.js +20 -0
  51. package/surveys/types/index.js.map +1 -0
  52. package/surveys/types/item-properties.d.ts +189 -0
  53. package/surveys/types/item-properties.js +3 -0
  54. package/surveys/types/item-properties.js.map +1 -0
  55. package/{src/surveys/types/item.ts → surveys/types/item.d.ts} +22 -42
  56. package/surveys/types/item.js +34 -0
  57. package/surveys/types/item.js.map +1 -0
  58. package/surveys/types/survey-definition.d.ts +19 -0
  59. package/surveys/types/survey-definition.js +60 -0
  60. package/surveys/types/survey-definition.js.map +1 -0
  61. package/surveys/utils/componentGenerators.d.ts +24 -0
  62. package/surveys/utils/componentGenerators.js +58 -0
  63. package/surveys/utils/componentGenerators.js.map +1 -0
  64. package/surveys/utils/optionDefGenerators.d.ts +69 -0
  65. package/surveys/utils/optionDefGenerators.js +169 -0
  66. package/surveys/utils/optionDefGenerators.js.map +1 -0
  67. package/surveys/utils/randomKeyGenerator.d.ts +1 -0
  68. package/{src/surveys/utils/randomKeyGenerator.ts → surveys/utils/randomKeyGenerator.js} +14 -9
  69. package/surveys/utils/randomKeyGenerator.js.map +1 -0
  70. package/surveys/utils/simple-generators.d.ts +13 -0
  71. package/surveys/utils/simple-generators.js +102 -0
  72. package/surveys/utils/simple-generators.js.map +1 -0
  73. package/surveys/utils/simple-question-editor.d.ts +14 -0
  74. package/surveys/utils/simple-question-editor.js +45 -0
  75. package/surveys/utils/simple-question-editor.js.map +1 -0
  76. package/types/duration.d.ts +9 -0
  77. package/{src/types/duration.ts → types/duration.js} +27 -30
  78. package/types/duration.js.map +1 -0
  79. package/types/expression.d.ts +4 -0
  80. package/types/expression.js +23 -0
  81. package/types/expression.js.map +1 -0
  82. package/types/study.d.ts +13 -0
  83. package/types/study.js +3 -0
  84. package/types/study.js.map +1 -0
  85. package/types/studyRules.d.ts +8 -0
  86. package/types/studyRules.js +32 -0
  87. package/types/studyRules.js.map +1 -0
  88. package/.editorconfig +0 -13
  89. package/LICENSE +0 -202
  90. package/publish.sh +0 -9
  91. package/readme.md +0 -18
  92. package/rollup.config.js +0 -49
  93. package/src/constants/key-definitions.ts +0 -14
  94. package/src/exporter/index.ts +0 -101
  95. package/src/expression-utils/studyEngineExpressions.ts +0 -359
  96. package/src/index.ts +0 -1
  97. package/src/logger/logger.ts +0 -31
  98. package/src/surveys/survey-editor/component-editor.ts +0 -133
  99. package/src/surveys/survey-editor/item-editor.ts +0 -529
  100. package/src/surveys/survey-editor/survey-editor.ts +0 -261
  101. package/src/surveys/survey-engine-expressions.ts +0 -483
  102. package/src/surveys/survey-items.ts +0 -1490
  103. package/src/surveys/types/group.ts +0 -73
  104. package/src/surveys/types/item-properties.ts +0 -204
  105. package/src/surveys/types/survey-definition.ts +0 -83
  106. package/src/surveys/utils/componentGenerators.ts +0 -76
  107. package/src/surveys/utils/optionDefGenerators.ts +0 -195
  108. package/src/surveys/utils/simple-generators.ts +0 -106
  109. package/src/surveys/utils/simple-question-editor.ts +0 -52
  110. package/src/types/expression.ts +0 -22
  111. package/src/types/study.ts +0 -17
  112. package/src/types/studyRules.ts +0 -39
  113. package/tsconfig.json +0 -100
@@ -0,0 +1,522 @@
1
+ 'use strict';
2
+
3
+ var surveys_surveyEditor_componentEditor = require('./surveys/survey-editor/component-editor.js');
4
+ var surveys_utils_randomKeyGenerator = require('./surveys/utils/randomKeyGenerator.js');
5
+ var logger_logger = require('./logger/logger.js');
6
+
7
+ var data_types = {};
8
+
9
+ var expression = {};
10
+
11
+ Object.defineProperty(expression, "__esModule", { value: true });
12
+ expression.isExpression = (value) => {
13
+ return typeof (value) === 'object' && value.name !== undefined && value.name.length > 0;
14
+ };
15
+ expression.expressionArgParser = (arg) => {
16
+ switch (arg.dtype) {
17
+ case 'num':
18
+ return arg.num;
19
+ case 'str':
20
+ return arg.str;
21
+ case 'exp':
22
+ return arg.exp;
23
+ default:
24
+ return arg.str;
25
+ }
26
+ };
27
+
28
+ var surveyItem = {};
29
+
30
+ Object.defineProperty(surveyItem, "__esModule", { value: true });
31
+ surveyItem.isSurveyGroupItem = (item) => {
32
+ const items = item.items;
33
+ return items !== undefined && items.length > 0;
34
+ };
35
+
36
+ var surveyItemComponent = {};
37
+
38
+ Object.defineProperty(surveyItemComponent, "__esModule", { value: true });
39
+ surveyItemComponent.isItemGroupComponent = (item) => {
40
+ const items = item.items;
41
+ return items !== undefined && items.length > 0;
42
+ };
43
+
44
+ var response = {};
45
+
46
+ Object.defineProperty(response, "__esModule", { value: true });
47
+ response.isSurveyGroupItemResponse = (item) => {
48
+ const items = item.items;
49
+ return items !== undefined && items.length > 0;
50
+ };
51
+
52
+ (function (exports) {
53
+ function __export(m) {
54
+ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
55
+ }
56
+ Object.defineProperty(exports, "__esModule", { value: true });
57
+ __export(expression);
58
+ __export(surveyItem);
59
+ __export(surveyItemComponent);
60
+ __export(response);
61
+ }(data_types));
62
+
63
+ const initialRootComp = () => {
64
+ return {
65
+ role: 'root',
66
+ order: { name: 'sequential' },
67
+ items: []
68
+ };
69
+ };
70
+ class ItemEditor {
71
+ constructor(existingItem, newItem) {
72
+ this.surveyItem = { key: '', version: 0 };
73
+ if (existingItem) {
74
+ this.surveyItem = Object.assign({}, existingItem);
75
+ // console.log(this.surveyItem);
76
+ }
77
+ else {
78
+ const key = (newItem === null || newItem === void 0 ? void 0 : newItem.itemKey) ? newItem.itemKey : 'no key';
79
+ if (newItem === null || newItem === void 0 ? void 0 : newItem.isGroup) {
80
+ const currentItem = {
81
+ key,
82
+ version: 1,
83
+ items: [],
84
+ };
85
+ this.surveyItem = currentItem;
86
+ }
87
+ else {
88
+ const currentItem = {
89
+ key,
90
+ version: 1,
91
+ };
92
+ if (newItem === null || newItem === void 0 ? void 0 : newItem.type) {
93
+ currentItem.type = newItem.type;
94
+ }
95
+ this.surveyItem = currentItem;
96
+ }
97
+ }
98
+ }
99
+ getItem() {
100
+ return Object.assign({}, this.surveyItem);
101
+ }
102
+ getItemJSON(pretty) {
103
+ return JSON.stringify(this.surveyItem, undefined, pretty ? ' ' : undefined);
104
+ }
105
+ setKey(newKey) {
106
+ this.surveyItem.key = newKey;
107
+ }
108
+ addToFollows(key) {
109
+ if (!this.surveyItem.follows) {
110
+ this.surveyItem.follows = [];
111
+ }
112
+ if (this.surveyItem.follows.includes(key)) {
113
+ console.warn('follows array already includes key: ', key);
114
+ return;
115
+ }
116
+ this.surveyItem.follows.push(key);
117
+ }
118
+ removeFromFollows(key) {
119
+ if (!this.surveyItem.follows) {
120
+ console.warn('follows array already empty');
121
+ return;
122
+ }
123
+ if (!this.surveyItem.follows.includes(key)) {
124
+ console.warn('follows array does not include key: ', key);
125
+ return;
126
+ }
127
+ this.surveyItem.follows = this.surveyItem.follows.filter(k => k !== key);
128
+ }
129
+ ;
130
+ clearFollows() {
131
+ if (!this.surveyItem.follows) {
132
+ console.warn('follows array already empty');
133
+ return;
134
+ }
135
+ this.surveyItem.follows = undefined;
136
+ }
137
+ ;
138
+ setCondition(exp) {
139
+ this.surveyItem.condition = exp;
140
+ }
141
+ ;
142
+ setPriority(prio) {
143
+ this.surveyItem.priority = prio;
144
+ }
145
+ ;
146
+ setVersion(version) {
147
+ this.surveyItem.version = version;
148
+ }
149
+ ;
150
+ setVersionTags(tags) {
151
+ this.surveyItem.versionTags = [...tags];
152
+ }
153
+ ;
154
+ // methods for survey group items:
155
+ addSurveyItem(item, atPosition) {
156
+ if (atPosition !== undefined) {
157
+ this.surveyItem.items.splice(atPosition, 0, Object.assign({}, item));
158
+ }
159
+ else {
160
+ this.surveyItem.items.push(Object.assign({}, item));
161
+ }
162
+ }
163
+ ;
164
+ updateSurveyItem(item) {
165
+ const ind = this.surveyItem.items.findIndex(it => item.key === it.key);
166
+ if (ind < 0) {
167
+ console.warn('item not found in the items array');
168
+ return;
169
+ }
170
+ this.surveyItem.items[ind] = Object.assign({}, item);
171
+ }
172
+ ;
173
+ removeItem(key) {
174
+ if (!this.surveyItem.items.find(it => it.key === key)) {
175
+ console.warn('group items does not contain item with key: ', key);
176
+ return;
177
+ }
178
+ this.surveyItem.items = this.surveyItem.items.filter(it => it.key !== key);
179
+ }
180
+ ;
181
+ changeItemPosition(key, newPosition) {
182
+ console.warn('unimplemented');
183
+ }
184
+ ;
185
+ setSelectionMethod(exp) {
186
+ this.surveyItem.selectionMethod = exp;
187
+ }
188
+ ;
189
+ // methods for survey single items:
190
+ setItemType(type) {
191
+ this.surveyItem.type = type;
192
+ }
193
+ ;
194
+ setTitleComponent(title) {
195
+ const currentItem = this.surveyItem;
196
+ if (!currentItem.components) {
197
+ currentItem.components = Object.assign({}, initialRootComp());
198
+ }
199
+ title.role = 'title';
200
+ const ind = currentItem.components.items.findIndex(comp => comp.role === 'title');
201
+ if (ind < 0) {
202
+ currentItem.components.items.push(Object.assign({}, title));
203
+ return;
204
+ }
205
+ currentItem.components.items[ind] = Object.assign({}, title);
206
+ }
207
+ setHelpGroupComponent(helpGroup) {
208
+ const currentItem = this.surveyItem;
209
+ if (!currentItem.components) {
210
+ currentItem.components = Object.assign({}, initialRootComp());
211
+ }
212
+ helpGroup.role = 'helpGroup';
213
+ const ind = currentItem.components.items.findIndex(comp => comp.role === 'helpGroup');
214
+ if (ind < 0) {
215
+ currentItem.components.items.push(Object.assign({}, helpGroup));
216
+ return;
217
+ }
218
+ currentItem.components.items[ind] = Object.assign({}, helpGroup);
219
+ }
220
+ ;
221
+ // for warning, error, texts:
222
+ addDisplayComponent(comp, atPosition) {
223
+ const currentItem = this.surveyItem;
224
+ if (!currentItem.components) {
225
+ currentItem.components = Object.assign({}, initialRootComp());
226
+ }
227
+ if (atPosition !== undefined) {
228
+ currentItem.components.items.splice(atPosition, 0, Object.assign({}, comp));
229
+ }
230
+ else {
231
+ currentItem.components.items.push(Object.assign({}, comp));
232
+ }
233
+ }
234
+ ;
235
+ updateDisplayComponent(at, comp) {
236
+ const currentItem = this.surveyItem;
237
+ if (!currentItem.components || !currentItem.components.items || currentItem.components.items.length <= at + 1 || at < 0) {
238
+ console.warn('component not found at ', at);
239
+ return;
240
+ }
241
+ currentItem.components.items[at] = Object.assign({}, comp);
242
+ }
243
+ ;
244
+ removeDisplayComponent(at) {
245
+ const currentItem = this.surveyItem;
246
+ if (!currentItem.components || !currentItem.components.items || currentItem.components.items.length <= at + 1 || at < 0) {
247
+ console.warn('component not found at ', at);
248
+ return;
249
+ }
250
+ currentItem.components.items.splice(at, 1);
251
+ }
252
+ ;
253
+ addNewResponseComponent(props, parentKey, atPosition) {
254
+ const currentItem = this.surveyItem;
255
+ if (!currentItem.components) {
256
+ currentItem.components = Object.assign({}, initialRootComp());
257
+ }
258
+ if (!parentKey) {
259
+ props.role = 'responseGroup';
260
+ if (!props.key) {
261
+ props.key = 'rg';
262
+ }
263
+ props.isGroup = true;
264
+ const newComponent = (new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, props)).getComponent();
265
+ const ind = currentItem.components.items.findIndex(comp => comp.role === 'responseGroup');
266
+ if (ind < 0) {
267
+ currentItem.components.items.push(newComponent);
268
+ return Object.assign({}, newComponent);
269
+ }
270
+ currentItem.components.items[ind] = newComponent;
271
+ return Object.assign({}, newComponent);
272
+ }
273
+ const ids = parentKey.split('.');
274
+ let obj = undefined;
275
+ for (const currentKey of ids) {
276
+ if (!obj) {
277
+ const ind = currentItem.components.items.findIndex(c => c.key === currentKey);
278
+ if (ind < 0) {
279
+ console.warn('response component not found: ', currentKey);
280
+ return;
281
+ }
282
+ obj = currentItem.components.items[ind];
283
+ continue;
284
+ }
285
+ if (!data_types.isItemGroupComponent(obj)) {
286
+ obj.items = [];
287
+ // leaf found
288
+ break;
289
+ }
290
+ const index = obj.items.findIndex(it => it.key === currentKey);
291
+ if (index < 0) {
292
+ console.warn('item component cannot be found: ', currentKey);
293
+ return;
294
+ }
295
+ obj = obj.items[index];
296
+ }
297
+ if (!obj) {
298
+ console.warn('survey item cannot be found: ', parentKey);
299
+ return;
300
+ }
301
+ if (obj.items.find(it => props.key === it.key)) {
302
+ logger_logger.Logger.criticalError('Duplicate key: ' + props.key);
303
+ return undefined;
304
+ }
305
+ const newComponent = (new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, props)).getComponent();
306
+ if (atPosition !== undefined) {
307
+ obj.items.splice(atPosition, 0, newComponent);
308
+ }
309
+ else {
310
+ obj.items.push(newComponent);
311
+ }
312
+ return newComponent;
313
+ }
314
+ ;
315
+ addExistingResponseComponent(newComp, parentKey, atPosition) {
316
+ const currentItem = this.surveyItem;
317
+ if (!currentItem.components) {
318
+ currentItem.components = Object.assign({}, initialRootComp());
319
+ }
320
+ if (newComp.key === undefined) {
321
+ newComp.key = surveys_utils_randomKeyGenerator.generateRandomKey(4);
322
+ }
323
+ if (!parentKey) {
324
+ const ind = currentItem.components.items.findIndex(comp => comp.role === 'responseGroup');
325
+ if (ind < 0) {
326
+ currentItem.components.items.push(newComp);
327
+ return Object.assign({}, newComp);
328
+ }
329
+ currentItem.components.items[ind] = newComp;
330
+ return Object.assign({}, newComp);
331
+ }
332
+ const ids = parentKey.split('.');
333
+ let obj = undefined;
334
+ for (const currentKey of ids) {
335
+ if (!obj) {
336
+ const ind = currentItem.components.items.findIndex(c => c.key === currentKey);
337
+ if (ind < 0) {
338
+ console.warn('response component not found: ', currentKey);
339
+ return;
340
+ }
341
+ obj = currentItem.components.items[ind];
342
+ continue;
343
+ }
344
+ if (!data_types.isItemGroupComponent(obj)) {
345
+ obj.items = [];
346
+ // leaf found
347
+ break;
348
+ }
349
+ const index = obj.items.findIndex(it => it.key === currentKey);
350
+ if (index < 0) {
351
+ console.warn('item component cannot be found: ', currentKey);
352
+ return;
353
+ }
354
+ obj = obj.items[index];
355
+ }
356
+ if (!obj) {
357
+ console.warn('item component cannot be found: ', parentKey);
358
+ return;
359
+ }
360
+ if (obj.items.find(it => newComp.key === it.key)) {
361
+ logger_logger.Logger.criticalError('Duplicate key: ' + newComp.key);
362
+ return undefined;
363
+ }
364
+ if (atPosition !== undefined) {
365
+ obj.items.splice(atPosition, 0, newComp);
366
+ }
367
+ else {
368
+ obj.items.push(newComp);
369
+ }
370
+ return newComp;
371
+ }
372
+ ;
373
+ updateResponseComponent(path, item) {
374
+ const currentItem = this.surveyItem;
375
+ if (!currentItem.components) {
376
+ return;
377
+ }
378
+ const responseGroup = currentItem.components.items.find(comp => comp.role === 'responseGroup');
379
+ if (!responseGroup) {
380
+ console.warn('no responseGroup found');
381
+ return;
382
+ }
383
+ if (responseGroup.key === path) {
384
+ const ind = currentItem.components.items.findIndex(it => it.key === path);
385
+ if (ind < 0) {
386
+ console.warn('item component cannot be found: ', path);
387
+ return;
388
+ }
389
+ currentItem.components.items[ind] = Object.assign({}, item);
390
+ return;
391
+ }
392
+ const ids = path.split('.');
393
+ const parentIds = ids.slice(1, ids.length - 1);
394
+ let obj = responseGroup;
395
+ for (const currentKey of parentIds) {
396
+ if (!data_types.isItemGroupComponent(obj)) {
397
+ // leaf found
398
+ break;
399
+ }
400
+ const index = obj.items.findIndex(it => it.key === currentKey);
401
+ if (index < 0) {
402
+ console.warn('item component cannot be found: ', currentKey);
403
+ return;
404
+ }
405
+ obj = obj.items[index];
406
+ }
407
+ if (!obj) {
408
+ console.warn('survey item cannot be found: ', path);
409
+ return;
410
+ }
411
+ const ind = obj.items.findIndex(it => it.key === ids[ids.length - 1]);
412
+ if (ind < 0) {
413
+ console.warn('item component cannot be found: ', path);
414
+ return;
415
+ }
416
+ obj.items[ind] = Object.assign({}, item);
417
+ }
418
+ ;
419
+ removeResponseComponent(keyPath) {
420
+ const currentItem = this.surveyItem;
421
+ if (!currentItem.components) {
422
+ return;
423
+ }
424
+ const responseGroup = currentItem.components.items.find(comp => comp.role === 'responseGroup');
425
+ if (!responseGroup) {
426
+ console.warn('no responseGroup found');
427
+ return;
428
+ }
429
+ if (responseGroup.key === keyPath) {
430
+ currentItem.components.items = currentItem.components.items.filter(it => it.role !== 'responseGroup');
431
+ return;
432
+ }
433
+ const ids = keyPath.split('.');
434
+ const parentIds = ids.slice(1, ids.length - 1);
435
+ let obj = responseGroup;
436
+ for (const currentKey of parentIds) {
437
+ if (!data_types.isItemGroupComponent(obj)) {
438
+ // leaf found
439
+ break;
440
+ }
441
+ const index = obj.items.findIndex(it => it.key === currentKey);
442
+ if (index < 0) {
443
+ console.warn('item component cannot be found: ', currentKey);
444
+ return;
445
+ }
446
+ obj = obj.items[index];
447
+ }
448
+ if (!obj) {
449
+ console.warn('survey item cannot be found: ', keyPath);
450
+ return;
451
+ }
452
+ obj.items = obj.items.filter(comp => comp.key !== ids[ids.length - 1]);
453
+ }
454
+ ;
455
+ findResponseComponent(key) {
456
+ const currentItem = this.surveyItem;
457
+ if (!currentItem.components) {
458
+ return;
459
+ }
460
+ const ids = key.split('.');
461
+ let obj = undefined;
462
+ for (const currentKey of ids) {
463
+ if (!obj) {
464
+ const ind = currentItem.components.items.findIndex(c => c.key === currentKey);
465
+ if (ind < 0) {
466
+ console.warn('item component not found: ', currentKey);
467
+ return;
468
+ }
469
+ obj = currentItem.components.items[ind];
470
+ continue;
471
+ }
472
+ if (!data_types.isItemGroupComponent(obj)) {
473
+ obj.items = [];
474
+ // leaf found
475
+ break;
476
+ }
477
+ const index = obj.items.findIndex(it => it.key === currentKey);
478
+ if (index < 0) {
479
+ console.warn('item component cannot be found: ', currentKey);
480
+ return;
481
+ }
482
+ obj = obj.items[index];
483
+ }
484
+ if (!obj) {
485
+ console.warn('item component cannot be found: ', key);
486
+ return;
487
+ }
488
+ return obj;
489
+ }
490
+ ;
491
+ addValidation(v) {
492
+ const currentItem = this.surveyItem;
493
+ if (!currentItem.validations) {
494
+ currentItem.validations = [];
495
+ }
496
+ if (currentItem.validations.find(valid => v.key === valid.key)) {
497
+ console.warn('validation key already used: ', v.key);
498
+ return;
499
+ }
500
+ currentItem.validations.push(Object.assign({}, v));
501
+ this.surveyItem = Object.assign({}, currentItem);
502
+ }
503
+ ;
504
+ removeValidation(vKey) {
505
+ const currentItem = this.surveyItem;
506
+ if (!currentItem.validations) {
507
+ console.warn('validation key not found used: ', vKey);
508
+ return;
509
+ }
510
+ if (currentItem.validations.find(valid => vKey === valid.key)) {
511
+ console.warn('validation key not found used: ', vKey);
512
+ return;
513
+ }
514
+ currentItem.validations = currentItem.validations.filter(v => v.key !== vKey);
515
+ this.surveyItem = Object.assign({}, currentItem);
516
+ }
517
+ ;
518
+ }
519
+
520
+ exports.ItemEditor = ItemEditor;
521
+ exports.data_types = data_types;
522
+ //# sourceMappingURL=item-editor-7f825952.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item-editor-7f825952.js","sources":["../node_modules/survey-engine/lib/data_types/expression.js","../node_modules/survey-engine/lib/data_types/survey-item.js","../node_modules/survey-engine/lib/data_types/survey-item-component.js","../node_modules/survey-engine/lib/data_types/response.js","../node_modules/survey-engine/lib/data_types/index.js"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.isExpression = (value) => {\n return typeof (value) === 'object' && value.name !== undefined && value.name.length > 0;\n};\nexports.expressionArgParser = (arg) => {\n switch (arg.dtype) {\n case 'num':\n return arg.num;\n case 'str':\n return arg.str;\n case 'exp':\n return arg.exp;\n default:\n return arg.str;\n }\n};\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.isSurveyGroupItem = (item) => {\n const items = item.items;\n return items !== undefined && items.length > 0;\n};\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.isItemGroupComponent = (item) => {\n const items = item.items;\n return items !== undefined && items.length > 0;\n};\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.isSurveyGroupItemResponse = (item) => {\n const items = item.items;\n return items !== undefined && items.length > 0;\n};\n","\"use strict\";\nfunction __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n}\nObject.defineProperty(exports, \"__esModule\", { value: true });\n__export(require(\"./expression\"));\n__export(require(\"./survey-item\"));\n__export(require(\"./survey-item-component\"));\n__export(require(\"./response\"));\n"],"names":["require$$0","require$$1","require$$2","require$$3"],"mappings":"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"}
@@ -1 +1 @@
1
- export { Logger } from './logger';
1
+ export { Logger } from './logger';
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var logger_logger = require('./logger.js');
6
+
7
+
8
+
9
+ exports.Logger = logger_logger.Logger;
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
@@ -0,0 +1,9 @@
1
+ export declare class Logger {
2
+ static pretty: boolean;
3
+ static warn: (msg: any) => void;
4
+ static error: (msg: any) => void;
5
+ static criticalError: (msg: any) => void;
6
+ static success: (msg: any) => void;
7
+ static log: (msg: any) => void;
8
+ private static prepocessMsg;
9
+ }
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ class Logger {
6
+ static prepocessMsg(msg) {
7
+ if (typeof (msg) === 'object') {
8
+ return JSON.stringify(msg, undefined, Logger.pretty ? 2 : undefined);
9
+ }
10
+ return msg;
11
+ }
12
+ }
13
+ Logger.pretty = true;
14
+ Logger.warn = (msg) => {
15
+ console.error(`\x1b[33m${Logger.prepocessMsg(msg)}\x1b[0m`);
16
+ };
17
+ Logger.error = (msg) => {
18
+ console.error(`\x1b[31m${Logger.prepocessMsg(msg)}\x1b[0m`);
19
+ };
20
+ Logger.criticalError = (msg) => {
21
+ console.error(`\x1b[41m${Logger.prepocessMsg(msg)}\x1b[0m`);
22
+ };
23
+ Logger.success = (msg) => {
24
+ console.log(`\x1b[32m${Logger.prepocessMsg(msg)}\x1b[0m`);
25
+ };
26
+ Logger.log = (msg) => {
27
+ console.log(`${Logger.prepocessMsg(msg)}`);
28
+ };
29
+
30
+ exports.Logger = Logger;
31
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "case-editor-tools",
3
3
  "description": "Javascript tools to simplify survey and study coding for CASE.",
4
- "version": "1.0.0-beta.16",
4
+ "version": "1.0.0-beta.17",
5
5
  "main": "index.js",
6
6
  "license": "Apache-2.0",
7
7
  "repository": "github:case-framework/case-editor-tools",
@@ -1,3 +1,3 @@
1
- export { SurveyItems } from './survey-items';
2
- export { SingleChoiceOptionTypes, MultipleChoiceOptionTypes, ClozeItemTypes } from './utils/optionDefGenerators';
3
- export { SurveyEngine } from './survey-engine-expressions';
1
+ export { SurveyItems } from './survey-items';
2
+ export { SingleChoiceOptionTypes, MultipleChoiceOptionTypes, ClozeItemTypes } from './utils/optionDefGenerators';
3
+ export { SurveyEngine } from './survey-engine-expressions';
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var surveys_surveyItems = require('./survey-items.js');
6
+ var surveys_utils_optionDefGenerators = require('./utils/optionDefGenerators.js');
7
+ var surveys_surveyEngineExpressions = require('./survey-engine-expressions.js');
8
+ require('./survey-editor/component-editor.js');
9
+ require('../item-editor-7f825952.js');
10
+ require('./utils/randomKeyGenerator.js');
11
+ require('../logger/logger.js');
12
+ require('./utils/componentGenerators.js');
13
+ require('./utils/simple-generators.js');
14
+ require('../types/duration.js');
15
+ require('../constants/key-definitions.js');
16
+ require('./utils/simple-question-editor.js');
17
+ require('../expression-utils/expressionGen.js');
18
+
19
+
20
+
21
+ exports.SurveyItems = surveys_surveyItems.SurveyItems;
22
+ exports.ClozeItemTypes = surveys_utils_optionDefGenerators.ClozeItemTypes;
23
+ exports.MultipleChoiceOptionTypes = surveys_utils_optionDefGenerators.MultipleChoiceOptionTypes;
24
+ exports.SingleChoiceOptionTypes = surveys_utils_optionDefGenerators.SingleChoiceOptionTypes;
25
+ exports.SurveyEngine = surveys_surveyEngineExpressions.SurveyEngine;
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}