case-editor-tools 1.7.1 → 1.8.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.
@@ -14,6 +14,8 @@ export declare const NativeStudyEngineExpressions: {
14
14
  hasResponseKeyWithValue: (itemKey: string, responseKey: string, value: string) => Expression;
15
15
  countResponseItems: (itemKey: string, responseKey: string) => Expression;
16
16
  isStudyCodePresent: (listKey: string | Expression, code: string | Expression) => Expression;
17
+ getCurrentStudyCounterValue: (scopeKey: string | Expression) => Expression;
18
+ getNextStudyCounterValue: (scopeKey: string | Expression) => Expression;
17
19
  checkConditionForOldResponses: (condition: Expression, checkType?: number | 'all' | 'any', surveyKey?: string, querySince?: number | Expression, queryUntil?: number | Expression) => Expression;
18
20
  eventPayload: {
19
21
  hasEventPayload: () => Expression;
@@ -55,6 +57,13 @@ export declare const NativeStudyEngineExpressions: {
55
57
  getMessageNextTime: (messageType: string) => Expression;
56
58
  };
57
59
  };
60
+ getStudyVariable: {
61
+ boolean: (key: string | Expression) => Expression;
62
+ string: (key: string | Expression) => Expression;
63
+ int: (key: string | Expression) => Expression;
64
+ float: (key: string | Expression) => Expression;
65
+ date: (key: string | Expression) => Expression;
66
+ };
58
67
  eq: (val1: Expression | string | number, val2: Expression | string | number) => Expression;
59
68
  lt: (val1: Expression | string | number, val2: Expression | string | number) => Expression;
60
69
  lte: (val1: Expression | string | number, val2: Expression | string | number) => Expression;
@@ -66,9 +75,11 @@ export declare const NativeStudyEngineExpressions: {
66
75
  sum: (...values: (Expression | number)[]) => Expression;
67
76
  neg: (value: Expression | number) => Expression;
68
77
  timestampWithOffset: (delta: Duration, reference?: number | Expression) => Expression;
78
+ timestampDiff: (laterTimestamp: number | Expression, earlierTimestamp: number | Expression) => Expression;
69
79
  getISOWeekForTs: (ts: number | Expression) => Expression;
70
80
  getTsForNextStartOfMonth: (month: Month | Expression, reference?: number | Expression) => Expression;
71
81
  getTsForNextISOWeek: (ISOWeek: number | Expression, reference?: number | Expression) => Expression;
82
+ getTsForStartOfISOWeek: (reference?: number | Expression) => Expression;
72
83
  parseValueAsNum: (valueRef: Expression | string | number) => Expression;
73
84
  generateRandomNumber: (min: number, max: number) => Expression;
74
85
  externalEventEval: (serviceName: string, route?: string, expectFloat?: boolean) => Expression;
@@ -80,8 +91,9 @@ export declare const StudyEngineActions: {
80
91
  participantActions: {
81
92
  updateStudyStatus: (status: string) => Expression;
82
93
  startNewStudySession: () => Expression;
83
- updateFlag: (key: string, newValue: string | number | Expression) => Expression;
84
- removeFlag: (key: string) => Expression;
94
+ updateFlag: (key: string | Expression, newValue: string | number | Expression) => Expression;
95
+ removeFlag: (key: string | Expression) => Expression;
96
+ getNextStudyCounterAsFlag: (scopeKey: string | Expression, flagKey: string | Expression, prefix: string | Expression, padding: number | Expression) => Expression;
85
97
  assignedSurveys: {
86
98
  add: (surveyKey: string, category: 'immediate' | 'prio' | 'normal' | 'optional', activeFrom?: number | Expression, activeUntil?: number | Expression) => Expression;
87
99
  removeAll: () => Expression;
@@ -100,6 +112,7 @@ export declare const StudyEngineActions: {
100
112
  set: (forKey: string | Expression, value: string | Expression) => Expression;
101
113
  delete: (forKey?: string | Expression) => Expression;
102
114
  drawFromStudyCodeList: (listKey: string | Expression, forKey?: string | Expression) => Expression;
115
+ getNextStudyCounterAsLinkingCode: (scopeKey: string | Expression, linkingCodeKey: string | Expression, prefix: string | Expression, padding: number | Expression) => Expression;
103
116
  };
104
117
  messages: {
105
118
  add: (messageType: string, scheduledFor: number | Expression) => Expression;
@@ -115,7 +128,15 @@ export declare const StudyEngineActions: {
115
128
  stopParticipation: () => Expression;
116
129
  finishParticipation: () => Expression;
117
130
  };
131
+ updateStudyVariable: {
132
+ boolean: (key: string | Expression, value: Expression) => Expression;
133
+ string: (key: string | Expression, value: Expression | string) => Expression;
134
+ int: (key: string | Expression, value: number | Expression) => Expression;
135
+ float: (key: string | Expression, value: number | Expression) => Expression;
136
+ date: (key: string | Expression, value: number | Expression) => Expression;
137
+ };
118
138
  removeStudyCode: (listKey: string | Expression, code: string | Expression) => Expression;
139
+ resetStudyCounter: (scopeKey: string | Expression) => Expression;
119
140
  notifyResearcher: (messageType: string, ...payload: Expression[] | string[]) => Expression;
120
141
  };
121
142
  export declare const StudyEngine: {
@@ -153,8 +174,9 @@ export declare const StudyEngine: {
153
174
  participantActions: {
154
175
  updateStudyStatus: (status: string) => Expression;
155
176
  startNewStudySession: () => Expression;
156
- updateFlag: (key: string, newValue: string | number | Expression) => Expression;
157
- removeFlag: (key: string) => Expression;
177
+ updateFlag: (key: string | Expression, newValue: string | number | Expression) => Expression;
178
+ removeFlag: (key: string | Expression) => Expression;
179
+ getNextStudyCounterAsFlag: (scopeKey: string | Expression, flagKey: string | Expression, prefix: string | Expression, padding: number | Expression) => Expression;
158
180
  assignedSurveys: {
159
181
  add: (surveyKey: string, category: 'immediate' | 'prio' | 'normal' | 'optional', activeFrom?: number | Expression, activeUntil?: number | Expression) => Expression;
160
182
  removeAll: () => Expression;
@@ -173,6 +195,7 @@ export declare const StudyEngine: {
173
195
  set: (forKey: string | Expression, value: string | Expression) => Expression;
174
196
  delete: (forKey?: string | Expression) => Expression;
175
197
  drawFromStudyCodeList: (listKey: string | Expression, forKey?: string | Expression) => Expression;
198
+ getNextStudyCounterAsLinkingCode: (scopeKey: string | Expression, linkingCodeKey: string | Expression, prefix: string | Expression, padding: number | Expression) => Expression;
176
199
  };
177
200
  messages: {
178
201
  add: (messageType: string, scheduledFor: number | Expression) => Expression;
@@ -188,7 +211,15 @@ export declare const StudyEngine: {
188
211
  stopParticipation: () => Expression;
189
212
  finishParticipation: () => Expression;
190
213
  };
214
+ updateStudyVariable: {
215
+ boolean: (key: string | Expression, value: Expression) => Expression;
216
+ string: (key: string | Expression, value: Expression | string) => Expression;
217
+ int: (key: string | Expression, value: number | Expression) => Expression;
218
+ float: (key: string | Expression, value: number | Expression) => Expression;
219
+ date: (key: string | Expression, value: number | Expression) => Expression;
220
+ };
191
221
  removeStudyCode: (listKey: string | Expression, code: string | Expression) => Expression;
222
+ resetStudyCounter: (scopeKey: string | Expression) => Expression;
192
223
  notifyResearcher: (messageType: string, ...payload: Expression[] | string[]) => Expression;
193
224
  checkEventType: (equalsType: 'ENTER' | 'SUBMIT' | 'TIMER' | 'MERGE' | 'CUSTOM' | 'LEAVE') => Expression;
194
225
  checkEventKey: (equalsKey: string) => Expression;
@@ -202,6 +233,8 @@ export declare const StudyEngine: {
202
233
  hasResponseKeyWithValue: (itemKey: string, responseKey: string, value: string) => Expression;
203
234
  countResponseItems: (itemKey: string, responseKey: string) => Expression;
204
235
  isStudyCodePresent: (listKey: string | Expression, code: string | Expression) => Expression;
236
+ getCurrentStudyCounterValue: (scopeKey: string | Expression) => Expression;
237
+ getNextStudyCounterValue: (scopeKey: string | Expression) => Expression;
205
238
  checkConditionForOldResponses: (condition: Expression, checkType?: number | 'all' | 'any', surveyKey?: string, querySince?: number | Expression, queryUntil?: number | Expression) => Expression;
206
239
  eventPayload: {
207
240
  hasEventPayload: () => Expression;
@@ -243,6 +276,13 @@ export declare const StudyEngine: {
243
276
  getMessageNextTime: (messageType: string) => Expression;
244
277
  };
245
278
  };
279
+ getStudyVariable: {
280
+ boolean: (key: string | Expression) => Expression;
281
+ string: (key: string | Expression) => Expression;
282
+ int: (key: string | Expression) => Expression;
283
+ float: (key: string | Expression) => Expression;
284
+ date: (key: string | Expression) => Expression;
285
+ };
246
286
  eq: (val1: Expression | string | number, val2: Expression | string | number) => Expression;
247
287
  lt: (val1: Expression | string | number, val2: Expression | string | number) => Expression;
248
288
  lte: (val1: Expression | string | number, val2: Expression | string | number) => Expression;
@@ -254,9 +294,11 @@ export declare const StudyEngine: {
254
294
  sum: (...values: (Expression | number)[]) => Expression;
255
295
  neg: (value: Expression | number) => Expression;
256
296
  timestampWithOffset: (delta: Duration, reference?: number | Expression) => Expression;
297
+ timestampDiff: (laterTimestamp: number | Expression, earlierTimestamp: number | Expression) => Expression;
257
298
  getISOWeekForTs: (ts: number | Expression) => Expression;
258
299
  getTsForNextStartOfMonth: (month: Month | Expression, reference?: number | Expression) => Expression;
259
300
  getTsForNextISOWeek: (ISOWeek: number | Expression, reference?: number | Expression) => Expression;
301
+ getTsForStartOfISOWeek: (reference?: number | Expression) => Expression;
260
302
  parseValueAsNum: (valueRef: Expression | string | number) => Expression;
261
303
  generateRandomNumber: (min: number, max: number) => Expression;
262
304
  externalEventEval: (serviceName: string, route?: string, expectFloat?: boolean) => Expression;
@@ -91,6 +91,22 @@ const countResponseItems = (itemKey, responseKey) => {
91
91
  const isStudyCodePresent = (listKey, code) => {
92
92
  return expressionUtils_expressionGen.generateExpression('isStudyCodePresent', undefined, listKey, code);
93
93
  };
94
+ /**
95
+ * Get the current study counter value for the given scope key (does not change the counter)
96
+ * @param scopeKey
97
+ * @returns
98
+ */
99
+ const getCurrentStudyCounterValue = (scopeKey) => {
100
+ return expressionUtils_expressionGen.generateExpression('getCurrentStudyCounterValue', undefined, scopeKey);
101
+ };
102
+ /**
103
+ * Get the next study counter value for the given scope key (increases the counter by 1)
104
+ * @param scopeKey
105
+ * @returns
106
+ */
107
+ const getNextStudyCounterValue = (scopeKey) => {
108
+ return expressionUtils_expressionGen.generateExpression('getNextStudyCounterValue', undefined, scopeKey);
109
+ };
94
110
  /**
95
111
  * Method to run a check on previous responses of the participant.
96
112
  * @param condition expression that will be evaluated on each retrieved response
@@ -193,6 +209,16 @@ const getLastSubmissionDateForIncoming = (surveyKey) => expressionUtils_expressi
193
209
  */
194
210
  const lastSubmissionDateOlderThan = (reference, surveyKey) => expressionUtils_expressionGen.generateExpression('lastSubmissionDateOlderThan', undefined, reference, surveyKey);
195
211
  const lastSubmissionDateOlderThanForIncoming = (reference, surveyKey) => expressionUtils_expressionGen.generateExpression('incomingState:lastSubmissionDateOlderThan', undefined, reference, surveyKey);
212
+ const getStudyVariableBoolean = (key) => expressionUtils_expressionGen.generateExpression('getStudyVariableBoolean', undefined, key);
213
+ const getStudyVariableString = (key) => expressionUtils_expressionGen.generateExpression('getStudyVariableString', undefined, key);
214
+ const getStudyVariableInt = (key) => expressionUtils_expressionGen.generateExpression('getStudyVariableInt', undefined, key);
215
+ const getStudyVariableFloat = (key) => expressionUtils_expressionGen.generateExpression('getStudyVariableFloat', undefined, key);
216
+ const getStudyVariableDate = (key) => expressionUtils_expressionGen.generateExpression('getStudyVariableDate', undefined, key);
217
+ const UPDATE_STUDY_VARIABLE_BOOLEAN = (key, value) => expressionUtils_expressionGen.generateExpression('UPDATE_STUDY_VARIABLE_BOOLEAN', undefined, key, value);
218
+ const UPDATE_STUDY_VARIABLE_STRING = (key, value) => expressionUtils_expressionGen.generateExpression('UPDATE_STUDY_VARIABLE_STRING', undefined, key, value);
219
+ const UPDATE_STUDY_VARIABLE_INT = (key, value) => expressionUtils_expressionGen.generateExpression('UPDATE_STUDY_VARIABLE_INT', undefined, key, value);
220
+ const UPDATE_STUDY_VARIABLE_FLOAT = (key, value) => expressionUtils_expressionGen.generateExpression('UPDATE_STUDY_VARIABLE_FLOAT', undefined, key, value);
221
+ const UPDATE_STUDY_VARIABLE_DATE = (key, value) => expressionUtils_expressionGen.generateExpression('UPDATE_STUDY_VARIABLE_DATE', undefined, key, value);
196
222
  const eq = (val1, val2) => expressionUtils_expressionGen.generateExpression('eq', undefined, val1, val2);
197
223
  const lt = (val1, val2) => expressionUtils_expressionGen.generateExpression('lt', undefined, val1, val2);
198
224
  const lte = (val1, val2) => expressionUtils_expressionGen.generateExpression('lte', undefined, val1, val2);
@@ -213,6 +239,13 @@ const timestampWithOffset = (delta, reference) => expressionUtils_expressionGen.
213
239
  * @returns
214
240
  */
215
241
  const getISOWeekForTs = (ts) => expressionUtils_expressionGen.generateExpression('getISOWeekForTs', undefined, ts);
242
+ /**
243
+ * Calculate the signed difference between two POSIX timestamps in seconds.
244
+ * @param laterTimestamp timestamp or expression returning a timestamp
245
+ * @param earlierTimestamp timestamp or expression returning a timestamp
246
+ * @returns laterTimestamp minus earlierTimestamp, which may be negative
247
+ */
248
+ const timestampDiff = (laterTimestamp, earlierTimestamp) => expressionUtils_expressionGen.generateExpression('timestampDiff', 'float', laterTimestamp, earlierTimestamp);
216
249
  /**
217
250
  * Generate a timestamp value (POSIX timestamp) for the beginning of the month for the first time that is later than the reference
218
251
  * @param month which ISO week should be used for the timestamp generation
@@ -227,6 +260,12 @@ const getTsForNextStartOfMonth = (month, reference) => expressionUtils_expressio
227
260
  * @returns
228
261
  */
229
262
  const getTsForNextISOWeek = (ISOWeek, reference) => expressionUtils_expressionGen.generateExpression('getTsForNextISOWeek', undefined, ISOWeek, reference ? reference : undefined);
263
+ /**
264
+ * Get the POSIX timestamp for Monday midnight of the ISO week containing the reference, using the backend's local timezone.
265
+ * @param reference optional timestamp or expression returning a timestamp; defaults to the current time
266
+ * @returns the start of the reference's ISO week in seconds
267
+ */
268
+ const getTsForStartOfISOWeek = (reference) => expressionUtils_expressionGen.generateExpression('getTsForStartOfISOWeek', undefined, reference);
230
269
  /**
231
270
  * Attempt to parse the resolved argument's value as a number
232
271
  * @param valueRef resolve this argument, and try to parse this as number. Boolean value will result in error.
@@ -433,6 +472,36 @@ const DELETE_LINKING_CODE = (forKey) => {
433
472
  const DRAW_STUDY_CODE_AS_LINKING_CODE = (listKey, forKey) => {
434
473
  return expressionUtils_expressionGen.generateExpression('DRAW_STUDY_CODE_AS_LINKING_CODE', undefined, listKey, forKey);
435
474
  };
475
+ /**
476
+ * Get the next study counter value for the given scope key (increases the counter by 1) and store it as a flag for the participant
477
+ * @param scopeKey
478
+ * @param flagKey
479
+ * @param prefix prefix to be added to the flag
480
+ * @param padding number of digits to pad the counter with
481
+ * @returns
482
+ */
483
+ const GET_NEXT_STUDY_COUNTER_AS_FLAG = (scopeKey, flagKey, prefix, padding) => {
484
+ return expressionUtils_expressionGen.generateExpression('GET_NEXT_STUDY_COUNTER_AS_FLAG', undefined, scopeKey, flagKey, prefix, padding);
485
+ };
486
+ /**
487
+ * Get the next study counter value for the given scope key (increases the counter by 1) and store it as a linking code for the participant
488
+ * @param scopeKey
489
+ * @param linkingCodeKey
490
+ * @param prefix prefix to be added to the linking code
491
+ * @param padding number of digits to pad the counter with
492
+ * @returns
493
+ */
494
+ const GET_NEXT_STUDY_COUNTER_AS_LINKING_CODE = (scopeKey, linkingCodeKey, prefix, padding) => {
495
+ return expressionUtils_expressionGen.generateExpression('GET_NEXT_STUDY_COUNTER_AS_LINKING_CODE', undefined, scopeKey, linkingCodeKey, prefix, padding);
496
+ };
497
+ /**
498
+ * Reset the study counter for the given scope key
499
+ * @param scopeKey
500
+ * @returns
501
+ */
502
+ const RESET_STUDY_COUNTER = (scopeKey) => {
503
+ return expressionUtils_expressionGen.generateExpression('RESET_STUDY_COUNTER', undefined, scopeKey);
504
+ };
436
505
  /**
437
506
  * Method to call external event handler
438
507
  * @param serviceName name of the external service endpoint that should be used (URL and API key are config of the service)
@@ -515,6 +584,8 @@ const NativeStudyEngineExpressions = {
515
584
  hasResponseKeyWithValue,
516
585
  countResponseItems,
517
586
  isStudyCodePresent,
587
+ getCurrentStudyCounterValue,
588
+ getNextStudyCounterValue,
518
589
  // Old responses
519
590
  checkConditionForOldResponses,
520
591
  // Event payload methods:
@@ -560,6 +631,13 @@ const NativeStudyEngineExpressions = {
560
631
  getMessageNextTime: getMessageNextTimeForIncoming,
561
632
  }
562
633
  },
634
+ getStudyVariable: {
635
+ boolean: getStudyVariableBoolean,
636
+ string: getStudyVariableString,
637
+ int: getStudyVariableInt,
638
+ float: getStudyVariableFloat,
639
+ date: getStudyVariableDate,
640
+ },
563
641
  // logical and comparision
564
642
  eq,
565
643
  lt,
@@ -573,9 +651,11 @@ const NativeStudyEngineExpressions = {
573
651
  neg,
574
652
  // Other
575
653
  timestampWithOffset,
654
+ timestampDiff,
576
655
  getISOWeekForTs,
577
656
  getTsForNextStartOfMonth,
578
657
  getTsForNextISOWeek,
658
+ getTsForStartOfISOWeek,
579
659
  parseValueAsNum,
580
660
  generateRandomNumber: (min, max) => expressionUtils_expressionGen.generateExpression('generateRandomNumber', undefined, min, max),
581
661
  externalEventEval,
@@ -589,6 +669,7 @@ const StudyEngineActions = {
589
669
  startNewStudySession: START_NEW_STUDY_SESSION,
590
670
  updateFlag: UPDATE_FLAG,
591
671
  removeFlag: REMOVE_FLAG,
672
+ getNextStudyCounterAsFlag: GET_NEXT_STUDY_COUNTER_AS_FLAG,
592
673
  assignedSurveys: {
593
674
  add: ADD_NEW_SURVEY,
594
675
  removeAll: REMOVE_ALL_SURVEYS,
@@ -608,6 +689,7 @@ const StudyEngineActions = {
608
689
  set: SET_LINKING_CODE,
609
690
  delete: DELETE_LINKING_CODE,
610
691
  drawFromStudyCodeList: DRAW_STUDY_CODE_AS_LINKING_CODE,
692
+ getNextStudyCounterAsLinkingCode: GET_NEXT_STUDY_COUNTER_AS_LINKING_CODE,
611
693
  },
612
694
  messages: {
613
695
  add: ADD_MESSAGE,
@@ -624,7 +706,15 @@ const StudyEngineActions = {
624
706
  stopParticipation,
625
707
  finishParticipation,
626
708
  },
709
+ updateStudyVariable: {
710
+ boolean: UPDATE_STUDY_VARIABLE_BOOLEAN,
711
+ string: UPDATE_STUDY_VARIABLE_STRING,
712
+ int: UPDATE_STUDY_VARIABLE_INT,
713
+ float: UPDATE_STUDY_VARIABLE_FLOAT,
714
+ date: UPDATE_STUDY_VARIABLE_DATE,
715
+ },
627
716
  removeStudyCode: REMOVE_STUDY_CODE,
717
+ resetStudyCounter: RESET_STUDY_COUNTER,
628
718
  notifyResearcher: NOTIFY_RESEARCHER,
629
719
  };
630
720
  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.7.1",
4
+ "version": "1.8.0",
5
5
  "main": "index.js",
6
6
  "license": "Apache-2.0",
7
7
  "repository": "github:case-framework/case-editor-tools",
@@ -81,6 +81,14 @@ export declare const SurveyEngine: {
81
81
  hasKeyAndValue: (key: string, value: string | Expression) => Expression;
82
82
  getAsNum: (key: string) => Expression;
83
83
  };
84
+ studyVariables: {
85
+ hasKey: (key: string | Expression) => Expression;
86
+ getBoolean: (key: string | Expression) => Expression;
87
+ getString: (key: string | Expression) => Expression;
88
+ getInt: (key: string | Expression) => Expression;
89
+ getFloat: (key: string | Expression) => Expression;
90
+ getDate: (key: string | Expression) => Expression;
91
+ };
84
92
  isLoggedIn: () => Expression;
85
93
  getters: {
86
94
  getContext: () => Expression;
@@ -321,6 +321,54 @@ const hasParticipantFlagKey = (key) => {
321
321
  const hasParticipantFlagKeyAndValue = (key, value) => {
322
322
  return expressionUtils_expressionGen.generateExpression('hasParticipantFlagKeyAndValue', undefined, key, value);
323
323
  };
324
+ /**
325
+ * Check if a study variable is present
326
+ * @param key look up this study variable
327
+ * @returns return true if key is present. If any of the two is different, or study variables is empty, it returns false.
328
+ */
329
+ const hasStudyVariableKey = (key) => {
330
+ return expressionUtils_expressionGen.generateExpression('hasStudyVariableKey', undefined, key);
331
+ };
332
+ /**
333
+ * Get a study variable value as a boolean
334
+ * @param key look up this study variable
335
+ * @returns return the value of the study variable
336
+ */
337
+ const getStudyVariableBoolean = (key) => {
338
+ return expressionUtils_expressionGen.generateExpression('getStudyVariableBoolean', undefined, key);
339
+ };
340
+ /**
341
+ * Get a study variable value as a string
342
+ * @param key look up this study variable
343
+ * @returns return the value of the study variable
344
+ */
345
+ const getStudyVariableString = (key) => {
346
+ return expressionUtils_expressionGen.generateExpression('getStudyVariableString', undefined, key);
347
+ };
348
+ /**
349
+ * Get a study variable value as an integer
350
+ * @param key look up this study variable
351
+ * @returns return the value of the study variable
352
+ */
353
+ const getStudyVariableInt = (key) => {
354
+ return expressionUtils_expressionGen.generateExpression('getStudyVariableInt', undefined, key);
355
+ };
356
+ /**
357
+ * Get a study variable value as a float
358
+ * @param key look up this study variable
359
+ * @returns return the value of the study variable
360
+ */
361
+ const getStudyVariableFloat = (key) => {
362
+ return expressionUtils_expressionGen.generateExpression('getStudyVariableFloat', undefined, key);
363
+ };
364
+ /**
365
+ * Get a study variable value as a date
366
+ * @param key look up this study variable
367
+ * @returns return the value of the study variable in posix timestamp format (seconds since 1970-01-01 00:00:00 UTC)
368
+ */
369
+ const getStudyVariableDate = (key) => {
370
+ return expressionUtils_expressionGen.generateExpression('getStudyVariableDate', undefined, key);
371
+ };
324
372
  /**
325
373
  * Check if the participant is logged in currently.
326
374
  * @returns true if context variable isLoggedIn is set and true
@@ -443,6 +491,13 @@ const SurveyEngine = Object.assign(Object.assign({}, NativeSurveyEngineExpressio
443
491
  hasKey: hasParticipantFlagKey,
444
492
  hasKeyAndValue: hasParticipantFlagKeyAndValue,
445
493
  getAsNum: parseParticipantFlagAsNum,
494
+ }, studyVariables: {
495
+ hasKey: hasStudyVariableKey,
496
+ getBoolean: getStudyVariableBoolean,
497
+ getString: getStudyVariableString,
498
+ getInt: getStudyVariableInt,
499
+ getFloat: getStudyVariableFloat,
500
+ getDate: getStudyVariableDate,
446
501
  }, isLoggedIn });
447
502
 
448
503
  exports.NativeSurveyEngineExpressions = NativeSurveyEngineExpressions;
@@ -1 +1 @@
1
- {"version":3,"file":"survey-engine-expressions.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"survey-engine-expressions.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}