case-editor-tools 1.6.11 → 1.6.13

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.
@@ -1,5 +1,6 @@
1
1
  import { Expression } from "survey-engine/data_types";
2
2
  import { Duration } from "../types/duration";
3
+ declare type Month = 'January' | 'February' | 'March' | 'April' | 'May' | 'June' | 'July' | 'August' | 'September' | 'October' | 'November' | 'December';
3
4
  export declare const NativeStudyEngineExpressions: {
4
5
  checkEventType: (equalsType: 'ENTER' | 'SUBMIT' | 'TIMER' | 'MERGE' | 'CUSTOM' | 'LEAVE') => Expression;
5
6
  checkEventKey: (equalsKey: string) => Expression;
@@ -66,6 +67,7 @@ export declare const NativeStudyEngineExpressions: {
66
67
  neg: (value: Expression | number) => Expression;
67
68
  timestampWithOffset: (delta: Duration, reference?: number | Expression) => Expression;
68
69
  getISOWeekForTs: (ts: number | Expression) => Expression;
70
+ getTsForNextStartOfMonth: (month: Month | Expression, reference?: number | Expression) => Expression;
69
71
  getTsForNextISOWeek: (ISOWeek: number | Expression, reference?: number | Expression) => Expression;
70
72
  parseValueAsNum: (valueRef: Expression | string | number) => Expression;
71
73
  generateRandomNumber: (min: number, max: number) => Expression;
@@ -251,8 +253,10 @@ export declare const StudyEngine: {
251
253
  neg: (value: Expression | number) => Expression;
252
254
  timestampWithOffset: (delta: Duration, reference?: number | Expression) => Expression;
253
255
  getISOWeekForTs: (ts: number | Expression) => Expression;
256
+ getTsForNextStartOfMonth: (month: Month | Expression, reference?: number | Expression) => Expression;
254
257
  getTsForNextISOWeek: (ISOWeek: number | Expression, reference?: number | Expression) => Expression;
255
258
  parseValueAsNum: (valueRef: Expression | string | number) => Expression;
256
259
  generateRandomNumber: (min: number, max: number) => Expression;
257
260
  externalEventEval: (serviceName: string, route?: string, expectFloat?: boolean) => Expression;
258
261
  };
262
+ export {};
@@ -213,6 +213,13 @@ const timestampWithOffset = (delta, reference) => expressionUtils_expressionGen.
213
213
  * @returns
214
214
  */
215
215
  const getISOWeekForTs = (ts) => expressionUtils_expressionGen.generateExpression('getISOWeekForTs', undefined, ts);
216
+ /**
217
+ * Generate a timestamp value (POSIX timestamp) for the beginning of the month for the first time that is later than the reference
218
+ * @param month which ISO week should be used for the timestamp generation
219
+ * @param reference optional - a hard coded number, or an expression that should retrieve a timestamp (e.g., surveys assigned from, or response to a date question)
220
+ * @returns
221
+ */
222
+ const getTsForNextStartOfMonth = (month, reference) => expressionUtils_expressionGen.generateExpression('getTsForNextStartOfMonth', undefined, month, reference ? reference : undefined);
216
223
  /**
217
224
  * Generate a timestamp value (POSIX timestamp) for the beginning of the week for the first time that is later than the reference and has the ISO week as defined in argument ISOWeek.
218
225
  * @param ISOWeek which ISO week should be used for the timestamp generation
@@ -560,6 +567,7 @@ const NativeStudyEngineExpressions = {
560
567
  // Other
561
568
  timestampWithOffset,
562
569
  getISOWeekForTs,
570
+ getTsForNextStartOfMonth,
563
571
  getTsForNextISOWeek,
564
572
  parseValueAsNum,
565
573
  generateRandomNumber: (min, max) => expressionUtils_expressionGen.generateExpression('generateRandomNumber', undefined, min, max),
@@ -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.11",
4
+ "version": "1.6.13",
5
5
  "main": "index.js",
6
6
  "license": "Apache-2.0",
7
7
  "repository": "github:case-framework/case-editor-tools",
@@ -78,7 +78,7 @@ export declare const SurveyEngine: {
78
78
  };
79
79
  participantFlags: {
80
80
  hasKey: (key: string) => Expression;
81
- hasKeyAndValue: (key: string, value: string) => Expression;
81
+ hasKeyAndValue: (key: string, value: string | Expression) => Expression;
82
82
  getAsNum: (key: string) => Expression;
83
83
  };
84
84
  isLoggedIn: () => Expression;
@@ -302,7 +302,7 @@ const dateResponseDiffFromNow = (itemKey, responseKey, unit, ignoreSign) => {
302
302
  * @returns
303
303
  */
304
304
  const parseParticipantFlagAsNum = (key) => {
305
- return parseValueAsNum(getAttribute(getAttribute(getContext(), 'participantFlags'), key));
305
+ return parseValueAsNum(expressionUtils_expressionGen.generateExpression('getParticipantFlagValue', undefined, key));
306
306
  };
307
307
  /**
308
308
  * Check participant flags object if contains the specified key value pair
@@ -310,7 +310,7 @@ const parseParticipantFlagAsNum = (key) => {
310
310
  * @returns
311
311
  */
312
312
  const hasParticipantFlagKey = (key) => {
313
- return isDefined(getAttribute(getAttribute(getContext(), 'participantFlags'), key));
313
+ return expressionUtils_expressionGen.generateExpression('hasParticipantFlagKey', undefined, key);
314
314
  };
315
315
  /**
316
316
  * Check participant flags object if contains the specified key value pair
@@ -319,7 +319,7 @@ const hasParticipantFlagKey = (key) => {
319
319
  * @returns
320
320
  */
321
321
  const hasParticipantFlagKeyAndValue = (key, value) => {
322
- return eq(getAttribute(getAttribute(getContext(), 'participantFlags'), key), value);
322
+ return expressionUtils_expressionGen.generateExpression('hasParticipantFlagKeyAndValue', undefined, key, value);
323
323
  };
324
324
  /**
325
325
  * Check if the participant is logged in currently.