case-editor-tools 1.6.7 → 1.6.9

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,8 +29,13 @@ 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;
38
+ getLastSubmissionDate: (surveyKey?: string) => Expression;
33
39
  lastSubmissionDateOlderThan: (reference: number | Expression, surveyKey?: string) => Expression;
34
40
  hasMessageTypeAssigned: (messageType: string) => Expression;
35
41
  getMessageNextTime: (messageType: string) => Expression;
@@ -42,6 +48,7 @@ export declare const NativeStudyEngineExpressions: {
42
48
  hasParticipantFlagKeyAndValue: (key: string, value: string) => Expression;
43
49
  hasParticipantFlagKey: (key: string) => Expression;
44
50
  getParticipantFlagValue: (key: string) => Expression;
51
+ getLastSubmissionDate: (surveyKey?: string) => Expression;
45
52
  lastSubmissionDateOlderThan: (reference: number | Expression, surveyKey?: string) => Expression;
46
53
  hasMessageTypeAssigned: (messageType: string) => Expression;
47
54
  getMessageNextTime: (messageType: string) => Expression;
@@ -55,6 +62,8 @@ export declare const NativeStudyEngineExpressions: {
55
62
  or: (...args: Expression[]) => Expression;
56
63
  and: (...args: Expression[]) => Expression;
57
64
  not: (arg: Expression) => Expression;
65
+ sum: (...values: (Expression | number)[]) => Expression;
66
+ neg: (value: Expression | number) => Expression;
58
67
  timestampWithOffset: (delta: Duration, reference?: number | Expression) => Expression;
59
68
  getISOWeekForTs: (ts: number | Expression) => Expression;
60
69
  getTsForNextISOWeek: (ISOWeek: number | Expression, reference?: number | Expression) => Expression;
@@ -85,6 +94,10 @@ export declare const StudyEngineActions: {
85
94
  setReportMessage: (reportKey: string, content: string, asTranslationKey?: boolean) => Expression;
86
95
  setReportSummary: (reportKey: string, content: string, asTranslationKey?: boolean) => Expression;
87
96
  };
97
+ linkingCodes: {
98
+ set: (forKey: string | Expression, value: string | Expression) => Expression;
99
+ delete: (forKey?: string | Expression) => Expression;
100
+ };
88
101
  messages: {
89
102
  add: (messageType: string, scheduledFor: number | Expression) => Expression;
90
103
  removeAll: () => Expression;
@@ -98,6 +111,7 @@ export declare const StudyEngineActions: {
98
111
  stopParticipation: () => Expression;
99
112
  finishParticipation: () => Expression;
100
113
  };
114
+ removeStudyCode: (listKey: string | Expression, code: string | Expression) => Expression;
101
115
  notifyResearcher: (messageType: string, ...payload: Expression[] | string[]) => Expression;
102
116
  };
103
117
  export declare const StudyEngine: {
@@ -151,6 +165,10 @@ export declare const StudyEngine: {
151
165
  setReportMessage: (reportKey: string, content: string, asTranslationKey?: boolean) => Expression;
152
166
  setReportSummary: (reportKey: string, content: string, asTranslationKey?: boolean) => Expression;
153
167
  };
168
+ linkingCodes: {
169
+ set: (forKey: string | Expression, value: string | Expression) => Expression;
170
+ delete: (forKey?: string | Expression) => Expression;
171
+ };
154
172
  messages: {
155
173
  add: (messageType: string, scheduledFor: number | Expression) => Expression;
156
174
  removeAll: () => Expression;
@@ -164,6 +182,7 @@ export declare const StudyEngine: {
164
182
  stopParticipation: () => Expression;
165
183
  finishParticipation: () => Expression;
166
184
  };
185
+ removeStudyCode: (listKey: string | Expression, code: string | Expression) => Expression;
167
186
  notifyResearcher: (messageType: string, ...payload: Expression[] | string[]) => Expression;
168
187
  checkEventType: (equalsType: 'ENTER' | 'SUBMIT' | 'TIMER' | 'MERGE' | 'CUSTOM' | 'LEAVE') => Expression;
169
188
  checkEventKey: (equalsKey: string) => Expression;
@@ -176,6 +195,7 @@ export declare const StudyEngine: {
176
195
  hasResponseKey: (itemKey: string, responseKey: string) => Expression;
177
196
  hasResponseKeyWithValue: (itemKey: string, responseKey: string, value: string) => Expression;
178
197
  countResponseItems: (itemKey: string, responseKey: string) => Expression;
198
+ isStudyCodePresent: (listKey: string | Expression, code: string | Expression) => Expression;
179
199
  checkConditionForOldResponses: (condition: Expression, checkType?: number | 'all' | 'any', surveyKey?: string, querySince?: number | Expression, queryUntil?: number | Expression) => Expression;
180
200
  eventPayload: {
181
201
  hasEventPayload: () => Expression;
@@ -192,8 +212,13 @@ export declare const StudyEngine: {
192
212
  hasStudyStatus: (status: string) => Expression;
193
213
  hasParticipantFlagKeyAndValue: (key: string, value: string) => Expression;
194
214
  hasParticipantFlagKey: (key: string) => Expression;
215
+ linkingCode: {
216
+ has: (forKey: string | Expression) => Expression;
217
+ get: (forKey: string | Expression) => Expression;
218
+ };
195
219
  getParticipantFlagValue: (key: string) => Expression;
196
220
  getParticipantFlagValueAsNum: (key: string) => Expression;
221
+ getLastSubmissionDate: (surveyKey?: string) => Expression;
197
222
  lastSubmissionDateOlderThan: (reference: number | Expression, surveyKey?: string) => Expression;
198
223
  hasMessageTypeAssigned: (messageType: string) => Expression;
199
224
  getMessageNextTime: (messageType: string) => Expression;
@@ -206,6 +231,7 @@ export declare const StudyEngine: {
206
231
  hasParticipantFlagKeyAndValue: (key: string, value: string) => Expression;
207
232
  hasParticipantFlagKey: (key: string) => Expression;
208
233
  getParticipantFlagValue: (key: string) => Expression;
234
+ getLastSubmissionDate: (surveyKey?: string) => Expression;
209
235
  lastSubmissionDateOlderThan: (reference: number | Expression, surveyKey?: string) => Expression;
210
236
  hasMessageTypeAssigned: (messageType: string) => Expression;
211
237
  getMessageNextTime: (messageType: string) => Expression;
@@ -219,6 +245,8 @@ export declare const StudyEngine: {
219
245
  or: (...args: Expression[]) => Expression;
220
246
  and: (...args: Expression[]) => Expression;
221
247
  not: (arg: Expression) => Expression;
248
+ sum: (...values: (Expression | number)[]) => Expression;
249
+ neg: (value: Expression | number) => Expression;
222
250
  timestampWithOffset: (delta: Duration, reference?: number | Expression) => Expression;
223
251
  getISOWeekForTs: (ts: number | Expression) => Expression;
224
252
  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
@@ -169,6 +178,13 @@ const hasMessageTypeAssignedForIncoming = (messageType) => expressionUtils_expre
169
178
  */
170
179
  const getMessageNextTime = (messageType) => expressionUtils_expressionGen.generateExpression('getMessageNextTime', undefined, messageType);
171
180
  const getMessageNextTimeForIncoming = (messageType) => expressionUtils_expressionGen.generateExpression('incomingState:getMessageNextTime', undefined, messageType);
181
+ /**
182
+ * Retrieve the timestamp of the last submission
183
+ * @param surveyKey - optional - check for this specific survey key. If empty, it would check for all the submissions.
184
+ * @returns timestamp value or zero
185
+ */
186
+ const getLastSubmissionDate = (surveyKey) => expressionUtils_expressionGen.generateExpression('getLastSubmissionDate', undefined, surveyKey);
187
+ const getLastSubmissionDateForIncoming = (surveyKey) => expressionUtils_expressionGen.generateExpression('incomingState:getLastSubmissionDate', undefined, surveyKey);
172
188
  /**
173
189
  * Check if the last submission is older than the reference timestamp
174
190
  * @param reference look up this flag
@@ -182,6 +198,8 @@ const lt = (val1, val2) => expressionUtils_expressionGen.generateExpression('lt'
182
198
  const lte = (val1, val2) => expressionUtils_expressionGen.generateExpression('lte', undefined, val1, val2);
183
199
  const gt = (val1, val2) => expressionUtils_expressionGen.generateExpression('gt', undefined, val1, val2);
184
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);
185
203
  /**
186
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.
187
205
  * @param delta offset for the timestamp generation
@@ -279,6 +297,13 @@ const REMOVE_ALL_MESSAGES = () => expressionUtils_expressionGen.generateExpressi
279
297
  * @returns
280
298
  */
281
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);
282
307
  /**
283
308
  * Add a new notification message for the subscribed researchers
284
309
  * @param messageType message type
@@ -352,6 +377,39 @@ const setReportMessage = (reportKey, content, asTranslationKey) => {
352
377
  const setReportSummary = (reportKey, content, asTranslationKey) => {
353
378
  return UPDATE_REPORT_DATA(reportKey, 'summary', content, asTranslationKey ? undefined : 'rawMessage');
354
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
+ };
355
413
  /**
356
414
  * Method to call external event handler
357
415
  * @param serviceName name of the external service endpoint that should be used (URL and API key are config of the service)
@@ -433,6 +491,7 @@ const NativeStudyEngineExpressions = {
433
491
  hasResponseKey,
434
492
  hasResponseKeyWithValue,
435
493
  countResponseItems,
494
+ isStudyCodePresent,
436
495
  // Old responses
437
496
  checkConditionForOldResponses,
438
497
  // Event payload methods:
@@ -452,8 +511,13 @@ const NativeStudyEngineExpressions = {
452
511
  hasStudyStatus,
453
512
  hasParticipantFlagKeyAndValue,
454
513
  hasParticipantFlagKey,
514
+ linkingCode: {
515
+ has: hasLinkingCode,
516
+ get: getLinkingCode,
517
+ },
455
518
  getParticipantFlagValue,
456
519
  getParticipantFlagValueAsNum,
520
+ getLastSubmissionDate,
457
521
  lastSubmissionDateOlderThan,
458
522
  hasMessageTypeAssigned,
459
523
  getMessageNextTime,
@@ -467,6 +531,7 @@ const NativeStudyEngineExpressions = {
467
531
  hasParticipantFlagKeyAndValue: hasParticipantFlagKeyAndValueForIncoming,
468
532
  hasParticipantFlagKey: hasParticipantFlagKeyForIncoming,
469
533
  getParticipantFlagValue: getParticipantFlagValueForIncoming,
534
+ getLastSubmissionDate: getLastSubmissionDateForIncoming,
470
535
  lastSubmissionDateOlderThan: lastSubmissionDateOlderThanForIncoming,
471
536
  hasMessageTypeAssigned: hasMessageTypeAssignedForIncoming,
472
537
  getMessageNextTime: getMessageNextTimeForIncoming,
@@ -481,6 +546,8 @@ const NativeStudyEngineExpressions = {
481
546
  or,
482
547
  and,
483
548
  not,
549
+ sum,
550
+ neg,
484
551
  // Other
485
552
  timestampWithOffset,
486
553
  getISOWeekForTs,
@@ -513,6 +580,10 @@ const StudyEngineActions = {
513
580
  setReportMessage,
514
581
  setReportSummary,
515
582
  },
583
+ linkingCodes: {
584
+ set: SET_LINKING_CODE,
585
+ delete: DELETE_LINKING_CODE,
586
+ },
516
587
  messages: {
517
588
  add: ADD_MESSAGE,
518
589
  removeAll: REMOVE_ALL_MESSAGES,
@@ -527,6 +598,7 @@ const StudyEngineActions = {
527
598
  stopParticipation,
528
599
  finishParticipation,
529
600
  },
601
+ removeStudyCode: REMOVE_STUDY_CODE,
530
602
  notifyResearcher: NOTIFY_RESEARCHER,
531
603
  };
532
604
  const StudyEngine = Object.assign(Object.assign(Object.assign({}, NativeStudyEngineExpressions), StudyEngineActions), { singleChoice: {
@@ -1 +1 @@
1
- {"version":3,"file":"studyEngineExpressions.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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or-tools",
3
3
  "description": "Javascript tools to simplify survey and study coding for CASE.",
4
- "version": "1.6.7",
4
+ "version": "1.6.9",
5
5
  "main": "index.js",
6
6
  "license": "Apache-2.0",
7
7
  "repository": "github:case-framework/case-editor-tools",