case-editor-tools 1.5.1 → 1.6.1
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/expression-utils/studyEngineExpressions.d.ts +8 -6
- package/expression-utils/studyEngineExpressions.js +7 -4
- package/expression-utils/studyEngineExpressions.js.map +1 -1
- package/package.json +1 -1
- package/surveys/utils/optionDefGenerators.d.ts +4 -0
- package/surveys/utils/optionDefGenerators.js +1 -1
- package/types/studyRules.d.ts +1 -0
- package/types/studyRules.js +3 -0
- package/types/studyRules.js.map +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Expression } from "survey-engine/data_types";
|
|
2
2
|
import { Duration } from "../types/duration";
|
|
3
3
|
export declare const NativeStudyEngineExpressions: {
|
|
4
|
-
checkEventType: (equalsType: 'ENTER' | 'SUBMIT' | 'TIMER' | 'MERGE') => Expression;
|
|
4
|
+
checkEventType: (equalsType: 'ENTER' | 'SUBMIT' | 'TIMER' | 'MERGE' | 'LEAVE') => Expression;
|
|
5
5
|
checkSurveyResponseKey: (surveyKey: string) => Expression;
|
|
6
6
|
responseHasKeysAny: (itemKey: string, responseSlotKey: string, ...optionKeys: string[]) => Expression;
|
|
7
7
|
responseHasOnlyKeysOtherThan: (itemKey: string, responseSlotKey: string, ...optionKeys: string[]) => Expression;
|
|
@@ -49,7 +49,8 @@ export declare const NativeStudyEngineExpressions: {
|
|
|
49
49
|
not: (arg: Expression) => Expression;
|
|
50
50
|
timestampWithOffset: (delta: Duration, reference?: number | Expression) => Expression;
|
|
51
51
|
parseValueAsNum: (valueRef: Expression | string | number) => Expression;
|
|
52
|
-
|
|
52
|
+
generateRandomNumber: (min: number, max: number) => Expression;
|
|
53
|
+
externalEventEval: (serviceName: string, route?: string, expectFloat?: boolean) => Expression;
|
|
53
54
|
};
|
|
54
55
|
export declare const StudyEngineActions: {
|
|
55
56
|
if: (condition: Expression, actionIfTrue: Expression, actionIfFalse?: Expression) => Expression;
|
|
@@ -83,7 +84,7 @@ export declare const StudyEngineActions: {
|
|
|
83
84
|
removeByKey: (key: string) => Expression;
|
|
84
85
|
removeAll: () => Expression;
|
|
85
86
|
};
|
|
86
|
-
externalEventHandler: (serviceName: string) => Expression;
|
|
87
|
+
externalEventHandler: (serviceName: string, route?: string) => Expression;
|
|
87
88
|
stopParticipation: () => Expression;
|
|
88
89
|
finishParticipation: () => Expression;
|
|
89
90
|
};
|
|
@@ -149,12 +150,12 @@ export declare const StudyEngine: {
|
|
|
149
150
|
removeByKey: (key: string) => Expression;
|
|
150
151
|
removeAll: () => Expression;
|
|
151
152
|
};
|
|
152
|
-
externalEventHandler: (serviceName: string) => Expression;
|
|
153
|
+
externalEventHandler: (serviceName: string, route?: string) => Expression;
|
|
153
154
|
stopParticipation: () => Expression;
|
|
154
155
|
finishParticipation: () => Expression;
|
|
155
156
|
};
|
|
156
157
|
notifyResearcher: (messageType: string, ...payload: Expression[] | string[]) => Expression;
|
|
157
|
-
checkEventType: (equalsType: 'ENTER' | 'SUBMIT' | 'TIMER' | 'MERGE') => Expression;
|
|
158
|
+
checkEventType: (equalsType: 'ENTER' | 'SUBMIT' | 'TIMER' | 'MERGE' | 'LEAVE') => Expression;
|
|
158
159
|
checkSurveyResponseKey: (surveyKey: string) => Expression;
|
|
159
160
|
responseHasKeysAny: (itemKey: string, responseSlotKey: string, ...optionKeys: string[]) => Expression;
|
|
160
161
|
responseHasOnlyKeysOtherThan: (itemKey: string, responseSlotKey: string, ...optionKeys: string[]) => Expression;
|
|
@@ -202,5 +203,6 @@ export declare const StudyEngine: {
|
|
|
202
203
|
not: (arg: Expression) => Expression;
|
|
203
204
|
timestampWithOffset: (delta: Duration, reference?: number | Expression) => Expression;
|
|
204
205
|
parseValueAsNum: (valueRef: Expression | string | number) => Expression;
|
|
205
|
-
|
|
206
|
+
generateRandomNumber: (min: number, max: number) => Expression;
|
|
207
|
+
externalEventEval: (serviceName: string, route?: string, expectFloat?: boolean) => Expression;
|
|
206
208
|
};
|
|
@@ -13,7 +13,7 @@ const and = (...args) => expressionUtils_expressionGen.generateExpression('and',
|
|
|
13
13
|
const not = (arg) => expressionUtils_expressionGen.generateExpression('not', undefined, arg);
|
|
14
14
|
/**
|
|
15
15
|
* Check if the current event has the given type
|
|
16
|
-
* @param equalsType string with the possible values: 'ENTER', 'SUBMIT', 'TIMER', 'MERGE'
|
|
16
|
+
* @param equalsType string with the possible values: 'ENTER', 'SUBMIT', 'TIMER', 'MERGE', 'LEAVE'
|
|
17
17
|
* @returns if event type matches the argument, return true otherwise false
|
|
18
18
|
*/
|
|
19
19
|
const checkEventType = (equalsType) => expressionUtils_expressionGen.generateExpression('checkEventType', undefined, equalsType);
|
|
@@ -189,10 +189,11 @@ const parseValueAsNum = (valueRef) => {
|
|
|
189
189
|
/**
|
|
190
190
|
*
|
|
191
191
|
* @param serviceName name of the external service endpoint that should be used (URL and API key are config of the service)
|
|
192
|
+
* @param route optional route to be appended to the service URL
|
|
192
193
|
* @param expectFloat optional flag if the response value is expected to be a float (number) - by default, string is expected
|
|
193
194
|
* @returns
|
|
194
195
|
*/
|
|
195
|
-
const externalEventEval = (serviceName, expectFloat) => expressionUtils_expressionGen.generateExpression('externalEventEval', expectFloat ? 'float' : undefined, serviceName);
|
|
196
|
+
const externalEventEval = (serviceName, route, expectFloat) => expressionUtils_expressionGen.generateExpression('externalEventEval', expectFloat ? 'float' : undefined, serviceName, route);
|
|
196
197
|
/**
|
|
197
198
|
* Control flow method to use an if-else like structure
|
|
198
199
|
* @param condition expression, return value interpreted as boolean
|
|
@@ -330,10 +331,11 @@ const setReportSummary = (reportKey, content, asTranslationKey) => {
|
|
|
330
331
|
/**
|
|
331
332
|
* Method to call external event handler
|
|
332
333
|
* @param serviceName name of the external service endpoint that should be used (URL and API key are config of the service)
|
|
334
|
+
* @param route optional route to be appended to the service URL
|
|
333
335
|
* @returns
|
|
334
336
|
*/
|
|
335
|
-
const EXTERNAL_EVENT_HANDLER = (serviceName) => {
|
|
336
|
-
return expressionUtils_expressionGen.generateExpression('EXTERNAL_EVENT_HANDLER', undefined, serviceName);
|
|
337
|
+
const EXTERNAL_EVENT_HANDLER = (serviceName, route) => {
|
|
338
|
+
return expressionUtils_expressionGen.generateExpression('EXTERNAL_EVENT_HANDLER', undefined, serviceName, route);
|
|
337
339
|
};
|
|
338
340
|
// ##################
|
|
339
341
|
// Prefill rule methods:
|
|
@@ -449,6 +451,7 @@ const NativeStudyEngineExpressions = {
|
|
|
449
451
|
// Other
|
|
450
452
|
timestampWithOffset,
|
|
451
453
|
parseValueAsNum,
|
|
454
|
+
generateRandomNumber: (min, max) => expressionUtils_expressionGen.generateExpression('generateRandomNumber', undefined, min, max),
|
|
452
455
|
externalEventEval,
|
|
453
456
|
};
|
|
454
457
|
const StudyEngineActions = {
|
|
@@ -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,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.
|
|
4
|
+
"version": "1.6.1",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": "github:case-framework/case-editor-tools",
|
|
@@ -20,6 +20,10 @@ export declare const SingleChoiceOptionTypes: {
|
|
|
20
20
|
displayCondition?: Expression;
|
|
21
21
|
alignText?: 'start' | 'center' | 'end';
|
|
22
22
|
}) => OptionDef;
|
|
23
|
+
dateInput: (props: DateInputProps & {
|
|
24
|
+
key: string;
|
|
25
|
+
displayCondition?: Expression;
|
|
26
|
+
}) => OptionDef;
|
|
23
27
|
timeInput: (props: TimeInputProps & {
|
|
24
28
|
key: string;
|
|
25
29
|
displayCondition?: Expression;
|
package/types/studyRules.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare class StudyRules {
|
|
|
4
4
|
private submitRules?;
|
|
5
5
|
private timerRules?;
|
|
6
6
|
private mergeRules?;
|
|
7
|
+
private leaveRules?;
|
|
7
8
|
constructor(enterRules?: Expression[], submitRules?: Expression[], timerRules?: Expression[], mergeRules?: Expression[]);
|
|
8
9
|
get(): Expression[];
|
|
9
10
|
}
|
package/types/studyRules.js
CHANGED
|
@@ -30,6 +30,9 @@ class StudyRules {
|
|
|
30
30
|
if (this.mergeRules) {
|
|
31
31
|
rules.push(expressionUtils_studyEngineExpressions.StudyEngine.ifThen(expressionUtils_studyEngineExpressions.StudyEngine.checkEventType('MERGE'), ...this.mergeRules));
|
|
32
32
|
}
|
|
33
|
+
if (this.leaveRules) {
|
|
34
|
+
rules.push(expressionUtils_studyEngineExpressions.StudyEngine.ifThen(expressionUtils_studyEngineExpressions.StudyEngine.checkEventType('LEAVE'), ...this.leaveRules));
|
|
35
|
+
}
|
|
33
36
|
return rules;
|
|
34
37
|
}
|
|
35
38
|
}
|
package/types/studyRules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"studyRules.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"studyRules.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|