case-editor-tools 1.0.0-beta.31 → 1.0.0-beta.32

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') => Expression;
4
+ checkEventType: (equalsType: 'ENTER' | 'SUBMIT' | 'TIMER' | 'MERGE') => 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;
@@ -22,6 +22,18 @@ export declare const NativeStudyEngineExpressions: {
22
22
  lastSubmissionDateOlderThan: (reference: number | Expression, surveyKey?: string | undefined) => Expression;
23
23
  hasMessageTypeAssigned: (messageType: string) => Expression;
24
24
  getMessageNextTime: (messageType: string) => Expression;
25
+ incomingParticipantState: {
26
+ getStudyEntryTime: () => Expression;
27
+ hasSurveyKeyAssigned: (surveyKey: string) => Expression;
28
+ getSurveyKeyAssignedFrom: (surveyKey: string) => Expression;
29
+ getSurveyKeyAssignedUntil: (surveyKey: string) => Expression;
30
+ hasStudyStatus: (status: string) => Expression;
31
+ hasParticipantFlagKeyAndValue: (key: string, value: string) => Expression;
32
+ hasParticipantFlagKey: (key: string) => Expression;
33
+ lastSubmissionDateOlderThan: (reference: number | Expression, surveyKey?: string | undefined) => Expression;
34
+ hasMessageTypeAssigned: (messageType: string) => Expression;
35
+ getMessageNextTime: (messageType: string) => Expression;
36
+ };
25
37
  };
26
38
  eq: (val1: Expression | string | number, val2: Expression | string | number) => Expression;
27
39
  lt: (val1: Expression | string | number, val2: Expression | string | number) => Expression;
@@ -47,9 +59,13 @@ export declare const StudyEngineActions: {
47
59
  remove: (surveyKey: string, selector: 'first' | 'last' | 'all') => Expression;
48
60
  };
49
61
  reports: {
50
- add: (itemKey: string) => Expression;
51
- removeAll: () => Expression;
52
- remove: (surveyKey: string, selector: 'first' | 'last' | 'all') => Expression;
62
+ init: (reportKey: string) => Expression;
63
+ cancel: (reportKey: string) => Expression;
64
+ updateData: (reportKey: string, attributeKey: string, value: number | string | Expression, dtype?: "string" | "date" | "float" | "int" | "rawMessage" | undefined) => Expression;
65
+ removeData: (reportKey: string, attributeKey: string) => Expression;
66
+ setReportIcon: (reportKey: string, icon: string) => Expression;
67
+ setReportMessage: (reportKey: string, content: string, asTranslationKey?: boolean | undefined) => Expression;
68
+ setReportSummary: (reportKey: string, content: string, asTranslationKey?: boolean | undefined) => Expression;
53
69
  };
54
70
  messages: {
55
71
  add: (messageType: string, scheduledFor: number | Expression) => Expression;
@@ -98,9 +114,13 @@ export declare const StudyEngine: {
98
114
  remove: (surveyKey: string, selector: 'first' | 'last' | 'all') => Expression;
99
115
  };
100
116
  reports: {
101
- add: (itemKey: string) => Expression;
102
- removeAll: () => Expression;
103
- remove: (surveyKey: string, selector: 'first' | 'last' | 'all') => Expression;
117
+ init: (reportKey: string) => Expression;
118
+ cancel: (reportKey: string) => Expression;
119
+ updateData: (reportKey: string, attributeKey: string, value: number | string | Expression, dtype?: "string" | "date" | "float" | "int" | "rawMessage" | undefined) => Expression;
120
+ removeData: (reportKey: string, attributeKey: string) => Expression;
121
+ setReportIcon: (reportKey: string, icon: string) => Expression;
122
+ setReportMessage: (reportKey: string, content: string, asTranslationKey?: boolean | undefined) => Expression;
123
+ setReportSummary: (reportKey: string, content: string, asTranslationKey?: boolean | undefined) => Expression;
104
124
  };
105
125
  messages: {
106
126
  add: (messageType: string, scheduledFor: number | Expression) => Expression;
@@ -110,7 +130,7 @@ export declare const StudyEngine: {
110
130
  stopParticipation: () => Expression;
111
131
  finishParticipation: () => Expression;
112
132
  };
113
- checkEventType: (equalsType: 'ENTER' | 'SUBMIT' | 'TIMER') => Expression;
133
+ checkEventType: (equalsType: 'ENTER' | 'SUBMIT' | 'TIMER' | 'MERGE') => Expression;
114
134
  checkSurveyResponseKey: (surveyKey: string) => Expression;
115
135
  responseHasKeysAny: (itemKey: string, responseSlotKey: string, ...optionKeys: string[]) => Expression;
116
136
  responseHasOnlyKeysOtherThan: (itemKey: string, responseSlotKey: string, ...optionKeys: string[]) => Expression;
@@ -131,6 +151,18 @@ export declare const StudyEngine: {
131
151
  lastSubmissionDateOlderThan: (reference: number | Expression, surveyKey?: string | undefined) => Expression;
132
152
  hasMessageTypeAssigned: (messageType: string) => Expression;
133
153
  getMessageNextTime: (messageType: string) => Expression;
154
+ incomingParticipantState: {
155
+ getStudyEntryTime: () => Expression;
156
+ hasSurveyKeyAssigned: (surveyKey: string) => Expression;
157
+ getSurveyKeyAssignedFrom: (surveyKey: string) => Expression;
158
+ getSurveyKeyAssignedUntil: (surveyKey: string) => Expression;
159
+ hasStudyStatus: (status: string) => Expression;
160
+ hasParticipantFlagKeyAndValue: (key: string, value: string) => Expression;
161
+ hasParticipantFlagKey: (key: string) => Expression;
162
+ lastSubmissionDateOlderThan: (reference: number | Expression, surveyKey?: string | undefined) => Expression;
163
+ hasMessageTypeAssigned: (messageType: string) => Expression;
164
+ getMessageNextTime: (messageType: string) => Expression;
165
+ };
134
166
  };
135
167
  eq: (val1: Expression | string | number, val2: Expression | string | number) => Expression;
136
168
  lt: (val1: Expression | string | number, val2: Expression | string | number) => Expression;
@@ -11,7 +11,7 @@ const and = (...args) => expressionUtils_expressionGen.generateExpression('and',
11
11
  const not = (arg) => expressionUtils_expressionGen.generateExpression('not', undefined, arg);
12
12
  /**
13
13
  * Check if the current event has the given type
14
- * @param equalsType string with the possible values: 'ENTER', 'SUBMIT', 'TIMER
14
+ * @param equalsType string with the possible values: 'ENTER', 'SUBMIT', 'TIMER', 'MERGE'
15
15
  * @returns if event type matches the argument, return true otherwise false
16
16
  */
17
17
  const checkEventType = (equalsType) => expressionUtils_expressionGen.generateExpression('checkEventType', undefined, equalsType);
@@ -80,30 +80,35 @@ const checkConditionForOldResponses = (condition, checkType, surveyKey, querySin
80
80
  * @returns timestamp
81
81
  */
82
82
  const getStudyEntryTime = () => expressionUtils_expressionGen.generateExpression('getStudyEntryTime');
83
+ const getStudyEntryTimeForIncoming = () => expressionUtils_expressionGen.generateExpression('incomingState:getStudyEntryTime');
83
84
  /**
84
85
  * Determines if a specific survey key is currently assigned to the participant.
85
86
  * @param surveyKey - string - key of the survey to check for.
86
87
  * @returns true if the participant has a survey with this surveyKey assigned, otherwise false.
87
88
  */
88
89
  const hasSurveyKeyAssigned = (surveyKey) => expressionUtils_expressionGen.generateExpression('hasSurveyKeyAssigned', undefined, surveyKey);
90
+ const hasSurveyKeyAssignedForIncoming = (surveyKey) => expressionUtils_expressionGen.generateExpression('incomingState:hasSurveyKeyAssigned', undefined, surveyKey);
89
91
  /**
90
92
  * Method to access the timestamp for a surveyKey is assigned from
91
93
  * @param surveyKey - string - key of the survey to check for.
92
94
  * @returns timestamp
93
95
  */
94
96
  const getSurveyKeyAssignedFrom = (surveyKey) => expressionUtils_expressionGen.generateExpression('getSurveyKeyAssignedFrom', undefined, surveyKey);
97
+ const getSurveyKeyAssignedFromForIncoming = (surveyKey) => expressionUtils_expressionGen.generateExpression('incomingState:getSurveyKeyAssignedFrom', undefined, surveyKey);
95
98
  /**
96
99
  * Method to access the timestamp for a surveyKey is assigned until
97
100
  * @param surveyKey - string - key of the survey to check for.
98
101
  * @returns timestamp
99
102
  */
100
103
  const getSurveyKeyAssignedUntil = (surveyKey) => expressionUtils_expressionGen.generateExpression('getSurveyKeyAssignedUntil', undefined, surveyKey);
104
+ const getSurveyKeyAssignedUntilForIncoming = (surveyKey) => expressionUtils_expressionGen.generateExpression('incomingState:getSurveyKeyAssignedUntil', undefined, surveyKey);
101
105
  /**
102
106
  * Check if a participant has a specific study status
103
107
  * @param status - string
104
108
  * @returns true/false
105
109
  */
106
110
  const hasStudyStatus = (status) => expressionUtils_expressionGen.generateExpression('getSurveyKeyAssignedUntil', undefined, status);
111
+ const hasStudyStatusForIncoming = (status) => expressionUtils_expressionGen.generateExpression('incomingState:getSurveyKeyAssignedUntil', undefined, status);
107
112
  /**
108
113
  * Check if a participant flag with specific value is present
109
114
  * @param key look up this flag
@@ -111,24 +116,28 @@ const hasStudyStatus = (status) => expressionUtils_expressionGen.generateExpress
111
116
  * @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.
112
117
  */
113
118
  const hasParticipantFlagKeyAndValue = (key, value) => expressionUtils_expressionGen.generateExpression('hasParticipantFlag', undefined, key, value);
119
+ const hasParticipantFlagKeyAndValueForIncoming = (key, value) => expressionUtils_expressionGen.generateExpression('incomingState:hasParticipantFlag', undefined, key, value);
114
120
  /**
115
121
  * Check if a participant flag is present
116
122
  * @param key look up this flag
117
123
  * @returns return true if key is present. If any of the two is different, or participant flags is empty, it returns false.
118
124
  */
119
125
  const hasParticipantFlagKey = (key) => expressionUtils_expressionGen.generateExpression('hasParticipantFlagKey', undefined, key);
126
+ const hasParticipantFlagKeyForIncoming = (key) => expressionUtils_expressionGen.generateExpression('incomingState:hasParticipantFlagKey', undefined, key);
120
127
  /**
121
128
  * Checks if the participant has a message type assigned (at least one)
122
129
  * @param messageType
123
130
  * @returns return true if a message with the given message type is assigned
124
131
  */
125
132
  const hasMessageTypeAssigned = (messageType) => expressionUtils_expressionGen.generateExpression('hasMessageTypeAssigned', undefined, messageType);
133
+ const hasMessageTypeAssignedForIncoming = (messageType) => expressionUtils_expressionGen.generateExpression('incomingState:hasMessageTypeAssigned', undefined, messageType);
126
134
  /**
127
135
  * Retrieve the timestamp (scheduledFor) for a particular message type. Return 0 if not assigned.
128
136
  * @param messageType
129
137
  * @returns timestamp value or zero
130
138
  */
131
139
  const getMessageNextTime = (messageType) => expressionUtils_expressionGen.generateExpression('getMessageNextTime', undefined, messageType);
140
+ const getMessageNextTimeForIncoming = (messageType) => expressionUtils_expressionGen.generateExpression('incomingState:getMessageNextTime', undefined, messageType);
132
141
  /**
133
142
  * Check if the last submission is older than the reference timestamp
134
143
  * @param reference look up this flag
@@ -136,6 +145,7 @@ const getMessageNextTime = (messageType) => expressionUtils_expressionGen.genera
136
145
  * @returns boolean
137
146
  */
138
147
  const lastSubmissionDateOlderThan = (reference, surveyKey) => expressionUtils_expressionGen.generateExpression('lastSubmissionDateOlderThan', undefined, reference, surveyKey);
148
+ const lastSubmissionDateOlderThanForIncoming = (reference, surveyKey) => expressionUtils_expressionGen.generateExpression('incomingState:lastSubmissionDateOlderThan', undefined, reference, surveyKey);
139
149
  const eq = (val1, val2) => expressionUtils_expressionGen.generateExpression('eq', undefined, val1, val2);
140
150
  const lt = (val1, val2) => expressionUtils_expressionGen.generateExpression('lt', undefined, val1, val2);
141
151
  const lte = (val1, val2) => expressionUtils_expressionGen.generateExpression('lte', undefined, val1, val2);
@@ -203,12 +213,6 @@ const REMOVE_ALL_MESSAGES = () => expressionUtils_expressionGen.generateExpressi
203
213
  * @returns
204
214
  */
205
215
  const REMOVE_MESSAGES_BY_TYPE = (messageType) => expressionUtils_expressionGen.generateExpression('REMOVE_MESSAGES_BY_TYPE', undefined, messageType);
206
- /**
207
- * When submitting the response, item response with the given key would be added to the report array
208
- * @param itemKey find and add this item to the report array
209
- * @returns
210
- */
211
- const ADD_REPORT = (itemKey) => expressionUtils_expressionGen.generateExpression('ADD_REPORT', undefined, itemKey);
212
216
  const REMOVE_SURVEY_BY_KEY = (surveyKey, selector) => {
213
217
  if (selector === 'all') {
214
218
  return expressionUtils_expressionGen.generateExpression('REMOVE_SURVEYS_BY_KEY', undefined, surveyKey);
@@ -217,14 +221,49 @@ const REMOVE_SURVEY_BY_KEY = (surveyKey, selector) => {
217
221
  return expressionUtils_expressionGen.generateExpression('REMOVE_SURVEY_BY_KEY', undefined, surveyKey, selector);
218
222
  }
219
223
  };
220
- const REMOVE_ALL_REPORTS = () => expressionUtils_expressionGen.generateExpression('REMOVE_ALL_REPORTS');
221
- const REMOVE_REPORT_BY_KEY = (surveyKey, selector) => {
222
- if (selector === 'all') {
223
- return expressionUtils_expressionGen.generateExpression('REMOVE_REPORTS_BY_KEY', undefined, surveyKey);
224
- }
225
- else {
226
- return expressionUtils_expressionGen.generateExpression('REMOVE_REPORT_BY_KEY', undefined, surveyKey, selector);
227
- }
224
+ /**
225
+ * Initialises or resets a report for the current event
226
+ * @param reportKey key to be used for the report
227
+ */
228
+ const INIT_REPORT = (reportKey) => {
229
+ return expressionUtils_expressionGen.generateExpression('INIT_REPORT', undefined, reportKey);
230
+ };
231
+ /**
232
+ * Remove the report from the list of reports to be added at the end of the event
233
+ * @param reportKey key of the report that should be removed
234
+ * @returns
235
+ */
236
+ const CANCEL_REPORT = (reportKey) => {
237
+ return expressionUtils_expressionGen.generateExpression('CANCEL_REPORT', undefined, reportKey);
238
+ };
239
+ /**
240
+ * Update one value attribute in a report. If report was not initialized, one will be added to the list.
241
+ * @param reportKey
242
+ * @param attributeKey update / create this attribute in the report
243
+ * @param value this should be the value for the given attribute
244
+ * @param dtype optional dtype to set info for the app how to render this data.
245
+ * @returns
246
+ */
247
+ const UPDATE_REPORT_DATA = (reportKey, attributeKey, value, dtype) => {
248
+ return expressionUtils_expressionGen.generateExpression('UPDATE_REPORT_DATA', undefined, reportKey, attributeKey, value, dtype);
249
+ };
250
+ /**
251
+ * Method to remove one attribute (key and value) from the report
252
+ * @param reportKey
253
+ * @param attributeKey
254
+ * @returns
255
+ */
256
+ const REMOVE_REPORT_DATA = (reportKey, attributeKey) => {
257
+ return expressionUtils_expressionGen.generateExpression('REMOVE_REPORT_DATA', undefined, reportKey, attributeKey);
258
+ };
259
+ const setReportIcon = (reportKey, icon) => {
260
+ return UPDATE_REPORT_DATA(reportKey, 'icon', icon);
261
+ };
262
+ const setReportMessage = (reportKey, content, asTranslationKey) => {
263
+ return UPDATE_REPORT_DATA(reportKey, 'message', content, asTranslationKey ? undefined : 'rawMessage');
264
+ };
265
+ const setReportSummary = (reportKey, content, asTranslationKey) => {
266
+ return UPDATE_REPORT_DATA(reportKey, 'summary', content, asTranslationKey ? undefined : 'rawMessage');
228
267
  };
229
268
  // ##################
230
269
  // Prefill rule methods:
@@ -304,6 +343,19 @@ const NativeStudyEngineExpressions = {
304
343
  lastSubmissionDateOlderThan,
305
344
  hasMessageTypeAssigned,
306
345
  getMessageNextTime,
346
+ incomingParticipantState: {
347
+ // for merge event
348
+ getStudyEntryTime: getStudyEntryTimeForIncoming,
349
+ hasSurveyKeyAssigned: hasSurveyKeyAssignedForIncoming,
350
+ getSurveyKeyAssignedFrom: getSurveyKeyAssignedFromForIncoming,
351
+ getSurveyKeyAssignedUntil: getSurveyKeyAssignedUntilForIncoming,
352
+ hasStudyStatus: hasStudyStatusForIncoming,
353
+ hasParticipantFlagKeyAndValue: hasParticipantFlagKeyAndValueForIncoming,
354
+ hasParticipantFlagKey: hasParticipantFlagKeyForIncoming,
355
+ lastSubmissionDateOlderThan: lastSubmissionDateOlderThanForIncoming,
356
+ hasMessageTypeAssigned: hasMessageTypeAssignedForIncoming,
357
+ getMessageNextTime: getMessageNextTimeForIncoming,
358
+ }
307
359
  },
308
360
  // logical and comparision
309
361
  eq,
@@ -331,9 +383,14 @@ const StudyEngineActions = {
331
383
  remove: REMOVE_SURVEY_BY_KEY,
332
384
  },
333
385
  reports: {
334
- add: ADD_REPORT,
335
- removeAll: REMOVE_ALL_REPORTS,
336
- remove: REMOVE_REPORT_BY_KEY,
386
+ init: INIT_REPORT,
387
+ cancel: CANCEL_REPORT,
388
+ updateData: UPDATE_REPORT_DATA,
389
+ removeData: REMOVE_REPORT_DATA,
390
+ // Extra methods:
391
+ setReportIcon,
392
+ setReportMessage,
393
+ setReportSummary,
337
394
  },
338
395
  messages: {
339
396
  add: ADD_MESSAGE,
@@ -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.0.0-beta.31",
4
+ "version": "1.0.0-beta.32",
5
5
  "main": "index.js",
6
6
  "license": "Apache-2.0",
7
7
  "repository": "github:case-framework/case-editor-tools",
@@ -3,6 +3,7 @@ export declare class StudyRules {
3
3
  private enterRules?;
4
4
  private submitRules?;
5
5
  private timerRules?;
6
- constructor(enterRules?: Expression[], submitRules?: Expression[], timerRules?: Expression[]);
6
+ private mergeRules?;
7
+ constructor(enterRules?: Expression[], submitRules?: Expression[], timerRules?: Expression[], mergeRules?: Expression[]);
7
8
  get(): Expression[];
8
9
  }
@@ -8,10 +8,11 @@ require('./duration.js');
8
8
  require('../expression-utils/expressionGen.js');
9
9
 
10
10
  class StudyRules {
11
- constructor(enterRules, submitRules, timerRules) {
11
+ constructor(enterRules, submitRules, timerRules, mergeRules) {
12
12
  this.enterRules = enterRules;
13
13
  this.submitRules = submitRules;
14
14
  this.timerRules = timerRules;
15
+ this.mergeRules = mergeRules;
15
16
  }
16
17
  get() {
17
18
  const rules = [];
@@ -24,6 +25,9 @@ class StudyRules {
24
25
  if (this.timerRules) {
25
26
  rules.push(expressionUtils_studyEngineExpressions.StudyEngine.ifThen(expressionUtils_studyEngineExpressions.StudyEngine.checkEventType('TIMER'), ...this.timerRules));
26
27
  }
28
+ if (this.mergeRules) {
29
+ rules.push(expressionUtils_studyEngineExpressions.StudyEngine.ifThen(expressionUtils_studyEngineExpressions.StudyEngine.checkEventType('MERGE'), ...this.mergeRules));
30
+ }
27
31
  return rules;
28
32
  }
29
33
  }
@@ -1 +1 @@
1
- {"version":3,"file":"studyRules.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"studyRules.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}