@defra/forms-model 3.0.643 → 3.0.645

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.
Files changed (58) hide show
  1. package/dist/module/form/form-audit/index.js +5 -4
  2. package/dist/module/form/form-audit/index.js.map +1 -1
  3. package/dist/module/form/form-definition/constants.js +3 -0
  4. package/dist/module/form/form-definition/constants.js.map +1 -0
  5. package/dist/module/form/form-definition/index.js +6 -9
  6. package/dist/module/form/form-definition/index.js.map +1 -1
  7. package/dist/module/form/form-editor/index.js +4 -1
  8. package/dist/module/form/form-editor/index.js.map +1 -1
  9. package/dist/module/form/form-metadata/index.js +4 -3
  10. package/dist/module/form/form-metadata/index.js.map +1 -1
  11. package/dist/module/form/form-metrics/enums.js +7 -0
  12. package/dist/module/form/form-metrics/enums.js.map +1 -0
  13. package/dist/module/form/form-metrics/types.js +2 -0
  14. package/dist/module/form/form-metrics/types.js.map +1 -0
  15. package/dist/module/form/utils/index.js +1 -0
  16. package/dist/module/form/utils/index.js.map +1 -1
  17. package/dist/module/form/utils/prevent-unicode.js +20 -0
  18. package/dist/module/form/utils/prevent-unicode.js.map +1 -0
  19. package/dist/module/index.js +2 -0
  20. package/dist/module/index.js.map +1 -1
  21. package/dist/module/pages/helpers.js +38 -2
  22. package/dist/module/pages/helpers.js.map +1 -1
  23. package/dist/module/pages/index.js +1 -1
  24. package/dist/module/pages/index.js.map +1 -1
  25. package/dist/types/form/form-definition/constants.d.ts +3 -0
  26. package/dist/types/form/form-definition/constants.d.ts.map +1 -0
  27. package/dist/types/form/form-definition/index.d.ts +1 -2
  28. package/dist/types/form/form-definition/index.d.ts.map +1 -1
  29. package/dist/types/form/form-editor/index.d.ts +2 -0
  30. package/dist/types/form/form-editor/index.d.ts.map +1 -1
  31. package/dist/types/form/form-metadata/index.d.ts.map +1 -1
  32. package/dist/types/form/form-metrics/enums.d.ts +6 -0
  33. package/dist/types/form/form-metrics/enums.d.ts.map +1 -0
  34. package/dist/types/form/form-metrics/types.d.ts +32 -0
  35. package/dist/types/form/form-metrics/types.d.ts.map +1 -0
  36. package/dist/types/form/utils/index.d.ts +1 -0
  37. package/dist/types/form/utils/index.d.ts.map +1 -1
  38. package/dist/types/form/utils/prevent-unicode.d.ts +10 -0
  39. package/dist/types/form/utils/prevent-unicode.d.ts.map +1 -0
  40. package/dist/types/index.d.ts +2 -0
  41. package/dist/types/index.d.ts.map +1 -1
  42. package/dist/types/pages/helpers.d.ts +9 -0
  43. package/dist/types/pages/helpers.d.ts.map +1 -1
  44. package/dist/types/pages/index.d.ts +1 -1
  45. package/dist/types/pages/index.d.ts.map +1 -1
  46. package/package.json +1 -1
  47. package/src/form/form-audit/index.ts +4 -4
  48. package/src/form/form-definition/constants.ts +2 -0
  49. package/src/form/form-definition/index.ts +13 -14
  50. package/src/form/form-editor/index.ts +11 -1
  51. package/src/form/form-metadata/index.ts +7 -8
  52. package/src/form/form-metrics/enums.ts +5 -0
  53. package/src/form/form-metrics/types.ts +39 -0
  54. package/src/form/utils/index.ts +1 -0
  55. package/src/form/utils/prevent-unicode.js +19 -0
  56. package/src/index.ts +2 -0
  57. package/src/pages/helpers.ts +43 -0
  58. package/src/pages/index.ts +2 -0
@@ -1,4 +1,5 @@
1
1
  import Joi from 'joi';
2
+ import { emailAddressNoUnicodeSchema } from "../form-editor/index.js";
2
3
  export const organisations = ['Animal and Plant Health Agency – APHA', 'Centre for Environment, Fisheries and Aquaculture Science – Cefas', 'Defra', 'Environment Agency', 'Forestry Commission', 'Marine Management Organisation – MMO', 'Natural England', 'Rural Payments Agency – RPA', 'Veterinary Medicines Directorate – VMD'];
3
4
  export const idSchema = Joi.string().hex().length(24).required().description('Unique identifier for the form, 24-character hexadecimal string');
4
5
  export const titleSchema = Joi.string().max(250).trim().required().description('Title of the form, displayed to users');
@@ -7,13 +8,13 @@ export const slugSchema = Joi.string().pattern(/^[a-z0-9-]+$/, {
7
8
  }).required().description('URL-friendly identifier used in form paths');
8
9
  export const organisationSchema = Joi.string().valid(...organisations).required().description('Defra organisation responsible for the form');
9
10
  export const teamNameSchema = Joi.string().max(100).trim().required().description('Name of the team responsible for the form');
10
- export const teamEmailSchema = Joi.string().email({
11
+ export const teamEmailSchema = emailAddressNoUnicodeSchema.email({
11
12
  tlds: {
12
13
  allow: ['uk']
13
14
  }
14
15
  }).trim().required().description('Contact email for the team responsible for the form');
15
16
  export const phoneSchema = Joi.string().trim().description('Phone number for form-related inquiries');
16
- export const emailAddressSchema = Joi.string().email().trim().required().description('Email address for form-related inquiries');
17
+ export const emailAddressSchema = emailAddressNoUnicodeSchema.required().description('Email address for form-related inquiries');
17
18
  export const emailResponseTimeSchema = Joi.string().trim().required().description('Expected response time for email inquiries');
18
19
  export const emailSchema = Joi.object().keys({
19
20
  address: emailAddressSchema,
@@ -39,7 +40,7 @@ export const privacyNoticeUrlSchema = Joi.string().uri({
39
40
  scheme: ['http', 'https']
40
41
  }).trim().description('URL to the privacy notice for this form');
41
42
  export const termsAndConditionsAgreedSchema = Joi.boolean().description('Whether the data protection terms and conditions have been agreed to');
42
- export const notificationEmailAddressSchema = Joi.string().email().trim().description('Email address to receive form submission notifications');
43
+ export const notificationEmailAddressSchema = emailAddressNoUnicodeSchema.description('Email address to receive form submission notifications');
43
44
  export const authoredAtSchema = Joi.date().iso().required().description('ISO format timestamp of when an action occurred');
44
45
  export const authorIdSchema = Joi.string().trim().required().description('Unique identifier for the author');
45
46
  export const authorDisplayNameSchema = Joi.string().trim().required().description('Human-readable name of the author');
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Joi","organisations","idSchema","string","hex","length","required","description","titleSchema","max","trim","slugSchema","pattern","name","organisationSchema","valid","teamNameSchema","teamEmailSchema","email","tlds","allow","phoneSchema","emailAddressSchema","emailResponseTimeSchema","emailSchema","object","keys","address","responseTime","onlineUrlSchema","uri","scheme","onlineTextSchema","onlineSchema","url","text","contactSchema","phone","online","submissionGuidanceSchema","privacyNoticeTypeSchema","privacyNoticeTextSchema","privacyNoticeUrlSchema","termsAndConditionsAgreedSchema","boolean","notificationEmailAddressSchema","authoredAtSchema","date","iso","authorIdSchema","authorDisplayNameSchema","formMetadataInputKeys","title","organisation","teamName","teamEmail","contact","submissionGuidance","privacyNoticeType","privacyNoticeText","when","is","then","otherwise","privacyNoticeUrl","termsAndConditionsAgreed","notificationEmail","formMetadataInputSchema","formMetadataAuthorSchema","id","displayName","formMetadataStateSchema","createdAt","createdBy","updatedAt","updatedBy","formVersionMetadataSchema","versionNumber","number","integer","min","formMetadataSchema","append","slug","draft","live","versions","array","items","optional"],"sources":["../../../../src/form/form-metadata/index.ts"],"sourcesContent":["import Joi from 'joi'\n\nimport {\n type FormMetadata,\n type FormMetadataAuthor,\n type FormMetadataContact,\n type FormMetadataContactEmail,\n type FormMetadataContactOnline,\n type FormMetadataInput,\n type FormMetadataState,\n type FormVersionMetadata\n} from '~/src/form/form-metadata/types.js'\n\nexport const organisations = [\n 'Animal and Plant Health Agency – APHA',\n 'Centre for Environment, Fisheries and Aquaculture Science – Cefas',\n 'Defra',\n 'Environment Agency',\n 'Forestry Commission',\n 'Marine Management Organisation – MMO',\n 'Natural England',\n 'Rural Payments Agency – RPA',\n 'Veterinary Medicines Directorate – VMD'\n]\n\nexport const idSchema = Joi.string()\n .hex()\n .length(24)\n .required()\n .description(\n 'Unique identifier for the form, 24-character hexadecimal string'\n )\n\nexport const titleSchema = Joi.string()\n .max(250)\n .trim()\n .required()\n .description('Title of the form, displayed to users')\n\nexport const slugSchema = Joi.string()\n .pattern(/^[a-z0-9-]+$/, { name: 'letters, numbers and hyphens only' })\n .required()\n .description('URL-friendly identifier used in form paths')\n\nexport const organisationSchema = Joi.string()\n .valid(...organisations)\n .required()\n .description('Defra organisation responsible for the form')\n\nexport const teamNameSchema = Joi.string()\n .max(100)\n .trim()\n .required()\n .description('Name of the team responsible for the form')\n\nexport const teamEmailSchema = Joi.string()\n .email({ tlds: { allow: ['uk'] } })\n .trim()\n .required()\n .description('Contact email for the team responsible for the form')\n\nexport const phoneSchema = Joi.string()\n .trim()\n .description('Phone number for form-related inquiries')\n\nexport const emailAddressSchema = Joi.string()\n .email()\n .trim()\n .required()\n .description('Email address for form-related inquiries')\n\nexport const emailResponseTimeSchema = Joi.string()\n .trim()\n .required()\n .description('Expected response time for email inquiries')\n\nexport const emailSchema = Joi.object<FormMetadataContactEmail>()\n .keys({\n address: emailAddressSchema,\n responseTime: emailResponseTimeSchema\n })\n .description('Email contact details including response expectations')\n\nexport const onlineUrlSchema = Joi.string()\n .uri({\n scheme: ['http', 'https']\n })\n .trim()\n .required()\n .description('URL for online contact method')\n\nexport const onlineTextSchema = Joi.string()\n .trim()\n .required()\n .description('Descriptive text for the online contact link')\n\nexport const onlineSchema = Joi.object<FormMetadataContactOnline>()\n .keys({\n url: onlineUrlSchema,\n text: onlineTextSchema\n })\n .description('Online contact details with URL and descriptive text')\n\nexport const contactSchema = Joi.object<FormMetadataContact>()\n .keys({\n phone: phoneSchema,\n email: emailSchema,\n online: onlineSchema\n })\n .description('Complete contact information for form-related inquiries')\n\nexport const submissionGuidanceSchema = Joi.string()\n .trim()\n .description('Guidance text shown to users when submitting the form')\n\nexport const privacyNoticeTypeSchema = Joi.string()\n .valid('text', 'link')\n .description('Type of privacy notice content')\n\nexport const privacyNoticeTextSchema = Joi.string()\n .trim()\n .description('URL to the privacy notice for this form')\n\nexport const privacyNoticeUrlSchema = Joi.string()\n .uri({\n scheme: ['http', 'https']\n })\n .trim()\n .description('URL to the privacy notice for this form')\n\nexport const termsAndConditionsAgreedSchema = Joi.boolean().description(\n 'Whether the data protection terms and conditions have been agreed to'\n)\n\nexport const notificationEmailAddressSchema = Joi.string()\n .email()\n .trim()\n .description('Email address to receive form submission notifications')\n\nexport const authoredAtSchema = Joi.date()\n .iso()\n .required()\n .description('ISO format timestamp of when an action occurred')\n\nexport const authorIdSchema = Joi.string()\n .trim()\n .required()\n .description('Unique identifier for the author')\n\nexport const authorDisplayNameSchema = Joi.string()\n .trim()\n .required()\n .description('Human-readable name of the author')\n\nexport const formMetadataInputKeys = {\n title: titleSchema,\n organisation: organisationSchema,\n teamName: teamNameSchema,\n teamEmail: teamEmailSchema,\n contact: contactSchema,\n submissionGuidance: submissionGuidanceSchema,\n privacyNoticeType: privacyNoticeTypeSchema,\n privacyNoticeText: Joi.when('privacyNoticeType', {\n is: 'text',\n then: privacyNoticeTextSchema,\n otherwise: privacyNoticeTextSchema.allow('')\n }),\n privacyNoticeUrl: Joi.when('privacyNoticeType', {\n is: 'link',\n then: privacyNoticeUrlSchema,\n otherwise: privacyNoticeUrlSchema.allow('')\n }),\n termsAndConditionsAgreed: termsAndConditionsAgreedSchema,\n notificationEmail: notificationEmailAddressSchema\n}\n\n/**\n * Joi schema for `FormMetadataInput` interface\n * @see {@link FormMetadataInput}\n */\nexport const formMetadataInputSchema = Joi.object<FormMetadataInput>()\n .keys(formMetadataInputKeys)\n .required()\n .description('Input data for creating or updating form metadata')\n\n/**\n * Joi schema for `FormMetadataAuthor` interface\n * @see {@link FormMetadataAuthor}\n */\nexport const formMetadataAuthorSchema = Joi.object<FormMetadataAuthor>()\n .keys({\n id: authorIdSchema,\n displayName: authorDisplayNameSchema\n })\n .required()\n .description('Information about the author of a form or form change')\n\n/**\n * Joi schema for `FormMetadataState` interface\n * @see {@link FormMetadataState}\n */\nexport const formMetadataStateSchema = Joi.object<FormMetadataState>()\n .keys({\n createdAt: authoredAtSchema.description(\n 'When this version was first created'\n ),\n createdBy: formMetadataAuthorSchema.description('Who created this version'),\n updatedAt: authoredAtSchema.description(\n 'When this version was last updated'\n ),\n updatedBy: formMetadataAuthorSchema.description(\n 'Who last updated this version'\n )\n })\n .description('Metadata about a specific version state (draft or live)')\n\n/**\n * Joi schema for `FormVersionMetadata` interface\n * @see {@link FormVersionMetadata}\n */\nexport const formVersionMetadataSchema = Joi.object<FormVersionMetadata>()\n .keys({\n versionNumber: Joi.number()\n .integer()\n .min(1)\n .required()\n .description('The version number'),\n createdAt: authoredAtSchema.description('When this version was created')\n })\n .description('Metadata for a specific version of the form')\n\n/**\n * Joi schema for `FormMetadata` interface\n * @see {@link FormMetadata}\n */\nexport const formMetadataSchema = formMetadataInputSchema\n .append<FormMetadata>({\n id: idSchema,\n slug: slugSchema,\n draft: formMetadataStateSchema.description(\n 'Metadata for the draft version'\n ),\n live: formMetadataStateSchema.description(\n 'Metadata for the published version'\n ),\n createdAt: authoredAtSchema.description('When the form was first created'),\n createdBy: formMetadataAuthorSchema.description('Who created the form'),\n updatedAt: authoredAtSchema.description('When the form was last updated'),\n updatedBy: formMetadataAuthorSchema.description(\n 'Who last updated the form'\n ),\n versions: Joi.array()\n .items(formVersionMetadataSchema)\n .optional()\n .description('Version history for the form')\n })\n .description(\n 'Complete metadata for a form, including version information and authoring details'\n )\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,KAAK;AAarB,OAAO,MAAMC,aAAa,GAAG,CAC3B,uCAAuC,EACvC,mEAAmE,EACnE,OAAO,EACP,oBAAoB,EACpB,qBAAqB,EACrB,sCAAsC,EACtC,iBAAiB,EACjB,6BAA6B,EAC7B,wCAAwC,CACzC;AAED,OAAO,MAAMC,QAAQ,GAAGF,GAAG,CAACG,MAAM,CAAC,CAAC,CACjCC,GAAG,CAAC,CAAC,CACLC,MAAM,CAAC,EAAE,CAAC,CACVC,QAAQ,CAAC,CAAC,CACVC,WAAW,CACV,iEACF,CAAC;AAEH,OAAO,MAAMC,WAAW,GAAGR,GAAG,CAACG,MAAM,CAAC,CAAC,CACpCM,GAAG,CAAC,GAAG,CAAC,CACRC,IAAI,CAAC,CAAC,CACNJ,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,uCAAuC,CAAC;AAEvD,OAAO,MAAMI,UAAU,GAAGX,GAAG,CAACG,MAAM,CAAC,CAAC,CACnCS,OAAO,CAAC,cAAc,EAAE;EAAEC,IAAI,EAAE;AAAoC,CAAC,CAAC,CACtEP,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,4CAA4C,CAAC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E,GAAG,CAACyB,MAAM,CAAsB,CAAC,CACvEC,IAAI,CAAC;EACJmD,aAAa,EAAE7E,GAAG,CAAC8E,MAAM,CAAC,CAAC,CACxBC,OAAO,CAAC,CAAC,CACTC,GAAG,CAAC,CAAC,CAAC,CACN1E,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,oBAAoB,CAAC;EACpCiE,SAAS,EAAE1B,gBAAgB,CAACvC,WAAW,CAAC,+BAA+B;AACzE,CAAC,CAAC,CACDA,WAAW,CAAC,6CAA6C,CAAC;;AAE7D;AACA;AACA;AACA;AACA,OAAO,MAAM0E,kBAAkB,GAAGd,uBAAuB,CACtDe,MAAM,CAAe;EACpBb,EAAE,EAAEnE,QAAQ;EACZiF,IAAI,EAAExE,UAAU;EAChByE,KAAK,EAAEb,uBAAuB,CAAChE,WAAW,CACxC,gCACF,CAAC;EACD8E,IAAI,EAAEd,uBAAuB,CAAChE,WAAW,CACvC,oCACF,CAAC;EACDiE,SAAS,EAAE1B,gBAAgB,CAACvC,WAAW,CAAC,iCAAiC,CAAC;EAC1EkE,SAAS,EAAEL,wBAAwB,CAAC7D,WAAW,CAAC,sBAAsB,CAAC;EACvEmE,SAAS,EAAE5B,gBAAgB,CAACvC,WAAW,CAAC,gCAAgC,CAAC;EACzEoE,SAAS,EAAEP,wBAAwB,CAAC7D,WAAW,CAC7C,2BACF,CAAC;EACD+E,QAAQ,EAAEtF,GAAG,CAACuF,KAAK,CAAC,CAAC,CAClBC,KAAK,CAACZ,yBAAyB,CAAC,CAChCa,QAAQ,CAAC,CAAC,CACVlF,WAAW,CAAC,8BAA8B;AAC/C,CAAC,CAAC,CACDA,WAAW,CACV,mFACF,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["Joi","emailAddressNoUnicodeSchema","organisations","idSchema","string","hex","length","required","description","titleSchema","max","trim","slugSchema","pattern","name","organisationSchema","valid","teamNameSchema","teamEmailSchema","email","tlds","allow","phoneSchema","emailAddressSchema","emailResponseTimeSchema","emailSchema","object","keys","address","responseTime","onlineUrlSchema","uri","scheme","onlineTextSchema","onlineSchema","url","text","contactSchema","phone","online","submissionGuidanceSchema","privacyNoticeTypeSchema","privacyNoticeTextSchema","privacyNoticeUrlSchema","termsAndConditionsAgreedSchema","boolean","notificationEmailAddressSchema","authoredAtSchema","date","iso","authorIdSchema","authorDisplayNameSchema","formMetadataInputKeys","title","organisation","teamName","teamEmail","contact","submissionGuidance","privacyNoticeType","privacyNoticeText","when","is","then","otherwise","privacyNoticeUrl","termsAndConditionsAgreed","notificationEmail","formMetadataInputSchema","formMetadataAuthorSchema","id","displayName","formMetadataStateSchema","createdAt","createdBy","updatedAt","updatedBy","formVersionMetadataSchema","versionNumber","number","integer","min","formMetadataSchema","append","slug","draft","live","versions","array","items","optional"],"sources":["../../../../src/form/form-metadata/index.ts"],"sourcesContent":["import Joi from 'joi'\n\nimport { emailAddressNoUnicodeSchema } from '~/src/form/form-editor/index.js'\nimport {\n type FormMetadata,\n type FormMetadataAuthor,\n type FormMetadataContact,\n type FormMetadataContactEmail,\n type FormMetadataContactOnline,\n type FormMetadataInput,\n type FormMetadataState,\n type FormVersionMetadata\n} from '~/src/form/form-metadata/types.js'\n\nexport const organisations = [\n 'Animal and Plant Health Agency – APHA',\n 'Centre for Environment, Fisheries and Aquaculture Science – Cefas',\n 'Defra',\n 'Environment Agency',\n 'Forestry Commission',\n 'Marine Management Organisation – MMO',\n 'Natural England',\n 'Rural Payments Agency – RPA',\n 'Veterinary Medicines Directorate – VMD'\n]\n\nexport const idSchema = Joi.string()\n .hex()\n .length(24)\n .required()\n .description(\n 'Unique identifier for the form, 24-character hexadecimal string'\n )\n\nexport const titleSchema = Joi.string()\n .max(250)\n .trim()\n .required()\n .description('Title of the form, displayed to users')\n\nexport const slugSchema = Joi.string()\n .pattern(/^[a-z0-9-]+$/, { name: 'letters, numbers and hyphens only' })\n .required()\n .description('URL-friendly identifier used in form paths')\n\nexport const organisationSchema = Joi.string()\n .valid(...organisations)\n .required()\n .description('Defra organisation responsible for the form')\n\nexport const teamNameSchema = Joi.string()\n .max(100)\n .trim()\n .required()\n .description('Name of the team responsible for the form')\n\nexport const teamEmailSchema = emailAddressNoUnicodeSchema\n .email({ tlds: { allow: ['uk'] } })\n .trim()\n .required()\n .description('Contact email for the team responsible for the form')\n\nexport const phoneSchema = Joi.string()\n .trim()\n .description('Phone number for form-related inquiries')\n\nexport const emailAddressSchema = emailAddressNoUnicodeSchema\n .required()\n .description('Email address for form-related inquiries')\n\nexport const emailResponseTimeSchema = Joi.string()\n .trim()\n .required()\n .description('Expected response time for email inquiries')\n\nexport const emailSchema = Joi.object<FormMetadataContactEmail>()\n .keys({\n address: emailAddressSchema,\n responseTime: emailResponseTimeSchema\n })\n .description('Email contact details including response expectations')\n\nexport const onlineUrlSchema = Joi.string()\n .uri({\n scheme: ['http', 'https']\n })\n .trim()\n .required()\n .description('URL for online contact method')\n\nexport const onlineTextSchema = Joi.string()\n .trim()\n .required()\n .description('Descriptive text for the online contact link')\n\nexport const onlineSchema = Joi.object<FormMetadataContactOnline>()\n .keys({\n url: onlineUrlSchema,\n text: onlineTextSchema\n })\n .description('Online contact details with URL and descriptive text')\n\nexport const contactSchema = Joi.object<FormMetadataContact>()\n .keys({\n phone: phoneSchema,\n email: emailSchema,\n online: onlineSchema\n })\n .description('Complete contact information for form-related inquiries')\n\nexport const submissionGuidanceSchema = Joi.string()\n .trim()\n .description('Guidance text shown to users when submitting the form')\n\nexport const privacyNoticeTypeSchema = Joi.string()\n .valid('text', 'link')\n .description('Type of privacy notice content')\n\nexport const privacyNoticeTextSchema = Joi.string()\n .trim()\n .description('URL to the privacy notice for this form')\n\nexport const privacyNoticeUrlSchema = Joi.string()\n .uri({\n scheme: ['http', 'https']\n })\n .trim()\n .description('URL to the privacy notice for this form')\n\nexport const termsAndConditionsAgreedSchema = Joi.boolean().description(\n 'Whether the data protection terms and conditions have been agreed to'\n)\n\nexport const notificationEmailAddressSchema =\n emailAddressNoUnicodeSchema.description(\n 'Email address to receive form submission notifications'\n )\n\nexport const authoredAtSchema = Joi.date()\n .iso()\n .required()\n .description('ISO format timestamp of when an action occurred')\n\nexport const authorIdSchema = Joi.string()\n .trim()\n .required()\n .description('Unique identifier for the author')\n\nexport const authorDisplayNameSchema = Joi.string()\n .trim()\n .required()\n .description('Human-readable name of the author')\n\nexport const formMetadataInputKeys = {\n title: titleSchema,\n organisation: organisationSchema,\n teamName: teamNameSchema,\n teamEmail: teamEmailSchema,\n contact: contactSchema,\n submissionGuidance: submissionGuidanceSchema,\n privacyNoticeType: privacyNoticeTypeSchema,\n privacyNoticeText: Joi.when('privacyNoticeType', {\n is: 'text',\n then: privacyNoticeTextSchema,\n otherwise: privacyNoticeTextSchema.allow('')\n }),\n privacyNoticeUrl: Joi.when('privacyNoticeType', {\n is: 'link',\n then: privacyNoticeUrlSchema,\n otherwise: privacyNoticeUrlSchema.allow('')\n }),\n termsAndConditionsAgreed: termsAndConditionsAgreedSchema,\n notificationEmail: notificationEmailAddressSchema\n}\n\n/**\n * Joi schema for `FormMetadataInput` interface\n * @see {@link FormMetadataInput}\n */\nexport const formMetadataInputSchema = Joi.object<FormMetadataInput>()\n .keys(formMetadataInputKeys)\n .required()\n .description('Input data for creating or updating form metadata')\n\n/**\n * Joi schema for `FormMetadataAuthor` interface\n * @see {@link FormMetadataAuthor}\n */\nexport const formMetadataAuthorSchema = Joi.object<FormMetadataAuthor>()\n .keys({\n id: authorIdSchema,\n displayName: authorDisplayNameSchema\n })\n .required()\n .description('Information about the author of a form or form change')\n\n/**\n * Joi schema for `FormMetadataState` interface\n * @see {@link FormMetadataState}\n */\nexport const formMetadataStateSchema = Joi.object<FormMetadataState>()\n .keys({\n createdAt: authoredAtSchema.description(\n 'When this version was first created'\n ),\n createdBy: formMetadataAuthorSchema.description('Who created this version'),\n updatedAt: authoredAtSchema.description(\n 'When this version was last updated'\n ),\n updatedBy: formMetadataAuthorSchema.description(\n 'Who last updated this version'\n )\n })\n .description('Metadata about a specific version state (draft or live)')\n\n/**\n * Joi schema for `FormVersionMetadata` interface\n * @see {@link FormVersionMetadata}\n */\nexport const formVersionMetadataSchema = Joi.object<FormVersionMetadata>()\n .keys({\n versionNumber: Joi.number()\n .integer()\n .min(1)\n .required()\n .description('The version number'),\n createdAt: authoredAtSchema.description('When this version was created')\n })\n .description('Metadata for a specific version of the form')\n\n/**\n * Joi schema for `FormMetadata` interface\n * @see {@link FormMetadata}\n */\nexport const formMetadataSchema = formMetadataInputSchema\n .append<FormMetadata>({\n id: idSchema,\n slug: slugSchema,\n draft: formMetadataStateSchema.description(\n 'Metadata for the draft version'\n ),\n live: formMetadataStateSchema.description(\n 'Metadata for the published version'\n ),\n createdAt: authoredAtSchema.description('When the form was first created'),\n createdBy: formMetadataAuthorSchema.description('Who created the form'),\n updatedAt: authoredAtSchema.description('When the form was last updated'),\n updatedBy: formMetadataAuthorSchema.description(\n 'Who last updated the form'\n ),\n versions: Joi.array()\n .items(formVersionMetadataSchema)\n .optional()\n .description('Version history for the form')\n })\n .description(\n 'Complete metadata for a form, including version information and authoring details'\n )\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,KAAK;AAErB,SAASC,2BAA2B;AAYpC,OAAO,MAAMC,aAAa,GAAG,CAC3B,uCAAuC,EACvC,mEAAmE,EACnE,OAAO,EACP,oBAAoB,EACpB,qBAAqB,EACrB,sCAAsC,EACtC,iBAAiB,EACjB,6BAA6B,EAC7B,wCAAwC,CACzC;AAED,OAAO,MAAMC,QAAQ,GAAGH,GAAG,CAACI,MAAM,CAAC,CAAC,CACjCC,GAAG,CAAC,CAAC,CACLC,MAAM,CAAC,EAAE,CAAC,CACVC,QAAQ,CAAC,CAAC,CACVC,WAAW,CACV,iEACF,CAAC;AAEH,OAAO,MAAMC,WAAW,GAAGT,GAAG,CAACI,MAAM,CAAC,CAAC,CACpCM,GAAG,CAAC,GAAG,CAAC,CACRC,IAAI,CAAC,CAAC,CACNJ,QAAQ,CAAC,CAAC,CACVC,WAAW,CAA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;AACA;AACA;AACA;AACA,OAAO,MAAMqE,yBAAyB,GAAG7E,GAAG,CAAC0B,MAAM,CAAsB,CAAC,CACvEC,IAAI,CAAC;EACJmD,aAAa,EAAE9E,GAAG,CAAC+E,MAAM,CAAC,CAAC,CACxBC,OAAO,CAAC,CAAC,CACTC,GAAG,CAAC,CAAC,CAAC,CACN1E,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,oBAAoB,CAAC;EACpCiE,SAAS,EAAE1B,gBAAgB,CAACvC,WAAW,CAAC,+BAA+B;AACzE,CAAC,CAAC,CACDA,WAAW,CAAC,6CAA6C,CAAC;;AAE7D;AACA;AACA;AACA;AACA,OAAO,MAAM0E,kBAAkB,GAAGd,uBAAuB,CACtDe,MAAM,CAAe;EACpBb,EAAE,EAAEnE,QAAQ;EACZiF,IAAI,EAAExE,UAAU;EAChByE,KAAK,EAAEb,uBAAuB,CAAChE,WAAW,CACxC,gCACF,CAAC;EACD8E,IAAI,EAAEd,uBAAuB,CAAChE,WAAW,CACvC,oCACF,CAAC;EACDiE,SAAS,EAAE1B,gBAAgB,CAACvC,WAAW,CAAC,iCAAiC,CAAC;EAC1EkE,SAAS,EAAEL,wBAAwB,CAAC7D,WAAW,CAAC,sBAAsB,CAAC;EACvEmE,SAAS,EAAE5B,gBAAgB,CAACvC,WAAW,CAAC,gCAAgC,CAAC;EACzEoE,SAAS,EAAEP,wBAAwB,CAAC7D,WAAW,CAC7C,2BACF,CAAC;EACD+E,QAAQ,EAAEvF,GAAG,CAACwF,KAAK,CAAC,CAAC,CAClBC,KAAK,CAACZ,yBAAyB,CAAC,CAChCa,QAAQ,CAAC,CAAC,CACVlF,WAAW,CAAC,8BAA8B;AAC/C,CAAC,CAAC,CACDA,WAAW,CACV,mFACF,CAAC","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ export let FormMetricType = /*#__PURE__*/function (FormMetricType) {
2
+ FormMetricType["HeadlineMetric"] = "headline-metric";
3
+ FormMetricType["OverviewMetric"] = "overview-metric";
4
+ FormMetricType["TimelineMetric"] = "timeline-metric";
5
+ return FormMetricType;
6
+ }({});
7
+ //# sourceMappingURL=enums.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enums.js","names":["FormMetricType"],"sources":["../../../../src/form/form-metrics/enums.ts"],"sourcesContent":["export enum FormMetricType {\n HeadlineMetric = 'headline-metric',\n OverviewMetric = 'overview-metric',\n TimelineMetric = 'timeline-metric'\n}\n"],"mappings":"AAAA,WAAYA,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../src/form/form-metrics/types.ts"],"sourcesContent":["import { type FormStatus } from '~/src/common/enums.js'\nimport { type FormMetricType } from '~/src/form/form-metrics/enums.js'\n\nexport interface FormHeadlineDetail {\n count: number\n countSevenDaysAgo: number\n countThirtyDaysAgo: number\n countOneYearAgo: number\n}\n\nexport interface FormHeadlineMetric {\n type: FormMetricType.HeadlineMetric\n headlineCounts: Record<string, FormHeadlineDetail>\n updatedAt: Date\n}\n\nexport interface FormOverviewMetric {\n type: FormMetricType.OverviewMetric\n formId: string\n formStatus: FormStatus\n summaryMetrics: Record<string, number | string | string[]>\n featureCounts: Record<string, number>\n submissionsCount: number\n updatedAt: Date\n}\n\nexport interface FormTimelineMetric {\n type: FormMetricType.TimelineMetric\n formId: string\n formStatus: FormStatus\n metricName: string\n metricValue: number\n createdAt: Date\n}\n\nexport type FormMetric =\n | FormHeadlineMetric\n | FormOverviewMetric\n | FormTimelineMetric\n"],"mappings":"","ignoreList":[]}
@@ -1,3 +1,4 @@
1
1
  export { findStartPage } from "./find-start-page.js";
2
2
  export { findDefinitionListFromComponent } from "./list.js";
3
+ export { preventUnicodeInEmail } from "./prevent-unicode.js";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["findStartPage","findDefinitionListFromComponent"],"sources":["../../../../src/form/utils/index.ts"],"sourcesContent":["export { findStartPage } from '~/src/form/utils/find-start-page.js'\nexport { findDefinitionListFromComponent } from '~/src/form/utils/list.js'\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,+BAA+B","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["findStartPage","findDefinitionListFromComponent","preventUnicodeInEmail"],"sources":["../../../../src/form/utils/index.ts"],"sourcesContent":["export { findStartPage } from '~/src/form/utils/find-start-page.js'\nexport { findDefinitionListFromComponent } from '~/src/form/utils/list.js'\nexport { preventUnicodeInEmail } from '~/src/form/utils/prevent-unicode.js'\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,+BAA+B;AACxC,SAASC,qBAAqB","ignoreList":[]}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Custom Joi validator to prevent Unicode characters in say an email address.
3
+ * Although Joi has Joi.email({ allowUnicode: false }), we can't differentiate from a general
4
+ * email format error or a Unicode error - hance the custom validator to allow a different error message
5
+ * @param {unknown} value
6
+ * @param {CustomHelpers<string>} helpers
7
+ */
8
+ export function preventUnicodeInEmail(value, helpers) {
9
+ if (!value || typeof value !== 'string') {
10
+ return helpers.error('string.empty');
11
+ }
12
+ const invalidCharsRegex = /[^a-zA-Z0-9.!#$%&'*+/=?^_`{|}~@-]/;
13
+ const invalid = invalidCharsRegex.exec(value);
14
+ return invalid ? helpers.error('string.unicode') : value;
15
+ }
16
+
17
+ /**
18
+ * @import { type CustomHelpers } from 'joi'
19
+ */
20
+ //# sourceMappingURL=prevent-unicode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prevent-unicode.js","names":["preventUnicodeInEmail","value","helpers","error","invalidCharsRegex","invalid","exec"],"sources":["../../../../src/form/utils/prevent-unicode.js"],"sourcesContent":["/**\n * Custom Joi validator to prevent Unicode characters in say an email address.\n * Although Joi has Joi.email({ allowUnicode: false }), we can't differentiate from a general\n * email format error or a Unicode error - hance the custom validator to allow a different error message\n * @param {unknown} value\n * @param {CustomHelpers<string>} helpers\n */\nexport function preventUnicodeInEmail(value, helpers) {\n if (!value || typeof value !== 'string') {\n return helpers.error('string.empty')\n }\n const invalidCharsRegex = /[^a-zA-Z0-9.!#$%&'*+/=?^_`{|}~@-]/\n const invalid = invalidCharsRegex.exec(value)\n return invalid ? helpers.error('string.unicode') : value\n}\n\n/**\n * @import { type CustomHelpers } from 'joi'\n */\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,qBAAqBA,CAACC,KAAK,EAAEC,OAAO,EAAE;EACpD,IAAI,CAACD,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IACvC,OAAOC,OAAO,CAACC,KAAK,CAAC,cAAc,CAAC;EACtC;EACA,MAAMC,iBAAiB,GAAG,mCAAmC;EAC7D,MAAMC,OAAO,GAAGD,iBAAiB,CAACE,IAAI,CAACL,KAAK,CAAC;EAC7C,OAAOI,OAAO,GAAGH,OAAO,CAACC,KAAK,CAAC,gBAAgB,CAAC,GAAGF,KAAK;AAC1D;;AAEA;AACA;AACA","ignoreList":[]}
@@ -10,6 +10,8 @@ export * from "./form/form-definition/index.js";
10
10
  export * from "./form/form-definition/types.js";
11
11
  export * from "./form/form-definition/helpers.js";
12
12
  export * from "./form/form-metadata/index.js";
13
+ export * from "./form/form-metrics/enums.js";
14
+ export * from "./form/form-metrics/types.js";
13
15
  export * from "./form/form-submission/index.js";
14
16
  export * from "./form/form-submission/enums.js";
15
17
  export * from "./form/utils/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["export * from '~/src/common/enums.js'\nexport * from '~/src/common/random-id.js'\nexport * from '~/src/common/schema.js'\nexport * from '~/src/common/pagination/index.js'\nexport * from '~/src/common/search/index.js'\nexport * from '~/src/common/sorting/index.js'\nexport * from '~/src/components/index.js'\nexport * from '~/src/conditions/index.js'\nexport * from '~/src/form/form-definition/index.js'\nexport * from '~/src/form/form-definition/types.js'\nexport * from '~/src/form/form-definition/helpers.js'\nexport * from '~/src/form/form-metadata/index.js'\nexport * from '~/src/form/form-submission/index.js'\nexport * from '~/src/form/form-submission/enums.js'\nexport * from '~/src/form/utils/index.js'\nexport * from '~/src/form/form-editor/index.js'\nexport * from '~/src/form/form-editor/preview/index.js'\nexport * from '~/src/form/form-manager/types.js'\nexport * from '~/src/form/form-manager/errors.js'\nexport * from '~/src/manage/dead-letter-queues.js'\nexport * from '~/src/manage/roles.js'\nexport * from '~/src/manage/users.js'\nexport * from '~/src/pages/index.js'\nexport * from '~/src/utils/helpers.js'\nexport * from '~/src/utils/markdown.js'\nexport * from '~/src/form/form-audit/index.js'\nexport * from '~/src/form/form-audit/enums.js'\nexport * from '~/src/form/form-audit/consolidation.js'\n\nexport type * from '~/src/common/types.js'\nexport type * from '~/src/common/pagination/types.js'\nexport type * from '~/src/common/search/types.js'\nexport type * from '~/src/common/sorting/types.js'\nexport type * from '~/src/components/types.js'\nexport type * from '~/src/conditions/types.js'\nexport type * from '~/src/form/form-definition/types.js'\nexport type * from '~/src/form/form-metadata/types.js'\nexport type * from '~/src/form/form-submission/types.js'\nexport type * from '~/src/form/form-editor/preview/types.js'\nexport type * from '~/src/form/form-editor/types.js'\nexport type * from '~/src/form/form-editor/macros/types.js'\nexport type * from '~/src/form/form-audit/types.js'\nexport type * from '~/src/manage/types.js'\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["export * from '~/src/common/enums.js'\nexport * from '~/src/common/random-id.js'\nexport * from '~/src/common/schema.js'\nexport * from '~/src/common/pagination/index.js'\nexport * from '~/src/common/search/index.js'\nexport * from '~/src/common/sorting/index.js'\nexport * from '~/src/components/index.js'\nexport * from '~/src/conditions/index.js'\nexport * from '~/src/form/form-definition/index.js'\nexport * from '~/src/form/form-definition/types.js'\nexport * from '~/src/form/form-definition/helpers.js'\nexport * from '~/src/form/form-metadata/index.js'\nexport * from '~/src/form/form-metrics/enums.js'\nexport * from '~/src/form/form-metrics/types.js'\nexport * from '~/src/form/form-submission/index.js'\nexport * from '~/src/form/form-submission/enums.js'\nexport * from '~/src/form/utils/index.js'\nexport * from '~/src/form/form-editor/index.js'\nexport * from '~/src/form/form-editor/preview/index.js'\nexport * from '~/src/form/form-manager/types.js'\nexport * from '~/src/form/form-manager/errors.js'\nexport * from '~/src/manage/dead-letter-queues.js'\nexport * from '~/src/manage/roles.js'\nexport * from '~/src/manage/users.js'\nexport * from '~/src/pages/index.js'\nexport * from '~/src/utils/helpers.js'\nexport * from '~/src/utils/markdown.js'\nexport * from '~/src/form/form-audit/index.js'\nexport * from '~/src/form/form-audit/enums.js'\nexport * from '~/src/form/form-audit/consolidation.js'\n\nexport type * from '~/src/common/types.js'\nexport type * from '~/src/common/pagination/types.js'\nexport type * from '~/src/common/search/types.js'\nexport type * from '~/src/common/sorting/types.js'\nexport type * from '~/src/components/types.js'\nexport type * from '~/src/conditions/types.js'\nexport type * from '~/src/form/form-definition/types.js'\nexport type * from '~/src/form/form-metadata/types.js'\nexport type * from '~/src/form/form-submission/types.js'\nexport type * from '~/src/form/form-editor/preview/types.js'\nexport type * from '~/src/form/form-editor/types.js'\nexport type * from '~/src/form/form-editor/macros/types.js'\nexport type * from '~/src/form/form-audit/types.js'\nexport type * from '~/src/manage/types.js'\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -86,6 +86,38 @@ export function onlyDeclarationComponents(components) {
86
86
  export function includesPaymentField(components) {
87
87
  return components.some(component => component.type === ComponentType.PaymentField);
88
88
  }
89
+
90
+ /**
91
+ * Helper function to determine if a payment question already exists in the form
92
+ */
93
+ export function hasPaymentQuestionInForm(definition) {
94
+ if (definition.pages.length === 0) {
95
+ return false;
96
+ }
97
+ for (const page of definition.pages) {
98
+ const hasPayment = hasComponents(page) ? includesPaymentField(page.components) : false;
99
+ if (hasPayment) {
100
+ return true;
101
+ }
102
+ }
103
+ return false;
104
+ }
105
+
106
+ /**
107
+ * Helper function to determine if a specific question type exists in the form
108
+ */
109
+ export function hasSpecificQuestionTypeInForm(definition, componentType) {
110
+ if (definition.pages.length === 0) {
111
+ return false;
112
+ }
113
+ for (const page of definition.pages) {
114
+ const hasPayment = hasComponents(page) ? page.components.some(component => component.type === componentType) : false;
115
+ if (hasPayment) {
116
+ return true;
117
+ }
118
+ }
119
+ return false;
120
+ }
89
121
  const SHOW_REPEATER_CONTROLLERS = [ControllerType.Page, ControllerType.Repeat];
90
122
  export function showRepeaterSettings(page) {
91
123
  if (page.controller && !SHOW_REPEATER_CONTROLLERS.includes(page.controller)) {
@@ -143,11 +175,15 @@ export function isSummaryPage(page) {
143
175
  * @returns {FormDefinition}
144
176
  */
145
177
  export function replaceCustomControllers(definition) {
146
- const standardControllers = new Set(Object.values(ControllerType).filter(x => x !== ControllerType.SummaryWithConfirmationEmail).map(x => x.toString()));
178
+ const standardControllers = new Set(Object.values(ControllerType).filter(x => x !== ControllerType.SummaryWithConfirmationEmail)
179
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-conversion
180
+ .map(x => x.toString()));
147
181
  return {
148
182
  ...definition,
149
183
  pages: definition.pages.map(page => {
150
- if (!standardControllers.has((page.controller ?? ControllerType.Page).toString())) {
184
+ if (!standardControllers.has(
185
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-conversion
186
+ (page.controller ?? ControllerType.Page).toString())) {
151
187
  return /** @type {Page} */{
152
188
  ...page,
153
189
  controller: ControllerType.Page
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","names":["ComponentType","hasFormField","isFormType","ControllerNames","ControllerTypes","ControllerType","PageTypes","getPageDefaults","page","nameOrPath","controller","Page","controllerNameFromPath","defaults","find","pageType","Error","structuredClone","hasComponents","hasNext","Array","isArray","components","hasComponentsEvenIfNoNext","undefined","hasFormComponents","Start","hasRepeater","Repeat","isControllerName","map","String","includes","Terminal","FileUpload","options","path","name","includesFileUploadField","some","component","type","FileUploadField","onlyDeclarationComponents","filter","comp","every","DeclarationField","includesPaymentField","PaymentField","SHOW_REPEATER_CONTROLLERS","showRepeaterSettings","getPageTitle","title","firstComp","getPageFromDefinition","definition","pageId","pages","x","id","summaryPageControllers","Summary","SummaryWithConfirmationEmail","isSummaryPage","replaceCustomControllers","standardControllers","Set","Object","values","toString","has","isPaymentPage","isEndPage"],"sources":["../../../src/pages/helpers.ts"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { hasFormField, isFormType } from '~/src/components/helpers.js'\nimport { type ComponentDef } from '~/src/components/types.js'\nimport {\n type Link,\n type Page,\n type PageFileUpload,\n type PageQuestion,\n type PageRepeat\n} from '~/src/form/form-definition/types.js'\nimport { type FormDefinition } from '~/src/index.js'\nimport {\n ControllerNames,\n ControllerTypes\n} from '~/src/pages/controller-types.js'\nimport { ControllerType } from '~/src/pages/enums.js'\nimport { PageTypes } from '~/src/pages/page-types.js'\n\n/**\n * Return component defaults by type\n */\nexport function getPageDefaults<PageType extends Page>(\n page?: Pick<PageType, 'controller'>\n) {\n const nameOrPath = page?.controller ?? ControllerType.Page\n const controller = controllerNameFromPath(nameOrPath)\n\n const defaults = PageTypes.find(\n (pageType) => pageType.controller === controller\n )\n\n if (!defaults) {\n throw new Error(`Defaults not found for page type '${nameOrPath}'`)\n }\n\n return structuredClone(defaults) as PageType\n}\n\n/**\n * Check page has components\n */\nexport function hasComponents(\n page?: Partial<Page>\n): page is Extract<Page, { components: ComponentDef[] }> {\n return hasNext(page) && Array.isArray(page.components)\n}\n\n/**\n * Check if the page has components (the page can be any page type e.g. SummaryPage)\n */\nexport function hasComponentsEvenIfNoNext(\n page?: Partial<Page>\n): page is Extract<Page, { components: ComponentDef[] }> {\n return (\n page !== undefined && 'components' in page && Array.isArray(page.components)\n )\n}\n\n/**\n * Check page has form components\n */\nexport function hasFormComponents(\n page?: Partial<Page>\n): page is PageQuestion | PageFileUpload {\n const controller = controllerNameFromPath(page?.controller)\n return hasComponents(page) && controller !== ControllerType.Start\n}\n\n/**\n * Check page has repeater\n */\nexport function hasRepeater(page?: Partial<Page>): page is PageRepeat {\n return controllerNameFromPath(page?.controller) === ControllerType.Repeat\n}\n\n/**\n * Check for known page controller names\n */\nexport function isControllerName(\n nameOrPath?: ControllerType | string\n): nameOrPath is ControllerType {\n return !!nameOrPath && ControllerNames.map(String).includes(nameOrPath)\n}\n\n/**\n * Check page has next link\n */\nexport function hasNext(\n page?: Partial<Page>\n): page is Extract<Page, { next: Link[] }> {\n if (!page || !('next' in page)) {\n return false\n }\n\n const controller = controllerNameFromPath(page.controller)\n\n return (\n !controller ||\n controller === ControllerType.Start ||\n controller === ControllerType.Page ||\n controller === ControllerType.Terminal ||\n controller === ControllerType.FileUpload ||\n controller === ControllerType.Repeat\n )\n}\n\n/**\n * Check and optionally replace legacy path with controller name\n * @param {string} [nameOrPath] - Controller name or legacy controller path\n */\nexport function controllerNameFromPath(nameOrPath?: ControllerType | string) {\n if (isControllerName(nameOrPath)) {\n return nameOrPath\n }\n\n const options = ControllerTypes.find(({ path }) => path === nameOrPath)\n return options?.name\n}\n\nexport function includesFileUploadField(components: ComponentDef[]): boolean {\n return components.some(\n (component) => component.type === ComponentType.FileUploadField\n )\n}\n\nexport function onlyDeclarationComponents(components: ComponentDef[]): boolean {\n return components\n .filter((comp) => isFormType(comp.type))\n .every((component) => component.type === ComponentType.DeclarationField)\n}\n\nexport function includesPaymentField(components: ComponentDef[]): boolean {\n return components.some(\n (component) => component.type === ComponentType.PaymentField\n )\n}\n\nconst SHOW_REPEATER_CONTROLLERS = [ControllerType.Page, ControllerType.Repeat]\n\nexport function showRepeaterSettings(page: Page): boolean {\n if (page.controller && !SHOW_REPEATER_CONTROLLERS.includes(page.controller)) {\n return false\n }\n if (hasComponents(page)) {\n if (includesFileUploadField(page.components)) {\n return false\n }\n if (onlyDeclarationComponents(page.components)) {\n return false\n }\n if (includesPaymentField(page.components)) {\n return false\n }\n }\n return true\n}\n\n/**\n * Gets page title, or title of first question (if no page title set)\n * @param {Page} page\n * @returns {string}\n */\nexport function getPageTitle(page: Page) {\n if (page.title !== '') {\n return page.title\n }\n\n if (hasComponentsEvenIfNoNext(page)) {\n const firstComp = page.components.find(hasFormField)\n if (firstComp) {\n return firstComp.title\n }\n }\n return 'Page title unknown'\n}\n\n/**\n *\n * @param {FormDefinition} definition\n * @param {string} pageId\n * @returns { Page | undefined }\n */\nexport function getPageFromDefinition(\n definition: FormDefinition,\n pageId: string\n): Page | undefined {\n return definition.pages.find((x) => x.id === pageId)\n}\n\nexport const summaryPageControllers = [\n ControllerType.Summary,\n ControllerType.SummaryWithConfirmationEmail\n]\n\nexport function isSummaryPage(page: Page | undefined) {\n return summaryPageControllers.includes(\n page?.controller ?? ControllerType.Page\n )\n}\n\n/**\n * Revert any custom controllers to their parent/base class since engine-plugin has no knowledge of them\n * @param {FormDefinition} definition\n * @returns {FormDefinition}\n */\nexport function replaceCustomControllers(definition: FormDefinition) {\n const standardControllers = new Set(\n Object.values(ControllerType)\n .filter((x) => x !== ControllerType.SummaryWithConfirmationEmail)\n .map((x) => x.toString())\n )\n\n return {\n ...definition,\n pages: definition.pages.map((page) => {\n if (\n !standardControllers.has(\n (page.controller ?? ControllerType.Page).toString()\n )\n ) {\n return /** @type {Page} */ {\n ...page,\n controller: ControllerType.Page\n }\n }\n return page\n })\n } as FormDefinition\n}\n\n/**\n * Helper function to determine if the current page contains a payment question\n * @param page - the page of the form\n * @returns {boolean}\n */\nexport function isPaymentPage(page: Page | undefined) {\n if (hasComponentsEvenIfNoNext(page)) {\n return page.components.some(\n (comp) => comp.type === ComponentType.PaymentField\n )\n }\n return false\n}\n\n/**\n * Helper function to determine if the current page is an end page i.e. summary page or payment page\n * @param page - the page of the form\n * @returns {boolean}\n */\nexport function isEndPage(page: Page | undefined) {\n return isSummaryPage(page) || isPaymentPage(page)\n}\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,YAAY,EAAEC,UAAU;AAUjC,SACEC,eAAe,EACfC,eAAe;AAEjB,SAASC,cAAc;AACvB,SAASC,SAAS;;AAElB;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAC7BC,IAAmC,EACnC;EACA,MAAMC,UAAU,GAAGD,IAAI,EAAEE,UAAU,IAAIL,cAAc,CAACM,IAAI;EAC1D,MAAMD,UAAU,GAAGE,sBAAsB,CAACH,UAAU,CAAC;EAErD,MAAMI,QAAQ,GAAGP,SAAS,CAACQ,IAAI,CAC5BC,QAAQ,IAAKA,QAAQ,CAACL,UAAU,KAAKA,UACxC,CAAC;EAED,IAAI,CAACG,QAAQ,EAAE;IACb,MAAM,IAAIG,KAAK,CAAC,qCAAqCP,UAAU,GAAG,CAAC;EACrE;EAEA,OAAOQ,eAAe,CAACJ,QAAQ,CAAC;AAClC;;AAEA;AACA;AACA;AACA,OAAO,SAASK,aAAaA,CAC3BV,IAAoB,EACmC;EACvD,OAAOW,OAAO,CAACX,IAAI,CAAC,IAAIY,KAAK,CAACC,OAAO,CAACb,IAAI,CAACc,UAAU,CAAC;AACxD;;AAEA;AACA;AACA;AACA,OAAO,SAASC,yBAAyBA,CACvCf,IAAoB,EACmC;EACvD,OACEA,IAAI,KAAKgB,SAAS,IAAI,YAAY,IAAIhB,IAAI,IAAIY,KAAK,CAACC,OAAO,CAACb,IAAI,CAACc,UAAU,CAAC;AAEhF;;AAEA;AACA;AACA;AACA,OAAO,SAASG,iBAAiBA,CAC/BjB,IAAoB,EACmB;EACvC,MA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AAIL,cAAc,CAACM,IAAI,EAAE2D,QAAQ,CAAC,CACpD,CAAC,EACD;QACA,OAAO,mBAAoB;UACzB,GAAG9D,IAAI;UACPE,UAAU,EAAEL,cAAc,CAACM;QAC7B,CAAC;MACH;MACA,OAAOH,IAAI;IACb,CAAC;EACH,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASgE,aAAaA,CAAChE,IAAsB,EAAE;EACpD,IAAIe,yBAAyB,CAACf,IAAI,CAAC,EAAE;IACnC,OAAOA,IAAI,CAACc,UAAU,CAACiB,IAAI,CACxBM,IAAI,IAAKA,IAAI,CAACJ,IAAI,KAAKzC,aAAa,CAACiD,YACxC,CAAC;EACH;EACA,OAAO,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASwB,SAASA,CAACjE,IAAsB,EAAE;EAChD,OAAOwD,aAAa,CAACxD,IAAI,CAAC,IAAIgE,aAAa,CAAChE,IAAI,CAAC;AACnD","ignoreList":[]}
1
+ {"version":3,"file":"helpers.js","names":["ComponentType","hasFormField","isFormType","ControllerNames","ControllerTypes","ControllerType","PageTypes","getPageDefaults","page","nameOrPath","controller","Page","controllerNameFromPath","defaults","find","pageType","Error","structuredClone","hasComponents","hasNext","Array","isArray","components","hasComponentsEvenIfNoNext","undefined","hasFormComponents","Start","hasRepeater","Repeat","isControllerName","map","String","includes","Terminal","FileUpload","options","path","name","includesFileUploadField","some","component","type","FileUploadField","onlyDeclarationComponents","filter","comp","every","DeclarationField","includesPaymentField","PaymentField","hasPaymentQuestionInForm","definition","pages","length","hasPayment","hasSpecificQuestionTypeInForm","componentType","SHOW_REPEATER_CONTROLLERS","showRepeaterSettings","getPageTitle","title","firstComp","getPageFromDefinition","pageId","x","id","summaryPageControllers","Summary","SummaryWithConfirmationEmail","isSummaryPage","replaceCustomControllers","standardControllers","Set","Object","values","toString","has","isPaymentPage","isEndPage"],"sources":["../../../src/pages/helpers.ts"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { hasFormField, isFormType } from '~/src/components/helpers.js'\nimport { type ComponentDef } from '~/src/components/types.js'\nimport {\n type Link,\n type Page,\n type PageFileUpload,\n type PageQuestion,\n type PageRepeat\n} from '~/src/form/form-definition/types.js'\nimport { type FormDefinition } from '~/src/index.js'\nimport {\n ControllerNames,\n ControllerTypes\n} from '~/src/pages/controller-types.js'\nimport { ControllerType } from '~/src/pages/enums.js'\nimport { PageTypes } from '~/src/pages/page-types.js'\n\n/**\n * Return component defaults by type\n */\nexport function getPageDefaults<PageType extends Page>(\n page?: Pick<PageType, 'controller'>\n) {\n const nameOrPath = page?.controller ?? ControllerType.Page\n const controller = controllerNameFromPath(nameOrPath)\n\n const defaults = PageTypes.find(\n (pageType) => pageType.controller === controller\n )\n\n if (!defaults) {\n throw new Error(`Defaults not found for page type '${nameOrPath}'`)\n }\n\n return structuredClone(defaults) as PageType\n}\n\n/**\n * Check page has components\n */\nexport function hasComponents(\n page?: Partial<Page>\n): page is Extract<Page, { components: ComponentDef[] }> {\n return hasNext(page) && Array.isArray(page.components)\n}\n\n/**\n * Check if the page has components (the page can be any page type e.g. SummaryPage)\n */\nexport function hasComponentsEvenIfNoNext(\n page?: Partial<Page>\n): page is Extract<Page, { components: ComponentDef[] }> {\n return (\n page !== undefined && 'components' in page && Array.isArray(page.components)\n )\n}\n\n/**\n * Check page has form components\n */\nexport function hasFormComponents(\n page?: Partial<Page>\n): page is PageQuestion | PageFileUpload {\n const controller = controllerNameFromPath(page?.controller)\n return hasComponents(page) && controller !== ControllerType.Start\n}\n\n/**\n * Check page has repeater\n */\nexport function hasRepeater(page?: Partial<Page>): page is PageRepeat {\n return controllerNameFromPath(page?.controller) === ControllerType.Repeat\n}\n\n/**\n * Check for known page controller names\n */\nexport function isControllerName(\n nameOrPath?: ControllerType | string\n): nameOrPath is ControllerType {\n return !!nameOrPath && ControllerNames.map(String).includes(nameOrPath)\n}\n\n/**\n * Check page has next link\n */\nexport function hasNext(\n page?: Partial<Page>\n): page is Extract<Page, { next: Link[] }> {\n if (!page || !('next' in page)) {\n return false\n }\n\n const controller = controllerNameFromPath(page.controller)\n\n return (\n !controller ||\n controller === ControllerType.Start ||\n controller === ControllerType.Page ||\n controller === ControllerType.Terminal ||\n controller === ControllerType.FileUpload ||\n controller === ControllerType.Repeat\n )\n}\n\n/**\n * Check and optionally replace legacy path with controller name\n * @param {string} [nameOrPath] - Controller name or legacy controller path\n */\nexport function controllerNameFromPath(nameOrPath?: ControllerType | string) {\n if (isControllerName(nameOrPath)) {\n return nameOrPath\n }\n\n const options = ControllerTypes.find(({ path }) => path === nameOrPath)\n return options?.name\n}\n\nexport function includesFileUploadField(components: ComponentDef[]): boolean {\n return components.some(\n (component) => component.type === ComponentType.FileUploadField\n )\n}\n\nexport function onlyDeclarationComponents(components: ComponentDef[]): boolean {\n return components\n .filter((comp) => isFormType(comp.type))\n .every((component) => component.type === ComponentType.DeclarationField)\n}\n\nexport function includesPaymentField(components: ComponentDef[]): boolean {\n return components.some(\n (component) => component.type === ComponentType.PaymentField\n )\n}\n\n/**\n * Helper function to determine if a payment question already exists in the form\n */\nexport function hasPaymentQuestionInForm(definition: FormDefinition) {\n if (definition.pages.length === 0) {\n return false\n }\n\n for (const page of definition.pages) {\n const hasPayment = hasComponents(page)\n ? includesPaymentField(page.components)\n : false\n if (hasPayment) {\n return true\n }\n }\n return false\n}\n\n/**\n * Helper function to determine if a specific question type exists in the form\n */\nexport function hasSpecificQuestionTypeInForm(\n definition: FormDefinition,\n componentType: ComponentType\n) {\n if (definition.pages.length === 0) {\n return false\n }\n\n for (const page of definition.pages) {\n const hasPayment = hasComponents(page)\n ? page.components.some((component) => component.type === componentType)\n : false\n if (hasPayment) {\n return true\n }\n }\n return false\n}\n\nconst SHOW_REPEATER_CONTROLLERS = [ControllerType.Page, ControllerType.Repeat]\n\nexport function showRepeaterSettings(page: Page): boolean {\n if (page.controller && !SHOW_REPEATER_CONTROLLERS.includes(page.controller)) {\n return false\n }\n if (hasComponents(page)) {\n if (includesFileUploadField(page.components)) {\n return false\n }\n if (onlyDeclarationComponents(page.components)) {\n return false\n }\n if (includesPaymentField(page.components)) {\n return false\n }\n }\n return true\n}\n\n/**\n * Gets page title, or title of first question (if no page title set)\n * @param {Page} page\n * @returns {string}\n */\nexport function getPageTitle(page: Page) {\n if (page.title !== '') {\n return page.title\n }\n\n if (hasComponentsEvenIfNoNext(page)) {\n const firstComp = page.components.find(hasFormField)\n if (firstComp) {\n return firstComp.title\n }\n }\n return 'Page title unknown'\n}\n\n/**\n *\n * @param {FormDefinition} definition\n * @param {string} pageId\n * @returns { Page | undefined }\n */\nexport function getPageFromDefinition(\n definition: FormDefinition,\n pageId: string\n): Page | undefined {\n return definition.pages.find((x) => x.id === pageId)\n}\n\nexport const summaryPageControllers = [\n ControllerType.Summary,\n ControllerType.SummaryWithConfirmationEmail\n]\n\nexport function isSummaryPage(page: Page | undefined) {\n return summaryPageControllers.includes(\n page?.controller ?? ControllerType.Page\n )\n}\n\n/**\n * Revert any custom controllers to their parent/base class since engine-plugin has no knowledge of them\n * @param {FormDefinition} definition\n * @returns {FormDefinition}\n */\nexport function replaceCustomControllers(definition: FormDefinition) {\n const standardControllers = new Set(\n Object.values(ControllerType)\n .filter((x) => x !== ControllerType.SummaryWithConfirmationEmail)\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-conversion\n .map((x) => x.toString())\n )\n\n return {\n ...definition,\n pages: definition.pages.map((page) => {\n if (\n !standardControllers.has(\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-conversion\n (page.controller ?? ControllerType.Page).toString()\n )\n ) {\n return /** @type {Page} */ {\n ...page,\n controller: ControllerType.Page\n }\n }\n return page\n })\n } as FormDefinition\n}\n\n/**\n * Helper function to determine if the current page contains a payment question\n * @param page - the page of the form\n * @returns {boolean}\n */\nexport function isPaymentPage(page: Page | undefined) {\n if (hasComponentsEvenIfNoNext(page)) {\n return page.components.some(\n (comp) => comp.type === ComponentType.PaymentField\n )\n }\n return false\n}\n\n/**\n * Helper function to determine if the current page is an end page i.e. summary page or payment page\n * @param page - the page of the form\n * @returns {boolean}\n */\nexport function isEndPage(page: Page | undefined) {\n return isSummaryPage(page) || isPaymentPage(page)\n}\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,YAAY,EAAEC,UAAU;AAUjC,SACEC,eAAe,EACfC,eAAe;AAEjB,SAASC,cAAc;AACvB,SAASC,SAAS;;AAElB;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAC7BC,IAAmC,EACnC;EACA,MAAMC,UAAU,GAAGD,IAAI,EAAEE,UAAU,IAAIL,cAAc,CAACM,IAAI;EAC1D,MAAMD,UAAU,GAAGE,sBAAsB,CAACH,UAAU,CAAC;EAErD,MAAMI,QAAQ,GAAGP,SAAS,CAACQ,IAAI,CAC5BC,QAAQ,IAAKA,QAAQ,CAACL,UAAU,KAAKA,UACxC,CAAC;EAED,IAAI,CAACG,QAAQ,EAAE;IACb,MAAM,IAAIG,KAAK,CAAC,qCAAqCP,UAAU,GAAG,CAAC;EACrE;EAEA,OAAOQ,eAAe,CAACJ,QAAQ,CAAC;AAClC;;AAEA;AACA;AACA;AACA,OAAO,SAASK,aAAaA,CAC3BV,IAAoB,EACmC;EACvD,OAAOW,OAAO,CAACX,IAAI,CAAC,IAAIY,KAAK,CAACC,OAAO,CAACb,IAAI,CAACc,UAAU,CAAC;AACxD;;AAEA;AACA;AACA;AACA,OAAO,SAASC,yBAAyBA,CACvCf,IAAoB,EACmC;EACvD,OACEA,IAAI,KAAKgB,SAAS,IAAI,YAAY,IAAIhB,IAAI,IAAIY,KAAK,CAACC,OAAO,CAACb,IAAI,CAACc,UAAU,CAAC;AAEhF;;AAEA;AACA;AACA;AACA,OAAO,SAASG,iBAAiBA,CAC/BjB,IAAoB,EACmB;EACvC,MAAME,UAAU,GAAGE,sBAAsB,CAACJ,IAAI,EAAEE,UAAU,CAAC;EAC3D,OAAOQ,aAAa,CAACV,IAAI,CAAC,IAAIE,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A;AACA,OAAO,SAAS6B,SAASA,CAACtE,IAAsB,EAAE;EAChD,OAAO6D,aAAa,CAAC7D,IAAI,CAAC,IAAIqE,aAAa,CAACrE,IAAI,CAAC;AACnD","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  export { ControllerNames, ControllerTypes } from "./controller-types.js";
2
2
  export { PageTypes } from "./page-types.js";
3
- export { controllerNameFromPath, getPageDefaults, getPageFromDefinition, getPageTitle, hasComponents, hasComponentsEvenIfNoNext, hasFormComponents, hasNext, hasRepeater, includesFileUploadField, includesPaymentField, isControllerName, isEndPage, isPaymentPage, isSummaryPage, replaceCustomControllers, showRepeaterSettings, summaryPageControllers } from "./helpers.js";
3
+ export { controllerNameFromPath, getPageDefaults, getPageFromDefinition, getPageTitle, hasComponents, hasComponentsEvenIfNoNext, hasFormComponents, hasNext, hasPaymentQuestionInForm, hasRepeater, hasSpecificQuestionTypeInForm, includesFileUploadField, includesPaymentField, isControllerName, isEndPage, isPaymentPage, isSummaryPage, replaceCustomControllers, showRepeaterSettings, summaryPageControllers } from "./helpers.js";
4
4
  export { ControllerPath, ControllerType } from "./enums.js";
5
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["ControllerNames","ControllerTypes","PageTypes","controllerNameFromPath","getPageDefaults","getPageFromDefinition","getPageTitle","hasComponents","hasComponentsEvenIfNoNext","hasFormComponents","hasNext","hasRepeater","includesFileUploadField","includesPaymentField","isControllerName","isEndPage","isPaymentPage","isSummaryPage","replaceCustomControllers","showRepeaterSettings","summaryPageControllers","ControllerPath","ControllerType"],"sources":["../../../src/pages/index.ts"],"sourcesContent":["export {\n ControllerNames,\n ControllerTypes\n} from '~/src/pages/controller-types.js'\n\nexport { PageTypes } from '~/src/pages/page-types.js'\n\nexport {\n controllerNameFromPath,\n getPageDefaults,\n getPageFromDefinition,\n getPageTitle,\n hasComponents,\n hasComponentsEvenIfNoNext,\n hasFormComponents,\n hasNext,\n hasRepeater,\n includesFileUploadField,\n includesPaymentField,\n isControllerName,\n isEndPage,\n isPaymentPage,\n isSummaryPage,\n replaceCustomControllers,\n showRepeaterSettings,\n summaryPageControllers\n} from '~/src/pages/helpers.js'\n\nexport { ControllerPath, ControllerType } from '~/src/pages/enums.js'\n"],"mappings":"AAAA,SACEA,eAAe,EACfC,eAAe;AAGjB,SAASC,SAAS;AAElB,SACEC,sBAAsB,EACtBC,eAAe,EACfC,qBAAqB,EACrBC,YAAY,EACZC,aAAa,EACbC,yBAAyB,EACzBC,iBAAiB,EACjBC,OAAO,EACPC,WAAW,EACXC,uBAAuB,EACvBC,oBAAoB,EACpBC,gBAAgB,EAChBC,SAAS,EACTC,aAAa,EACbC,aAAa,EACbC,wBAAwB,EACxBC,oBAAoB,EACpBC,sBAAsB;AAGxB,SAASC,cAAc,EAAEC,cAAc","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["ControllerNames","ControllerTypes","PageTypes","controllerNameFromPath","getPageDefaults","getPageFromDefinition","getPageTitle","hasComponents","hasComponentsEvenIfNoNext","hasFormComponents","hasNext","hasPaymentQuestionInForm","hasRepeater","hasSpecificQuestionTypeInForm","includesFileUploadField","includesPaymentField","isControllerName","isEndPage","isPaymentPage","isSummaryPage","replaceCustomControllers","showRepeaterSettings","summaryPageControllers","ControllerPath","ControllerType"],"sources":["../../../src/pages/index.ts"],"sourcesContent":["export {\n ControllerNames,\n ControllerTypes\n} from '~/src/pages/controller-types.js'\n\nexport { PageTypes } from '~/src/pages/page-types.js'\n\nexport {\n controllerNameFromPath,\n getPageDefaults,\n getPageFromDefinition,\n getPageTitle,\n hasComponents,\n hasComponentsEvenIfNoNext,\n hasFormComponents,\n hasNext,\n hasPaymentQuestionInForm,\n hasRepeater,\n hasSpecificQuestionTypeInForm,\n includesFileUploadField,\n includesPaymentField,\n isControllerName,\n isEndPage,\n isPaymentPage,\n isSummaryPage,\n replaceCustomControllers,\n showRepeaterSettings,\n summaryPageControllers\n} from '~/src/pages/helpers.js'\n\nexport { ControllerPath, ControllerType } from '~/src/pages/enums.js'\n"],"mappings":"AAAA,SACEA,eAAe,EACfC,eAAe;AAGjB,SAASC,SAAS;AAElB,SACEC,sBAAsB,EACtBC,eAAe,EACfC,qBAAqB,EACrBC,YAAY,EACZC,aAAa,EACbC,yBAAyB,EACzBC,iBAAiB,EACjBC,OAAO,EACPC,wBAAwB,EACxBC,WAAW,EACXC,6BAA6B,EAC7BC,uBAAuB,EACvBC,oBAAoB,EACpBC,gBAAgB,EAChBC,SAAS,EACTC,aAAa,EACbC,aAAa,EACbC,wBAAwB,EACxBC,oBAAoB,EACpBC,sBAAsB;AAGxB,SAASC,cAAc,EAAEC,cAAc","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ export declare const MIN_NUMBER_OF_REPEAT_ITEMS = 1;
2
+ export declare const MAX_NUMBER_OF_REPEAT_ITEMS = 200;
3
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/form/form-definition/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B,IAAI,CAAA;AAC3C,eAAO,MAAM,0BAA0B,MAAM,CAAA"}
@@ -3,8 +3,6 @@ import { type ComponentDef, type ContentComponentsDef, type FileUploadFieldCompo
3
3
  import { type ConditionDataV2, type ConditionListItemRefValueDataV2 } from '../../conditions/types.js';
4
4
  import { type ConditionWrapperV2, type FormDefinition, type List, type Page, type Repeat, type Section } from '../../form/form-definition/types.js';
5
5
  export declare const listItemIdValidator: (value: string, helpers: CustomHelpers<ConditionListItemRefValueDataV2>) => string | JoiBase.ErrorReport;
6
- export declare const MIN_NUMBER_OF_REPEAT_ITEMS = 1;
7
- export declare const MAX_NUMBER_OF_REPEAT_ITEMS = 200;
8
6
  export declare const conditionDataSchemaV2: JoiBase.ObjectSchema<ConditionDataV2>;
9
7
  export declare const conditionWrapperSchemaV2: JoiBase.ObjectSchema<ConditionWrapperV2>;
10
8
  export declare const regexCustomValidator: (value: string, helpers: CustomHelpers<string>) => string | JoiBase.ErrorReport;
@@ -40,5 +38,6 @@ export declare const sectionsSchemaV2: JoiBase.ObjectSchema<Section>;
40
38
  */
41
39
  export declare const formDefinitionSchema: JoiBase.ObjectSchema<FormDefinition>;
42
40
  export declare const formDefinitionV2Schema: JoiBase.ObjectSchema<FormDefinition>;
41
+ export { MAX_NUMBER_OF_REPEAT_ITEMS, MIN_NUMBER_OF_REPEAT_ITEMS } from '../../form/form-definition/constants.js';
43
42
  export declare const Schema: JoiBase.ObjectSchema<FormDefinition>;
44
43
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/form/form-definition/index.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,EAAE,EAAE,KAAK,aAAa,EAAyB,MAAM,KAAK,CAAA;AAMxE,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC9B,MAAM,2BAA2B,CAAA;AAElC,OAAO,EAEL,KAAK,eAAe,EAIpB,KAAK,+BAA+B,EAOrC,MAAM,2BAA2B,CAAA;AAKlC,OAAO,EAGL,KAAK,kBAAkB,EAIvB,KAAK,cAAc,EAGnB,KAAK,IAAI,EACT,KAAK,IAAI,EAET,KAAK,MAAM,EAGX,KAAK,OAAO,EACb,MAAM,qCAAqC,CAAA;AA0C5C,eAAO,MAAM,mBAAmB,GAC9B,OAAO,MAAM,EACb,SAAS,aAAa,CAAC,+BAA+B,CAAC,iCAqCxD,CAAA;AA6ND,eAAO,MAAM,0BAA0B,IAAI,CAAA;AAC3C,eAAO,MAAM,0BAA0B,MAAM,CAAA;AAE7C,eAAO,MAAM,qBAAqB,uCAyD9B,CAAA;AAoDJ,eAAO,MAAM,wBAAwB,0CAwBU,CAAA;AAE/C,eAAO,MAAM,oBAAoB,GAC/B,OAAO,MAAM,EACb,SAAS,aAAa,CAAC,MAAM,CAAC,iCAW/B,CA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C9B,OAAO,MAAM,EACb,SAAS,aAAa,CAAC,+BAA+B,CAAC,iCAqCxD,CAAA;AA6ND,eAAO,MAAM,qBAAqB,uCAyD9B,CAAA;AAoDJ,eAAO,MAAM,wBAAwB,0CAwBU,CAAA;AAE/C,eAAO,MAAM,oBAAoB,GAC/B,OAAO,MAAM,EACb,SAAS,aAAa,CAAC,MAAM,CAAC,iCAW/B,CAAA;AAED,eAAO,MAAM,eAAe,oCA8HZ,CAAA;AAEhB,eAAO,MAAM,iBAAiB,oCAciB,CAAA;AAE/C,eAAO,MAAM,wBAAwB,oCASsB,CAAA;AAE3D,eAAO,MAAM,yBAAyB,oCAMpC,CAAA;AAEF,eAAO,MAAM,sBAAsB,oCAUjC,CAAA;AAuDF,eAAO,MAAM,gBAAgB,8BASzB,CAAA;AAyCJ,eAAO,MAAM,0BAA0B,sEAWmB,CAAA;AAE1D;;;GAGG;AACH,eAAO,MAAM,UAAU,4BAmDnB,CAAA;AAEJ;;GAEG;AACH,eAAO,MAAM,YAAY,4BAuCiB,CAAA;AAE1C,eAAO,MAAM,mBAAmB,4BAgBkB,CAAA;AAwDlD,eAAO,MAAM,UAAU,4BA8CnB,CAAA;AAEJ;;GAEG;AACH,eAAO,MAAM,YAAY,4BAIiB,CAAA;AAE1C;;GAEG;AACH,eAAO,MAAM,gBAAgB,+BAIgB,CAAA;AA+C7C;;;GAGG;AACH,eAAO,MAAM,oBAAoB,sCA+F7B,CAAA;AAEJ,eAAO,MAAM,sBAAsB,sCAyDY,CAAA;AAE/C,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAC3B,MAAM,yCAAyC,CAAA;AAIhD,eAAO,MAAM,MAAM,sCAAuB,CAAA"}
@@ -1,5 +1,7 @@
1
1
  import Joi, { type ArraySchema } from 'joi';
2
2
  import { type FormEditorInputCheckAnswersSettings, type FormEditorInputPage, type FormEditorInputPageSettings, type FormEditorInputQuestion, type GovukField, type GovukFieldQuestionOptional, type GovukFieldUsePostcodeLookup, type GovukStringField } from '../../form/form-editor/types.js';
3
+ export declare const emailAddressNoUnicodeSchema: Joi.StringSchema<string>;
4
+ export declare const UNICODE_EMAIL_ERROR_MESSAGE = "The email address you entered includes invalid characters, for example, long dashes";
3
5
  export declare enum QuestionTypeSubGroup {
4
6
  WrittenAnswerSubGroup = "writtenAnswerSub",
5
7
  DateSubGroup = "dateSub",
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/form/form-editor/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,EAAE,EAAE,KAAK,WAAW,EAAuB,MAAM,KAAK,CAAA;AAQhE,OAAO,EACL,KAAK,mCAAmC,EACxC,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,EAChC,KAAK,uBAAuB,EAC5B,KAAK,UAAU,EACf,KAAK,0BAA0B,EAC/B,KAAK,2BAA2B,EAChC,KAAK,gBAAgB,EACtB,MAAM,iCAAiC,CAAA;AAExC,oBAAY,oBAAoB;IAC9B,qBAAqB,qBAAqB;IAC1C,YAAY,YAAY;IACxB,YAAY,YAAY;IACxB,gBAAgB,gBAAgB;CACjC;AAED,eAAO,MAAM,cAAc,0BAG6C,CAAA;AAExE,eAAO,MAAM,kBAAkB,0BAmB2C,CAAA;AAE1E,eAAO,MAAM,sBAAsB,0BAyBmC,CAAA;AAEtE,eAAO,MAAM,sBAAsB,0BAOmB,CAAA;AAEtD,eAAO,MAAM,aAAa,0BAG0B,CAAA;AAEpD,eAAO,MAAM,aAAa,0BAS0B,CAAA;AAEpD,eAAO,MAAM,iBAAiB,0BAU0B,CAAA;AAExD,eAAO,MAAM,UAAU,0BAG0B,CAAA;AAEjD,eAAO,MAAM,cAAc,0BAG8B,CAAA;AAEzD,eAAO,MAAM,cAAc,0BAI0C,CAAA;AAErE,eAAO,MAAM,qBAAqB,0BAM/B,CAAA;AAEH,eAAO,MAAM,sBAAsB,0BAMhC,CAAA;AAEH,eAAO,MAAM,qBAAqB,0BAIgC,CAAA;AAElE,eAA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AM,cAAc,0BAIgC,CAAA;AAE3D,eAAO,MAAM,eAAe,0BAIyC,CAAA;AAErE,eAAO,MAAM,WAAW,0BAEiC,CAAA;AAEzD,eAAO,MAAM,kBAAkB,0BAE2B,CAAA;AAE1D,eAAO,MAAM,uBAAuB,0BAGwB,CAAA;AAE5D,eAAO,MAAM,WAAW,4CAK+C,CAAA;AAEvE,eAAO,MAAM,eAAe,0BAMmB,CAAA;AAE/C,eAAO,MAAM,gBAAgB,0BAGiC,CAAA;AAE9D,eAAO,MAAM,YAAY,6CAK6C,CAAA;AAEtE,eAAO,MAAM,aAAa,uCAM+C,CAAA;AAEzE,eAAO,MAAM,wBAAwB,0BAEkC,CAAA;AAEvE,eAAO,MAAM,uBAAuB,0BAEY,CAAA;AAEhD,eAAO,MAAM,uBAAuB,0BAEqB,CAAA;AAEzD,eAAO,MAAM,sBAAsB,0BAKsB,CAAA;AAEzD,eAAO,MAAM,8BAA8B,4BAE1C,CAAA;AAED,eAAO,MAAM,8BAA8B,0BAGxC,CAAA;AAEH,eAAO,MAAM,gBAAgB,sBAGoC,CAAA;AAEjE,eAAO,MAAM,cAAc,0BAGuB,CAAA;AAElD,eAAO,MAAM,uBAAuB,0BAGe,CAAA;AAEnD,eAAO,MAAM,qBAAqB;;;;;;;;;;;;CAoBjC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,qCAG+B,CAAA;AAEnE;;;GAGG;AACH,eAAO,MAAM,wBAAwB,sCAMkC,CAAA;AAEvE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,qCAaqC,CAAA;AAEzE;;;GAGG;AACH,eAAO,MAAM,yBAAyB,uCASuB,CAAA;AAE7D;;;GAGG;AACH,eAAO,MAAM,kBAAkB,gCAuB5B,CAAA"}
@@ -0,0 +1,6 @@
1
+ export declare enum FormMetricType {
2
+ HeadlineMetric = "headline-metric",
3
+ OverviewMetric = "overview-metric",
4
+ TimelineMetric = "timeline-metric"
5
+ }
6
+ //# sourceMappingURL=enums.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../../src/form/form-metrics/enums.ts"],"names":[],"mappings":"AAAA,oBAAY,cAAc;IACxB,cAAc,oBAAoB;IAClC,cAAc,oBAAoB;IAClC,cAAc,oBAAoB;CACnC"}
@@ -0,0 +1,32 @@
1
+ import { type FormStatus } from '../../common/enums.js';
2
+ import { type FormMetricType } from '../../form/form-metrics/enums.js';
3
+ export interface FormHeadlineDetail {
4
+ count: number;
5
+ countSevenDaysAgo: number;
6
+ countThirtyDaysAgo: number;
7
+ countOneYearAgo: number;
8
+ }
9
+ export interface FormHeadlineMetric {
10
+ type: FormMetricType.HeadlineMetric;
11
+ headlineCounts: Record<string, FormHeadlineDetail>;
12
+ updatedAt: Date;
13
+ }
14
+ export interface FormOverviewMetric {
15
+ type: FormMetricType.OverviewMetric;
16
+ formId: string;
17
+ formStatus: FormStatus;
18
+ summaryMetrics: Record<string, number | string | string[]>;
19
+ featureCounts: Record<string, number>;
20
+ submissionsCount: number;
21
+ updatedAt: Date;
22
+ }
23
+ export interface FormTimelineMetric {
24
+ type: FormMetricType.TimelineMetric;
25
+ formId: string;
26
+ formStatus: FormStatus;
27
+ metricName: string;
28
+ metricValue: number;
29
+ createdAt: Date;
30
+ }
31
+ export type FormMetric = FormHeadlineMetric | FormOverviewMetric | FormTimelineMetric;
32
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/form/form-metrics/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,kCAAkC,CAAA;AAEtE,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAA;IACb,iBAAiB,EAAE,MAAM,CAAA;IACzB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,eAAe,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,cAAc,CAAC,cAAc,CAAA;IACnC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAA;IAClD,SAAS,EAAE,IAAI,CAAA;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,cAAc,CAAC,cAAc,CAAA;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,UAAU,CAAA;IACtB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,CAAA;IAC1D,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACrC,gBAAgB,EAAE,MAAM,CAAA;IACxB,SAAS,EAAE,IAAI,CAAA;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,cAAc,CAAC,cAAc,CAAA;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,UAAU,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,IAAI,CAAA;CAChB;AAED,MAAM,MAAM,UAAU,GAClB,kBAAkB,GAClB,kBAAkB,GAClB,kBAAkB,CAAA"}
@@ -1,3 +1,4 @@
1
1
  export { findStartPage } from '../../form/utils/find-start-page.js';
2
2
  export { findDefinitionListFromComponent } from '../../form/utils/list.js';
3
+ export { preventUnicodeInEmail } from '../../form/utils/prevent-unicode.js';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/form/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAA;AACnE,OAAO,EAAE,+BAA+B,EAAE,MAAM,0BAA0B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/form/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAA;AACnE,OAAO,EAAE,+BAA+B,EAAE,MAAM,0BAA0B,CAAA;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAA"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Custom Joi validator to prevent Unicode characters in say an email address.
3
+ * Although Joi has Joi.email({ allowUnicode: false }), we can't differentiate from a general
4
+ * email format error or a Unicode error - hance the custom validator to allow a different error message
5
+ * @param {unknown} value
6
+ * @param {CustomHelpers<string>} helpers
7
+ */
8
+ export function preventUnicodeInEmail(value: unknown, helpers: CustomHelpers<string>): string | import("joi").ErrorReport;
9
+ import type { CustomHelpers } from 'joi';
10
+ //# sourceMappingURL=prevent-unicode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prevent-unicode.d.ts","sourceRoot":"","sources":["../../../../src/form/utils/prevent-unicode.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,6CAHW,OAAO,WACP,cAAc,MAAM,CAAC,sCAS/B;mCAGsC,KAAK"}
@@ -10,6 +10,8 @@ export * from './form/form-definition/index.js';
10
10
  export * from './form/form-definition/types.js';
11
11
  export * from './form/form-definition/helpers.js';
12
12
  export * from './form/form-metadata/index.js';
13
+ export * from './form/form-metrics/enums.js';
14
+ export * from './form/form-metrics/types.js';
13
15
  export * from './form/form-submission/index.js';
14
16
  export * from './form/form-submission/enums.js';
15
17
  export * from './form/utils/index.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA;AACzC,cAAc,wBAAwB,CAAA;AACtC,cAAc,kCAAkC,CAAA;AAChD,cAAc,8BAA8B,CAAA;AAC5C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,2BAA2B,CAAA;AACzC,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,2BAA2B,CAAA;AACzC,cAAc,qCAAqC,CAAA;AACnD,cAAc,qCAAqC,CAAA;AACnD,cAAc,uCAAuC,CAAA;AACrD,cAAc,mCAAmC,CAAA;AACjD,cAAc,kCAAkC,CAAA;AAChD,cAAc,kCAAkC,CAAA;AAChD,cAAc,qCAAqC,CAAA;AACnD,cAAc,qCAAqC,CAAA;AACnD,cAAc,2BAA2B,CAAA;AACzC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,yCAAyC,CAAA;AACvD,cAAc,kCAAkC,CAAA;AAChD,cAAc,mCAAmC,CAAA;AACjD,cAAc,oCAAoC,CAAA;AAClD,cAAc,uBAAuB,CAAA;AACrC,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,yBAAyB,CAAA;AACvC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wCAAwC,CAAA;AAEtD,mBAAmB,uBAAuB,CAAA;AAC1C,mBAAmB,kCAAkC,CAAA;AACrD,mBAAmB,8BAA8B,CAAA;AACjD,mBAAmB,+BAA+B,CAAA;AAClD,mBAAmB,2BAA2B,CAAA;AAC9C,mBAAmB,2BAA2B,CAAA;AAC9C,mBAAmB,qCAAqC,CAAA;AACxD,mBAAmB,mCAAmC,CAAA;AACtD,mBAAmB,qCAAqC,CAAA;AACxD,mBAAmB,yCAAyC,CAAA;AAC5D,mBAAmB,iCAAiC,CAAA;AACpD,mBAAmB,wCAAwC,CAAA;AAC3D,mBAAmB,gCAAgC,CAAA;AACnD,mBAAmB,uBAAuB,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { ComponentType } from '../components/enums.js';
1
2
  import { type ComponentDef } from '../components/types.js';
2
3
  import { type Link, type Page, type PageFileUpload, type PageQuestion, type PageRepeat } from '../form/form-definition/types.js';
3
4
  import { type FormDefinition } from '../index.js';
@@ -44,6 +45,14 @@ export declare function controllerNameFromPath(nameOrPath?: ControllerType | str
44
45
  export declare function includesFileUploadField(components: ComponentDef[]): boolean;
45
46
  export declare function onlyDeclarationComponents(components: ComponentDef[]): boolean;
46
47
  export declare function includesPaymentField(components: ComponentDef[]): boolean;
48
+ /**
49
+ * Helper function to determine if a payment question already exists in the form
50
+ */
51
+ export declare function hasPaymentQuestionInForm(definition: FormDefinition): boolean;
52
+ /**
53
+ * Helper function to determine if a specific question type exists in the form
54
+ */
55
+ export declare function hasSpecificQuestionTypeInForm(definition: FormDefinition, componentType: ComponentType): boolean;
47
56
  export declare function showRepeaterSettings(page: Page): boolean;
48
57
  /**
49
58
  * Gets page title, or title of first question (if no page title set)
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/pages/helpers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EACL,KAAK,IAAI,EACT,KAAK,IAAI,EACT,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,UAAU,EAChB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAKpD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAGrD;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,SAAS,IAAI,EACnD,IAAI,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,GAaC,QAAQ,CAC7C;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,GACnB,IAAI,IAAI,OAAO,CAAC,IAAI,EAAE;IAAE,UAAU,EAAE,YAAY,EAAE,CAAA;CAAE,CAAC,CAEvD;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,GACnB,IAAI,IAAI,OAAO,CAAC,IAAI,EAAE;IAAE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AED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,cAAc,GAwB5D,cAAc,CACpB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,WAOnD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,WAE/C"}
@@ -1,5 +1,5 @@
1
1
  export { ControllerNames, ControllerTypes } from '../pages/controller-types.js';
2
2
  export { PageTypes } from '../pages/page-types.js';
3
- export { controllerNameFromPath, getPageDefaults, getPageFromDefinition, getPageTitle, hasComponents, hasComponentsEvenIfNoNext, hasFormComponents, hasNext, hasRepeater, includesFileUploadField, includesPaymentField, isControllerName, isEndPage, isPaymentPage, isSummaryPage, replaceCustomControllers, showRepeaterSettings, summaryPageControllers } from '../pages/helpers.js';
3
+ export { controllerNameFromPath, getPageDefaults, getPageFromDefinition, getPageTitle, hasComponents, hasComponentsEvenIfNoNext, hasFormComponents, hasNext, hasPaymentQuestionInForm, hasRepeater, hasSpecificQuestionTypeInForm, includesFileUploadField, includesPaymentField, isControllerName, isEndPage, isPaymentPage, isSummaryPage, replaceCustomControllers, showRepeaterSettings, summaryPageControllers } from '../pages/helpers.js';
4
4
  export { ControllerPath, ControllerType } from '../pages/enums.js';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pages/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,eAAe,EAChB,MAAM,iCAAiC,CAAA;AAExC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAErD,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,qBAAqB,EACrB,YAAY,EACZ,aAAa,EACb,yBAAyB,EACzB,iBAAiB,EACjB,OAAO,EACP,WAAW,EACX,uBAAuB,EACvB,oBAAoB,EACpB,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,aAAa,EACb,wBAAwB,EACxB,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pages/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,eAAe,EAChB,MAAM,iCAAiC,CAAA;AAExC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAErD,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,qBAAqB,EACrB,YAAY,EACZ,aAAa,EACb,yBAAyB,EACzB,iBAAiB,EACjB,OAAO,EACP,wBAAwB,EACxB,WAAW,EACX,6BAA6B,EAC7B,uBAAuB,EACvB,oBAAoB,EACpB,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,aAAa,EACb,wBAAwB,EACxB,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/forms-model",
3
- "version": "3.0.643",
3
+ "version": "3.0.645",
4
4
  "description": "A hapi plugin providing the model for Defra forms",
5
5
  "homepage": "https://github.com/DEFRA/forms-designer/tree/main/model#readme",
6
6
  "types": "dist/types/index.d.ts",