case-editor-tools 1.0.0-beta.25 → 1.0.0-beta.29

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.
@@ -7,6 +7,8 @@ export declare const NativeStudyEngineExpressions: {
7
7
  responseHasOnlyKeysOtherThan: (itemKey: string, responseSlotKey: string, ...optionKeys: string[]) => Expression;
8
8
  getResponseValueAsNum: (itemKey: string, responseKey: string) => Expression;
9
9
  getResponseValueAsStr: (itemKey: string, responseKey: string) => Expression;
10
+ hasResponseKey: (itemKey: string, responseKey: string) => Expression;
11
+ hasResponseKeyWithValue: (itemKey: string, responseKey: string, value: string) => Expression;
10
12
  countResponseItems: (itemKey: string, responseKey: string) => Expression;
11
13
  checkConditionForOldResponses: (condition: Expression, checkType?: number | "all" | "any" | undefined, surveyKey?: string | undefined, querySince?: number | Expression | undefined, queryUntil?: number | Expression | undefined) => Expression;
12
14
  participantState: {
@@ -15,7 +17,8 @@ export declare const NativeStudyEngineExpressions: {
15
17
  getSurveyKeyAssignedFrom: (surveyKey: string) => Expression;
16
18
  getSurveyKeyAssignedUntil: (surveyKey: string) => Expression;
17
19
  hasStudyStatus: (status: string) => Expression;
18
- hasParticipantFlag: (key: string, value: string) => Expression;
20
+ hasParticipantFlagKeyAndValue: (key: string, value: string) => Expression;
21
+ hasParticipantFlagKey: (key: string) => Expression;
19
22
  lastSubmissionDateOlderThan: (reference: number | Expression, surveyKey?: string | undefined) => Expression;
20
23
  hasMessageTypeAssigned: (messageType: string) => Expression;
21
24
  getMessageNextTime: (messageType: string) => Expression;
@@ -36,7 +39,7 @@ export declare const StudyEngineActions: {
36
39
  ifThen: (condition: Expression, ...args: Expression[]) => Expression;
37
40
  participantActions: {
38
41
  updateStudyStatus: (status: string) => Expression;
39
- updateFlag: (key: string, newValue: string) => Expression;
42
+ updateFlag: (key: string, newValue: string | number | Expression) => Expression;
40
43
  removeFlag: (key: string) => Expression;
41
44
  assignedSurveys: {
42
45
  add: (surveyKey: string, category: 'immediate' | 'prio' | 'normal' | 'optional', activeFrom?: number | Expression | undefined, activeUntil?: number | Expression | undefined) => Expression;
@@ -87,7 +90,7 @@ export declare const StudyEngine: {
87
90
  ifThen: (condition: Expression, ...args: Expression[]) => Expression;
88
91
  participantActions: {
89
92
  updateStudyStatus: (status: string) => Expression;
90
- updateFlag: (key: string, newValue: string) => Expression;
93
+ updateFlag: (key: string, newValue: string | number | Expression) => Expression;
91
94
  removeFlag: (key: string) => Expression;
92
95
  assignedSurveys: {
93
96
  add: (surveyKey: string, category: 'immediate' | 'prio' | 'normal' | 'optional', activeFrom?: number | Expression | undefined, activeUntil?: number | Expression | undefined) => Expression;
@@ -113,6 +116,8 @@ export declare const StudyEngine: {
113
116
  responseHasOnlyKeysOtherThan: (itemKey: string, responseSlotKey: string, ...optionKeys: string[]) => Expression;
114
117
  getResponseValueAsNum: (itemKey: string, responseKey: string) => Expression;
115
118
  getResponseValueAsStr: (itemKey: string, responseKey: string) => Expression;
119
+ hasResponseKey: (itemKey: string, responseKey: string) => Expression;
120
+ hasResponseKeyWithValue: (itemKey: string, responseKey: string, value: string) => Expression;
116
121
  countResponseItems: (itemKey: string, responseKey: string) => Expression;
117
122
  checkConditionForOldResponses: (condition: Expression, checkType?: number | "all" | "any" | undefined, surveyKey?: string | undefined, querySince?: number | Expression | undefined, queryUntil?: number | Expression | undefined) => Expression;
118
123
  participantState: {
@@ -121,7 +126,8 @@ export declare const StudyEngine: {
121
126
  getSurveyKeyAssignedFrom: (surveyKey: string) => Expression;
122
127
  getSurveyKeyAssignedUntil: (surveyKey: string) => Expression;
123
128
  hasStudyStatus: (status: string) => Expression;
124
- hasParticipantFlag: (key: string, value: string) => Expression;
129
+ hasParticipantFlagKeyAndValue: (key: string, value: string) => Expression;
130
+ hasParticipantFlagKey: (key: string) => Expression;
125
131
  lastSubmissionDateOlderThan: (reference: number | Expression, surveyKey?: string | undefined) => Expression;
126
132
  hasMessageTypeAssigned: (messageType: string) => Expression;
127
133
  getMessageNextTime: (messageType: string) => Expression;
@@ -37,6 +37,25 @@ const responseHasKeysAny = (itemKey, responseSlotKey, ...optionKeys) => expressi
37
37
  * @returns true if a response key is present, but is not in the list defined by optionKeys. If item or the response group is not found, returns false.
38
38
  */
39
39
  const responseHasOnlyKeysOtherThan = (itemKey, responseSlotKey, ...optionKeys) => expressionUtils_expressionGen.generateExpression('responseHasOnlyKeysOtherThan', undefined, itemKey, responseSlotKey, ...optionKeys);
40
+ /**
41
+ *
42
+ * @param itemKey full key to the survey item, in the form, e.g., <surveyKey>.<groupKey>.<itemKey>
43
+ * @param responseKey full key to the response that should exists
44
+ * @returns if item contains responseKey return true
45
+ */
46
+ const hasResponseKey = (itemKey, responseKey) => {
47
+ return expressionUtils_expressionGen.generateExpression('hasResponseKey', undefined, itemKey, responseKey);
48
+ };
49
+ /**
50
+ *
51
+ * @param itemKey full key to the survey item, in the form, e.g., <surveyKey>.<groupKey>.<itemKey>
52
+ * @param responseKey full key to the response that should exists
53
+ * @param value the response object with the above key should have this value
54
+ * @returns if the response object exists and has the value return true
55
+ */
56
+ const hasResponseKeyWithValue = (itemKey, responseKey, value) => {
57
+ return expressionUtils_expressionGen.generateExpression('hasResponseKeyWithValue', undefined, itemKey, responseKey, value);
58
+ };
40
59
  const getResponseValueAsNum = (itemKey, responseKey) => {
41
60
  return expressionUtils_expressionGen.generateExpression('getResponseValueAsNum', 'float', itemKey, responseKey);
42
61
  };
@@ -86,12 +105,18 @@ const getSurveyKeyAssignedUntil = (surveyKey) => expressionUtils_expressionGen.g
86
105
  */
87
106
  const hasStudyStatus = (status) => expressionUtils_expressionGen.generateExpression('getSurveyKeyAssignedUntil', undefined, status);
88
107
  /**
89
- * Check if a participant flag is present
108
+ * Check if a participant flag with specific value is present
90
109
  * @param key look up this flag
91
110
  * @param value and for this value
92
111
  * @returns return true if key - value pair (with case sensitive matching for both key and value) is present. If any of the two is different, or participant flags is empty, it returns false.
93
112
  */
94
- const hasParticipantFlag = (key, value) => expressionUtils_expressionGen.generateExpression('hasParticipantFlag', undefined, key, value);
113
+ const hasParticipantFlagKeyAndValue = (key, value) => expressionUtils_expressionGen.generateExpression('hasParticipantFlag', undefined, key, value);
114
+ /**
115
+ * Check if a participant flag is present
116
+ * @param key look up this flag
117
+ * @returns return true if key is present. If any of the two is different, or participant flags is empty, it returns false.
118
+ */
119
+ const hasParticipantFlagKey = (key) => expressionUtils_expressionGen.generateExpression('hasParticipantFlagKey', undefined, key);
95
120
  /**
96
121
  * Checks if the participant has a message type assigned (at least one)
97
122
  * @param messageType
@@ -153,7 +178,7 @@ const UPDATE_STUDY_STATUS = (status) => expressionUtils_expressionGen.generateEx
153
178
  /**
154
179
  * Add or update a participant flag
155
180
  * @param key
156
- * @param newValue
181
+ * @param newValue: string, number or expression where result should be written in the flag's value
157
182
  * @returns
158
183
  */
159
184
  const UPDATE_FLAG = (key, newValue) => expressionUtils_expressionGen.generateExpression('UPDATE_FLAG', undefined, key, newValue);
@@ -262,6 +287,8 @@ const NativeStudyEngineExpressions = {
262
287
  responseHasOnlyKeysOtherThan,
263
288
  getResponseValueAsNum,
264
289
  getResponseValueAsStr,
290
+ hasResponseKey,
291
+ hasResponseKeyWithValue,
265
292
  countResponseItems,
266
293
  // Old responses
267
294
  checkConditionForOldResponses,
@@ -272,7 +299,8 @@ const NativeStudyEngineExpressions = {
272
299
  getSurveyKeyAssignedFrom,
273
300
  getSurveyKeyAssignedUntil,
274
301
  hasStudyStatus,
275
- hasParticipantFlag,
302
+ hasParticipantFlagKeyAndValue,
303
+ hasParticipantFlagKey,
276
304
  lastSubmissionDateOlderThan,
277
305
  hasMessageTypeAssigned,
278
306
  getMessageNextTime,
@@ -1 +1 @@
1
- {"version":3,"file":"studyEngineExpressions.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"studyEngineExpressions.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,13 +1,13 @@
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.25",
4
+ "version": "1.0.0-beta.29",
5
5
  "main": "index.js",
6
6
  "license": "Apache-2.0",
7
7
  "repository": "github:case-framework/case-editor-tools",
8
8
  "devDependencies": {
9
9
  "@rollup/plugin-commonjs": "^21.0.1",
10
- "@rollup/plugin-node-resolve": "^13.1.1",
10
+ "@rollup/plugin-node-resolve": "^13.1.3",
11
11
  "rollup": "^2.61.1",
12
12
  "rollup-plugin-copy": "^3.4.0",
13
13
  "rollup-plugin-delete": "^2.0.0",
@@ -20,6 +20,6 @@
20
20
  "build": "rollup -c"
21
21
  },
22
22
  "dependencies": {
23
- "survey-engine": "^1.0.2"
23
+ "survey-engine": "^1.0.3"
24
24
  }
25
25
  }
@@ -22,6 +22,7 @@ export declare const NativeSurveyEngineExpressions: {
22
22
  isDefined: (arg: Expression) => Expression;
23
23
  hasResponse: (itemKey: string, responseKey: string) => Expression;
24
24
  getResponseItem: (itemKey: string, responseKey: string) => Expression;
25
+ parseValueAsNum: (valueRef: Expression) => Expression;
25
26
  getResponseValueAsNum: (itemKey: string, responseKey: string) => Expression;
26
27
  getResponseValueAsStr: (itemKey: string, responseKey: string) => Expression;
27
28
  checkResponseValueWithRegex: (itemKey: string, responseKey: string, regexPattern: string) => Expression;
@@ -72,7 +73,11 @@ export declare const SurveyEngine: {
72
73
  datePicker: {
73
74
  get: (itemKey: string) => Expression;
74
75
  };
75
- hasParticipantFlag: (key: string, value: string) => Expression;
76
+ participantFlags: {
77
+ hasKey: (key: string) => Expression;
78
+ hasKeyAndValue: (key: string, value: string) => Expression;
79
+ getAsNum: (key: string) => Expression;
80
+ };
76
81
  getters: {
77
82
  getContext: () => Expression;
78
83
  getResponses: () => Expression;
@@ -94,6 +99,7 @@ export declare const SurveyEngine: {
94
99
  isDefined: (arg: Expression) => Expression;
95
100
  hasResponse: (itemKey: string, responseKey: string) => Expression;
96
101
  getResponseItem: (itemKey: string, responseKey: string) => Expression;
102
+ parseValueAsNum: (valueRef: Expression) => Expression;
97
103
  getResponseValueAsNum: (itemKey: string, responseKey: string) => Expression;
98
104
  getResponseValueAsStr: (itemKey: string, responseKey: string) => Expression;
99
105
  checkResponseValueWithRegex: (itemKey: string, responseKey: string, regexPattern: string) => Expression;
@@ -61,6 +61,14 @@ const gte = (val1, val2) => expressionUtils_expressionGen.generateExpression('gt
61
61
  * @returns
62
62
  */
63
63
  const timestampWithOffset = (delta, reference) => expressionUtils_expressionGen.generateExpression('timestampWithOffset', undefined, types_duration.durationObjectToSeconds(delta), reference ? reference : undefined);
64
+ /**
65
+ * Parse the result of an expression as a number
66
+ * @param valueRef expression that returns a string with the value that should be parsed
67
+ * @returns expression that returns the value or undefined
68
+ */
69
+ const parseValueAsNum = (valueRef) => {
70
+ return expressionUtils_expressionGen.generateExpression('parseValueAsNum', 'float', valueRef);
71
+ };
64
72
  /**
65
73
  * Extract value from a response if exits parsed as a number
66
74
  * @param itemKey full key of the survey item (e.g. SURVEY.GROUP.QUESTIONKEY)
@@ -286,13 +294,29 @@ const getSurveyItemValidation = (itemKey, validationKey) => {
286
294
  const dateResponseDiffFromNow = (itemKey, responseKey, unit, ignoreSign) => {
287
295
  return expressionUtils_expressionGen.generateExpression('dateResponseDiffFromNow', undefined, itemKey, responseKey, unit, ignoreSign ? 1 : undefined);
288
296
  };
297
+ /**
298
+ * Check participant flags object if contains the specified key value pair
299
+ * @param key retrieve participant flag's value for this key
300
+ * @returns
301
+ */
302
+ const parseParticipantFlagAsNum = (key) => {
303
+ return parseValueAsNum(getAttribute(getAttribute(getContext(), 'participantFlags'), key));
304
+ };
305
+ /**
306
+ * Check participant flags object if contains the specified key value pair
307
+ * @param key retrieve participant flag's value for this key
308
+ * @returns
309
+ */
310
+ const hasParticipantFlagKey = (key) => {
311
+ return isDefined(getAttribute(getAttribute(getContext(), 'participantFlags'), key));
312
+ };
289
313
  /**
290
314
  * Check participant flags object if contains the specified key value pair
291
315
  * @param key retrieve participant flag's value for this key
292
316
  * @param value string value to be checked for a match
293
317
  * @returns
294
318
  */
295
- const hasParticipantFlag = (key, value) => {
319
+ const hasParticipantFlagKeyAndValue = (key, value) => {
296
320
  return eq(getAttribute(getAttribute(getContext(), 'participantFlags'), key), value);
297
321
  };
298
322
  /**
@@ -355,6 +379,7 @@ const NativeSurveyEngineExpressions = {
355
379
  isDefined,
356
380
  hasResponse,
357
381
  getResponseItem,
382
+ parseValueAsNum,
358
383
  getResponseValueAsNum,
359
384
  getResponseValueAsStr,
360
385
  checkResponseValueWithRegex,
@@ -400,7 +425,11 @@ const SurveyEngine = Object.assign(Object.assign({}, NativeSurveyEngineExpressio
400
425
  regexCheck: multilineTextInputRegexCheck,
401
426
  }, datePicker: {
402
427
  get: getDatePickerResponseValue,
403
- }, hasParticipantFlag });
428
+ }, participantFlags: {
429
+ hasKey: hasParticipantFlagKey,
430
+ hasKeyAndValue: hasParticipantFlagKeyAndValue,
431
+ getAsNum: parseParticipantFlagAsNum,
432
+ } });
404
433
 
405
434
  exports.NativeSurveyEngineExpressions = NativeSurveyEngineExpressions;
406
435
  exports.SurveyEngine = SurveyEngine;
@@ -1 +1 @@
1
- {"version":3,"file":"survey-engine-expressions.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"survey-engine-expressions.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -16,7 +16,8 @@ export declare abstract class SurveyDefinition {
16
16
  abstract buildSurvey(): void;
17
17
  getSurvey(): import("survey-engine/data_types").Survey;
18
18
  getSurveyJSON(pretty?: boolean): string;
19
- addItem(item: SurveyItem): void;
19
+ addItem(item: SurveyItem, pageBreakAfter?: boolean): void;
20
+ addPageBreak(): void;
20
21
  addSurveyItemToPath(item: SurveyItem, parentKey: string): void;
21
22
  private checkDuplicateChildKeys;
22
23
  }
@@ -34,8 +34,14 @@ class SurveyDefinition {
34
34
  this.checkDuplicateChildKeys();
35
35
  return this.editor.getSurveyJSON(pretty);
36
36
  }
37
- addItem(item) {
37
+ addItem(item, pageBreakAfter) {
38
38
  this.editor.addExistingSurveyItem(item, this.key);
39
+ if (pageBreakAfter) {
40
+ this.addPageBreak();
41
+ }
42
+ }
43
+ addPageBreak() {
44
+ this.editor.addExistingSurveyItem(surveys_utils_simpleGenerators.generatePageBreak(this.key), this.key);
39
45
  }
40
46
  addSurveyItemToPath(item, parentKey) {
41
47
  this.editor.addExistingSurveyItem(item, parentKey);
@@ -1 +1 @@
1
- {"version":3,"file":"survey-definition.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"survey-definition.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}