case-editor-tools 1.0.5 → 1.0.6

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;
@@ -75,11 +76,13 @@ export declare const StudyEngineActions: {
75
76
  add: (messageType: string, scheduledFor: number | Expression) => Expression;
76
77
  removeAll: () => Expression;
77
78
  remove: (messageType: string) => Expression;
79
+ notifyResearcher: (messageType: string, ...payload: Expression[] | string[]) => Expression;
78
80
  };
79
81
  confidentialResponses: {
80
82
  removeByKey: (key: string) => Expression;
81
83
  removeAll: () => Expression;
82
84
  };
85
+ externalEventHandler: (serviceName: string) => Expression;
83
86
  stopParticipation: () => Expression;
84
87
  finishParticipation: () => Expression;
85
88
  };
@@ -139,11 +142,13 @@ export declare const StudyEngine: {
139
142
  add: (messageType: string, scheduledFor: number | Expression) => Expression;
140
143
  removeAll: () => Expression;
141
144
  remove: (messageType: string) => Expression;
145
+ notifyResearcher: (messageType: string, ...payload: Expression[] | string[]) => Expression;
142
146
  };
143
147
  confidentialResponses: {
144
148
  removeByKey: (key: string) => Expression;
145
149
  removeAll: () => Expression;
146
150
  };
151
+ externalEventHandler: (serviceName: string) => Expression;
147
152
  stopParticipation: () => Expression;
148
153
  finishParticipation: () => Expression;
149
154
  };
@@ -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,
@@ -443,11 +465,13 @@ const StudyEngineActions = {
443
465
  add: ADD_MESSAGE,
444
466
  removeAll: REMOVE_ALL_MESSAGES,
445
467
  remove: REMOVE_MESSAGES_BY_TYPE,
468
+ notifyResearcher: NOTIFY_RESEARCHER,
446
469
  },
447
470
  confidentialResponses: {
448
471
  removeByKey: REMOVE_CONFIDENTIAL_RESPONSE_BY_KEY,
449
472
  removeAll: REMOVE_ALL_CONFIDENTIAL_RESPONSES,
450
473
  },
474
+ externalEventHandler: EXTERNAL_EVENT_HANDLER,
451
475
  // Extra methods:
452
476
  stopParticipation,
453
477
  finishParticipation,
@@ -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.5",
4
+ "version": "1.0.6",
5
5
  "main": "index.js",
6
6
  "license": "Apache-2.0",
7
7
  "repository": "github:case-framework/case-editor-tools",