case-editor-tools 1.6.8 → 1.6.10

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.
@@ -12,6 +12,7 @@ export declare const NativeStudyEngineExpressions: {
12
12
  hasResponseKey: (itemKey: string, responseKey: string) => Expression;
13
13
  hasResponseKeyWithValue: (itemKey: string, responseKey: string, value: string) => Expression;
14
14
  countResponseItems: (itemKey: string, responseKey: string) => Expression;
15
+ isStudyCodePresent: (listKey: string | Expression, code: string | Expression) => Expression;
15
16
  checkConditionForOldResponses: (condition: Expression, checkType?: number | 'all' | 'any', surveyKey?: string, querySince?: number | Expression, queryUntil?: number | Expression) => Expression;
16
17
  eventPayload: {
17
18
  hasEventPayload: () => Expression;
@@ -28,6 +29,10 @@ export declare const NativeStudyEngineExpressions: {
28
29
  hasStudyStatus: (status: string) => Expression;
29
30
  hasParticipantFlagKeyAndValue: (key: string, value: string) => Expression;
30
31
  hasParticipantFlagKey: (key: string) => Expression;
32
+ linkingCode: {
33
+ has: (forKey: string | Expression) => Expression;
34
+ get: (forKey: string | Expression) => Expression;
35
+ };
31
36
  getParticipantFlagValue: (key: string) => Expression;
32
37
  getParticipantFlagValueAsNum: (key: string) => Expression;
33
38
  getLastSubmissionDate: (surveyKey?: string) => Expression;
@@ -57,6 +62,8 @@ export declare const NativeStudyEngineExpressions: {
57
62
  or: (...args: Expression[]) => Expression;
58
63
  and: (...args: Expression[]) => Expression;
59
64
  not: (arg: Expression) => Expression;
65
+ sum: (...values: (Expression | number)[]) => Expression;
66
+ neg: (value: Expression | number) => Expression;
60
67
  timestampWithOffset: (delta: Duration, reference?: number | Expression) => Expression;
61
68
  getISOWeekForTs: (ts: number | Expression) => Expression;
62
69
  getTsForNextISOWeek: (ISOWeek: number | Expression, reference?: number | Expression) => Expression;
@@ -87,6 +94,11 @@ export declare const StudyEngineActions: {
87
94
  setReportMessage: (reportKey: string, content: string, asTranslationKey?: boolean) => Expression;
88
95
  setReportSummary: (reportKey: string, content: string, asTranslationKey?: boolean) => Expression;
89
96
  };
97
+ linkingCodes: {
98
+ set: (forKey: string | Expression, value: string | Expression) => Expression;
99
+ delete: (forKey?: string | Expression) => Expression;
100
+ drawFromStudyCodeList: (listKey: string | Expression, forKey?: string | Expression) => Expression;
101
+ };
90
102
  messages: {
91
103
  add: (messageType: string, scheduledFor: number | Expression) => Expression;
92
104
  removeAll: () => Expression;
@@ -100,6 +112,7 @@ export declare const StudyEngineActions: {
100
112
  stopParticipation: () => Expression;
101
113
  finishParticipation: () => Expression;
102
114
  };
115
+ removeStudyCode: (listKey: string | Expression, code: string | Expression) => Expression;
103
116
  notifyResearcher: (messageType: string, ...payload: Expression[] | string[]) => Expression;
104
117
  };
105
118
  export declare const StudyEngine: {
@@ -153,6 +166,11 @@ export declare const StudyEngine: {
153
166
  setReportMessage: (reportKey: string, content: string, asTranslationKey?: boolean) => Expression;
154
167
  setReportSummary: (reportKey: string, content: string, asTranslationKey?: boolean) => Expression;
155
168
  };
169
+ linkingCodes: {
170
+ set: (forKey: string | Expression, value: string | Expression) => Expression;
171
+ delete: (forKey?: string | Expression) => Expression;
172
+ drawFromStudyCodeList: (listKey: string | Expression, forKey?: string | Expression) => Expression;
173
+ };
156
174
  messages: {
157
175
  add: (messageType: string, scheduledFor: number | Expression) => Expression;
158
176
  removeAll: () => Expression;
@@ -166,6 +184,7 @@ export declare const StudyEngine: {
166
184
  stopParticipation: () => Expression;
167
185
  finishParticipation: () => Expression;
168
186
  };
187
+ removeStudyCode: (listKey: string | Expression, code: string | Expression) => Expression;
169
188
  notifyResearcher: (messageType: string, ...payload: Expression[] | string[]) => Expression;
170
189
  checkEventType: (equalsType: 'ENTER' | 'SUBMIT' | 'TIMER' | 'MERGE' | 'CUSTOM' | 'LEAVE') => Expression;
171
190
  checkEventKey: (equalsKey: string) => Expression;
@@ -178,6 +197,7 @@ export declare const StudyEngine: {
178
197
  hasResponseKey: (itemKey: string, responseKey: string) => Expression;
179
198
  hasResponseKeyWithValue: (itemKey: string, responseKey: string, value: string) => Expression;
180
199
  countResponseItems: (itemKey: string, responseKey: string) => Expression;
200
+ isStudyCodePresent: (listKey: string | Expression, code: string | Expression) => Expression;
181
201
  checkConditionForOldResponses: (condition: Expression, checkType?: number | 'all' | 'any', surveyKey?: string, querySince?: number | Expression, queryUntil?: number | Expression) => Expression;
182
202
  eventPayload: {
183
203
  hasEventPayload: () => Expression;
@@ -194,6 +214,10 @@ export declare const StudyEngine: {
194
214
  hasStudyStatus: (status: string) => Expression;
195
215
  hasParticipantFlagKeyAndValue: (key: string, value: string) => Expression;
196
216
  hasParticipantFlagKey: (key: string) => Expression;
217
+ linkingCode: {
218
+ has: (forKey: string | Expression) => Expression;
219
+ get: (forKey: string | Expression) => Expression;
220
+ };
197
221
  getParticipantFlagValue: (key: string) => Expression;
198
222
  getParticipantFlagValueAsNum: (key: string) => Expression;
199
223
  getLastSubmissionDate: (surveyKey?: string) => Expression;
@@ -223,6 +247,8 @@ export declare const StudyEngine: {
223
247
  or: (...args: Expression[]) => Expression;
224
248
  and: (...args: Expression[]) => Expression;
225
249
  not: (arg: Expression) => Expression;
250
+ sum: (...values: (Expression | number)[]) => Expression;
251
+ neg: (value: Expression | number) => Expression;
226
252
  timestampWithOffset: (delta: Duration, reference?: number | Expression) => Expression;
227
253
  getISOWeekForTs: (ts: number | Expression) => Expression;
228
254
  getTsForNextISOWeek: (ISOWeek: number | Expression, reference?: number | Expression) => Expression;
@@ -82,6 +82,15 @@ const getSelectedKeys = (itemKey, responseKey) => {
82
82
  const countResponseItems = (itemKey, responseKey) => {
83
83
  return expressionUtils_expressionGen.generateExpression('countResponseItems', undefined, itemKey, responseKey);
84
84
  };
85
+ /**
86
+ * Check if a study code is present in the study wide list with the given list key
87
+ * @param listKey
88
+ * @param code
89
+ * @returns
90
+ */
91
+ const isStudyCodePresent = (listKey, code) => {
92
+ return expressionUtils_expressionGen.generateExpression('isStudyCodePresent', undefined, listKey, code);
93
+ };
85
94
  /**
86
95
  * Method to run a check on previous responses of the participant.
87
96
  * @param condition expression that will be evaluated on each retrieved response
@@ -189,6 +198,8 @@ const lt = (val1, val2) => expressionUtils_expressionGen.generateExpression('lt'
189
198
  const lte = (val1, val2) => expressionUtils_expressionGen.generateExpression('lte', undefined, val1, val2);
190
199
  const gt = (val1, val2) => expressionUtils_expressionGen.generateExpression('gt', undefined, val1, val2);
191
200
  const gte = (val1, val2) => expressionUtils_expressionGen.generateExpression('gte', undefined, val1, val2);
201
+ const sum = (...values) => expressionUtils_expressionGen.generateExpression('sum', "float", ...values);
202
+ const neg = (value) => expressionUtils_expressionGen.generateExpression("neg", "float", value);
192
203
  /**
193
204
  * Generate a timestamp value (POSIX timestamp). T = T_ref + delta. If 'reference' is not defined, the current time will be used as a reference.
194
205
  * @param delta offset for the timestamp generation
@@ -286,6 +297,13 @@ const REMOVE_ALL_MESSAGES = () => expressionUtils_expressionGen.generateExpressi
286
297
  * @returns
287
298
  */
288
299
  const REMOVE_MESSAGES_BY_TYPE = (messageType) => expressionUtils_expressionGen.generateExpression('REMOVE_MESSAGES_BY_TYPE', undefined, messageType);
300
+ /**
301
+ * Remove a study code from a list
302
+ * @param listKey
303
+ * @param code
304
+ * @returns
305
+ */
306
+ const REMOVE_STUDY_CODE = (listKey, code) => expressionUtils_expressionGen.generateExpression('REMOVE_STUDY_CODE', undefined, listKey, code);
289
307
  /**
290
308
  * Add a new notification message for the subscribed researchers
291
309
  * @param messageType message type
@@ -359,6 +377,48 @@ const setReportMessage = (reportKey, content, asTranslationKey) => {
359
377
  const setReportSummary = (reportKey, content, asTranslationKey) => {
360
378
  return UPDATE_REPORT_DATA(reportKey, 'summary', content, asTranslationKey ? undefined : 'rawMessage');
361
379
  };
380
+ /**
381
+ * Method to check if a participant has any linking code for a specific key
382
+ * @param forKey
383
+ * @returns
384
+ */
385
+ const hasLinkingCode = (forKey) => {
386
+ return expressionUtils_expressionGen.generateExpression('hasLinkingCode', undefined, forKey);
387
+ };
388
+ /**
389
+ * Retrieve the value of a linking code for a specific key. Will return empty string if not present
390
+ * @param forKey
391
+ * @returns
392
+ */
393
+ const getLinkingCode = (forKey) => {
394
+ return expressionUtils_expressionGen.generateExpression("getLinkingCode", undefined, forKey);
395
+ };
396
+ /**
397
+ * Set a linking code for a specific key. This will override any existing value for that key, if already present.
398
+ * @param forKey: will result in an error if empty
399
+ * @param value
400
+ * @returns
401
+ */
402
+ const SET_LINKING_CODE = (forKey, value) => {
403
+ return expressionUtils_expressionGen.generateExpression('SET_LINKING_CODE', undefined, forKey, value);
404
+ };
405
+ /**
406
+ * Delete a linking code for a specific key or all linling codes if no key is specified
407
+ * @param forKey
408
+ * @returns
409
+ */
410
+ const DELETE_LINKING_CODE = (forKey) => {
411
+ return expressionUtils_expressionGen.generateExpression('DELETE_LINKING_CODE', undefined, forKey);
412
+ };
413
+ /**
414
+ * Draw (find one and delete) a study code from a list and store it as a linking code for the participant
415
+ * @param listKey Pick one from this list of study codes if available
416
+ * @param forKey optional key to store the linking code for. If not defined, the listKey will be used.
417
+ * @returns
418
+ */
419
+ const DRAW_STUDY_CODE_AS_LINKING_CODE = (listKey, forKey) => {
420
+ return expressionUtils_expressionGen.generateExpression('DRAW_STUDY_CODE_AS_LINKING_CODE', undefined, listKey, forKey);
421
+ };
362
422
  /**
363
423
  * Method to call external event handler
364
424
  * @param serviceName name of the external service endpoint that should be used (URL and API key are config of the service)
@@ -440,6 +500,7 @@ const NativeStudyEngineExpressions = {
440
500
  hasResponseKey,
441
501
  hasResponseKeyWithValue,
442
502
  countResponseItems,
503
+ isStudyCodePresent,
443
504
  // Old responses
444
505
  checkConditionForOldResponses,
445
506
  // Event payload methods:
@@ -459,6 +520,10 @@ const NativeStudyEngineExpressions = {
459
520
  hasStudyStatus,
460
521
  hasParticipantFlagKeyAndValue,
461
522
  hasParticipantFlagKey,
523
+ linkingCode: {
524
+ has: hasLinkingCode,
525
+ get: getLinkingCode,
526
+ },
462
527
  getParticipantFlagValue,
463
528
  getParticipantFlagValueAsNum,
464
529
  getLastSubmissionDate,
@@ -490,6 +555,8 @@ const NativeStudyEngineExpressions = {
490
555
  or,
491
556
  and,
492
557
  not,
558
+ sum,
559
+ neg,
493
560
  // Other
494
561
  timestampWithOffset,
495
562
  getISOWeekForTs,
@@ -522,6 +589,11 @@ const StudyEngineActions = {
522
589
  setReportMessage,
523
590
  setReportSummary,
524
591
  },
592
+ linkingCodes: {
593
+ set: SET_LINKING_CODE,
594
+ delete: DELETE_LINKING_CODE,
595
+ drawFromStudyCodeList: DRAW_STUDY_CODE_AS_LINKING_CODE,
596
+ },
525
597
  messages: {
526
598
  add: ADD_MESSAGE,
527
599
  removeAll: REMOVE_ALL_MESSAGES,
@@ -536,6 +608,7 @@ const StudyEngineActions = {
536
608
  stopParticipation,
537
609
  finishParticipation,
538
610
  },
611
+ removeStudyCode: REMOVE_STUDY_CODE,
539
612
  notifyResearcher: NOTIFY_RESEARCHER,
540
613
  };
541
614
  const StudyEngine = Object.assign(Object.assign(Object.assign({}, NativeStudyEngineExpressions), StudyEngineActions), { singleChoice: {
@@ -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.6.8",
4
+ "version": "1.6.10",
5
5
  "main": "index.js",
6
6
  "license": "Apache-2.0",
7
7
  "repository": "github:case-framework/case-editor-tools",