@defra/forms-model 3.0.663 → 3.0.665

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.
@@ -41,7 +41,7 @@ export const privacyNoticeUrlSchema = Joi.string().uri({
41
41
  }).trim().description('URL to the privacy notice for this form');
42
42
  export const termsAndConditionsAgreedSchema = Joi.boolean().description('Whether the data protection terms and conditions have been agreed to');
43
43
  export const notificationEmailAddressSchema = emailAddressNoUnicodeSchema.description('Email address to receive form submission notifications');
44
- export const offlineSchema = Joi.boolean().description('Whether the form has been taken offline; runtime renders an unavailable page when true');
44
+ export const offlineSchema = Joi.boolean().optional().default(false).description('Whether the form has been taken offline and is unavailable to new sessions');
45
45
  export const authoredAtSchema = Joi.date().iso().required().description('ISO format timestamp of when an action occurred');
46
46
  export const authorIdSchema = Joi.string().trim().required().description('Unique identifier for the author');
47
47
  export const authorDisplayNameSchema = Joi.string().trim().required().description('Human-readable name of the author');
@@ -110,6 +110,7 @@ export const formVersionMetadataSchema = Joi.object().keys({
110
110
  export const formMetadataSchema = formMetadataInputSchema.append({
111
111
  id: idSchema,
112
112
  slug: slugSchema,
113
+ offline: offlineSchema,
113
114
  draft: formMetadataStateSchema.description('Metadata for the draft version'),
114
115
  live: formMetadataStateSchema.description('Metadata for the published version'),
115
116
  createdAt: authoredAtSchema.description('When the form was first created'),
@@ -1 +1 @@
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","offlineSchema","authoredAtSchema","date","iso","authorIdSchema","authorDisplayNameSchema","formMetadataInputKeys","title","organisation","teamName","teamEmail","contact","submissionGuidance","privacyNoticeType","privacyNoticeText","when","is","then","otherwise","privacyNoticeUrl","termsAndConditionsAgreed","notificationEmail","offline","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 offlineSchema = Joi.boolean().description(\n 'Whether the form has been taken offline; runtime renders an unavailable page when true'\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 offline: offlineSchema\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,CAAC,uCAAuC,CAAC;AAEvD,OAAO,MAAMI,UAAU,GAAGZ,GAAG,CAACI,MAAM,CAAC,CAAC,CACnCS,OAAO,CAAC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AAC,yDAAyD,CAAC;;AAEzE;AACA;AACA;AACA;AACA,OAAO,MAAMuE,yBAAyB,GAAG/E,GAAG,CAAC0B,MAAM,CAAsB,CAAC,CACvEC,IAAI,CAAC;EACJqD,aAAa,EAAEhF,GAAG,CAACiF,MAAM,CAAC,CAAC,CACxBC,OAAO,CAAC,CAAC,CACTC,GAAG,CAAC,CAAC,CAAC,CACN5E,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,oBAAoB,CAAC;EACpCmE,SAAS,EAAE3B,gBAAgB,CAACxC,WAAW,CAAC,+BAA+B;AACzE,CAAC,CAAC,CACDA,WAAW,CAAC,6CAA6C,CAAC;;AAE7D;AACA;AACA;AACA;AACA,OAAO,MAAM4E,kBAAkB,GAAGd,uBAAuB,CACtDe,MAAM,CAAe;EACpBb,EAAE,EAAErE,QAAQ;EACZmF,IAAI,EAAE1E,UAAU;EAChB2E,KAAK,EAAEb,uBAAuB,CAAClE,WAAW,CACxC,gCACF,CAAC;EACDgF,IAAI,EAAEd,uBAAuB,CAAClE,WAAW,CACvC,oCACF,CAAC;EACDmE,SAAS,EAAE3B,gBAAgB,CAACxC,WAAW,CAAC,iCAAiC,CAAC;EAC1EoE,SAAS,EAAEL,wBAAwB,CAAC/D,WAAW,CAAC,sBAAsB,CAAC;EACvEqE,SAAS,EAAE7B,gBAAgB,CAACxC,WAAW,CAAC,gCAAgC,CAAC;EACzEsE,SAAS,EAAEP,wBAAwB,CAAC/D,WAAW,CAC7C,2BACF,CAAC;EACDiF,QAAQ,EAAEzF,GAAG,CAAC0F,KAAK,CAAC,CAAC,CAClBC,KAAK,CAACZ,yBAAyB,CAAC,CAChCa,QAAQ,CAAC,CAAC,CACVpF,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","offlineSchema","optional","default","authoredAtSchema","date","iso","authorIdSchema","authorDisplayNameSchema","formMetadataInputKeys","title","organisation","teamName","teamEmail","contact","submissionGuidance","privacyNoticeType","privacyNoticeText","when","is","then","otherwise","privacyNoticeUrl","termsAndConditionsAgreed","notificationEmail","offline","formMetadataInputSchema","formMetadataAuthorSchema","id","displayName","formMetadataStateSchema","createdAt","createdBy","updatedAt","updatedBy","formVersionMetadataSchema","versionNumber","number","integer","min","formMetadataSchema","append","slug","draft","live","versions","array","items"],"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 offlineSchema = Joi.boolean()\n .optional()\n .default(false)\n .description(\n 'Whether the form has been taken offline and is unavailable to new sessions'\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 offline: offlineSchema\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 offline: offlineSchema,\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,QA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CAAC,gCAAgC,CAAC;EACzEwE,SAAS,EAAEP,wBAAwB,CAACjE,WAAW,CAC7C,2BACF,CAAC;EACDmF,QAAQ,EAAE3F,GAAG,CAAC4F,KAAK,CAAC,CAAC,CAClBC,KAAK,CAACZ,yBAAyB,CAAC,CAChCjC,QAAQ,CAAC,CAAC,CACVxC,WAAW,CAAC,8BAA8B;AAC/C,CAAC,CAAC,CACDA,WAAW,CACV,mFACF,CAAC","ignoreList":[]}
@@ -103,6 +103,22 @@ export function hasPaymentQuestionInForm(definition) {
103
103
  return false;
104
104
  }
105
105
 
106
+ /**
107
+ * Helper function to determine if the form uses postcode lookup
108
+ */
109
+ export function hasPostcodeLookupInForm(definition) {
110
+ if (definition.pages.length === 0) {
111
+ return false;
112
+ }
113
+ for (const page of definition.pages) {
114
+ const addressField = hasComponents(page) ? page.components.find(component => component.type === ComponentType.UkAddressField) : undefined;
115
+ if (addressField?.options.usePostcodeLookup) {
116
+ return true;
117
+ }
118
+ }
119
+ return false;
120
+ }
121
+
106
122
  /**
107
123
  * Helper function to determine if a specific question type exists in the form
108
124
  */
@@ -111,8 +127,8 @@ export function hasSpecificQuestionTypeInForm(definition, componentType) {
111
127
  return false;
112
128
  }
113
129
  for (const page of definition.pages) {
114
- const hasPayment = hasComponents(page) ? page.components.some(component => component.type === componentType) : false;
115
- if (hasPayment) {
130
+ const hasSpecificComponent = hasComponents(page) ? page.components.some(component => component.type === componentType) : false;
131
+ if (hasSpecificComponent) {
116
132
  return true;
117
133
  }
118
134
  }
@@ -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","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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;MACA,OAAOH,IAAI;IACb,CAAC;EACH,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASqE,aAAaA,CAACrE,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,SAAS6B,SAASA,CAACtE,IAAsB,EAAE;EAChD,OAAO6D,aAAa,CAAC7D,IAAI,CAAC,IAAIqE,aAAa,CAACrE,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","hasPostcodeLookupInForm","addressField","UkAddressField","usePostcodeLookup","hasSpecificQuestionTypeInForm","componentType","hasSpecificComponent","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 the form uses postcode lookup\n */\nexport function hasPostcodeLookupInForm(definition: FormDefinition) {\n if (definition.pages.length === 0) {\n return false\n }\n\n for (const page of definition.pages) {\n const addressField = hasComponents(page)\n ? page.components.find(\n (component) => component.type === ComponentType.UkAddressField\n )\n : undefined\n if (addressField?.options.usePostcodeLookup) {\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 hasSpecificComponent = hasComponents(page)\n ? page.components.some((component) => component.type === componentType)\n : false\n if (hasSpecificComponent) {\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,SA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G7B,UAAU;IACbC,KAAK,EAAED,UAAU,CAACC,KAAK,CAACtB,GAAG,CAAEtB,IAAI,IAAK;MACpC,IACE,CAACoE,mBAAmB,CAACK,GAAG;MACtB;MACA,CAACzE,IAAI,CAACE,UAAU,IAAIL,cAAc,CAACM,IAAI,EAAEqE,QAAQ,CAAC,CACpD,CAAC,EACD;QACA,OAAO,mBAAoB;UACzB,GAAGxE,IAAI;UACPE,UAAU,EAAEL,cAAc,CAACM;QAC7B,CAAC;MACH;MACA,OAAOH,IAAI;IACb,CAAC;EACH,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS0E,aAAaA,CAAC1E,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,SAASkC,SAASA,CAAC3E,IAAsB,EAAE;EAChD,OAAOkE,aAAa,CAAClE,IAAI,CAAC,IAAI0E,aAAa,CAAC1E,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, hasPaymentQuestionInForm, hasRepeater, hasSpecificQuestionTypeInForm, includesFileUploadField, includesPaymentField, isControllerName, isEndPage, isPaymentPage, isSummaryPage, replaceCustomControllers, showRepeaterSettings, summaryPageControllers } from "./helpers.js";
3
+ export { controllerNameFromPath, getPageDefaults, getPageFromDefinition, getPageTitle, hasComponents, hasComponentsEvenIfNoNext, hasFormComponents, hasNext, hasPaymentQuestionInForm, hasPostcodeLookupInForm, 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","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":[]}
1
+ {"version":3,"file":"index.js","names":["ControllerNames","ControllerTypes","PageTypes","controllerNameFromPath","getPageDefaults","getPageFromDefinition","getPageTitle","hasComponents","hasComponentsEvenIfNoNext","hasFormComponents","hasNext","hasPaymentQuestionInForm","hasPostcodeLookupInForm","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 hasPostcodeLookupInForm,\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,uBAAuB,EACvBC,WAAW,EACXC,6BAA6B,EAC7BC,uBAAuB,EACvBC,oBAAoB,EACpBC,gBAAgB,EAChBC,SAAS,EACTC,aAAa,EACbC,aAAa,EACbC,wBAAwB,EACxBC,oBAAoB,EAC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AAW,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,aAAa,4BAKvB,CAAA;AAEH,eAAO,MAAM,gBAAgB,sBAGoC,CAAA;AAEjE,eAAO,MAAM,cAAc,0BAGuB,CAAA;AAElD,eAAO,MAAM,uBAAuB,0BAGe,CAAA;AAEnD,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;CAqBjC,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,gCAwB5B,CAAA"}
@@ -49,6 +49,10 @@ export declare function includesPaymentField(components: ComponentDef[]): boolea
49
49
  * Helper function to determine if a payment question already exists in the form
50
50
  */
51
51
  export declare function hasPaymentQuestionInForm(definition: FormDefinition): boolean;
52
+ /**
53
+ * Helper function to determine if the form uses postcode lookup
54
+ */
55
+ export declare function hasPostcodeLookupInForm(definition: FormDefinition): boolean;
52
56
  /**
53
57
  * Helper function to determine if a specific question type exists in the form
54
58
  */
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.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IG;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, hasPaymentQuestionInForm, hasRepeater, hasSpecificQuestionTypeInForm, includesFileUploadField, includesPaymentField, isControllerName, isEndPage, isPaymentPage, isSummaryPage, replaceCustomControllers, showRepeaterSettings, summaryPageControllers } from '../pages/helpers.js';
3
+ export { controllerNameFromPath, getPageDefaults, getPageFromDefinition, getPageTitle, hasComponents, hasComponentsEvenIfNoNext, hasFormComponents, hasNext, hasPaymentQuestionInForm, hasPostcodeLookupInForm, 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,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"}
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,uBAAuB,EACvB,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.663",
3
+ "version": "3.0.665",
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",
@@ -180,7 +180,8 @@
180
180
  },
181
181
  "offline": {
182
182
  "type": "boolean",
183
- "description": "Whether the form has been taken offline; runtime renders an unavailable page when true",
183
+ "description": "Whether the form has been taken offline and is unavailable to new sessions",
184
+ "default": false,
184
185
  "title": "Offline"
185
186
  }
186
187
  },
@@ -178,11 +178,6 @@
178
178
  "format": "email",
179
179
  "title": "Notification Email"
180
180
  },
181
- "offline": {
182
- "type": "boolean",
183
- "description": "Whether the form has been taken offline; runtime renders an unavailable page when true",
184
- "title": "Offline"
185
- },
186
181
  "id": {
187
182
  "type": "string",
188
183
  "description": "Unique identifier for the form, 24-character hexadecimal string",
@@ -194,6 +189,12 @@
194
189
  "pattern": "^[a-z0-9-]+$",
195
190
  "title": "Slug"
196
191
  },
192
+ "offline": {
193
+ "type": "boolean",
194
+ "description": "Whether the form has been taken offline and is unavailable to new sessions",
195
+ "default": false,
196
+ "title": "Offline"
197
+ },
197
198
  "draft": {
198
199
  "type": "object",
199
200
  "description": "Metadata for the draft version",
@@ -136,9 +136,12 @@ export const notificationEmailAddressSchema =
136
136
  'Email address to receive form submission notifications'
137
137
  )
138
138
 
139
- export const offlineSchema = Joi.boolean().description(
140
- 'Whether the form has been taken offline; runtime renders an unavailable page when true'
141
- )
139
+ export const offlineSchema = Joi.boolean()
140
+ .optional()
141
+ .default(false)
142
+ .description(
143
+ 'Whether the form has been taken offline and is unavailable to new sessions'
144
+ )
142
145
 
143
146
  export const authoredAtSchema = Joi.date()
144
147
  .iso()
@@ -241,6 +244,7 @@ export const formMetadataSchema = formMetadataInputSchema
241
244
  .append<FormMetadata>({
242
245
  id: idSchema,
243
246
  slug: slugSchema,
247
+ offline: offlineSchema,
244
248
  draft: formMetadataStateSchema.description(
245
249
  'Metadata for the draft version'
246
250
  ),
@@ -154,6 +154,27 @@ export function hasPaymentQuestionInForm(definition: FormDefinition) {
154
154
  return false
155
155
  }
156
156
 
157
+ /**
158
+ * Helper function to determine if the form uses postcode lookup
159
+ */
160
+ export function hasPostcodeLookupInForm(definition: FormDefinition) {
161
+ if (definition.pages.length === 0) {
162
+ return false
163
+ }
164
+
165
+ for (const page of definition.pages) {
166
+ const addressField = hasComponents(page)
167
+ ? page.components.find(
168
+ (component) => component.type === ComponentType.UkAddressField
169
+ )
170
+ : undefined
171
+ if (addressField?.options.usePostcodeLookup) {
172
+ return true
173
+ }
174
+ }
175
+ return false
176
+ }
177
+
157
178
  /**
158
179
  * Helper function to determine if a specific question type exists in the form
159
180
  */
@@ -166,10 +187,10 @@ export function hasSpecificQuestionTypeInForm(
166
187
  }
167
188
 
168
189
  for (const page of definition.pages) {
169
- const hasPayment = hasComponents(page)
190
+ const hasSpecificComponent = hasComponents(page)
170
191
  ? page.components.some((component) => component.type === componentType)
171
192
  : false
172
- if (hasPayment) {
193
+ if (hasSpecificComponent) {
173
194
  return true
174
195
  }
175
196
  }
@@ -15,6 +15,7 @@ export {
15
15
  hasFormComponents,
16
16
  hasNext,
17
17
  hasPaymentQuestionInForm,
18
+ hasPostcodeLookupInForm,
18
19
  hasRepeater,
19
20
  hasSpecificQuestionTypeInForm,
20
21
  includesFileUploadField,