case-editor-tools 1.5.0 → 1.6.0

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.
@@ -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;
@@ -21,7 +21,7 @@ export declare const NativeStudyEngineExpressions: {
21
21
  hasParticipantFlagKeyAndValue: (key: string, value: string) => Expression;
22
22
  hasParticipantFlagKey: (key: string) => Expression;
23
23
  getParticipantFlagValue: (key: string) => Expression;
24
- getParticipantFlagAsNum: (key: string) => Expression;
24
+ getParticipantFlagValueAsNum: (key: string) => Expression;
25
25
  lastSubmissionDateOlderThan: (reference: number | Expression, surveyKey?: string) => Expression;
26
26
  hasMessageTypeAssigned: (messageType: string) => Expression;
27
27
  getMessageNextTime: (messageType: string) => Expression;
@@ -49,7 +49,7 @@ 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
- externalEventEval: (serviceName: string, expectFloat?: boolean) => Expression;
52
+ externalEventEval: (serviceName: string, route?: string, expectFloat?: boolean) => Expression;
53
53
  };
54
54
  export declare const StudyEngineActions: {
55
55
  if: (condition: Expression, actionIfTrue: Expression, actionIfFalse?: Expression) => Expression;
@@ -83,7 +83,7 @@ export declare const StudyEngineActions: {
83
83
  removeByKey: (key: string) => Expression;
84
84
  removeAll: () => Expression;
85
85
  };
86
- externalEventHandler: (serviceName: string) => Expression;
86
+ externalEventHandler: (serviceName: string, route?: string) => Expression;
87
87
  stopParticipation: () => Expression;
88
88
  finishParticipation: () => Expression;
89
89
  };
@@ -149,12 +149,12 @@ export declare const StudyEngine: {
149
149
  removeByKey: (key: string) => Expression;
150
150
  removeAll: () => Expression;
151
151
  };
152
- externalEventHandler: (serviceName: string) => Expression;
152
+ externalEventHandler: (serviceName: string, route?: string) => Expression;
153
153
  stopParticipation: () => Expression;
154
154
  finishParticipation: () => Expression;
155
155
  };
156
156
  notifyResearcher: (messageType: string, ...payload: Expression[] | string[]) => Expression;
157
- checkEventType: (equalsType: 'ENTER' | 'SUBMIT' | 'TIMER' | 'MERGE') => Expression;
157
+ checkEventType: (equalsType: 'ENTER' | 'SUBMIT' | 'TIMER' | 'MERGE' | 'LEAVE') => Expression;
158
158
  checkSurveyResponseKey: (surveyKey: string) => Expression;
159
159
  responseHasKeysAny: (itemKey: string, responseSlotKey: string, ...optionKeys: string[]) => Expression;
160
160
  responseHasOnlyKeysOtherThan: (itemKey: string, responseSlotKey: string, ...optionKeys: string[]) => Expression;
@@ -174,7 +174,7 @@ export declare const StudyEngine: {
174
174
  hasParticipantFlagKeyAndValue: (key: string, value: string) => Expression;
175
175
  hasParticipantFlagKey: (key: string) => Expression;
176
176
  getParticipantFlagValue: (key: string) => Expression;
177
- getParticipantFlagAsNum: (key: string) => Expression;
177
+ getParticipantFlagValueAsNum: (key: string) => Expression;
178
178
  lastSubmissionDateOlderThan: (reference: number | Expression, surveyKey?: string) => Expression;
179
179
  hasMessageTypeAssigned: (messageType: string) => Expression;
180
180
  getMessageNextTime: (messageType: string) => Expression;
@@ -202,5 +202,5 @@ export declare const StudyEngine: {
202
202
  not: (arg: Expression) => Expression;
203
203
  timestampWithOffset: (delta: Duration, reference?: number | Expression) => Expression;
204
204
  parseValueAsNum: (valueRef: Expression | string | number) => Expression;
205
- externalEventEval: (serviceName: string, expectFloat?: boolean) => Expression;
205
+ externalEventEval: (serviceName: string, route?: string, expectFloat?: boolean) => Expression;
206
206
  };
@@ -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);
@@ -143,7 +143,7 @@ const hasParticipantFlagKeyForIncoming = (key) => expressionUtils_expressionGen.
143
143
  const getParticipantFlagValue = (key) => expressionUtils_expressionGen.generateExpression('getParticipantFlagValue', undefined, key);
144
144
  const getParticipantFlagValueForIncoming = (key) => expressionUtils_expressionGen.generateExpression('incomingState:getParticipantFlagValue', undefined, key);
145
145
  // Convinience method to parse participant flag's value as a number
146
- const getParticipantFlagAsNum = (key) => parseValueAsNum(getParticipantFlagValue(key));
146
+ const getParticipantFlagValueAsNum = (key) => parseValueAsNum(getParticipantFlagValue(key));
147
147
  /**
148
148
  * Checks if the participant has a message type assigned (at least one)
149
149
  * @param messageType
@@ -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:
@@ -418,7 +420,7 @@ const NativeStudyEngineExpressions = {
418
420
  hasParticipantFlagKeyAndValue,
419
421
  hasParticipantFlagKey,
420
422
  getParticipantFlagValue,
421
- getParticipantFlagAsNum,
423
+ getParticipantFlagValueAsNum,
422
424
  lastSubmissionDateOlderThan,
423
425
  hasMessageTypeAssigned,
424
426
  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,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.5.0",
4
+ "version": "1.6.0",
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;
@@ -191,7 +191,7 @@ const clozeLineBreak = () => {
191
191
  const SingleChoiceOptionTypes = {
192
192
  option,
193
193
  textInput,
194
- //dateInput,
194
+ dateInput,
195
195
  timeInput,
196
196
  numberInput,
197
197
  cloze,
@@ -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
  }
@@ -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
  }
@@ -1 +1 @@
1
- {"version":3,"file":"studyRules.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"studyRules.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}