@planning-inspectorate/dynamic-forms 3.3.3 → 3.4.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.
- package/.azure/pipelines/azure-pipelines-pr.yml +4 -0
- package/.azure/pipelines/release.yml +4 -0
- package/.gitattributes +2 -0
- package/README.md +20 -9
- package/package.json +13 -5
- package/src/components/address/question.js +1 -10
- package/src/components/boolean/question.js +1 -1
- package/src/components/checkbox/question.js +2 -6
- package/src/components/date/question.js +1 -8
- package/src/components/date-period/question.js +1 -8
- package/src/components/email/question.js +4 -4
- package/src/components/manage-list/question.test.js +4 -19
- package/src/components/multi-field-input/question.js +3 -3
- package/src/components/multi-field-input/question.test.js +1 -1
- package/src/components/number-entry/question.js +1 -5
- package/src/components/radio/question.js +1 -1
- package/src/components/select/question.js +1 -1
- package/src/components/single-line-input/question.js +0 -8
- package/src/components/text-entry/question.js +4 -4
- package/src/components/text-entry-redact/index.njk +15 -11
- package/src/components/text-entry-redact/question.js +6 -16
- package/src/components/unit-option-entry/question.js +4 -11
- package/src/components/utils/component-types.js +18 -0
- package/src/index.js +72 -25
- package/src/middleware/redirect-to-unanswered-question.test.js +1 -1
- package/src/questions/options-question.js +5 -12
- package/src/questions/question-types.d.ts +3 -3
- package/src/questions/question.js +6 -6
- package/src/questions/questions.js +1 -1
- package/test/check-your-answers.test.js +3 -8
- package/test/conditional-journey.test.js +431 -0
- package/test/questions.test.js +15 -28
- package/test/snapshots/secret-wish.html +15 -11
- package/test/utils/question-test-utils.js +52 -4
- package/test/utils/test-server.js +1 -0
- package/test/utils/utils.js +16 -1
- package/tsconfig.json +9 -1
- package/types/commitlint.config.d.ts +7 -0
- package/types/commitlint.config.d.ts.map +1 -0
- package/types/eslint.config.d.ts +95 -0
- package/types/eslint.config.d.ts.map +1 -0
- package/types/src/components/address/question.d.ts +31 -0
- package/types/src/components/address/question.d.ts.map +1 -0
- package/types/src/components/address/question.test.d.ts +2 -0
- package/types/src/components/address/question.test.d.ts.map +1 -0
- package/types/src/components/boolean/question.d.ts +47 -0
- package/types/src/components/boolean/question.d.ts.map +1 -0
- package/types/src/components/boolean/question.test.d.ts +2 -0
- package/types/src/components/boolean/question.test.d.ts.map +1 -0
- package/types/src/components/checkbox/question.d.ts +49 -0
- package/types/src/components/checkbox/question.d.ts.map +1 -0
- package/types/src/components/checkbox/question.test.d.ts +2 -0
- package/types/src/components/checkbox/question.test.d.ts.map +1 -0
- package/types/src/components/date/question.d.ts +22 -0
- package/types/src/components/date/question.d.ts.map +1 -0
- package/types/src/components/date/question.test.d.ts +2 -0
- package/types/src/components/date/question.test.d.ts.map +1 -0
- package/types/src/components/date-period/question.d.ts +29 -0
- package/types/src/components/date-period/question.d.ts.map +1 -0
- package/types/src/components/date-period/question.test.d.ts +2 -0
- package/types/src/components/date-period/question.test.d.ts.map +1 -0
- package/types/src/components/date-time/question.d.ts +24 -0
- package/types/src/components/date-time/question.d.ts.map +1 -0
- package/types/src/components/date-time/question.test.d.ts +2 -0
- package/types/src/components/date-time/question.test.d.ts.map +1 -0
- package/types/src/components/email/question.d.ts +30 -0
- package/types/src/components/email/question.d.ts.map +1 -0
- package/types/src/components/email/question.test.d.ts +2 -0
- package/types/src/components/email/question.test.d.ts.map +1 -0
- package/types/src/components/identifier/question.d.ts +15 -0
- package/types/src/components/identifier/question.d.ts.map +1 -0
- package/types/src/components/identifier/question.test.d.ts +2 -0
- package/types/src/components/identifier/question.test.d.ts.map +1 -0
- package/types/src/components/manage-list/manage-list-section.d.ts +16 -0
- package/types/src/components/manage-list/manage-list-section.d.ts.map +1 -0
- package/types/src/components/manage-list/manage-list-section.test.d.ts +2 -0
- package/types/src/components/manage-list/manage-list-section.test.d.ts.map +1 -0
- package/types/src/components/manage-list/question.d.ts +41 -0
- package/types/src/components/manage-list/question.d.ts.map +1 -0
- package/types/src/components/manage-list/question.test.d.ts +2 -0
- package/types/src/components/manage-list/question.test.d.ts.map +1 -0
- package/types/src/components/manage-list/utils.d.ts +18 -0
- package/types/src/components/manage-list/utils.d.ts.map +1 -0
- package/types/src/components/manage-list/utils.test.d.ts +2 -0
- package/types/src/components/manage-list/utils.test.d.ts.map +1 -0
- package/types/src/components/multi-field-input/question.d.ts +106 -0
- package/types/src/components/multi-field-input/question.d.ts.map +1 -0
- package/types/src/components/multi-field-input/question.test.d.ts +2 -0
- package/types/src/components/multi-field-input/question.test.d.ts.map +1 -0
- package/types/src/components/number-entry/question.d.ts +37 -0
- package/types/src/components/number-entry/question.d.ts.map +1 -0
- package/types/src/components/radio/question.d.ts +53 -0
- package/types/src/components/radio/question.d.ts.map +1 -0
- package/types/src/components/radio/question.test.d.ts +2 -0
- package/types/src/components/radio/question.test.d.ts.map +1 -0
- package/types/src/components/select/question.d.ts +51 -0
- package/types/src/components/select/question.d.ts.map +1 -0
- package/types/src/components/select/question.test.d.ts +2 -0
- package/types/src/components/select/question.test.d.ts.map +1 -0
- package/types/src/components/single-line-input/question.d.ts +18 -0
- package/types/src/components/single-line-input/question.d.ts.map +1 -0
- package/types/src/components/single-line-input/question.test.d.ts +2 -0
- package/types/src/components/single-line-input/question.test.d.ts.map +1 -0
- package/types/src/components/text-entry/question.d.ts +34 -0
- package/types/src/components/text-entry/question.d.ts.map +1 -0
- package/types/src/components/text-entry/question.test.d.ts +2 -0
- package/types/src/components/text-entry/question.test.d.ts.map +1 -0
- package/types/src/components/text-entry-redact/question.d.ts +42 -0
- package/types/src/components/text-entry-redact/question.d.ts.map +1 -0
- package/types/src/components/text-entry-redact/question.test.d.ts +2 -0
- package/types/src/components/text-entry-redact/question.test.d.ts.map +1 -0
- package/types/src/components/unit-option-entry/question.d.ts +83 -0
- package/types/src/components/unit-option-entry/question.d.ts.map +1 -0
- package/types/src/components/unit-option-entry/question.test.d.ts +2 -0
- package/types/src/components/unit-option-entry/question.test.d.ts.map +1 -0
- package/types/src/components/utils/component-types.d.ts +19 -0
- package/types/src/components/utils/component-types.d.ts.map +1 -0
- package/types/src/components/utils/persisted-number-answer.d.ts +2 -0
- package/types/src/components/utils/persisted-number-answer.d.ts.map +1 -0
- package/types/src/components/utils/question-has-answer.d.ts +17 -0
- package/types/src/components/utils/question-has-answer.d.ts.map +1 -0
- package/types/src/components/utils/question-has-answer.test.d.ts +2 -0
- package/types/src/components/utils/question-has-answer.test.d.ts.map +1 -0
- package/types/src/components/utils/question-utils.d.ts +15 -0
- package/types/src/components/utils/question-utils.d.ts.map +1 -0
- package/types/src/components/utils/question-utils.test.d.ts +2 -0
- package/types/src/components/utils/question-utils.test.d.ts.map +1 -0
- package/types/src/controller.d.ts +78 -0
- package/types/src/controller.d.ts.map +1 -0
- package/types/src/controller.test.d.ts +2 -0
- package/types/src/controller.test.d.ts.map +1 -0
- package/types/src/index.d.ts +54 -0
- package/types/src/index.d.ts.map +1 -0
- package/types/src/journey/journey-response.d.ts +32 -0
- package/types/src/journey/journey-response.d.ts.map +1 -0
- package/types/src/journey/journey-response.test.d.ts +2 -0
- package/types/src/journey/journey-response.test.d.ts.map +1 -0
- package/types/src/journey/journey.d.ts +144 -0
- package/types/src/journey/journey.d.ts.map +1 -0
- package/types/src/journey/journey.test.d.ts +2 -0
- package/types/src/journey/journey.test.d.ts.map +1 -0
- package/types/src/lib/address-utils.d.ts +6 -0
- package/types/src/lib/address-utils.d.ts.map +1 -0
- package/types/src/lib/address-utils.test.d.ts +2 -0
- package/types/src/lib/address-utils.test.d.ts.map +1 -0
- package/types/src/lib/address.d.ts +43 -0
- package/types/src/lib/address.d.ts.map +1 -0
- package/types/src/lib/address.test.d.ts +2 -0
- package/types/src/lib/address.test.d.ts.map +1 -0
- package/types/src/lib/date-utils.d.ts +60 -0
- package/types/src/lib/date-utils.d.ts.map +1 -0
- package/types/src/lib/date-utils.test.d.ts +2 -0
- package/types/src/lib/date-utils.test.d.ts.map +1 -0
- package/types/src/lib/session-answer-store.d.ts +84 -0
- package/types/src/lib/session-answer-store.d.ts.map +1 -0
- package/types/src/lib/session-answer-store.test.d.ts +2 -0
- package/types/src/lib/session-answer-store.test.d.ts.map +1 -0
- package/types/src/lib/utils.d.ts +19 -0
- package/types/src/lib/utils.d.ts.map +1 -0
- package/types/src/lib/utils.test.d.ts +2 -0
- package/types/src/lib/utils.test.d.ts.map +1 -0
- package/types/src/lib/uuid.d.ts +7 -0
- package/types/src/lib/uuid.d.ts.map +1 -0
- package/types/src/lib/uuid.test.d.ts +2 -0
- package/types/src/lib/uuid.test.d.ts.map +1 -0
- package/types/src/middleware/build-get-journey.d.ts +6 -0
- package/types/src/middleware/build-get-journey.d.ts.map +1 -0
- package/types/src/middleware/redirect-to-unanswered-question.d.ts +12 -0
- package/types/src/middleware/redirect-to-unanswered-question.d.ts.map +1 -0
- package/types/src/middleware/redirect-to-unanswered-question.test.d.ts +2 -0
- package/types/src/middleware/redirect-to-unanswered-question.test.d.ts.map +1 -0
- package/types/src/questions/create-questions.d.ts +21 -0
- package/types/src/questions/create-questions.d.ts.map +1 -0
- package/types/src/questions/options-question.d.ts +74 -0
- package/types/src/questions/options-question.d.ts.map +1 -0
- package/types/src/questions/options-question.test.d.ts +2 -0
- package/types/src/questions/options-question.test.d.ts.map +1 -0
- package/types/src/questions/question.d.ts +274 -0
- package/types/src/questions/question.d.ts.map +1 -0
- package/types/src/questions/question.test.d.ts +2 -0
- package/types/src/questions/question.test.d.ts.map +1 -0
- package/types/src/questions/questions.d.ts +3 -0
- package/types/src/questions/questions.d.ts.map +1 -0
- package/types/src/section.d.ts +107 -0
- package/types/src/section.d.ts.map +1 -0
- package/types/src/section.test.d.ts +2 -0
- package/types/src/section.test.d.ts.map +1 -0
- package/types/src/validator/address-validator.d.ts +41 -0
- package/types/src/validator/address-validator.d.ts.map +1 -0
- package/types/src/validator/address-validator.test.d.ts +2 -0
- package/types/src/validator/address-validator.test.d.ts.map +1 -0
- package/types/src/validator/base-validator.d.ts +11 -0
- package/types/src/validator/base-validator.d.ts.map +1 -0
- package/types/src/validator/base-validator.test.d.ts +2 -0
- package/types/src/validator/base-validator.test.d.ts.map +1 -0
- package/types/src/validator/conditional-required-validator.d.ts +24 -0
- package/types/src/validator/conditional-required-validator.d.ts.map +1 -0
- package/types/src/validator/conditional-required-validator.test.d.ts +2 -0
- package/types/src/validator/conditional-required-validator.test.d.ts.map +1 -0
- package/types/src/validator/confirmation-checkbox-validator.d.ts +27 -0
- package/types/src/validator/confirmation-checkbox-validator.d.ts.map +1 -0
- package/types/src/validator/confirmation-checkbox-validator.test.d.ts +2 -0
- package/types/src/validator/confirmation-checkbox-validator.test.d.ts.map +1 -0
- package/types/src/validator/coordinates-validator.d.ts +22 -0
- package/types/src/validator/coordinates-validator.d.ts.map +1 -0
- package/types/src/validator/coordinates-validator.test.d.ts +2 -0
- package/types/src/validator/coordinates-validator.test.d.ts.map +1 -0
- package/types/src/validator/date-period-validator.d.ts +63 -0
- package/types/src/validator/date-period-validator.d.ts.map +1 -0
- package/types/src/validator/date-period-validator.test.d.ts +2 -0
- package/types/src/validator/date-period-validator.test.d.ts.map +1 -0
- package/types/src/validator/date-time-validator.d.ts +26 -0
- package/types/src/validator/date-time-validator.d.ts.map +1 -0
- package/types/src/validator/date-time-validator.test.d.ts +2 -0
- package/types/src/validator/date-time-validator.test.d.ts.map +1 -0
- package/types/src/validator/date-validator.d.ts +48 -0
- package/types/src/validator/date-validator.d.ts.map +1 -0
- package/types/src/validator/date-validator.test.d.ts +2 -0
- package/types/src/validator/date-validator.test.d.ts.map +1 -0
- package/types/src/validator/document-upload-validator.d.ts +10 -0
- package/types/src/validator/document-upload-validator.d.ts.map +1 -0
- package/types/src/validator/document-upload-validator.test.d.ts +2 -0
- package/types/src/validator/document-upload-validator.test.d.ts.map +1 -0
- package/types/src/validator/email-validator.d.ts +73 -0
- package/types/src/validator/email-validator.d.ts.map +1 -0
- package/types/src/validator/email-validator.test.d.ts +2 -0
- package/types/src/validator/email-validator.test.d.ts.map +1 -0
- package/types/src/validator/multi-field-input-validator.d.ts +70 -0
- package/types/src/validator/multi-field-input-validator.d.ts.map +1 -0
- package/types/src/validator/multi-field-input-validator.test.d.ts +2 -0
- package/types/src/validator/multi-field-input-validator.test.d.ts.map +1 -0
- package/types/src/validator/numeric-validator.d.ts +49 -0
- package/types/src/validator/numeric-validator.d.ts.map +1 -0
- package/types/src/validator/numeric-validator.test.d.ts +2 -0
- package/types/src/validator/numeric-validator.test.d.ts.map +1 -0
- package/types/src/validator/required-validator.d.ts +22 -0
- package/types/src/validator/required-validator.d.ts.map +1 -0
- package/types/src/validator/required-validator.test.d.ts +2 -0
- package/types/src/validator/required-validator.test.d.ts.map +1 -0
- package/types/src/validator/same-answer-validator.d.ts +18 -0
- package/types/src/validator/same-answer-validator.d.ts.map +1 -0
- package/types/src/validator/same-answer-validator.test.d.ts +2 -0
- package/types/src/validator/same-answer-validator.test.d.ts.map +1 -0
- package/types/src/validator/string-validator.d.ts +58 -0
- package/types/src/validator/string-validator.d.ts.map +1 -0
- package/types/src/validator/string-validator.test.d.ts +2 -0
- package/types/src/validator/string-validator.test.d.ts.map +1 -0
- package/types/src/validator/unit-option-entry-validator.d.ts +40 -0
- package/types/src/validator/unit-option-entry-validator.d.ts.map +1 -0
- package/types/src/validator/unit-option-entry-validator.test.d.ts +2 -0
- package/types/src/validator/unit-option-entry-validator.test.d.ts.map +1 -0
- package/types/src/validator/valid-option-validator.d.ts +22 -0
- package/types/src/validator/valid-option-validator.d.ts.map +1 -0
- package/types/src/validator/valid-option-validator.test.d.ts +2 -0
- package/types/src/validator/valid-option-validator.test.d.ts.map +1 -0
- package/types/src/validator/validation-error-handler.d.ts +20 -0
- package/types/src/validator/validation-error-handler.d.ts.map +1 -0
- package/types/src/validator/validation-error-handler.test.d.ts +2 -0
- package/types/src/validator/validation-error-handler.test.d.ts.map +1 -0
- package/types/src/validator/validator.d.ts +5 -0
- package/types/src/validator/validator.d.ts.map +1 -0
- package/types/src/validator/validator.test.d.ts +2 -0
- package/types/src/validator/validator.test.d.ts.map +1 -0
- package/types/test/mock/journey.d.ts +3 -0
- package/types/test/mock/journey.d.ts.map +1 -0
- package/types/test/mock/uuid.d.ts +7 -0
- package/types/test/mock/uuid.d.ts.map +1 -0
- package/types/test/utils/nunjucks.d.ts +2 -0
- package/types/test/utils/nunjucks.d.ts.map +1 -0
- package/types/test/utils/utils.d.ts +32 -0
- package/types/test/utils/utils.d.ts.map +1 -0
- package/src/lib/address.d.ts +0 -7
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display the date in Europe/London
|
|
3
|
+
* @param {Date|string} [date]
|
|
4
|
+
* @param {Object} [options]
|
|
5
|
+
* @param {string} [options.format] date formatting string
|
|
6
|
+
* @returns {string} formatted date string or empty string if invalid value passed in
|
|
7
|
+
*/
|
|
8
|
+
export function formatDateForDisplay(date?: Date | string, { format }?: {
|
|
9
|
+
format?: string | undefined;
|
|
10
|
+
}): string;
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {Object} DateTimeParams
|
|
13
|
+
* @property {number} year
|
|
14
|
+
* @property {number} month
|
|
15
|
+
* @property {number} day
|
|
16
|
+
* @property {number} [hour]
|
|
17
|
+
* @property {number} [minute]
|
|
18
|
+
* @property {number} [second]
|
|
19
|
+
* @property {boolean} [convertToUTC]
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Parse the date and time parameters provided by a user
|
|
23
|
+
* @param {DateTimeParams} params
|
|
24
|
+
* @returns {Date}
|
|
25
|
+
*/
|
|
26
|
+
export function parseDateInput({ year, month, day, hour, minute, second }: DateTimeParams): Date;
|
|
27
|
+
/**
|
|
28
|
+
* Start of the day in UK time zone
|
|
29
|
+
*/
|
|
30
|
+
export function startOfDay(): Date;
|
|
31
|
+
/**
|
|
32
|
+
* End of the day in UK time zone
|
|
33
|
+
*/
|
|
34
|
+
export function endOfDay(): Date;
|
|
35
|
+
/**
|
|
36
|
+
* Check if today is within the date range inclusive (start <= now <= end)
|
|
37
|
+
* @param {Date} startDate
|
|
38
|
+
* @param {Date} endDate
|
|
39
|
+
* @returns {boolean}
|
|
40
|
+
*/
|
|
41
|
+
export function nowIsWithinRange(startDate: Date, endDate: Date): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Check if today is on or after the start date
|
|
44
|
+
* @param {Date} startDate
|
|
45
|
+
* @returns {boolean}
|
|
46
|
+
*/
|
|
47
|
+
export function isNowAfterStartDate(startDate: Date): boolean;
|
|
48
|
+
export function dateIsAfterToday(date: Date): boolean;
|
|
49
|
+
export function dateIsBeforeToday(date: Date): boolean;
|
|
50
|
+
export function dateIsToday(date: Date): boolean;
|
|
51
|
+
export type DateTimeParams = {
|
|
52
|
+
year: number;
|
|
53
|
+
month: number;
|
|
54
|
+
day: number;
|
|
55
|
+
hour?: number | undefined;
|
|
56
|
+
minute?: number | undefined;
|
|
57
|
+
second?: number | undefined;
|
|
58
|
+
convertToUTC?: boolean | undefined;
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=date-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/date-utils.js"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,4CALW,IAAI,GAAC,MAAM,eAEnB;IAAyB,MAAM;CAC/B,GAAU,MAAM,CAMlB;AAED;;;;;;;;;GASG;AAEH;;;;GAIG;AACH,2EAHW,cAAc,GACZ,IAAI,CAMhB;AAED;;GAEG;AACH,mCAWC;AAED;;GAEG;AACH,iCAWC;AAqCD;;;;;GAKG;AACH,4CAJW,IAAI,WACJ,IAAI,GACF,OAAO,CASnB;AAED;;;;GAIG;AACH,+CAHW,IAAI,GACF,OAAO,CASnB;AA/CM,uCAHI,IAAI,GACF,OAAO,CAInB;AAMM,wCAHI,IAAI,GACF,OAAO,CAInB;AAMM,kCAHI,IAAI,GACF,OAAO,CAInB;;UArFa,MAAM;WACN,MAAM;SACN,MAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-utils.test.d.ts","sourceRoot":"","sources":["../../../src/lib/date-utils.test.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A `SaveDataFn` implementation that saves answers to the session.
|
|
3
|
+
* Answers are saved into a forms object, keyed by the journeyId, and optionally by a request parameter
|
|
4
|
+
* @example
|
|
5
|
+
* req: {
|
|
6
|
+
* session: {
|
|
7
|
+
* forms: {
|
|
8
|
+
* 'journey-id-1': {
|
|
9
|
+
* questionOne: 'my answer'
|
|
10
|
+
* // ...
|
|
11
|
+
* }
|
|
12
|
+
* }
|
|
13
|
+
* }
|
|
14
|
+
* }
|
|
15
|
+
*
|
|
16
|
+
* or when keyed by a req parameter:
|
|
17
|
+
* @example
|
|
18
|
+
* req: {
|
|
19
|
+
* session: {
|
|
20
|
+
* forms: {
|
|
21
|
+
* 'some-req-param': {
|
|
22
|
+
* 'journey-id-1': {
|
|
23
|
+
* questionOne: 'my answer'
|
|
24
|
+
* // ...
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* }
|
|
30
|
+
*
|
|
31
|
+
*
|
|
32
|
+
* @param {Object} opts
|
|
33
|
+
* @param {string} [opts.reqParam]
|
|
34
|
+
* - optional request parameter to use as a key
|
|
35
|
+
* @returns {import('../controller').SaveDataFn}
|
|
36
|
+
*/
|
|
37
|
+
export function buildSaveDataToSession({ reqParam }?: {
|
|
38
|
+
reqParam?: string | undefined;
|
|
39
|
+
}): any;
|
|
40
|
+
/**
|
|
41
|
+
* A function to clear journey answers from the session
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* req: {
|
|
45
|
+
* session: {
|
|
46
|
+
* forms: {
|
|
47
|
+
* 'journey-id-1': {
|
|
48
|
+
* questionOne: 'my answer'
|
|
49
|
+
* // ...
|
|
50
|
+
* }
|
|
51
|
+
* }
|
|
52
|
+
* }
|
|
53
|
+
* }
|
|
54
|
+
*
|
|
55
|
+
* @param {Object} params
|
|
56
|
+
* @param {import('express').Request} params.req
|
|
57
|
+
* @param {string} params.journeyId
|
|
58
|
+
* @param {Object<string, any>} [params.replaceWith] - optional data to replace the form answers with
|
|
59
|
+
* @param {string} [params.reqParam] - optional request parameter used as a key
|
|
60
|
+
* @returns {void}
|
|
61
|
+
*/
|
|
62
|
+
export function clearDataFromSession({ req, journeyId, replaceWith, reqParam }: {
|
|
63
|
+
req: any;
|
|
64
|
+
journeyId: string;
|
|
65
|
+
replaceWith?: {
|
|
66
|
+
[x: string]: any;
|
|
67
|
+
} | undefined;
|
|
68
|
+
reqParam?: string | undefined;
|
|
69
|
+
}): void;
|
|
70
|
+
/**
|
|
71
|
+
* Fetch session answers from the session
|
|
72
|
+
*
|
|
73
|
+
* @param {string} journeyId
|
|
74
|
+
* @param {string} [reqParam] - optional request parameter used as a key
|
|
75
|
+
* @returns {import('express').Handler}
|
|
76
|
+
*/
|
|
77
|
+
export function buildGetJourneyResponseFromSession(journeyId: string, reqParam?: string): any;
|
|
78
|
+
/**
|
|
79
|
+
* Default save-to-session function with no request parameter
|
|
80
|
+
*
|
|
81
|
+
* @type {import('../controller').SaveDataFn}
|
|
82
|
+
*/
|
|
83
|
+
export const saveDataToSession: any;
|
|
84
|
+
//# sourceMappingURL=session-answer-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-answer-store.d.ts","sourceRoot":"","sources":["../../../src/lib/session-answer-store.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,sDAJG;IAAsB,QAAQ;CAE9B,OA4BF;AASD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,gFANG;IAA0C,GAAG,EAArC,GAAyB;IACV,SAAS,EAAxB,MAAM;IACuB,WAAW;;;IACxB,QAAQ;CAChC,GAAU,IAAI,CAkBhB;AAED;;;;;;GAMG;AACH,8DAJW,MAAM,aACN,MAAM,OA4BhB;AA/ED;;;;GAIG;AACH,oCAA0D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-answer-store.test.d.ts","sourceRoot":"","sources":["../../../src/lib/session-answer-store.test.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* replaces new line chars with a <br>
|
|
3
|
+
* @param {string} [value]
|
|
4
|
+
* @returns {string}
|
|
5
|
+
*/
|
|
6
|
+
export function nl2br(value?: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* @param {string|any} str
|
|
9
|
+
* @returns {string}
|
|
10
|
+
*/
|
|
11
|
+
export function capitalize(str: string | any): string;
|
|
12
|
+
/**
|
|
13
|
+
* Trim a trailing slash if present
|
|
14
|
+
*
|
|
15
|
+
* @param {string} [str]
|
|
16
|
+
* @returns {string}
|
|
17
|
+
*/
|
|
18
|
+
export function trimTrailingSlash(str?: string): string;
|
|
19
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,8BAHW,MAAM,GACJ,MAAM,CAMlB;AAED;;;GAGG;AACH,gCAHW,MAAM,GAAC,GAAG,GACR,MAAM,CAKlB;AAED;;;;;GAKG;AACH,wCAHW,MAAM,GACJ,MAAM,CAKlB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.test.d.ts","sourceRoot":"","sources":["../../../src/lib/utils.test.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../../../src/lib/uuid.js"],"names":[],"mappings":"AAEA;;GAEG;AACH;IACC,yEAEC;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uuid.test.d.ts","sourceRoot":"","sources":["../../../src/lib/uuid.test.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {(req: import('express').Request, journeyResponse: import('../journey/journey-response.js').JourneyResponse) => import('../journey/journey.js').Journey} createJourney
|
|
3
|
+
* @returns {import('express').Handler}
|
|
4
|
+
*/
|
|
5
|
+
export function buildGetJourney(createJourney: (req: any, journeyResponse: import("../journey/journey-response.js").JourneyResponse) => import("../journey/journey.js").Journey): any;
|
|
6
|
+
//# sourceMappingURL=build-get-journey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-get-journey.d.ts","sourceRoot":"","sources":["../../../src/middleware/build-get-journey.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH,+CAHW,CAAC,GAAG,EAAE,GAAyB,EAAE,eAAe,EAAE,OAAO,gCAAgC,EAAE,eAAe,KAAK,OAAO,uBAAuB,EAAE,OAAO,OAiBhK"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {function(import('../section').Question, import('../journey/journey-response').JourneyResponse): boolean} ShouldDisplayCondition
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Redirects to the first unanswered question in a journey, or to the task list if complete
|
|
6
|
+
*
|
|
7
|
+
* @param {ShouldDisplayCondition[]} [conditions]
|
|
8
|
+
* @returns {import('express').Handler}
|
|
9
|
+
*/
|
|
10
|
+
export function redirectToUnansweredQuestion(conditions?: ShouldDisplayCondition[]): any;
|
|
11
|
+
export type ShouldDisplayCondition = (arg0: any, arg1: any) => boolean;
|
|
12
|
+
//# sourceMappingURL=redirect-to-unanswered-question.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirect-to-unanswered-question.d.ts","sourceRoot":"","sources":["../../../src/middleware/redirect-to-unanswered-question.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;GAKG;AACH,0DAHW,sBAAsB,EAAE,OA+BlC;qCArCY,CAAS,IAA6B,EAA7B,GAA6B,EAAE,IAAqD,EAArD,GAAqD,KAAG,OAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirect-to-unanswered-question.test.d.ts","sourceRoot":"","sources":["../../../src/middleware/redirect-to-unanswered-question.test.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** @typedef {import('./question-props').QuestionProps} QuestionProps */
|
|
2
|
+
/**
|
|
3
|
+
* @param {{[questionName: string]: QuestionProps}} questionPropsRecord
|
|
4
|
+
* @param {Record<string, typeof import('./question').Question>} questionClasses
|
|
5
|
+
* @param {{[questionType: string]: Record<string, Function>}} questionMethodOverrides
|
|
6
|
+
* @param {{notStartedText?: string, continueButtonText?: string, changeActionText?: string, answerActionText?: string}} [textOverrides] - customise question text
|
|
7
|
+
*/
|
|
8
|
+
export function createQuestions(questionPropsRecord: {
|
|
9
|
+
[questionName: string]: QuestionProps;
|
|
10
|
+
}, questionClasses: Record<string, typeof import("./question").Question>, questionMethodOverrides: {
|
|
11
|
+
[questionType: string]: Record<string, Function>;
|
|
12
|
+
}, textOverrides?: {
|
|
13
|
+
notStartedText?: string;
|
|
14
|
+
continueButtonText?: string;
|
|
15
|
+
changeActionText?: string;
|
|
16
|
+
answerActionText?: string;
|
|
17
|
+
}): {
|
|
18
|
+
[k: string]: any;
|
|
19
|
+
};
|
|
20
|
+
export type QuestionProps = any;
|
|
21
|
+
//# sourceMappingURL=create-questions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-questions.d.ts","sourceRoot":"","sources":["../../../src/questions/create-questions.js"],"names":[],"mappings":"AAAA,wEAAwE;AAExE;;;;;GAKG;AACH,qDALW;IAAC,CAAC,YAAY,EAAE,MAAM,GAAG,aAAa,CAAA;CAAC,mBACvC,MAAM,CAAC,MAAM,EAAE,cAAc,YAAY,EAAE,QAAQ,CAAC,2BACpD;IAAC,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,WAAW,CAAA;CAAC,kBAClD;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAAC;;EAwBtH"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {{
|
|
3
|
+
* text: string;
|
|
4
|
+
* value: string;
|
|
5
|
+
* hint?: object;
|
|
6
|
+
* checked?: boolean | undefined;
|
|
7
|
+
* attributes?: Record<string, string>;
|
|
8
|
+
* behaviour?: 'exclusive';
|
|
9
|
+
* conditional?: {
|
|
10
|
+
* question: string;
|
|
11
|
+
* type: string;
|
|
12
|
+
* fieldName: string;
|
|
13
|
+
* inputClasses?: string;
|
|
14
|
+
* html?: string;
|
|
15
|
+
* value?: unknown;
|
|
16
|
+
* label?: string;
|
|
17
|
+
* hint?: string
|
|
18
|
+
* };
|
|
19
|
+
* conditionalText?: {
|
|
20
|
+
* html: string;
|
|
21
|
+
* }
|
|
22
|
+
*}} Option
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* @typedef {import('./question').QuestionViewModel & { question: { options: Option[] } }} OptionsViewModel
|
|
26
|
+
*/
|
|
27
|
+
export default class OptionsQuestion extends Question {
|
|
28
|
+
/**
|
|
29
|
+
* @param {import('#question-types').QuestionParameters} params
|
|
30
|
+
* @param {Array<Option>} params.options
|
|
31
|
+
*/
|
|
32
|
+
constructor(params: import("#question-types").QuestionParameters);
|
|
33
|
+
/** @type {Array<Option>} */
|
|
34
|
+
options: Array<Option>;
|
|
35
|
+
optionJoinString: string;
|
|
36
|
+
/**
|
|
37
|
+
* gets the view model for this question
|
|
38
|
+
* @param {import('#section').Section} section - the current section
|
|
39
|
+
* @param {import('#journey').Journey} journey - the journey we are in
|
|
40
|
+
* @param {Record<string, unknown>} [customViewData] additional data to send to view
|
|
41
|
+
* @param {Record<string, unknown>} [payload]
|
|
42
|
+
* @param {import('#src/questions/question-types.d.ts').PrepQuestionForRenderingOptions} options
|
|
43
|
+
* @returns {import('./question').QuestionViewModel} QuestionViewModel
|
|
44
|
+
*/
|
|
45
|
+
prepQuestionForRendering(section: import("#section").Section, journey: import("#journey").Journey, customViewData?: Record<string, unknown>, payload?: Record<string, unknown>, options: import("#src/questions/question-types.d.ts").PrepQuestionForRenderingOptions): any;
|
|
46
|
+
}
|
|
47
|
+
export type Option = {
|
|
48
|
+
text: string;
|
|
49
|
+
value: string;
|
|
50
|
+
hint?: object;
|
|
51
|
+
checked?: boolean | undefined;
|
|
52
|
+
attributes?: Record<string, string>;
|
|
53
|
+
behaviour?: "exclusive";
|
|
54
|
+
conditional?: {
|
|
55
|
+
question: string;
|
|
56
|
+
type: string;
|
|
57
|
+
fieldName: string;
|
|
58
|
+
inputClasses?: string;
|
|
59
|
+
html?: string;
|
|
60
|
+
value?: unknown;
|
|
61
|
+
label?: string;
|
|
62
|
+
hint?: string;
|
|
63
|
+
};
|
|
64
|
+
conditionalText?: {
|
|
65
|
+
html: string;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
export type OptionsViewModel = any & {
|
|
69
|
+
question: {
|
|
70
|
+
options: Option[];
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
import { Question } from './question.js';
|
|
74
|
+
//# sourceMappingURL=options-question.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options-question.d.ts","sourceRoot":"","sources":["../../../src/questions/options-question.js"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;GAEG;AAEH;IAIC;;;OAGG;IACH,oBAHW,OAAO,iBAAiB,EAAE,kBAAkB,EAgBtD;IApBD,4BAA4B;IAC5B,SADW,KAAK,CAAC,MAAM,CAAC,CAChB;IAkBP,yBAA+C;IAGhD;;;;;;;;OAQG;IACH,kCAPW,OAAO,UAAU,EAAE,OAAO,WAC1B,OAAO,UAAU,EAAE,OAAO,mBAC1B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YACvB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,WACvB,OAAO,oCAAoC,EAAE,+BAA+B,OAmDtF;CAmCD;qBA9IY;IACR,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,WAAW,CAAC,EAAE;QACZ,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;QACd,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,IAAI,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,OAAO,CAAC;QACZ,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAA;KAClB,CAAC;IACA,eAAe,CAAC,EAAE;QAChB,IAAI,EAAE,MAAM,CAAC;KAChB,CAAA;CACH;+BAIU,GAAsC,GAAG;IAAE,QAAQ,EAAE;QAAE,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,CAAA;CAAE;yBA/BhE,eAAe"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options-question.test.d.ts","sourceRoot":"","sources":["../../../src/questions/options-question.test.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {BaseValidator} from "#base-validator"
|
|
3
|
+
* @import {Journey} from "#journey"
|
|
4
|
+
* @import {JourneyResponse} from "#journey-response"
|
|
5
|
+
* @import {Section} from "#section"
|
|
6
|
+
* @import {ActionView} from "../controller.js"
|
|
7
|
+
* @import {ActionLink} from "./question-types.js"
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {Object} PreppedQuestion
|
|
11
|
+
* @property {Object} value
|
|
12
|
+
* @property {string} question
|
|
13
|
+
* @property {string} fieldName
|
|
14
|
+
* @property {string} pageTitle
|
|
15
|
+
* @property {string} [description]
|
|
16
|
+
* @property {string} [html]
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {Record<string, any>} QuestionViewModel
|
|
20
|
+
* @property {PreppedQuestion} question
|
|
21
|
+
* @property {string} layoutTemplate
|
|
22
|
+
* @property {string} pageCaption
|
|
23
|
+
* @property {string} [continueButtonText]
|
|
24
|
+
* @property {string} backLink
|
|
25
|
+
* @property {boolean} showBackToListLink
|
|
26
|
+
* @property {string} listLink
|
|
27
|
+
* @property {Object} util
|
|
28
|
+
* @property {function(string): string} util.trimTrailingSlash
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* A specific question within a journey which is made up of one (usually) or many (sometimes) components and their required content.
|
|
32
|
+
* @class
|
|
33
|
+
*/
|
|
34
|
+
export class Question {
|
|
35
|
+
/**
|
|
36
|
+
* @param {import('#question-types').QuestionParameters} params
|
|
37
|
+
* @param {Record<string, Function>} [methodOverrides]
|
|
38
|
+
*/
|
|
39
|
+
constructor({ title, question, viewFolder, fieldName, url, pageTitle, description, validators, html, hint, interfaceType, shouldDisplay, autocomplete, editable, actionLink, viewData }: import("#question-types").QuestionParameters, methodOverrides?: Record<string, Function>);
|
|
40
|
+
/** @type {string} - html page title, defaults to question if not provided */
|
|
41
|
+
pageTitle: string;
|
|
42
|
+
/** @type {string} - title used in the summary list */
|
|
43
|
+
title: string;
|
|
44
|
+
/** @type {string} - question shown to user on question page */
|
|
45
|
+
question: string;
|
|
46
|
+
/** @type {string|undefined} - additional information to user about the question */
|
|
47
|
+
description: string | undefined;
|
|
48
|
+
/** @type {string} the folder name of the view */
|
|
49
|
+
viewFolder: string;
|
|
50
|
+
/** @type {string} the unique name of the input on the page, also used as a url segment (should this be separated) */
|
|
51
|
+
fieldName: string;
|
|
52
|
+
/** @type {boolean} if the question should appear in the journey overview task list or not */
|
|
53
|
+
taskList: boolean;
|
|
54
|
+
/** @type {Array.<BaseValidator>} array of validators that a question uses to validate answers */
|
|
55
|
+
validators: Array<escape>;
|
|
56
|
+
/** @type {string|undefined} hint text displayed to user */
|
|
57
|
+
hint: string | undefined;
|
|
58
|
+
/** @type {boolean} show return to listing page link after question */
|
|
59
|
+
showBackToListLink: boolean;
|
|
60
|
+
/** @type {string|undefined} alternative url slug */
|
|
61
|
+
url: string | undefined;
|
|
62
|
+
/** @type {string|undefined} optional html content */
|
|
63
|
+
html: string | undefined;
|
|
64
|
+
/** @type {string|undefined} optional question type */
|
|
65
|
+
interfaceType: string | undefined;
|
|
66
|
+
/** @type {ActionLink|undefined} override action link */
|
|
67
|
+
actionLink: ActionLink | undefined;
|
|
68
|
+
/** @type {string} 'not started' text to display (if a question has no answer) */
|
|
69
|
+
notStartedText: string;
|
|
70
|
+
/** @type {string} button text to display */
|
|
71
|
+
continueButtonText: string;
|
|
72
|
+
/** @type {string} text to display for 'change' link */
|
|
73
|
+
changeActionText: string;
|
|
74
|
+
/** @type {string} text to display for 'answer' link */
|
|
75
|
+
answerActionText: string;
|
|
76
|
+
/** @type {string} text to display for 'add' link */
|
|
77
|
+
addActionText: string;
|
|
78
|
+
/**
|
|
79
|
+
* @param {JourneyResponse} [response]
|
|
80
|
+
* @returns {boolean}
|
|
81
|
+
*/
|
|
82
|
+
shouldDisplay: () => boolean;
|
|
83
|
+
details: {
|
|
84
|
+
title: string;
|
|
85
|
+
text: string;
|
|
86
|
+
};
|
|
87
|
+
autocomplete: string | undefined;
|
|
88
|
+
editable: boolean;
|
|
89
|
+
viewData: Record<string, any>;
|
|
90
|
+
/**
|
|
91
|
+
* Is this question a manage list question?
|
|
92
|
+
* Implemented as a getter so manage list question implementations can override it,
|
|
93
|
+
* but it cannot be changed at runtime.
|
|
94
|
+
*
|
|
95
|
+
* @returns {boolean}
|
|
96
|
+
*/
|
|
97
|
+
get isManageListQuestion(): boolean;
|
|
98
|
+
set isInManageListSection(value: boolean);
|
|
99
|
+
/**
|
|
100
|
+
* Is this question added to a ManageListSection?
|
|
101
|
+
*
|
|
102
|
+
* @returns {boolean}
|
|
103
|
+
*/
|
|
104
|
+
get isInManageListSection(): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* gets the view model for this question
|
|
107
|
+
*
|
|
108
|
+
* Wraps prepQuestionForRendering to add the back link - which requires more parameters
|
|
109
|
+
* that prepQuestionForRendering doesn't need
|
|
110
|
+
*
|
|
111
|
+
* @param {Object} options
|
|
112
|
+
* @param {import('#src/journey/journey-types.d.ts').RouteParams} options.params
|
|
113
|
+
* @param {import('#src/components/manage-list/question.js')} [options.manageListQuestion]
|
|
114
|
+
* @param {Section} options.section - the current section
|
|
115
|
+
* @param {Journey} options.journey - the journey we are in
|
|
116
|
+
* @param {Record<string, unknown>} [options.customViewData] additional data to send to view
|
|
117
|
+
* @param {unknown} [options.payload]
|
|
118
|
+
* @returns {QuestionViewModel}
|
|
119
|
+
*/
|
|
120
|
+
toViewModel({ params, manageListQuestion, section, journey, customViewData, payload }: {
|
|
121
|
+
params: import("#src/journey/journey-types.d.ts").RouteParams;
|
|
122
|
+
manageListQuestion?: typeof import("#src/components/manage-list/question.js") | undefined;
|
|
123
|
+
section: Section;
|
|
124
|
+
journey: Journey;
|
|
125
|
+
customViewData?: Record<string, unknown> | undefined;
|
|
126
|
+
payload?: unknown;
|
|
127
|
+
}): QuestionViewModel;
|
|
128
|
+
/**
|
|
129
|
+
* gets the base view model for this question
|
|
130
|
+
*
|
|
131
|
+
* @param {Section} section - the current section
|
|
132
|
+
* @param {Journey} journey - the journey we are in
|
|
133
|
+
* @param {Record<string, unknown>} [customViewData] additional data to send to view
|
|
134
|
+
* @param {unknown} [payload]
|
|
135
|
+
* @param {import('./question-types.d.ts').PrepQuestionForRenderingOptions} [options] - required to support manage list question
|
|
136
|
+
* @returns {QuestionViewModel}
|
|
137
|
+
*/
|
|
138
|
+
prepQuestionForRendering(section: Section, journey: Journey, customViewData?: Record<string, unknown>, payload?: unknown, options?: import("./question-types.d.ts").PrepQuestionForRenderingOptions): QuestionViewModel;
|
|
139
|
+
/**
|
|
140
|
+
* The answer to this question for use in the viewModel
|
|
141
|
+
*
|
|
142
|
+
* Question implementations can override this for more complex answer types
|
|
143
|
+
*
|
|
144
|
+
* @param {Record<string, any>} answers - collection of answers to pull the answer from, may be from the response or the request/payload
|
|
145
|
+
* @param {Boolean} isPayload - whether the answers object is from the request/payload
|
|
146
|
+
* @returns {*|string}
|
|
147
|
+
*/ answerForViewModel(answers: Record<string, any>, isPayload: boolean): any | string;
|
|
148
|
+
/**
|
|
149
|
+
* Question implementations can override this to add configuration or other values to the view model
|
|
150
|
+
*
|
|
151
|
+
* If possible override this method instead of prepQuestionForRendering for simple changes to the view model
|
|
152
|
+
*
|
|
153
|
+
* @param {QuestionViewModel} viewModel
|
|
154
|
+
*/ addCustomDataToViewModel(viewModel: QuestionViewModel): void;
|
|
155
|
+
/**
|
|
156
|
+
* Get the answers object from the journey response, which may be nested in an array for manage list questions
|
|
157
|
+
*
|
|
158
|
+
* @param {JourneyResponse} response
|
|
159
|
+
* @param {import('./question-types.d.ts').PrepQuestionForRenderingOptions} [options]
|
|
160
|
+
* @returns {Record<string, any>}
|
|
161
|
+
*/
|
|
162
|
+
answerObjectFromJourneyResponse(response: JourneyResponse, { params, manageListQuestion }?: import("./question-types.d.ts").PrepQuestionForRenderingOptions): Record<string, any>;
|
|
163
|
+
/**
|
|
164
|
+
* renders the question
|
|
165
|
+
* @param {import('express').Response} res - the express response
|
|
166
|
+
* @param {QuestionViewModel} viewModel additional data to send to view
|
|
167
|
+
* @returns {void}
|
|
168
|
+
*/
|
|
169
|
+
renderAction(res: any, viewModel: QuestionViewModel): void;
|
|
170
|
+
/**
|
|
171
|
+
* check for validation errors
|
|
172
|
+
* @param {import('express').Request} req
|
|
173
|
+
* @param {Journey} journey
|
|
174
|
+
* @param {Section} section
|
|
175
|
+
* @param {import('#src/components/manage-list/question.js')} [manageListQuestion]
|
|
176
|
+
* @returns {QuestionViewModel|undefined} returns the view model for displaying the error or undefined if there are no errors
|
|
177
|
+
*/
|
|
178
|
+
checkForValidationErrors(req: any, section: Section, journey: Journey, manageListQuestion?: typeof import("#src/components/manage-list/question.js")): QuestionViewModel | undefined;
|
|
179
|
+
/**
|
|
180
|
+
* Get the data to save from the request, returns an object of answers
|
|
181
|
+
*
|
|
182
|
+
* @param {import('express').Request} req
|
|
183
|
+
* @param {JourneyResponse} journeyResponse - current journey response
|
|
184
|
+
* @returns {Promise<{ answers: Record<string, unknown> }>}
|
|
185
|
+
*/ getDataToSave(req: any, journeyResponse: JourneyResponse): Promise<{
|
|
186
|
+
answers: Record<string, unknown>;
|
|
187
|
+
}>;
|
|
188
|
+
/**
|
|
189
|
+
* check for errors after saving, by default this does nothing
|
|
190
|
+
* @param {import('express').Request} req
|
|
191
|
+
* @param {Journey} journey
|
|
192
|
+
* @param {Section} sectionObj
|
|
193
|
+
* @returns {QuestionViewModel | undefined} returns the view model for displaying the error or undefined if there are no errors
|
|
194
|
+
*/ checkForSavingErrors(req: any, sectionObj: Section, journey: Journey): QuestionViewModel | undefined;
|
|
195
|
+
/**
|
|
196
|
+
* Handles redirect after saving. Kept around for backwards compatibility.
|
|
197
|
+
*
|
|
198
|
+
* @param {import('express').Response} res
|
|
199
|
+
* @param {Journey} journey
|
|
200
|
+
* @param {string} sectionSegment
|
|
201
|
+
* @param {string} questionSegment
|
|
202
|
+
* @returns {void}
|
|
203
|
+
* @deprecated - use `journey.redirectToNextQuestion`
|
|
204
|
+
*/
|
|
205
|
+
handleNextQuestion(res: any, journey: Journey, sectionSegment: string, questionSegment: string): void;
|
|
206
|
+
/**
|
|
207
|
+
* returns the formatted answers values to be used to build task list elements
|
|
208
|
+
* @param {String} sectionSegment
|
|
209
|
+
* @param {Journey} journey
|
|
210
|
+
* @param {Object} answer
|
|
211
|
+
* @returns {Array<{
|
|
212
|
+
* key: string;
|
|
213
|
+
* value: string | Object;
|
|
214
|
+
* action: {
|
|
215
|
+
* href: string;
|
|
216
|
+
* text: string;
|
|
217
|
+
* visuallyHiddenText: string;
|
|
218
|
+
* };
|
|
219
|
+
* }>}
|
|
220
|
+
*/
|
|
221
|
+
formatAnswerForSummary(sectionSegment: string, journey: Journey, answer: Object, capitals?: boolean): Array<{
|
|
222
|
+
key: string;
|
|
223
|
+
value: string | Object;
|
|
224
|
+
action: {
|
|
225
|
+
href: string;
|
|
226
|
+
text: string;
|
|
227
|
+
visuallyHiddenText: string;
|
|
228
|
+
};
|
|
229
|
+
}>;
|
|
230
|
+
/**
|
|
231
|
+
* Returns the action link for the question
|
|
232
|
+
* @param {Object} answer
|
|
233
|
+
* @param {Journey} journey
|
|
234
|
+
* @param {String} sectionSegment
|
|
235
|
+
* @returns {ActionView|ActionView[]|undefined}
|
|
236
|
+
*/
|
|
237
|
+
getAction(sectionSegment: string, journey: Journey, answer: Object): ActionView | ActionView[] | undefined;
|
|
238
|
+
/**
|
|
239
|
+
* @param {unknown} answer
|
|
240
|
+
* @returns {unknown}
|
|
241
|
+
*/
|
|
242
|
+
format(answer: unknown): unknown;
|
|
243
|
+
/**
|
|
244
|
+
* @returns {boolean}
|
|
245
|
+
*/
|
|
246
|
+
isRequired(): boolean;
|
|
247
|
+
/**
|
|
248
|
+
* @param {string} inputField
|
|
249
|
+
* @returns {boolean}
|
|
250
|
+
*/
|
|
251
|
+
fieldIsRequired(inputField: string): boolean;
|
|
252
|
+
/**
|
|
253
|
+
* @param {JourneyResponse} journeyResponse
|
|
254
|
+
* @param {string} [fieldName] optional fieldname for multi field input questions
|
|
255
|
+
* @returns {boolean}
|
|
256
|
+
*/
|
|
257
|
+
isAnswered(journeyResponse: JourneyResponse, fieldName?: string): boolean;
|
|
258
|
+
#private;
|
|
259
|
+
}
|
|
260
|
+
export type PreppedQuestion = {
|
|
261
|
+
value: Object;
|
|
262
|
+
question: string;
|
|
263
|
+
fieldName: string;
|
|
264
|
+
pageTitle: string;
|
|
265
|
+
description?: string | undefined;
|
|
266
|
+
html?: string | undefined;
|
|
267
|
+
};
|
|
268
|
+
export type QuestionViewModel = Record<string, any>;
|
|
269
|
+
import type { ActionLink } from "./question-types.js";
|
|
270
|
+
import type { Section } from "#section";
|
|
271
|
+
import type { Journey } from "#journey";
|
|
272
|
+
import type { JourneyResponse } from "#journey-response";
|
|
273
|
+
import type { ActionView } from "../controller.js";
|
|
274
|
+
//# sourceMappingURL=question.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question.d.ts","sourceRoot":"","sources":["../../../src/questions/question.js"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question.test.d.ts","sourceRoot":"","sources":["../../../src/questions/question.test.js"],"names":[],"mappings":""}
|