case-editor-tools 1.0.4 → 1.0.7

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.
@@ -47,6 +47,7 @@ export declare const NativeStudyEngineExpressions: {
47
47
  and: (...args: Expression[]) => Expression;
48
48
  not: (arg: Expression) => Expression;
49
49
  timestampWithOffset: (delta: Duration, reference?: number | Expression | undefined) => Expression;
50
+ externalEventEval: (serviceName: string, expectFloat?: boolean | undefined) => Expression;
50
51
  };
51
52
  export declare const StudyEngineActions: {
52
53
  if: (condition: Expression, actionIfTrue: Expression, actionIfFalse?: Expression | undefined) => Expression;
@@ -80,9 +81,11 @@ export declare const StudyEngineActions: {
80
81
  removeByKey: (key: string) => Expression;
81
82
  removeAll: () => Expression;
82
83
  };
84
+ externalEventHandler: (serviceName: string) => Expression;
83
85
  stopParticipation: () => Expression;
84
86
  finishParticipation: () => Expression;
85
87
  };
88
+ notifyResearcher: (messageType: string, ...payload: Expression[] | string[]) => Expression;
86
89
  };
87
90
  export declare const StudyEngine: {
88
91
  singleChoice: {
@@ -144,9 +147,11 @@ export declare const StudyEngine: {
144
147
  removeByKey: (key: string) => Expression;
145
148
  removeAll: () => Expression;
146
149
  };
150
+ externalEventHandler: (serviceName: string) => Expression;
147
151
  stopParticipation: () => Expression;
148
152
  finishParticipation: () => Expression;
149
153
  };
154
+ notifyResearcher: (messageType: string, ...payload: Expression[] | string[]) => Expression;
150
155
  checkEventType: (equalsType: 'ENTER' | 'SUBMIT' | 'TIMER' | 'MERGE') => Expression;
151
156
  checkSurveyResponseKey: (surveyKey: string) => Expression;
152
157
  responseHasKeysAny: (itemKey: string, responseSlotKey: string, ...optionKeys: string[]) => Expression;
@@ -193,4 +198,5 @@ export declare const StudyEngine: {
193
198
  and: (...args: Expression[]) => Expression;
194
199
  not: (arg: Expression) => Expression;
195
200
  timestampWithOffset: (delta: Duration, reference?: number | Expression | undefined) => Expression;
201
+ externalEventEval: (serviceName: string, expectFloat?: boolean | undefined) => Expression;
196
202
  };
@@ -174,6 +174,13 @@ const gte = (val1, val2) => expressionUtils_expressionGen.generateExpression('gt
174
174
  * @returns
175
175
  */
176
176
  const timestampWithOffset = (delta, reference) => expressionUtils_expressionGen.generateExpression('timestampWithOffset', undefined, types_duration.durationObjectToSeconds(delta), reference ? reference : undefined);
177
+ /**
178
+ *
179
+ * @param serviceName name of the external service endpoint that should be used (URL and API key are config of the service)
180
+ * @param expectFloat optional flag if the response value is expected to be a float (number) - by default, string is expected
181
+ * @returns
182
+ */
183
+ const externalEventEval = (serviceName, expectFloat) => expressionUtils_expressionGen.generateExpression('externalEventEval', expectFloat ? 'float' : undefined, serviceName);
177
184
  /**
178
185
  * Control flow method to use an if-else like structure
179
186
  * @param condition expression, return value interpreted as boolean
@@ -235,6 +242,12 @@ const REMOVE_ALL_MESSAGES = () => expressionUtils_expressionGen.generateExpressi
235
242
  * @returns
236
243
  */
237
244
  const REMOVE_MESSAGES_BY_TYPE = (messageType) => expressionUtils_expressionGen.generateExpression('REMOVE_MESSAGES_BY_TYPE', undefined, messageType);
245
+ /**
246
+ * Add a new notification message for the subscribed researchers
247
+ * @param messageType message type
248
+ * @returns
249
+ */
250
+ const NOTIFY_RESEARCHER = (messageType, ...payload) => expressionUtils_expressionGen.generateExpression('NOTIFY_RESEARCHER', undefined, messageType, ...payload);
238
251
  const REMOVE_SURVEY_BY_KEY = (surveyKey, selector) => {
239
252
  if (selector === 'all') {
240
253
  return expressionUtils_expressionGen.generateExpression('REMOVE_SURVEYS_BY_KEY', undefined, surveyKey);
@@ -302,6 +315,14 @@ const setReportMessage = (reportKey, content, asTranslationKey) => {
302
315
  const setReportSummary = (reportKey, content, asTranslationKey) => {
303
316
  return UPDATE_REPORT_DATA(reportKey, 'summary', content, asTranslationKey ? undefined : 'rawMessage');
304
317
  };
318
+ /**
319
+ * Method to call external event handler
320
+ * @param serviceName name of the external service endpoint that should be used (URL and API key are config of the service)
321
+ * @returns
322
+ */
323
+ const EXTERNAL_EVENT_HANDLER = (serviceName) => {
324
+ return expressionUtils_expressionGen.generateExpression('EXTERNAL_EVENT_HANDLER', undefined, serviceName);
325
+ };
305
326
  // ##################
306
327
  // Prefill rule methods:
307
328
  const PREFILL_SLOT_WITH_VALUE = (itemKey, slotKey, value) => {
@@ -414,6 +435,7 @@ const NativeStudyEngineExpressions = {
414
435
  not,
415
436
  // Other
416
437
  timestampWithOffset,
438
+ externalEventEval,
417
439
  };
418
440
  const StudyEngineActions = {
419
441
  if: IF,
@@ -448,10 +470,12 @@ const StudyEngineActions = {
448
470
  removeByKey: REMOVE_CONFIDENTIAL_RESPONSE_BY_KEY,
449
471
  removeAll: REMOVE_ALL_CONFIDENTIAL_RESPONSES,
450
472
  },
473
+ externalEventHandler: EXTERNAL_EVENT_HANDLER,
451
474
  // Extra methods:
452
475
  stopParticipation,
453
476
  finishParticipation,
454
- }
477
+ },
478
+ notifyResearcher: NOTIFY_RESEARCHER,
455
479
  };
456
480
  const StudyEngine = Object.assign(Object.assign(Object.assign({}, NativeStudyEngineExpressions), StudyEngineActions), { singleChoice: {
457
481
  any: singleChoiceOptionsSelected,
@@ -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.4",
4
+ "version": "1.0.7",
5
5
  "main": "index.js",
6
6
  "license": "Apache-2.0",
7
7
  "repository": "github:case-framework/case-editor-tools",
@@ -18,7 +18,7 @@ export declare const SingleChoiceOptionTypes: {
18
18
  textInput: (props: TextInputProps & {
19
19
  key: string;
20
20
  displayCondition?: Expression;
21
- alignText: 'start' | 'center' | 'end';
21
+ alignText?: 'start' | 'center' | 'end';
22
22
  }) => OptionDef;
23
23
  timeInput: (props: TimeInputProps & {
24
24
  key: string;
@@ -27,7 +27,7 @@ export declare const SingleChoiceOptionTypes: {
27
27
  numberInput: (props: NumericInputProps & {
28
28
  key: string;
29
29
  displayCondition?: Expression;
30
- alignText: 'start' | 'center' | 'end';
30
+ alignText?: 'start' | 'center' | 'end';
31
31
  }) => OptionDef;
32
32
  cloze: (props: ClozeProps & {
33
33
  key: string;
@@ -41,7 +41,7 @@ export declare const MultipleChoiceOptionTypes: {
41
41
  textInput: (props: TextInputProps & {
42
42
  key: string;
43
43
  displayCondition?: Expression;
44
- alignText: 'start' | 'center' | 'end';
44
+ alignText?: 'start' | 'center' | 'end';
45
45
  }) => OptionDef;
46
46
  timeInput: (props: TimeInputProps & {
47
47
  key: string;
@@ -50,7 +50,7 @@ export declare const MultipleChoiceOptionTypes: {
50
50
  numberInput: (props: NumericInputProps & {
51
51
  key: string;
52
52
  displayCondition?: Expression;
53
- alignText: 'start' | 'center' | 'end';
53
+ alignText?: 'start' | 'center' | 'end';
54
54
  }) => OptionDef;
55
55
  cloze: (props: ClozeProps & {
56
56
  key: string;
@@ -64,7 +64,7 @@ export declare const ClozeItemTypes: {
64
64
  textInput: (props: TextInputProps & {
65
65
  key: string;
66
66
  displayCondition?: Expression;
67
- alignText: 'start' | 'center' | 'end';
67
+ alignText?: 'start' | 'center' | 'end';
68
68
  }) => OptionDef;
69
69
  dateInput: (props: DateInputProps & {
70
70
  key: string;
@@ -78,7 +78,7 @@ export declare const ClozeItemTypes: {
78
78
  numberInput: (props: NumericInputProps & {
79
79
  key: string;
80
80
  displayCondition?: Expression;
81
- alignText: 'start' | 'center' | 'end';
81
+ alignText?: 'start' | 'center' | 'end';
82
82
  }) => OptionDef;
83
83
  dropDown: (props: {
84
84
  key: string;