@defra/forms-model 3.0.688 → 3.0.690
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/dist/module/form/form-editor/translations/translations-config.js +6 -0
- package/dist/module/form/form-editor/translations/translations-config.js.map +1 -1
- package/dist/module/form/form-editor/translations/translations.js +4 -4
- package/dist/module/form/form-editor/translations/translations.js.map +1 -1
- package/dist/module/form/form-submission/index.js +3 -0
- package/dist/module/form/form-submission/index.js.map +1 -1
- package/dist/module/form/form-submission/types.js.map +1 -1
- package/dist/types/form/form-editor/translations/translations-config.d.ts.map +1 -1
- package/dist/types/form/form-editor/translations/translations.d.ts +13 -1
- package/dist/types/form/form-editor/translations/translations.d.ts.map +1 -1
- package/dist/types/form/form-submission/index.d.ts.map +1 -1
- package/dist/types/form/form-submission/types.d.ts +4 -0
- package/dist/types/form/form-submission/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/schemas/form-submit-payload-schema.json +5 -0
- package/src/form/form-editor/translations/translations-config.js +7 -0
- package/src/form/form-editor/translations/translations.js +6 -7
- package/src/form/form-submission/index.ts +7 -0
- package/src/form/form-submission/types.ts +5 -0
|
@@ -64,6 +64,12 @@ export const keyConfig = {
|
|
|
64
64
|
displayName: 'Short description',
|
|
65
65
|
getLabel: (pageNum, questionNum) => `Welsh short description - Page ${pageNum}, question ${questionNum}`
|
|
66
66
|
},
|
|
67
|
+
[TranslationRowTypes.ErrorDescription]: {
|
|
68
|
+
jsonPrefix: 'components',
|
|
69
|
+
jsonSuffix: 'errorDescription',
|
|
70
|
+
displayName: 'Error description',
|
|
71
|
+
getLabel: (pageNum, questionNum) => `Welsh error description - Page ${pageNum}, question ${questionNum}`
|
|
72
|
+
},
|
|
67
73
|
[TranslationRowTypes.InstructionText]: {
|
|
68
74
|
jsonPrefix: 'components',
|
|
69
75
|
jsonSuffix: 'instructionText',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translations-config.js","names":["ComponentType","TranslationRowTypes","PageHeading","PageGuidance","RepeatTitle","QuestionText","QuestionHint","ShortDescription","ErrorDescription","ListItemText","ListItemHint","InstructionText","DeclarationBody","PaymentDescription","TEXTAREA_3_ROWS","TEXTAREA_5_ROWS","TEXTAREA_12_ROWS_WITH_MARKDOWN","LIST_ITEM_HINT","LIST_ITEM_WITH_HINT_FOLLOWING","keyConfig","jsonPrefix","jsonSuffix","displayName","getLabel","pageNum","questionNum","itemNum","IGNORE_FIELDS","Details","Html","InsetText","HiddenField","lookupTranslation","key","translations","drillDown","keyType","entity","resolveData","options","instructionText","hint","text","content","description","func","entityWithDynamicProperties"],"sources":["../../../../../src/form/form-editor/translations/translations-config.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\n\n/**\n * @typedef {object} TranslationRow\n * @property {string} name - the key name\n * @property {string} [type] - type of text\n * @property {string | undefined} englishContent - English text\n * @property {string | undefined} welshContent - Welsh text\n * @property {number} [pageNum] - page number\n * @property {number} [questionNum] - question number\n * @property {number} [itemNum] - list item number\n * @property {string} [label] - label for field\n */\n\n/**\n * @typedef {{ text: string, href?: string }} ErrorDetailsItem\n * @typedef {Record<string, ErrorDetailsItem>} ErrorDetails\n */\n\n/**\n * @template {object} [Schema=object]\n * @typedef {object} ValidationFailure\n * @property {ErrorDetails} formErrors - Formatted errors for error summary\n * @property {Schema} formValues - Form POST payload from Hapi request\n */\n\nexport const TranslationRowTypes = {\n PageHeading: 'PageHeading',\n PageGuidance: 'PageGuidance',\n RepeatTitle: 'RepeatTitle',\n QuestionText: 'QuestionText',\n QuestionHint: 'QuestionHint',\n ShortDescription: 'ShortDescription',\n ErrorDescription: 'ErrorDescription',\n ListItemText: 'ListItemText',\n ListItemHint: 'ListItemHint',\n InstructionText: 'InstructionText',\n DeclarationBody: 'DeclarationBody',\n PaymentDescription: 'PaymentDescription'\n}\n\nexport const TEXTAREA_3_ROWS = 'textarea3'\nexport const TEXTAREA_5_ROWS = 'textarea5'\nexport const TEXTAREA_12_ROWS_WITH_MARKDOWN = 'textarea12markdown'\nexport const LIST_ITEM_HINT = 'listitemhint'\nexport const LIST_ITEM_WITH_HINT_FOLLOWING = 'listoptionwithhintfollowing'\n\n/** @type {Record<string, { jsonPrefix: string, jsonSuffix: string, displayName: string, getLabel: (pageNum: number, questionNum?: number, itemNum?: number) => string }>} */\nexport const keyConfig = {\n [TranslationRowTypes.QuestionText]: {\n jsonPrefix: 'components',\n jsonSuffix: 'title',\n displayName: 'Question text',\n getLabel: (pageNum, questionNum) =>\n `Welsh question text - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.QuestionHint]: {\n jsonPrefix: 'components',\n jsonSuffix: 'hint',\n displayName: 'Hint',\n getLabel: (pageNum, questionNum) =>\n `Welsh hint - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.ShortDescription]: {\n jsonPrefix: 'components',\n jsonSuffix: 'shortDescription',\n displayName: 'Short description',\n getLabel: (pageNum, questionNum) =>\n `Welsh short description - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.InstructionText]: {\n jsonPrefix: 'components',\n jsonSuffix: 'instructionText',\n displayName: 'Instruction text',\n getLabel: (pageNum, questionNum) =>\n `Welsh instruction text - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.DeclarationBody]: {\n jsonPrefix: 'components',\n jsonSuffix: 'content',\n displayName: 'Declaration body',\n getLabel: (pageNum, questionNum) =>\n `Welsh declaration body - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.PaymentDescription]: {\n jsonPrefix: 'components',\n jsonSuffix: 'paymentDescription',\n displayName: 'Payment description',\n getLabel: (pageNum, questionNum) =>\n `Welsh payment description - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.ListItemText]: {\n jsonPrefix: 'listItems',\n jsonSuffix: 'text',\n displayName: 'Option',\n getLabel: (pageNum, questionNum, itemNum) =>\n `Welsh option ${itemNum} - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.ListItemHint]: {\n jsonPrefix: 'listItems',\n jsonSuffix: 'hint',\n displayName: 'Option hint',\n getLabel: (pageNum, questionNum, itemNum) =>\n `Welsh hint for option ${itemNum} - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.PageGuidance]: {\n jsonPrefix: 'components',\n jsonSuffix: 'content',\n displayName: 'Guidance text',\n getLabel: (pageNum) => `Welsh guidance text (markdown) - page ${pageNum}`\n },\n [TranslationRowTypes.PageHeading]: {\n jsonPrefix: 'pages',\n jsonSuffix: 'title',\n displayName: 'Page heading',\n getLabel: (pageNum) => `Welsh page heading - page ${pageNum}`\n },\n [TranslationRowTypes.RepeatTitle]: {\n jsonPrefix: 'pages',\n jsonSuffix: 'repeatTitle',\n displayName: 'Repeat name',\n getLabel: (pageNum) => `Welsh repeat name - page ${pageNum}`\n }\n}\n\nexport const IGNORE_FIELDS = [\n ComponentType.Details,\n ComponentType.Html,\n ComponentType.InsetText,\n ComponentType.HiddenField\n]\n\n/**\n * Lookup a translation from a list of translation records.\n * @param {string} key - The translation key to look up.\n * @param {Record<string, string> | undefined} translations - The translation values to search.\n */\nexport function lookupTranslation(key, translations) {\n if (!translations) {\n return ''\n }\n return translations[key] ?? ''\n}\n\n/**\n * Resolve the underlying content for a translation row from an entity.\n * Involves using the appropriate child properties if necessary.\n * @param {string} keyType - The translation row type being resolved.\n * @param {ComponentDef | Page | Item} entity - The entity that may contain the content to translate.\n * @param {string} jsonSuffix - The property name to read from the entity.\n */\nexport function drillDown(keyType, entity, jsonSuffix) {\n /** @type {Partial<Record<string, (entity: ComponentDef | Page | Item) => string>>} */\n const resolveData = {\n [TranslationRowTypes.InstructionText]: () =>\n // @ts-expect-error - dynamic property lookup\n 'options' in entity ? entity.options?.instructionText : '',\n [TranslationRowTypes.ListItemHint]: () =>\n // @ts-expect-error - dynamic property lookup\n 'hint' in entity ? entity.hint.text : '',\n [TranslationRowTypes.DeclarationBody]: () =>\n 'content' in entity ? entity.content : '',\n [TranslationRowTypes.PaymentDescription]: () =>\n // @ts-expect-error - dynamic property lookup\n 'options' in entity ? entity.options?.description : ''\n }\n const func = resolveData[keyType]\n if (func) {\n return func(entity)\n } else {\n const entityWithDynamicProperties = /** @type {Record<string, unknown>} */ (\n /** @type {unknown} */ (entity)\n )\n if (typeof entity === 'object') {\n return jsonSuffix in entityWithDynamicProperties\n ? /** @type {string} */ (entityWithDynamicProperties[jsonSuffix])\n : ''\n }\n }\n return entity\n}\n\n/**\n * @import { ComponentDef } from '~/src/components/types.js'\n * @import { Item, Page } from '~/src/form/form-definition/types.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,mBAAmB,GAAG;EACjCC,WAAW,EAAE,aAAa;EAC1BC,YAAY,EAAE,cAAc;EAC5BC,WAAW,EAAE,aAAa;EAC1BC,YAAY,EAAE,cAAc;EAC5BC,YAAY,EAAE,cAAc;EAC5BC,gBAAgB,EAAE,kBAAkB;EACpCC,gBAAgB,EAAE,kBAAkB;EACpCC,YAAY,EAAE,cAAc;EAC5BC,YAAY,EAAE,cAAc;EAC5BC,eAAe,EAAE,iBAAiB;EAClCC,eAAe,EAAE,iBAAiB;EAClCC,kBAAkB,EAAE;AACtB,CAAC;AAED,OAAO,MAAMC,eAAe,GAAG,WAAW;AAC1C,OAAO,MAAMC,eAAe,GAAG,WAAW;AAC1C,OAAO,MAAMC,8BAA8B,GAAG,oBAAoB;AAClE,OAAO,MAAMC,cAAc,GAAG,cAAc;AAC5C,OAAO,MAAMC,6BAA6B,GAAG,6BAA6B;;AAE1E;AACA,OAAO,MAAMC,SAAS,GAAG;EACvB,CAAClB,mBAAmB,CAACI,YAAY,GAAG;IAClCe,UAAU,EAAE,YAAY;IACxBC,UAAU,EAAE,OAAO;IACnBC,WAAW,EAAE,eAAe;IAC5B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;EACX;EACA,OAAOA,YAAY,CAACD,GAAG,CAAC,IAAI,EAAE;AAChC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,SAASA,CAACC,OAAO,EAAEC,MAAM,EAAEhB,UAAU,EAAE;EACrD;EACA,MAAMiB,WAAW,GAAG;IAClB,CAACrC,mBAAmB,CAACU,eAAe,GAAG;IACrC;IACA,SAAS,IAAI0B,MAAM,GAAGA,MAAM,CAACE,OAAO,EAAEC,eAAe,GAAG,EAAE;IAC5D,CAACvC,mBAAmB,CAACS,YAAY,GAAG;IAClC;IACA,MAAM,IAAI2B,MAAM,GAAGA,MAAM,CAACI,IAAI,CAACC,IAAI,GAAG,EAAE;IAC1C,CAACzC,mBAAmB,CAACW,eAAe,GAAG,MACrC,SAAS,IAAIyB,MAAM,GAAGA,MAAM,CAACM,OAAO,GAAG,EAAE;IAC3C,CAAC1C,mBAAmB,CAACY,kBAAkB,GAAG;IACxC;IACA,SAAS,IAAIwB,MAAM,GAAGA,MAAM,CAACE,OAAO,EAAEK,WAAW,GAAG;EACxD,CAAC;EACD,MAAMC,IAAI,GAAGP,WAAW,CAACF,OAAO,CAAC;EACjC,IAAIS,IAAI,EAAE;IACR,OAAOA,IAAI,CAACR,MAAM,CAAC;EACrB,CAAC,MAAM;IACL,MAAMS,2BAA2B,GAAG;IAClC,sBAAwBT,MACzB;IACD,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAE;MAC9B,OAAOhB,UAAU,IAAIyB,2BAA2B,IAC5C,qBAAuBA,2BAA2B,CAACzB,UAAU,CAAC,IAC9D,EAAE;IACR;EACF;EACA,OAAOgB,MAAM;AACf;;AAEA;AACA;AACA;AACA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"translations-config.js","names":["ComponentType","TranslationRowTypes","PageHeading","PageGuidance","RepeatTitle","QuestionText","QuestionHint","ShortDescription","ErrorDescription","ListItemText","ListItemHint","InstructionText","DeclarationBody","PaymentDescription","TEXTAREA_3_ROWS","TEXTAREA_5_ROWS","TEXTAREA_12_ROWS_WITH_MARKDOWN","LIST_ITEM_HINT","LIST_ITEM_WITH_HINT_FOLLOWING","keyConfig","jsonPrefix","jsonSuffix","displayName","getLabel","pageNum","questionNum","itemNum","IGNORE_FIELDS","Details","Html","InsetText","HiddenField","lookupTranslation","key","translations","drillDown","keyType","entity","resolveData","options","instructionText","hint","text","content","description","func","entityWithDynamicProperties"],"sources":["../../../../../src/form/form-editor/translations/translations-config.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\n\n/**\n * @typedef {object} TranslationRow\n * @property {string} name - the key name\n * @property {string} [type] - type of text\n * @property {string | undefined} englishContent - English text\n * @property {string | undefined} welshContent - Welsh text\n * @property {number} [pageNum] - page number\n * @property {number} [questionNum] - question number\n * @property {number} [itemNum] - list item number\n * @property {string} [label] - label for field\n */\n\n/**\n * @typedef {{ text: string, href?: string }} ErrorDetailsItem\n * @typedef {Record<string, ErrorDetailsItem>} ErrorDetails\n */\n\n/**\n * @template {object} [Schema=object]\n * @typedef {object} ValidationFailure\n * @property {ErrorDetails} formErrors - Formatted errors for error summary\n * @property {Schema} formValues - Form POST payload from Hapi request\n */\n\nexport const TranslationRowTypes = {\n PageHeading: 'PageHeading',\n PageGuidance: 'PageGuidance',\n RepeatTitle: 'RepeatTitle',\n QuestionText: 'QuestionText',\n QuestionHint: 'QuestionHint',\n ShortDescription: 'ShortDescription',\n ErrorDescription: 'ErrorDescription',\n ListItemText: 'ListItemText',\n ListItemHint: 'ListItemHint',\n InstructionText: 'InstructionText',\n DeclarationBody: 'DeclarationBody',\n PaymentDescription: 'PaymentDescription'\n}\n\nexport const TEXTAREA_3_ROWS = 'textarea3'\nexport const TEXTAREA_5_ROWS = 'textarea5'\nexport const TEXTAREA_12_ROWS_WITH_MARKDOWN = 'textarea12markdown'\nexport const LIST_ITEM_HINT = 'listitemhint'\nexport const LIST_ITEM_WITH_HINT_FOLLOWING = 'listoptionwithhintfollowing'\n\n/** @type {Record<string, { jsonPrefix: string, jsonSuffix: string, displayName: string, getLabel: (pageNum: number, questionNum?: number, itemNum?: number) => string }>} */\nexport const keyConfig = {\n [TranslationRowTypes.QuestionText]: {\n jsonPrefix: 'components',\n jsonSuffix: 'title',\n displayName: 'Question text',\n getLabel: (pageNum, questionNum) =>\n `Welsh question text - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.QuestionHint]: {\n jsonPrefix: 'components',\n jsonSuffix: 'hint',\n displayName: 'Hint',\n getLabel: (pageNum, questionNum) =>\n `Welsh hint - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.ShortDescription]: {\n jsonPrefix: 'components',\n jsonSuffix: 'shortDescription',\n displayName: 'Short description',\n getLabel: (pageNum, questionNum) =>\n `Welsh short description - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.ErrorDescription]: {\n jsonPrefix: 'components',\n jsonSuffix: 'errorDescription',\n displayName: 'Error description',\n getLabel: (pageNum, questionNum) =>\n `Welsh error description - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.InstructionText]: {\n jsonPrefix: 'components',\n jsonSuffix: 'instructionText',\n displayName: 'Instruction text',\n getLabel: (pageNum, questionNum) =>\n `Welsh instruction text - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.DeclarationBody]: {\n jsonPrefix: 'components',\n jsonSuffix: 'content',\n displayName: 'Declaration body',\n getLabel: (pageNum, questionNum) =>\n `Welsh declaration body - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.PaymentDescription]: {\n jsonPrefix: 'components',\n jsonSuffix: 'paymentDescription',\n displayName: 'Payment description',\n getLabel: (pageNum, questionNum) =>\n `Welsh payment description - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.ListItemText]: {\n jsonPrefix: 'listItems',\n jsonSuffix: 'text',\n displayName: 'Option',\n getLabel: (pageNum, questionNum, itemNum) =>\n `Welsh option ${itemNum} - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.ListItemHint]: {\n jsonPrefix: 'listItems',\n jsonSuffix: 'hint',\n displayName: 'Option hint',\n getLabel: (pageNum, questionNum, itemNum) =>\n `Welsh hint for option ${itemNum} - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.PageGuidance]: {\n jsonPrefix: 'components',\n jsonSuffix: 'content',\n displayName: 'Guidance text',\n getLabel: (pageNum) => `Welsh guidance text (markdown) - page ${pageNum}`\n },\n [TranslationRowTypes.PageHeading]: {\n jsonPrefix: 'pages',\n jsonSuffix: 'title',\n displayName: 'Page heading',\n getLabel: (pageNum) => `Welsh page heading - page ${pageNum}`\n },\n [TranslationRowTypes.RepeatTitle]: {\n jsonPrefix: 'pages',\n jsonSuffix: 'repeatTitle',\n displayName: 'Repeat name',\n getLabel: (pageNum) => `Welsh repeat name - page ${pageNum}`\n }\n}\n\nexport const IGNORE_FIELDS = [\n ComponentType.Details,\n ComponentType.Html,\n ComponentType.InsetText,\n ComponentType.HiddenField\n]\n\n/**\n * Lookup a translation from a list of translation records.\n * @param {string} key - The translation key to look up.\n * @param {Record<string, string> | undefined} translations - The translation values to search.\n */\nexport function lookupTranslation(key, translations) {\n if (!translations) {\n return ''\n }\n return translations[key] ?? ''\n}\n\n/**\n * Resolve the underlying content for a translation row from an entity.\n * Involves using the appropriate child properties if necessary.\n * @param {string} keyType - The translation row type being resolved.\n * @param {ComponentDef | Page | Item} entity - The entity that may contain the content to translate.\n * @param {string} jsonSuffix - The property name to read from the entity.\n */\nexport function drillDown(keyType, entity, jsonSuffix) {\n /** @type {Partial<Record<string, (entity: ComponentDef | Page | Item) => string>>} */\n const resolveData = {\n [TranslationRowTypes.InstructionText]: () =>\n // @ts-expect-error - dynamic property lookup\n 'options' in entity ? entity.options?.instructionText : '',\n [TranslationRowTypes.ListItemHint]: () =>\n // @ts-expect-error - dynamic property lookup\n 'hint' in entity ? entity.hint.text : '',\n [TranslationRowTypes.DeclarationBody]: () =>\n 'content' in entity ? entity.content : '',\n [TranslationRowTypes.PaymentDescription]: () =>\n // @ts-expect-error - dynamic property lookup\n 'options' in entity ? entity.options?.description : ''\n }\n const func = resolveData[keyType]\n if (func) {\n return func(entity)\n } else {\n const entityWithDynamicProperties = /** @type {Record<string, unknown>} */ (\n /** @type {unknown} */ (entity)\n )\n if (typeof entity === 'object') {\n return jsonSuffix in entityWithDynamicProperties\n ? /** @type {string} */ (entityWithDynamicProperties[jsonSuffix])\n : ''\n }\n }\n return entity\n}\n\n/**\n * @import { ComponentDef } from '~/src/components/types.js'\n * @import { Item, Page } from '~/src/form/form-definition/types.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,mBAAmB,GAAG;EACjCC,WAAW,EAAE,aAAa;EAC1BC,YAAY,EAAE,cAAc;EAC5BC,WAAW,EAAE,aAAa;EAC1BC,YAAY,EAAE,cAAc;EAC5BC,YAAY,EAAE,cAAc;EAC5BC,gBAAgB,EAAE,kBAAkB;EACpCC,gBAAgB,EAAE,kBAAkB;EACpCC,YAAY,EAAE,cAAc;EAC5BC,YAAY,EAAE,cAAc;EAC5BC,eAAe,EAAE,iBAAiB;EAClCC,eAAe,EAAE,iBAAiB;EAClCC,kBAAkB,EAAE;AACtB,CAAC;AAED,OAAO,MAAMC,eAAe,GAAG,WAAW;AAC1C,OAAO,MAAMC,eAAe,GAAG,WAAW;AAC1C,OAAO,MAAMC,8BAA8B,GAAG,oBAAoB;AAClE,OAAO,MAAMC,cAAc,GAAG,cAAc;AAC5C,OAAO,MAAMC,6BAA6B,GAAG,6BAA6B;;AAE1E;AACA,OAAO,MAAMC,SAAS,GAAG;EACvB,CAAClB,mBAAmB,CAACI,YAAY,GAAG;IAClCe,UAAU,EAAE,YAAY;IACxBC,UAAU,EAAE,OAAO;IACnBC,WAAW,EAAE,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EACA,OAAOgB,MAAM;AACf;;AAEA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -100,7 +100,7 @@ function buildPage(page, pageNum, translations, validation) {
|
|
|
100
100
|
* @param {ValidationFailure<any>} [validation] - Optional validation context for posted form values.
|
|
101
101
|
* @returns {TranslationRow[]} The translation rows generated for the component.
|
|
102
102
|
*/
|
|
103
|
-
function buildComponent(definition, component, pageNum, questionNum, translations, validation) {
|
|
103
|
+
export function buildComponent(definition, component, pageNum, questionNum, translations, validation) {
|
|
104
104
|
if (IGNORE_FIELDS.includes(component.type)) {
|
|
105
105
|
return [];
|
|
106
106
|
}
|
|
@@ -120,15 +120,15 @@ function buildComponent(definition, component, pageNum, questionNum, translation
|
|
|
120
120
|
}
|
|
121
121
|
if (component.type !== ComponentType.PaymentField) {
|
|
122
122
|
rows.push(createRow(component, TranslationRowTypes.ShortDescription, options));
|
|
123
|
+
if (typed.errorDescription) {
|
|
124
|
+
rows.push(createRow(component, TranslationRowTypes.ErrorDescription, options));
|
|
125
|
+
}
|
|
123
126
|
} else {
|
|
124
127
|
rows.push(createRow(component, TranslationRowTypes.PaymentDescription, options));
|
|
125
128
|
}
|
|
126
129
|
if (component.type === ComponentType.DeclarationField) {
|
|
127
130
|
rows.push(createRow(component, TranslationRowTypes.DeclarationBody, options));
|
|
128
131
|
}
|
|
129
|
-
if (component.type === ComponentType.PaymentField) {
|
|
130
|
-
rows.push(createRow(component, TranslationRowTypes.PaymentDescription, options));
|
|
131
|
-
}
|
|
132
132
|
if (typed.options.instructionText && isTypeWithInstructions(component.type)) {
|
|
133
133
|
rows.push(createRow(component, TranslationRowTypes.InstructionText, options));
|
|
134
134
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translations.js","names":["ComponentType","isListType","isTypeWithInstructions","IGNORE_FIELDS","TranslationRowTypes","drillDown","keyConfig","lookupTranslation","buildOverviewSection","getListFromComponent","getPageNum","getQuestionNum","ControllerType","hasComponents","createRow","entity","keyType","pageNum","questionNum","itemNum","translations","validation","keyProperties","innerEnglishContent","jsonSuffix","keyName","jsonPrefix","id","name","type","englishContent","welshContent","formValues","label","getLabel","allowedControllerTypesSet","Set","Page","Repeat","Start","FileUpload","Terminal","buildPage","page","controller","has","translationRows","title","PageHeading","push","guidance","components","Markdown","undefined","PageGuidance","content","RepeatTitle","repeat","options","buildComponent","definition","component","includes","rows","typed","PaymentField","QuestionText","hint","QuestionHint","ShortDescription","PaymentDescription","DeclarationField","DeclarationBody","instructionText","InstructionText","addSelectionOptions","YesNoField","list","items","length","item","listOptions","ListItemText","ListItemHint","buildTranslationDataRows","metadata","translationsJSON","cy","overviewRows","formRows","pages","pageId","questionId"],"sources":["../../../../../src/form/form-editor/translations/translations.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { isListType, isTypeWithInstructions } from '~/src/components/helpers.js'\nimport {\n IGNORE_FIELDS,\n TranslationRowTypes,\n drillDown,\n keyConfig,\n lookupTranslation\n} from '~/src/form/form-editor/translations/translations-config.js'\nimport { buildOverviewSection } from '~/src/form/form-editor/translations/translations-overview.js'\nimport { getListFromComponent } from '~/src/form/utils/list.js'\nimport { getPageNum, getQuestionNum } from '~/src/form/utils/numbering.js'\nimport { ControllerType } from '~/src/pages/enums.js'\nimport { hasComponents } from '~/src/pages/helpers.js'\n\n/**\n * Create a translation row for a single entity field.\n * @param {ComponentDef | Page | Item} entity - The source entity that contains the English content.\n * @param {string} keyType - The translation row type to build.\n * @param {{ pageNum: number, questionNum?: number, itemNum?: number, translations: Record<string, string>, validation?: ValidationFailure<any> }} options - The row context including numbering and translation values.\n * @returns {TranslationRow} The populated translation row for the entity field.\n */\nfunction createRow(\n entity,\n keyType,\n { pageNum, questionNum, itemNum, translations, validation }\n) {\n const keyProperties = keyConfig[keyType]\n\n const innerEnglishContent = drillDown(\n keyType,\n entity,\n keyProperties.jsonSuffix\n )\n\n const keyName = `${keyProperties.jsonPrefix}.${entity.id}.${keyProperties.jsonSuffix}`\n\n return {\n name: keyName,\n type: keyType,\n pageNum,\n questionNum,\n itemNum,\n englishContent: innerEnglishContent,\n welshContent:\n validation?.formValues[keyName] ??\n lookupTranslation(keyName, translations),\n label: keyProperties.getLabel(pageNum, questionNum, itemNum)\n }\n}\n\nconst allowedControllerTypesSet = new Set([\n ControllerType.Page,\n ControllerType.Repeat,\n ControllerType.Start,\n ControllerType.FileUpload,\n ControllerType.Terminal\n])\n\n/**\n * Build the translation rows for a single page.\n * @param {Page} page - The page definition to inspect for translatable content.\n * @param {number} pageNum - The page number used in the generated labels.\n * @param {Record<string, string>} translations - Existing Welsh translations keyed by translation name.\n * @param {ValidationFailure<any>} [validation] - Optional validation context for posted form values.\n * @returns {TranslationRow[]} The translation rows generated for the page.\n */\nfunction buildPage(page, pageNum, translations, validation) {\n if (page.controller && !allowedControllerTypesSet.has(page.controller)) {\n return []\n }\n\n const translationRows = []\n if (page.title) {\n const keyProperties = keyConfig[TranslationRowTypes.PageHeading]\n\n const keyName = `${keyProperties.jsonPrefix}.${page.id}.${keyProperties.jsonSuffix}`\n\n translationRows.push({\n name: keyName,\n type: TranslationRowTypes.PageHeading,\n pageNum,\n englishContent: page.title,\n welshContent:\n validation?.formValues[keyName] ??\n lookupTranslation(keyName, translations),\n label: keyProperties.getLabel(pageNum)\n })\n }\n\n const guidance =\n hasComponents(page) && page.components[0].type === ComponentType.Markdown\n ? page.components[0]\n : undefined\n if (guidance) {\n const keyProperties = keyConfig[TranslationRowTypes.PageGuidance]\n const keyName = `${keyProperties.jsonPrefix}.${guidance.id}.${keyProperties.jsonSuffix}`\n\n translationRows.push({\n name: keyName,\n type: TranslationRowTypes.PageGuidance,\n pageNum,\n englishContent: guidance.content,\n welshContent:\n validation?.formValues[keyName] ??\n lookupTranslation(keyName, translations),\n label: keyProperties.getLabel(pageNum)\n })\n }\n\n if (page.controller === ControllerType.Repeat) {\n const keyProperties = keyConfig[TranslationRowTypes.RepeatTitle]\n const keyName = `${keyProperties.jsonPrefix}.${page.id}.${keyProperties.jsonSuffix}`\n\n translationRows.push({\n name: keyName,\n type: TranslationRowTypes.RepeatTitle,\n pageNum,\n englishContent: page.repeat.options.title,\n welshContent:\n validation?.formValues[keyName] ??\n lookupTranslation(keyName, translations),\n label: keyProperties.getLabel(pageNum)\n })\n }\n\n return translationRows\n}\n\n/**\n * Build the translation rows for a single component.\n * @param {FormDefinition} definition - The overall form definition used to resolve list-based content.\n * @param {ComponentDef} component - The component to inspect for translatable fields.\n * @param {number} pageNum - The page number used in the generated labels.\n * @param {number} questionNum - The question number used in the generated labels.\n * @param {Record<string, string>} translations - Existing Welsh translations keyed by translation name.\n * @param {ValidationFailure<any>} [validation] - Optional validation context for posted form values.\n * @returns {TranslationRow[]} The translation rows generated for the component.\n */\nfunction buildComponent(\n definition,\n component,\n pageNum,\n questionNum,\n translations,\n validation\n) {\n if (IGNORE_FIELDS.includes(component.type)) {\n return []\n }\n\n const rows = []\n\n const options = { pageNum, questionNum, translations, validation }\n\n const typed = /** @type {InputFieldsComponentsDef} */ (component)\n if (typed.title && component.type !== ComponentType.PaymentField) {\n rows.push(createRow(component, TranslationRowTypes.QuestionText, options))\n }\n if (typed.hint) {\n rows.push(createRow(component, TranslationRowTypes.QuestionHint, options))\n }\n\n if (component.type !== ComponentType.PaymentField) {\n rows.push(\n createRow(component, TranslationRowTypes.ShortDescription, options)\n )\n } else {\n rows.push(\n createRow(component, TranslationRowTypes.PaymentDescription, options)\n )\n }\n\n if (component.type === ComponentType.DeclarationField) {\n rows.push(\n createRow(component, TranslationRowTypes.DeclarationBody, options)\n )\n }\n\n if (component.type === ComponentType.PaymentField) {\n rows.push(\n createRow(component, TranslationRowTypes.PaymentDescription, options)\n )\n }\n\n if (typed.options.instructionText && isTypeWithInstructions(component.type)) {\n rows.push(\n createRow(component, TranslationRowTypes.InstructionText, options)\n )\n }\n\n if (isListType(component.type)) {\n addSelectionOptions(rows, component, definition, options)\n }\n return rows\n}\n\n/**\n * Add translation rows for the select item options of a list-based component.\n * @param {any[]} rows - The accumulator for translation rows.\n * @param {ComponentDef} component - The list-based component to inspect.\n * @param {FormDefinition} definition - The form definition that contains the option list data.\n * @param {{ pageNum: number, questionNum?: number, translations: Record<string, string>, validation?: ValidationFailure<any> }} options - The row context including numbering and translation values.\n */\nfunction addSelectionOptions(rows, component, definition, options) {\n // Temporary workaround - ignore for Yes/No and use defaults in the plugin,\n // until we create a solution that allows users to override the Yes/No options\n if (component.type === ComponentType.YesNoField) {\n return\n }\n\n const list = getListFromComponent(component, definition)\n if (list?.items.length) {\n let itemNum = 0\n for (const item of list.items) {\n itemNum++\n const listOptions = {\n ...options,\n itemNum\n }\n if (item.hint) {\n rows.push(\n createRow(item, TranslationRowTypes.ListItemText, listOptions),\n createRow(item, TranslationRowTypes.ListItemHint, listOptions)\n )\n } else {\n rows.push(\n createRow(item, TranslationRowTypes.ListItemText, listOptions)\n )\n }\n }\n }\n}\n\n/**\n * Build the overview and form translation rows for a form definition.\n * @param {FormMetadata} metadata - The form metadata used to build the overview section.\n * @param {FormDefinition} definition - The form definition containing pages and components.\n * @param {ValidationFailure<any>} [validation] - Optional validation context for posted form values.\n * @returns {{ overviewRows: TranslationRow[], formRows: TranslationRow[] }} The generated overview and form translation rows.\n */\nexport function buildTranslationDataRows(metadata, definition, validation) {\n const translationsJSON = /** @type {Record<string, string>} */ (\n // @ts-expect-error - dynamic language definition\n definition.metadata?.translations?.cy\n )\n\n const overviewRows = buildOverviewSection(\n metadata,\n definition,\n translationsJSON,\n validation\n )\n\n const formRows = []\n for (const page of definition.pages) {\n const pageId = /** @type {string} */ (page.id)\n const pageNum = getPageNum(definition, pageId)\n const components = hasComponents(page) ? page.components : []\n if (components.length === 0) {\n continue\n }\n\n formRows.push(...buildPage(page, pageNum, translationsJSON, validation))\n\n for (const component of components) {\n if (component.type === ComponentType.Markdown) {\n continue\n }\n const questionId = /** @type {string} */ (component.id)\n const questionNum = getQuestionNum(definition, pageId, questionId)\n\n formRows.push(\n ...buildComponent(\n definition,\n component,\n pageNum,\n questionNum,\n translationsJSON,\n validation\n )\n )\n }\n }\n\n return {\n overviewRows,\n formRows\n }\n}\n\n/**\n * @import { ComponentDef, InputFieldsComponentsDef } from '~/src/components/types.js'\n * @import { FormMetadata } from '~/src/form/form-metadata/types.js'\n * @import { FormDefinition, Item, Page } from '~/src/form/form-definition/types.js'\n * @import { TranslationRow, ValidationFailure } from '~/src/form/form-editor/translations/translations-config.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,UAAU,EAAEC,sBAAsB;AAC3C,SACEC,aAAa,EACbC,mBAAmB,EACnBC,SAAS,EACTC,SAAS,EACTC,iBAAiB;AAEnB,SAASC,oBAAoB;AAC7B,SAASC,oBAAoB;AAC7B,SAASC,UAAU,EAAEC,cAAc;AACnC,SAASC,cAAc;AACvB,SAASC,aAAa;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,SAASA,CAChBC,MAAM,EACNC,OAAO,EACP;EAAEC,OAAO;EAAEC,WAAW;EAAEC,OAAO;EAAEC,YAAY;EAAEC;AAAW,CAAC,EAC3D;EACA,MAAMC,aAAa,GAAGhB,SAAS,CAACU,OAAO,CAAC;EAExC,MAAMO,mBAAmB,GAAGlB,SAAS,CACnCW,OAAO,EACPD,MAAM,EACNO,aAAa,CAACE,UAChB,CAAC;EAED,MAAMC,OAAO,GAAG,GAAGH,aAAa,CAACI,UAAU,IAAIX,MAAM,CAACY,EAAE,IAAIL,aAAa,CAACE,UAAU,EAAE;EAEtF,OAAO;IACLI,IAAI,EAAEH,OAAO;IACbI,IAAI,EAAEb,OAAO;IACbC,OAAO;IACPC,WAAW;IACXC,OAAO;IACPW,cAAc,EAAEP,mBAAmB;IACnCQ,YAAY,EACVV,UAAU,EAAEW,UAAU,CAACP,OAAO,CAAC,IAC/BlB,iBAAiB,CAACkB,OAAO,EAAEL,YAAY,CAAC;IAC1Ca,KAAK,EAAEX,aAAa,CAACY,QAAQ,CAACjB,OAAO,EAAEC,WAA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D,UAAU,EAAE+B,MAAM,EAAEC,UAAU,CAAC;MAElEH,QAAQ,CAACxC,IAAI,CACX,GAAGU,cAAc,CACfC,UAAU,EACVC,SAAS,EACT5C,OAAO,EACPC,WAAW,EACXoE,gBAAgB,EAChBjE,UACF,CACF,CAAC;IACH;EACF;EAEA,OAAO;IACLmE,YAAY;IACZC;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"translations.js","names":["ComponentType","isListType","isTypeWithInstructions","IGNORE_FIELDS","TranslationRowTypes","drillDown","keyConfig","lookupTranslation","buildOverviewSection","getListFromComponent","getPageNum","getQuestionNum","ControllerType","hasComponents","createRow","entity","keyType","pageNum","questionNum","itemNum","translations","validation","keyProperties","innerEnglishContent","jsonSuffix","keyName","jsonPrefix","id","name","type","englishContent","welshContent","formValues","label","getLabel","allowedControllerTypesSet","Set","Page","Repeat","Start","FileUpload","Terminal","buildPage","page","controller","has","translationRows","title","PageHeading","push","guidance","components","Markdown","undefined","PageGuidance","content","RepeatTitle","repeat","options","buildComponent","definition","component","includes","rows","typed","PaymentField","QuestionText","hint","QuestionHint","ShortDescription","errorDescription","ErrorDescription","PaymentDescription","DeclarationField","DeclarationBody","instructionText","InstructionText","addSelectionOptions","YesNoField","list","items","length","item","listOptions","ListItemText","ListItemHint","buildTranslationDataRows","metadata","translationsJSON","cy","overviewRows","formRows","pages","pageId","questionId"],"sources":["../../../../../src/form/form-editor/translations/translations.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { isListType, isTypeWithInstructions } from '~/src/components/helpers.js'\nimport {\n IGNORE_FIELDS,\n TranslationRowTypes,\n drillDown,\n keyConfig,\n lookupTranslation\n} from '~/src/form/form-editor/translations/translations-config.js'\nimport { buildOverviewSection } from '~/src/form/form-editor/translations/translations-overview.js'\nimport { getListFromComponent } from '~/src/form/utils/list.js'\nimport { getPageNum, getQuestionNum } from '~/src/form/utils/numbering.js'\nimport { ControllerType } from '~/src/pages/enums.js'\nimport { hasComponents } from '~/src/pages/helpers.js'\n\n/**\n * Create a translation row for a single entity field.\n * @param {ComponentDef | Page | Item} entity - The source entity that contains the English content.\n * @param {string} keyType - The translation row type to build.\n * @param {{ pageNum: number, questionNum?: number, itemNum?: number, translations: Record<string, string>, validation?: ValidationFailure<any> }} options - The row context including numbering and translation values.\n * @returns {TranslationRow} The populated translation row for the entity field.\n */\nfunction createRow(\n entity,\n keyType,\n { pageNum, questionNum, itemNum, translations, validation }\n) {\n const keyProperties = keyConfig[keyType]\n\n const innerEnglishContent = drillDown(\n keyType,\n entity,\n keyProperties.jsonSuffix\n )\n\n const keyName = `${keyProperties.jsonPrefix}.${entity.id}.${keyProperties.jsonSuffix}`\n\n return {\n name: keyName,\n type: keyType,\n pageNum,\n questionNum,\n itemNum,\n englishContent: innerEnglishContent,\n welshContent:\n validation?.formValues[keyName] ??\n lookupTranslation(keyName, translations),\n label: keyProperties.getLabel(pageNum, questionNum, itemNum)\n }\n}\n\nconst allowedControllerTypesSet = new Set([\n ControllerType.Page,\n ControllerType.Repeat,\n ControllerType.Start,\n ControllerType.FileUpload,\n ControllerType.Terminal\n])\n\n/**\n * Build the translation rows for a single page.\n * @param {Page} page - The page definition to inspect for translatable content.\n * @param {number} pageNum - The page number used in the generated labels.\n * @param {Record<string, string>} translations - Existing Welsh translations keyed by translation name.\n * @param {ValidationFailure<any>} [validation] - Optional validation context for posted form values.\n * @returns {TranslationRow[]} The translation rows generated for the page.\n */\nfunction buildPage(page, pageNum, translations, validation) {\n if (page.controller && !allowedControllerTypesSet.has(page.controller)) {\n return []\n }\n\n const translationRows = []\n if (page.title) {\n const keyProperties = keyConfig[TranslationRowTypes.PageHeading]\n\n const keyName = `${keyProperties.jsonPrefix}.${page.id}.${keyProperties.jsonSuffix}`\n\n translationRows.push({\n name: keyName,\n type: TranslationRowTypes.PageHeading,\n pageNum,\n englishContent: page.title,\n welshContent:\n validation?.formValues[keyName] ??\n lookupTranslation(keyName, translations),\n label: keyProperties.getLabel(pageNum)\n })\n }\n\n const guidance =\n hasComponents(page) && page.components[0].type === ComponentType.Markdown\n ? page.components[0]\n : undefined\n if (guidance) {\n const keyProperties = keyConfig[TranslationRowTypes.PageGuidance]\n const keyName = `${keyProperties.jsonPrefix}.${guidance.id}.${keyProperties.jsonSuffix}`\n\n translationRows.push({\n name: keyName,\n type: TranslationRowTypes.PageGuidance,\n pageNum,\n englishContent: guidance.content,\n welshContent:\n validation?.formValues[keyName] ??\n lookupTranslation(keyName, translations),\n label: keyProperties.getLabel(pageNum)\n })\n }\n\n if (page.controller === ControllerType.Repeat) {\n const keyProperties = keyConfig[TranslationRowTypes.RepeatTitle]\n const keyName = `${keyProperties.jsonPrefix}.${page.id}.${keyProperties.jsonSuffix}`\n\n translationRows.push({\n name: keyName,\n type: TranslationRowTypes.RepeatTitle,\n pageNum,\n englishContent: page.repeat.options.title,\n welshContent:\n validation?.formValues[keyName] ??\n lookupTranslation(keyName, translations),\n label: keyProperties.getLabel(pageNum)\n })\n }\n\n return translationRows\n}\n\n/**\n * Build the translation rows for a single component.\n * @param {FormDefinition} definition - The overall form definition used to resolve list-based content.\n * @param {ComponentDef} component - The component to inspect for translatable fields.\n * @param {number} pageNum - The page number used in the generated labels.\n * @param {number} questionNum - The question number used in the generated labels.\n * @param {Record<string, string>} translations - Existing Welsh translations keyed by translation name.\n * @param {ValidationFailure<any>} [validation] - Optional validation context for posted form values.\n * @returns {TranslationRow[]} The translation rows generated for the component.\n */\nexport function buildComponent(\n definition,\n component,\n pageNum,\n questionNum,\n translations,\n validation\n) {\n if (IGNORE_FIELDS.includes(component.type)) {\n return []\n }\n\n const rows = []\n\n const options = { pageNum, questionNum, translations, validation }\n\n const typed = /** @type {InputFieldsComponentsDef} */ (component)\n if (typed.title && component.type !== ComponentType.PaymentField) {\n rows.push(createRow(component, TranslationRowTypes.QuestionText, options))\n }\n if (typed.hint) {\n rows.push(createRow(component, TranslationRowTypes.QuestionHint, options))\n }\n\n if (component.type !== ComponentType.PaymentField) {\n rows.push(\n createRow(component, TranslationRowTypes.ShortDescription, options)\n )\n if (typed.errorDescription) {\n rows.push(\n createRow(component, TranslationRowTypes.ErrorDescription, options)\n )\n }\n } else {\n rows.push(\n createRow(component, TranslationRowTypes.PaymentDescription, options)\n )\n }\n\n if (component.type === ComponentType.DeclarationField) {\n rows.push(\n createRow(component, TranslationRowTypes.DeclarationBody, options)\n )\n }\n\n if (typed.options.instructionText && isTypeWithInstructions(component.type)) {\n rows.push(\n createRow(component, TranslationRowTypes.InstructionText, options)\n )\n }\n\n if (isListType(component.type)) {\n addSelectionOptions(rows, component, definition, options)\n }\n return rows\n}\n\n/**\n * Add translation rows for the select item options of a list-based component.\n * @param {any[]} rows - The accumulator for translation rows.\n * @param {ComponentDef} component - The list-based component to inspect.\n * @param {FormDefinition} definition - The form definition that contains the option list data.\n * @param {{ pageNum: number, questionNum?: number, translations: Record<string, string>, validation?: ValidationFailure<any> }} options - The row context including numbering and translation values.\n */\nfunction addSelectionOptions(rows, component, definition, options) {\n // Temporary workaround - ignore for Yes/No and use defaults in the plugin,\n // until we create a solution that allows users to override the Yes/No options\n if (component.type === ComponentType.YesNoField) {\n return\n }\n\n const list = getListFromComponent(component, definition)\n if (list?.items.length) {\n let itemNum = 0\n for (const item of list.items) {\n itemNum++\n const listOptions = {\n ...options,\n itemNum\n }\n if (item.hint) {\n rows.push(\n createRow(item, TranslationRowTypes.ListItemText, listOptions),\n createRow(item, TranslationRowTypes.ListItemHint, listOptions)\n )\n } else {\n rows.push(\n createRow(item, TranslationRowTypes.ListItemText, listOptions)\n )\n }\n }\n }\n}\n\n/**\n * Build the overview and form translation rows for a form definition.\n * @param {FormMetadata} metadata - The form metadata used to build the overview section.\n * @param {FormDefinition} definition - The form definition containing pages and components.\n * @param {ValidationFailure<any>} [validation] - Optional validation context for posted form values.\n * @returns {{ overviewRows: TranslationRow[], formRows: TranslationRow[] }} The generated overview and form translation rows.\n */\nexport function buildTranslationDataRows(metadata, definition, validation) {\n const translationsJSON = /** @type {Record<string, string>} */ (\n // @ts-expect-error - dynamic language definition\n definition.metadata?.translations?.cy\n )\n\n const overviewRows = buildOverviewSection(\n metadata,\n definition,\n translationsJSON,\n validation\n )\n\n const formRows = []\n for (const page of definition.pages) {\n const pageId = /** @type {string} */ (page.id)\n const pageNum = getPageNum(definition, pageId)\n const components = hasComponents(page) ? page.components : []\n if (components.length === 0) {\n continue\n }\n\n formRows.push(...buildPage(page, pageNum, translationsJSON, validation))\n\n for (const component of components) {\n if (component.type === ComponentType.Markdown) {\n continue\n }\n const questionId = /** @type {string} */ (component.id)\n const questionNum = getQuestionNum(definition, pageId, questionId)\n\n formRows.push(\n ...buildComponent(\n definition,\n component,\n pageNum,\n questionNum,\n translationsJSON,\n validation\n )\n )\n }\n }\n\n return {\n overviewRows,\n formRows\n }\n}\n\n/**\n * @import { ComponentDef, InputFieldsComponentsDef } from '~/src/components/types.js'\n * @import { FormMetadata } from '~/src/form/form-metadata/types.js'\n * @import { FormDefinition, Item, Page } from '~/src/form/form-definition/types.js'\n * @import { TranslationRow, ValidationFailure } from '~/src/form/form-editor/translations/translations-config.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,UAAU,EAAEC,sBAAsB;AAC3C,SACEC,aAAa,EACbC,mBAAmB,EACnBC,SAAS,EACTC,SAAS,EACTC,iBAAiB;AAEnB,SAASC,oBAAoB;AAC7B,SAASC,oBAAoB;AAC7B,SAASC,UAAU,EAAEC,cAAc;AACnC,SAASC,cAAc;AACvB,SAASC,aAAa;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,SAASA,CAChBC,MAAM,EACNC,OAAO,EACP;EAAEC,OAAO;EAAEC,WAAW;EAAEC,OAAO;EAAEC,YAAY;EAAEC;AAAW,CAAC,EAC3D;EACA,MAAMC,aAAa,GAAGhB,SAAS,CAACU,OAAO,CAAC;EAExC,MAAMO,mBAAmB,GAAGlB,SAAS,CACnCW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AAI,CAACQ,UAAU,GAAG,EAAE;IAC7D,IAAIA,UAAU,CAAC8B,MAAM,KAAK,CAAC,EAAE;MAC3B;IACF;IAEAU,QAAQ,CAAC1C,IAAI,CAAC,GAAGP,SAAS,CAACC,IAAI,EAAE1B,OAAO,EAAEuE,gBAAgB,EAAEnE,UAAU,CAAC,CAAC;IAExE,KAAK,MAAMwC,SAAS,IAAIV,UAAU,EAAE;MAClC,IAAIU,SAAS,CAAChC,IAAI,KAAK7B,aAAa,CAACoD,QAAQ,EAAE;QAC7C;MACF;MACA,MAAM0C,UAAU,GAAG,qBAAuBjC,SAAS,CAAClC,EAAG;MACvD,MAAMT,WAAW,GAAGP,cAAc,CAACiD,UAAU,EAAEiC,MAAM,EAAEC,UAAU,CAAC;MAElEH,QAAQ,CAAC1C,IAAI,CACX,GAAGU,cAAc,CACfC,UAAU,EACVC,SAAS,EACT5C,OAAO,EACPC,WAAW,EACXsE,gBAAgB,EAChBnE,UACF,CACF,CAAC;IACH;EACF;EAEA,OAAO;IACLqE,YAAY;IACZC;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -31,6 +31,9 @@ export const formSubmitPayloadSchema = Joi.object().keys({
|
|
|
31
31
|
referenceNumber: Joi.string()
|
|
32
32
|
// TODO - make this required in later releases - optional for now to avoid release glitches
|
|
33
33
|
.optional().allow('').description('Reference number for the form submission'),
|
|
34
|
+
language: Joi.string()
|
|
35
|
+
// TODO - make this required in later releases - optional for now to avoid release glitches
|
|
36
|
+
.optional().allow('').description('The currently-selected language at point of form submission'),
|
|
34
37
|
main: Joi.array().items(formSubmitRecordSchema).required().description('Main (non-repeating) field values from the form'),
|
|
35
38
|
repeaters: Joi.array().items(formSubmitRecordsetSchema).required().description('Repeatable section values from the form')
|
|
36
39
|
}).required().label('FormSubmitPayload').description('Complete form submission payload structure with all form data');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Joi","FormStatus","SecurityQuestionsEnum","SubmissionEventMessageCategory","SubmissionEventMessageSchemaVersion","SubmissionEventMessageSource","SubmissionEventMessageType","formSubmitRecordSchema","object","name","string","required","description","title","value","allow","label","formSubmitRecordsetSchema","array","items","formSubmitPayloadSchema","keys","retrievalKey","sessionId","referenceNumber","optional","main","repeaters","saveAndExitMessageData","form","id","status","valid","Draft","Live","isPreview","boolean","baseUrl","email","security","question","Object","values","answer","state","magicLinkGroupId","submissionMessageSchema","schemaVersion","category","source","type","createdAt","date","messageCreatedAt","data"],"sources":["../../../../src/form/form-submission/index.ts"],"sourcesContent":["import Joi from 'joi'\n\nimport { FormStatus } from '~/src/common/enums.js'\nimport {\n SecurityQuestionsEnum,\n SubmissionEventMessageCategory,\n SubmissionEventMessageSchemaVersion,\n SubmissionEventMessageSource,\n SubmissionEventMessageType\n} from '~/src/form/form-submission/enums.js'\nimport {\n type SaveAndExitMessage,\n type SaveAndExitMessageData,\n type SubmitPayload,\n type SubmitRecord,\n type SubmitRecordset\n} from '~/src/form/form-submission/types.js'\n\n/**\n * Joi schema for `SubmitRecord` interface\n * @see {@link SubmitRecord}\n */\nexport const formSubmitRecordSchema = Joi.object<SubmitRecord>({\n name: Joi.string()\n .required()\n .description('Field identifier matching the component name'),\n title: Joi.string()\n .required()\n .description('Human-readable label for the field'),\n value: Joi.string()\n .required()\n .allow('')\n .description('User-submitted value for the field, may be empty')\n})\n .label('FormSubmitRecord')\n .description('Individual field value in a form submission')\n\n/**\n * Joi schema for `SubmitRecordset` interface\n * @see {@link SubmitRecordset}\n */\nexport const formSubmitRecordsetSchema = Joi.object<SubmitRecordset>({\n name: Joi.string()\n .required()\n .description('Identifier for the repeatable section'),\n title: Joi.string()\n .required()\n .description('Human-readable title for the repeatable section'),\n value: Joi.array<SubmitRecord[]>()\n .items(\n Joi.array<SubmitRecord>()\n .items(formSubmitRecordSchema)\n .required()\n .label('FormSubmitRecordGroup')\n )\n .required()\n .description(\n 'Array of record arrays, each representing a repeated instance'\n )\n})\n .label('FormSubmitRecordset')\n .description('Collection of repeated field values from a repeatable section')\n\n/**\n * Joi schema for `SubmitPayload` interface\n * @see {@link SubmitPayload}\n */\nexport const formSubmitPayloadSchema = Joi.object<SubmitPayload>()\n .keys({\n retrievalKey: Joi.string()\n .required()\n .description('Unique key to retrieve this submission later'),\n sessionId: Joi.string()\n .required()\n .description('User session identifier for tracking and security'),\n referenceNumber: Joi.string()\n // TODO - make this required in later releases - optional for now to avoid release glitches\n .optional()\n .allow('')\n .description('Reference number for the form submission'),\n main: Joi.array<SubmitRecord>()\n .items(formSubmitRecordSchema)\n .required()\n .description('Main (non-repeating) field values from the form'),\n repeaters: Joi.array<SubmitRecordset>()\n .items(formSubmitRecordsetSchema)\n .required()\n .description('Repeatable section values from the form')\n })\n .required()\n .label('FormSubmitPayload')\n .description('Complete form submission payload structure with all form data')\n\nexport const saveAndExitMessageData = Joi.object<SaveAndExitMessageData>()\n .keys({\n form: Joi.object({\n id: Joi.string().required(),\n title: Joi.string().required(),\n status: Joi.string().valid(FormStatus.Draft, FormStatus.Live).required(),\n isPreview: Joi.boolean().required(),\n baseUrl: Joi.string().required()\n }).label('SaveAndExitForm'),\n email: Joi.string().required(),\n security: Joi.object({\n question: Joi.string()\n .valid(...Object.values(SecurityQuestionsEnum))\n .required(),\n answer: Joi.string().required()\n }).label('SaveAndExitSecurity'),\n state: Joi.object().required(),\n magicLinkGroupId: Joi.string().optional()\n })\n .label('SaveAndExitMessageData')\n\nexport const submissionMessageSchema = Joi.object<SaveAndExitMessage>().keys({\n schemaVersion: Joi.string()\n .valid(...Object.values(SubmissionEventMessageSchemaVersion))\n .required()\n .description(\n 'The version of the SubmissionMessage - bumped with breaking changes'\n ),\n category: Joi.string()\n .valid(...Object.values(SubmissionEventMessageCategory))\n .required()\n .description('The message category - what does the entityId represent?'),\n source: Joi.string()\n .valid(...Object.values(SubmissionEventMessageSource))\n .required()\n .description('Source of the message - which service?'),\n type: Joi.string()\n .valid(...Object.values(SubmissionEventMessageType))\n .description('Event type'),\n createdAt: Joi.date()\n .required()\n .description(\n 'The ISO timestamp where the action took place - should be the same as updated_at field in DB'\n ),\n messageCreatedAt: Joi.date()\n .required()\n .description('ISO timestamp when the message was published'),\n data: saveAndExitMessageData\n})\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,KAAK;AAErB,SAASC,UAAU;AACnB,SACEC,qBAAqB,EACrBC,8BAA8B,EAC9BC,mCAAmC,EACnCC,4BAA4B,EAC5BC,0BAA0B;AAU5B;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAGP,GAAG,CAACQ,MAAM,CAAe;EAC7DC,IAAI,EAAET,GAAG,CAACU,MAAM,CAAC,CAAC,CACfC,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,8CAA8C,CAAC;EAC9DC,KAAK,EAAEb,GAAG,CAACU,MAAM,CAAC,CAAC,CAChBC,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,oCAAoC,CAAC;EACpDE,KAAK,EAAEd,GAAG,CAACU,MAAM,CAAC,CAAC,CAChBC,QAAQ,CAAC,CAAC,CACVI,KAAK,CAAC,EAAE,CAAC,CACTH,WAAW,CAAC,kDAAkD;AACnE,CAAC,CAAC,CACCI,KAAK,CAAC,kBAAkB,CAAC,CACzBJ,WAAW,CAAC,6CAA6C,CAAC;;AAE7D;AACA;AACA;AACA;AACA,OAAO,MAAMK,yBAAyB,GAAGjB,GAAG,CAACQ,MAAM,CAAkB;EACnEC,IAAI,EAAET,GAAG,CAACU,MAAM,CAAC,CAAC,CACfC,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,uCAAuC,CAAC;EACvDC,KAAK,EAAEb,GAAG,CAACU,MAAM,CAAC,CAAC,CAChBC,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,iDAAiD,CAAC;EACjEE,KAAK,EAAEd,GAAG,CAACkB,KAAK,CAAiB,CAAC,CAC/BC,KAAK,CACJnB,GAAG,CAACkB,KAAK,CAAe,CAAC,CACtBC,KAAK,CAACZ,sBAAsB,CAAC,CAC7BI,QAAQ,CAAC,CAAC,CACVK,KAAK,CAAC,uBAAuB,CAClC,CAAC,CACAL,QAAQ,CAAC,CAAC,CACVC,WAAW,CACV,+DACF;AACJ,CAAC,CAAC,CACCI,KAAK,CAAC,qBAAqB,CAAC,CAC5BJ,WAAW,CAAC,+DAA+D,CAAC;;AAE/E;AACA;AACA;AACA;AACA,OAAO,MAAMQ,uBAAuB,GAAGpB,GAAG,CAACQ,MAAM,CAAgB,CAAC,CAC/Da,IAAI,CAAC;EACJC,YAAY,EAAEtB,GAAG,CAACU,MAAM,CAAC,CAAC,CACvBC,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,8CAA8C,CAAC;EAC9DW,SAAS,EAAEvB,GAAG,CAACU,MAAM,CAAC,CAAC,CACpBC,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,mDAAmD,CAAC;EACnEY,eAAe,EAAExB,GAAG,CAACU,MAAM,CAAC;EAC1B;EAAA,CACCe,QAAQ,CAAC,CAAC,CACVV,KAAK,CAAC,EAAE,CAAC,CACTH,WAAW,CAAC,0CAA0C,CAAC;EAC1Dc,
|
|
1
|
+
{"version":3,"file":"index.js","names":["Joi","FormStatus","SecurityQuestionsEnum","SubmissionEventMessageCategory","SubmissionEventMessageSchemaVersion","SubmissionEventMessageSource","SubmissionEventMessageType","formSubmitRecordSchema","object","name","string","required","description","title","value","allow","label","formSubmitRecordsetSchema","array","items","formSubmitPayloadSchema","keys","retrievalKey","sessionId","referenceNumber","optional","language","main","repeaters","saveAndExitMessageData","form","id","status","valid","Draft","Live","isPreview","boolean","baseUrl","email","security","question","Object","values","answer","state","magicLinkGroupId","submissionMessageSchema","schemaVersion","category","source","type","createdAt","date","messageCreatedAt","data"],"sources":["../../../../src/form/form-submission/index.ts"],"sourcesContent":["import Joi from 'joi'\n\nimport { FormStatus } from '~/src/common/enums.js'\nimport {\n SecurityQuestionsEnum,\n SubmissionEventMessageCategory,\n SubmissionEventMessageSchemaVersion,\n SubmissionEventMessageSource,\n SubmissionEventMessageType\n} from '~/src/form/form-submission/enums.js'\nimport {\n type SaveAndExitMessage,\n type SaveAndExitMessageData,\n type SubmitPayload,\n type SubmitRecord,\n type SubmitRecordset\n} from '~/src/form/form-submission/types.js'\n\n/**\n * Joi schema for `SubmitRecord` interface\n * @see {@link SubmitRecord}\n */\nexport const formSubmitRecordSchema = Joi.object<SubmitRecord>({\n name: Joi.string()\n .required()\n .description('Field identifier matching the component name'),\n title: Joi.string()\n .required()\n .description('Human-readable label for the field'),\n value: Joi.string()\n .required()\n .allow('')\n .description('User-submitted value for the field, may be empty')\n})\n .label('FormSubmitRecord')\n .description('Individual field value in a form submission')\n\n/**\n * Joi schema for `SubmitRecordset` interface\n * @see {@link SubmitRecordset}\n */\nexport const formSubmitRecordsetSchema = Joi.object<SubmitRecordset>({\n name: Joi.string()\n .required()\n .description('Identifier for the repeatable section'),\n title: Joi.string()\n .required()\n .description('Human-readable title for the repeatable section'),\n value: Joi.array<SubmitRecord[]>()\n .items(\n Joi.array<SubmitRecord>()\n .items(formSubmitRecordSchema)\n .required()\n .label('FormSubmitRecordGroup')\n )\n .required()\n .description(\n 'Array of record arrays, each representing a repeated instance'\n )\n})\n .label('FormSubmitRecordset')\n .description('Collection of repeated field values from a repeatable section')\n\n/**\n * Joi schema for `SubmitPayload` interface\n * @see {@link SubmitPayload}\n */\nexport const formSubmitPayloadSchema = Joi.object<SubmitPayload>()\n .keys({\n retrievalKey: Joi.string()\n .required()\n .description('Unique key to retrieve this submission later'),\n sessionId: Joi.string()\n .required()\n .description('User session identifier for tracking and security'),\n referenceNumber: Joi.string()\n // TODO - make this required in later releases - optional for now to avoid release glitches\n .optional()\n .allow('')\n .description('Reference number for the form submission'),\n language: Joi.string()\n // TODO - make this required in later releases - optional for now to avoid release glitches\n .optional()\n .allow('')\n .description(\n 'The currently-selected language at point of form submission'\n ),\n main: Joi.array<SubmitRecord>()\n .items(formSubmitRecordSchema)\n .required()\n .description('Main (non-repeating) field values from the form'),\n repeaters: Joi.array<SubmitRecordset>()\n .items(formSubmitRecordsetSchema)\n .required()\n .description('Repeatable section values from the form')\n })\n .required()\n .label('FormSubmitPayload')\n .description('Complete form submission payload structure with all form data')\n\nexport const saveAndExitMessageData = Joi.object<SaveAndExitMessageData>()\n .keys({\n form: Joi.object({\n id: Joi.string().required(),\n title: Joi.string().required(),\n status: Joi.string().valid(FormStatus.Draft, FormStatus.Live).required(),\n isPreview: Joi.boolean().required(),\n baseUrl: Joi.string().required()\n }).label('SaveAndExitForm'),\n email: Joi.string().required(),\n security: Joi.object({\n question: Joi.string()\n .valid(...Object.values(SecurityQuestionsEnum))\n .required(),\n answer: Joi.string().required()\n }).label('SaveAndExitSecurity'),\n state: Joi.object().required(),\n magicLinkGroupId: Joi.string().optional()\n })\n .label('SaveAndExitMessageData')\n\nexport const submissionMessageSchema = Joi.object<SaveAndExitMessage>().keys({\n schemaVersion: Joi.string()\n .valid(...Object.values(SubmissionEventMessageSchemaVersion))\n .required()\n .description(\n 'The version of the SubmissionMessage - bumped with breaking changes'\n ),\n category: Joi.string()\n .valid(...Object.values(SubmissionEventMessageCategory))\n .required()\n .description('The message category - what does the entityId represent?'),\n source: Joi.string()\n .valid(...Object.values(SubmissionEventMessageSource))\n .required()\n .description('Source of the message - which service?'),\n type: Joi.string()\n .valid(...Object.values(SubmissionEventMessageType))\n .description('Event type'),\n createdAt: Joi.date()\n .required()\n .description(\n 'The ISO timestamp where the action took place - should be the same as updated_at field in DB'\n ),\n messageCreatedAt: Joi.date()\n .required()\n .description('ISO timestamp when the message was published'),\n data: saveAndExitMessageData\n})\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,KAAK;AAErB,SAASC,UAAU;AACnB,SACEC,qBAAqB,EACrBC,8BAA8B,EAC9BC,mCAAmC,EACnCC,4BAA4B,EAC5BC,0BAA0B;AAU5B;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAGP,GAAG,CAAC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M,CAAC,CAAC,CACnBuB,KAAK,CAAC,GAAGS,MAAM,CAACC,MAAM,CAACxC,8BAA8B,CAAC,CAAC,CACvDQ,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,0DAA0D,CAAC;EAC1EsC,MAAM,EAAElD,GAAG,CAACU,MAAM,CAAC,CAAC,CACjBuB,KAAK,CAAC,GAAGS,MAAM,CAACC,MAAM,CAACtC,4BAA4B,CAAC,CAAC,CACrDM,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,wCAAwC,CAAC;EACxDuC,IAAI,EAAEnD,GAAG,CAACU,MAAM,CAAC,CAAC,CACfuB,KAAK,CAAC,GAAGS,MAAM,CAACC,MAAM,CAACrC,0BAA0B,CAAC,CAAC,CACnDM,WAAW,CAAC,YAAY,CAAC;EAC5BwC,SAAS,EAAEpD,GAAG,CAACqD,IAAI,CAAC,CAAC,CAClB1C,QAAQ,CAAC,CAAC,CACVC,WAAW,CACV,8FACF,CAAC;EACH0C,gBAAgB,EAAEtD,GAAG,CAACqD,IAAI,CAAC,CAAC,CACzB1C,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,8CAA8C,CAAC;EAC9D2C,IAAI,EAAE1B;AACR,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/form/form-submission/types.ts"],"sourcesContent":["import { type FormStatus } from '~/src/common/enums.js'\nimport {\n type SecurityQuestionsEnum,\n type SubmissionEventMessageCategory,\n type SubmissionEventMessageSchemaVersion,\n type SubmissionEventMessageSource,\n type SubmissionEventMessageType\n} from '~/src/form/form-submission/enums.js'\nimport {\n formSubmitPayloadSchema,\n formSubmitRecordSchema,\n formSubmitRecordsetSchema\n} from '~/src/form/form-submission/index.js'\n\n/**\n * Interface for an individual submit record\n * @see {@link formSubmitRecordSchema}\n */\nexport interface SubmitRecord {\n /**\n * The field name\n */\n name: string\n\n /**\n * The field title\n */\n title: string\n\n /**\n * The field display value\n */\n value: string\n}\n\n/**\n * Interface for an individual submit recordset (e.g. a repeater question set)\n * @see {@link formSubmitRecordsetSchema}\n */\nexport interface SubmitRecordset {\n /**\n * The name of the recordset\n */\n name: string\n\n /**\n * The title of the recordset\n */\n title: string\n\n /**\n * The record items\n */\n value: SubmitRecord[][]\n}\n\n/**\n * Interface for the submission-api `/submit` payload\n * @see {@link formSubmitPayloadSchema}\n */\nexport interface SubmitPayload {\n /**\n * The retrieval key for files created in the submission\n */\n retrievalKey: string\n\n /**\n * The id of the user session\n */\n sessionId: string\n\n /**\n * The reference number of the user session\n */\n referenceNumber?: string\n\n /**\n * The main form anwsers\n */\n main: SubmitRecord[]\n\n /**\n * The repeaters form answers\n */\n repeaters: SubmitRecordset[]\n}\n\n/**\n * Interface for the submission-api `/submit` response payload\n */\nexport interface SubmitResponsePayload {\n message: string\n result: {\n files: {\n main: string\n repeaters: Record<string, string>\n }\n }\n}\n\nexport interface SaveAndExitMessageData {\n magicLinkGroupId?: string\n form: {\n id: string\n title: string\n status: FormStatus\n isPreview: boolean\n baseUrl: string\n }\n email: string\n security: {\n question: SecurityQuestionsEnum\n answer: string\n }\n state: object\n}\n\nexport interface SaveAndExitMessage {\n schemaVersion: SubmissionEventMessageSchemaVersion\n source: SubmissionEventMessageSource\n createdAt: Date\n messageCreatedAt: Date\n category: SubmissionEventMessageCategory.RUNNER\n type: SubmissionEventMessageType.RUNNER_SAVE_AND_EXIT\n data: SaveAndExitMessageData\n}\n\nexport interface SaveAndExitRecord {\n magicLinkId: string\n magicLinkGroupId: string\n form: {\n id: string\n status: FormStatus\n isPreview: boolean\n baseUrl: string\n }\n email: string\n security: {\n question: SecurityQuestionsEnum\n answer: string\n }\n state: object\n invalidPasswordAttempts: number\n createdAt: Date\n}\n\nexport type RunnerMessage = SaveAndExitMessage\n\nexport interface RunnerRecordBase {\n messageId: string\n recordCreatedAt: Date\n}\n\nexport interface RunnerRecordInputMeta extends RunnerRecordBase {\n id: string\n}\n\nexport type RunnerRecordInput = RunnerMessage & RunnerRecordBase\n\nexport type RunnerRecord = RunnerMessage & RunnerRecordInputMeta\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/form/form-submission/types.ts"],"sourcesContent":["import { type FormStatus } from '~/src/common/enums.js'\nimport {\n type SecurityQuestionsEnum,\n type SubmissionEventMessageCategory,\n type SubmissionEventMessageSchemaVersion,\n type SubmissionEventMessageSource,\n type SubmissionEventMessageType\n} from '~/src/form/form-submission/enums.js'\nimport {\n formSubmitPayloadSchema,\n formSubmitRecordSchema,\n formSubmitRecordsetSchema\n} from '~/src/form/form-submission/index.js'\n\n/**\n * Interface for an individual submit record\n * @see {@link formSubmitRecordSchema}\n */\nexport interface SubmitRecord {\n /**\n * The field name\n */\n name: string\n\n /**\n * The field title\n */\n title: string\n\n /**\n * The field display value\n */\n value: string\n}\n\n/**\n * Interface for an individual submit recordset (e.g. a repeater question set)\n * @see {@link formSubmitRecordsetSchema}\n */\nexport interface SubmitRecordset {\n /**\n * The name of the recordset\n */\n name: string\n\n /**\n * The title of the recordset\n */\n title: string\n\n /**\n * The record items\n */\n value: SubmitRecord[][]\n}\n\n/**\n * Interface for the submission-api `/submit` payload\n * @see {@link formSubmitPayloadSchema}\n */\nexport interface SubmitPayload {\n /**\n * The retrieval key for files created in the submission\n */\n retrievalKey: string\n\n /**\n * The id of the user session\n */\n sessionId: string\n\n /**\n * The reference number of the user session\n */\n referenceNumber?: string\n\n /**\n * The currently-selected language at the point of submission\n */\n language?: string\n\n /**\n * The main form anwsers\n */\n main: SubmitRecord[]\n\n /**\n * The repeaters form answers\n */\n repeaters: SubmitRecordset[]\n}\n\n/**\n * Interface for the submission-api `/submit` response payload\n */\nexport interface SubmitResponsePayload {\n message: string\n result: {\n files: {\n main: string\n repeaters: Record<string, string>\n }\n }\n}\n\nexport interface SaveAndExitMessageData {\n magicLinkGroupId?: string\n form: {\n id: string\n title: string\n status: FormStatus\n isPreview: boolean\n baseUrl: string\n }\n email: string\n security: {\n question: SecurityQuestionsEnum\n answer: string\n }\n state: object\n}\n\nexport interface SaveAndExitMessage {\n schemaVersion: SubmissionEventMessageSchemaVersion\n source: SubmissionEventMessageSource\n createdAt: Date\n messageCreatedAt: Date\n category: SubmissionEventMessageCategory.RUNNER\n type: SubmissionEventMessageType.RUNNER_SAVE_AND_EXIT\n data: SaveAndExitMessageData\n}\n\nexport interface SaveAndExitRecord {\n magicLinkId: string\n magicLinkGroupId: string\n form: {\n id: string\n status: FormStatus\n isPreview: boolean\n baseUrl: string\n }\n email: string\n security: {\n question: SecurityQuestionsEnum\n answer: string\n }\n state: object\n invalidPasswordAttempts: number\n createdAt: Date\n}\n\nexport type RunnerMessage = SaveAndExitMessage\n\nexport interface RunnerRecordBase {\n messageId: string\n recordCreatedAt: Date\n}\n\nexport interface RunnerRecordInputMeta extends RunnerRecordBase {\n id: string\n}\n\nexport type RunnerRecordInput = RunnerMessage & RunnerRecordBase\n\nexport type RunnerRecord = RunnerMessage & RunnerRecordInputMeta\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translations-config.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/translations/translations-config.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"translations-config.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/translations/translations-config.js"],"names":[],"mappings":"AA2IA;;;;GAIG;AACH,uCAHW,MAAM,gBACN,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,UAO5C;AAED;;;;;;GAMG;AACH,mCAJW,MAAM,UACN,YAAY,GAAG,IAAI,GAAG,IAAI,cAC1B,MAAM,UA+BhB;;;;;;;;;;;;;;;AAlJD,8BAA+B,WAAW,CAAA;AAC1C,8BAA+B,WAAW,CAAA;AAC1C,6CAA8C,oBAAoB,CAAA;AAClE,6BAA8B,cAAc,CAAA;AAC5C,4CAA6C,6BAA6B,CAAA;AAE1E,6KAA6K;AAC7K,wBADW,MAAM,CAAC,MAAM,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,MAAM,CAAA;CAAE,CAAC,CAmFxK;AAED,4CAKC;;;;;UArIa,MAAM;;;;;;;;oBAEN,MAAM,GAAG,SAAS;;;;kBAClB,MAAM,GAAG,SAAS;;;;;;;;;;;;;;;;;;+BAQnB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE;2BAC/B,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC;8BAItB,MAAM;;;;gBAEf,YAAY;;;;gBACZ,MAAM;;kCAuKa,2BAA2B;0BAC7B,qCAAqC;0BAArC,qCAAqC;8BA/LtC,2BAA2B"}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build the translation rows for a single component.
|
|
3
|
+
* @param {FormDefinition} definition - The overall form definition used to resolve list-based content.
|
|
4
|
+
* @param {ComponentDef} component - The component to inspect for translatable fields.
|
|
5
|
+
* @param {number} pageNum - The page number used in the generated labels.
|
|
6
|
+
* @param {number} questionNum - The question number used in the generated labels.
|
|
7
|
+
* @param {Record<string, string>} translations - Existing Welsh translations keyed by translation name.
|
|
8
|
+
* @param {ValidationFailure<any>} [validation] - Optional validation context for posted form values.
|
|
9
|
+
* @returns {TranslationRow[]} The translation rows generated for the component.
|
|
10
|
+
*/
|
|
11
|
+
export function buildComponent(definition: FormDefinition, component: ComponentDef, pageNum: number, questionNum: number, translations: Record<string, string>, validation?: ValidationFailure<any>): TranslationRow[];
|
|
1
12
|
/**
|
|
2
13
|
* Build the overview and form translation rows for a form definition.
|
|
3
14
|
* @param {FormMetadata} metadata - The form metadata used to build the overview section.
|
|
@@ -9,8 +20,9 @@ export function buildTranslationDataRows(metadata: FormMetadata, definition: For
|
|
|
9
20
|
overviewRows: TranslationRow[];
|
|
10
21
|
formRows: TranslationRow[];
|
|
11
22
|
};
|
|
12
|
-
import type { FormMetadata } from '../../../form/form-metadata/types.js';
|
|
13
23
|
import type { FormDefinition } from '../../../form/form-definition/types.js';
|
|
24
|
+
import type { ComponentDef } from '../../../components/types.js';
|
|
14
25
|
import type { ValidationFailure } from '../../../form/form-editor/translations/translations-config.js';
|
|
15
26
|
import type { TranslationRow } from '../../../form/form-editor/translations/translations-config.js';
|
|
27
|
+
import type { FormMetadata } from '../../../form/form-metadata/types.js';
|
|
16
28
|
//# sourceMappingURL=translations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/translations/translations.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/translations/translations.js"],"names":[],"mappings":"AAiIA;;;;;;;;;GASG;AACH,2CARW,cAAc,aACd,YAAY,WACZ,MAAM,eACN,MAAM,gBACN,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,eACtB,kBAAkB,GAAG,CAAC,GACpB,cAAc,EAAE,CAyD5B;AAuCD;;;;;;GAMG;AACH,mDALW,YAAY,cACZ,cAAc,eACd,kBAAkB,GAAG,CAAC,GACpB;IAAE,YAAY,EAAE,cAAc,EAAE,CAAC;IAAC,QAAQ,EAAE,cAAc,EAAE,CAAA;CAAE,CAkD1E;oCAK8C,qCAAqC;kCAFzB,2BAA2B;uCAGhC,4DAA4D;oCAA5D,4DAA4D;kCAFjF,mCAAmC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/form/form-submission/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AAUrB,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,eAAe,EACrB,MAAM,qCAAqC,CAAA;AAE5C;;;GAGG;AACH,eAAO,MAAM,sBAAsB,gCAa0B,CAAA;AAE7D;;;GAGG;AACH,eAAO,MAAM,yBAAyB,mCAoByC,CAAA;AAE/E;;;GAGG;AACH,eAAO,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/form/form-submission/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AAUrB,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,eAAe,EACrB,MAAM,qCAAqC,CAAA;AAE5C;;;GAGG;AACH,eAAO,MAAM,sBAAsB,gCAa0B,CAAA;AAE7D;;;GAGG;AACH,eAAO,MAAM,yBAAyB,mCAoByC,CAAA;AAE/E;;;GAGG;AACH,eAAO,MAAM,uBAAuB,iCA+B2C,CAAA;AAE/E,eAAO,MAAM,sBAAsB,0CAmBD,CAAA;AAElC,eAAO,MAAM,uBAAuB,sCA2BlC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/form/form-submission/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,8BAA8B,EACnC,KAAK,mCAAmC,EACxC,KAAK,4BAA4B,EACjC,KAAK,0BAA0B,EAChC,MAAM,qCAAqC,CAAA;AAO5C;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IA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
"title": "Reference Number"
|
|
19
19
|
},
|
|
20
|
+
"language": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "The currently-selected language at point of form submission",
|
|
23
|
+
"title": "Language"
|
|
24
|
+
},
|
|
20
25
|
"main": {
|
|
21
26
|
"type": "array",
|
|
22
27
|
"description": "Main (non-repeating) field values from the form",
|
|
@@ -68,6 +68,13 @@ export const keyConfig = {
|
|
|
68
68
|
getLabel: (pageNum, questionNum) =>
|
|
69
69
|
`Welsh short description - Page ${pageNum}, question ${questionNum}`
|
|
70
70
|
},
|
|
71
|
+
[TranslationRowTypes.ErrorDescription]: {
|
|
72
|
+
jsonPrefix: 'components',
|
|
73
|
+
jsonSuffix: 'errorDescription',
|
|
74
|
+
displayName: 'Error description',
|
|
75
|
+
getLabel: (pageNum, questionNum) =>
|
|
76
|
+
`Welsh error description - Page ${pageNum}, question ${questionNum}`
|
|
77
|
+
},
|
|
71
78
|
[TranslationRowTypes.InstructionText]: {
|
|
72
79
|
jsonPrefix: 'components',
|
|
73
80
|
jsonSuffix: 'instructionText',
|
|
@@ -137,7 +137,7 @@ function buildPage(page, pageNum, translations, validation) {
|
|
|
137
137
|
* @param {ValidationFailure<any>} [validation] - Optional validation context for posted form values.
|
|
138
138
|
* @returns {TranslationRow[]} The translation rows generated for the component.
|
|
139
139
|
*/
|
|
140
|
-
function buildComponent(
|
|
140
|
+
export function buildComponent(
|
|
141
141
|
definition,
|
|
142
142
|
component,
|
|
143
143
|
pageNum,
|
|
@@ -165,6 +165,11 @@ function buildComponent(
|
|
|
165
165
|
rows.push(
|
|
166
166
|
createRow(component, TranslationRowTypes.ShortDescription, options)
|
|
167
167
|
)
|
|
168
|
+
if (typed.errorDescription) {
|
|
169
|
+
rows.push(
|
|
170
|
+
createRow(component, TranslationRowTypes.ErrorDescription, options)
|
|
171
|
+
)
|
|
172
|
+
}
|
|
168
173
|
} else {
|
|
169
174
|
rows.push(
|
|
170
175
|
createRow(component, TranslationRowTypes.PaymentDescription, options)
|
|
@@ -177,12 +182,6 @@ function buildComponent(
|
|
|
177
182
|
)
|
|
178
183
|
}
|
|
179
184
|
|
|
180
|
-
if (component.type === ComponentType.PaymentField) {
|
|
181
|
-
rows.push(
|
|
182
|
-
createRow(component, TranslationRowTypes.PaymentDescription, options)
|
|
183
|
-
)
|
|
184
|
-
}
|
|
185
|
-
|
|
186
185
|
if (typed.options.instructionText && isTypeWithInstructions(component.type)) {
|
|
187
186
|
rows.push(
|
|
188
187
|
createRow(component, TranslationRowTypes.InstructionText, options)
|
|
@@ -78,6 +78,13 @@ export const formSubmitPayloadSchema = Joi.object<SubmitPayload>()
|
|
|
78
78
|
.optional()
|
|
79
79
|
.allow('')
|
|
80
80
|
.description('Reference number for the form submission'),
|
|
81
|
+
language: Joi.string()
|
|
82
|
+
// TODO - make this required in later releases - optional for now to avoid release glitches
|
|
83
|
+
.optional()
|
|
84
|
+
.allow('')
|
|
85
|
+
.description(
|
|
86
|
+
'The currently-selected language at point of form submission'
|
|
87
|
+
),
|
|
81
88
|
main: Joi.array<SubmitRecord>()
|
|
82
89
|
.items(formSubmitRecordSchema)
|
|
83
90
|
.required()
|