@defra/forms-model 3.0.624 → 3.0.626

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.
@@ -50,7 +50,7 @@ export const formMetadataInputKeys = {
50
50
  teamEmail: teamEmailSchema,
51
51
  contact: contactSchema,
52
52
  submissionGuidance: submissionGuidanceSchema,
53
- privacyNoticeType: privacyNoticeTypeSchema.default('link'),
53
+ privacyNoticeType: privacyNoticeTypeSchema,
54
54
  privacyNoticeText: Joi.when('privacyNoticeType', {
55
55
  is: 'text',
56
56
  then: privacyNoticeTextSchema,
@@ -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","default","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.default('link'),\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,GAA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CACF,CAAC;EACD+E,IAAI,EAAEd,uBAAuB,CAACjE,WAAW,CACvC,oCACF,CAAC;EACDkE,SAAS,EAAE3B,gBAAgB,CAACvC,WAAW,CAAC,iCAAiC,CAAC;EAC1EmE,SAAS,EAAEL,wBAAwB,CAAC9D,WAAW,CAAC,sBAAsB,CAAC;EACvEoE,SAAS,EAAE7B,gBAAgB,CAACvC,WAAW,CAAC,gCAAgC,CAAC;EACzEqE,SAAS,EAAEP,wBAAwB,CAAC9D,WAAW,CAC7C,2BACF,CAAC;EACDgF,QAAQ,EAAEvF,GAAG,CAACwF,KAAK,CAAC,CAAC,CAClBC,KAAK,CAACZ,yBAAyB,CAAC,CAChCa,QAAQ,CAAC,CAAC,CACVnF,WAAW,CAAC,8BAA8B;AAC/C,CAAC,CAAC,CACDA,WAAW,CACV,mFACF,CAAC","ignoreList":[]}
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;AAE5D,OAAO,MAAMO,kBAAkB,GAAGd,GAAG,CAACG,MAAM,CAAC,CAAC,CAC3CY,KAAK,CAAC,GAAGd,aAAa,CAAC,CACvBK,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,6CAA6C,CAAC;AAE7D,OAAO,MAAMS,cAAc,GAAGhB,GAAG,CAACG,MAAM,CAAC,CAAC,CACvCM,GAAG,CAAC,GAAG,CAAC,CACRC,IAAI,CAAC,CAAC,CACNJ,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,2CAA2C,CAAC;AAE3D,OAAO,MAAMU,eAAe,GAAGjB,GAAG,CAACG,MAAM,CAAC,CAAC,CACxC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e;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":[]}
@@ -24,6 +24,12 @@ export const RoleScopes = {
24
24
  [Roles.FormPublisher]: [Scopes.FormDelete, Scopes.FormEdit, Scopes.FormRead, Scopes.FormPublish],
25
25
  [Roles.FormCreator]: [Scopes.FormRead, Scopes.FormEdit, Scopes.FormDelete]
26
26
  };
27
+ export const RoleNames = {
28
+ [Roles.Superadmin]: 'Superadmin',
29
+ [Roles.Admin]: 'Admin',
30
+ [Roles.FormPublisher]: 'Form publisher',
31
+ [Roles.FormCreator]: 'Form creator'
32
+ };
27
33
 
28
34
  /**
29
35
  * Return a unique list of scopes based on the array of roles passed in
@@ -1 +1 @@
1
- {"version":3,"file":"roles.js","names":["Roles","Scopes","RoleScopes","Superadmin","Object","values","Admin","FormDelete","FormEdit","FormRead","FormPublish","UserCreate","UserDelete","UserEdit","FormsFeedback","FormPublisher","FormCreator","mapScopesToRoles","roles","scopeSet","Set","forEach","role","scopes","scope","add","Array","from"],"sources":["../../../src/manage/roles.ts"],"sourcesContent":["export enum Roles {\n Superadmin = 'superadmin',\n Admin = 'admin',\n FormPublisher = 'form-publisher',\n FormCreator = 'form-creator'\n}\n\nexport enum Scopes {\n FormDelete = 'form-delete',\n FormEdit = 'form-edit',\n FormRead = 'form-read',\n FormPublish = 'form-publish',\n UserCreate = 'user-create',\n UserDelete = 'user-delete',\n UserEdit = 'user-edit',\n FormsFeedback = 'forms-feedback',\n FormsBackup = 'forms-backup',\n ResetSaveAndExit = 'reset-save-and-exit'\n}\n\nexport const RoleScopes = {\n [Roles.Superadmin]: Object.values(Scopes),\n [Roles.Admin]: [\n Scopes.FormDelete,\n Scopes.FormEdit,\n Scopes.FormRead,\n Scopes.FormPublish,\n Scopes.UserCreate,\n Scopes.UserDelete,\n Scopes.UserEdit,\n Scopes.FormsFeedback\n ],\n [Roles.FormPublisher]: [\n Scopes.FormDelete,\n Scopes.FormEdit,\n Scopes.FormRead,\n Scopes.FormPublish\n ],\n [Roles.FormCreator]: [Scopes.FormRead, Scopes.FormEdit, Scopes.FormDelete]\n}\n\n/**\n * Return a unique list of scopes based on the array of roles passed in\n */\nexport function mapScopesToRoles(roles: Roles[]) {\n const scopeSet = new Set<string>()\n roles.forEach((role) => {\n const scopes = RoleScopes[role]\n scopes.forEach((scope) => {\n scopeSet.add(scope)\n })\n })\n return Array.from(scopeSet)\n}\n"],"mappings":"AAAA,WAAYA,KAAK,0BAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAAA,OAALA,KAAK;AAAA;AAOjB,WAAYC,MAAM,0BAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAAA,OAANA,MAAM;AAAA;AAalB,OAAO,MAAMC,UAAU,GAAG;EACxB,CAACF,KAAK,CAACG,UAAU,GAAGC,MAAM,CAACC,MAAM,CAACJ,MAAM,CAAC;EACzC,CAACD,KAAK,CAACM,KAAK,GAAG,CACbL,MAAM,CAACM,UAAU,EACjBN,MAAM,CAACO,QAAQ,EACfP,MAAM,CAACQ,QAAQ,EACfR,MAAM,CAACS,WAAW,EAClBT,MAAM,CAACU,UAAU,EACjBV,MAAM,CAACW,UAAU,EACjBX,MAAM,CAACY,QAAQ,EACfZ,MAAM,CAACa,aAAa,CACrB;EACD,CAACd,KAAK,CAACe,aAAa,GAAG,CACrBd,MAAM,CAACM,UAAU,EACjBN,MAAM,CAACO,QAAQ,EACfP,MAAM,CAACQ,QAAQ,EACfR,MAAM,CAACS,WAAW,CACnB;EACD,CAACV,KAAK,CAACgB,WAAW,GAAG,CAACf,MAAM,CAACQ,QAAQ,EAAER,MAAM,CAACO,QAAQ,EAAEP,MAAM,CAACM,UAAU;AAC3E,CAAC;;AAED;AACA;AACA;AACA,OAAO,SAASU,gBAAgBA,CAACC,KAAc,EAAE;EAC/C,MAAMC,QAAQ,GAAG,IAAIC,GAAG,CAAS,CAAC;EAClCF,KAAK,CAACG,OAAO,CAAEC,IAAI,IAAK;IACtB,MAAMC,MAAM,GAAGrB,UAAU,CAACoB,IAAI,CAAC;IAC/BC,MAAM,CAACF,OAAO,CAAEG,KAAK,IAAK;MACxBL,QAAQ,CAACM,GAAG,CAACD,KAAK,CAAC;IACrB,CAAC,CAAC;EACJ,CAAC,CAAC;EACF,OAAOE,KAAK,CAACC,IAAI,CAACR,QAAQ,CAAC;AAC7B","ignoreList":[]}
1
+ {"version":3,"file":"roles.js","names":["Roles","Scopes","RoleScopes","Superadmin","Object","values","Admin","FormDelete","FormEdit","FormRead","FormPublish","UserCreate","UserDelete","UserEdit","FormsFeedback","FormPublisher","FormCreator","RoleNames","mapScopesToRoles","roles","scopeSet","Set","forEach","role","scopes","scope","add","Array","from"],"sources":["../../../src/manage/roles.ts"],"sourcesContent":["export enum Roles {\n Superadmin = 'superadmin',\n Admin = 'admin',\n FormPublisher = 'form-publisher',\n FormCreator = 'form-creator'\n}\n\nexport enum Scopes {\n FormDelete = 'form-delete',\n FormEdit = 'form-edit',\n FormRead = 'form-read',\n FormPublish = 'form-publish',\n UserCreate = 'user-create',\n UserDelete = 'user-delete',\n UserEdit = 'user-edit',\n FormsFeedback = 'forms-feedback',\n FormsBackup = 'forms-backup',\n ResetSaveAndExit = 'reset-save-and-exit'\n}\n\nexport const RoleScopes = {\n [Roles.Superadmin]: Object.values(Scopes),\n [Roles.Admin]: [\n Scopes.FormDelete,\n Scopes.FormEdit,\n Scopes.FormRead,\n Scopes.FormPublish,\n Scopes.UserCreate,\n Scopes.UserDelete,\n Scopes.UserEdit,\n Scopes.FormsFeedback\n ],\n [Roles.FormPublisher]: [\n Scopes.FormDelete,\n Scopes.FormEdit,\n Scopes.FormRead,\n Scopes.FormPublish\n ],\n [Roles.FormCreator]: [Scopes.FormRead, Scopes.FormEdit, Scopes.FormDelete]\n}\n\nexport const RoleNames = {\n [Roles.Superadmin]: 'Superadmin',\n [Roles.Admin]: 'Admin',\n [Roles.FormPublisher]: 'Form publisher',\n [Roles.FormCreator]: 'Form creator'\n}\n\n/**\n * Return a unique list of scopes based on the array of roles passed in\n */\nexport function mapScopesToRoles(roles: Roles[]) {\n const scopeSet = new Set<Scopes>()\n roles.forEach((role) => {\n const scopes = RoleScopes[role]\n scopes.forEach((scope) => {\n scopeSet.add(scope)\n })\n })\n return Array.from(scopeSet)\n}\n"],"mappings":"AAAA,WAAYA,KAAK,0BAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAAA,OAALA,KAAK;AAAA;AAOjB,WAAYC,MAAM,0BAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAAA,OAANA,MAAM;AAAA;AAalB,OAAO,MAAMC,UAAU,GAAG;EACxB,CAACF,KAAK,CAACG,UAAU,GAAGC,MAAM,CAACC,MAAM,CAACJ,MAAM,CAAC;EACzC,CAACD,KAAK,CAACM,KAAK,GAAG,CACbL,MAAM,CAACM,UAAU,EACjBN,MAAM,CAACO,QAAQ,EACfP,MAAM,CAACQ,QAAQ,EACfR,MAAM,CAACS,WAAW,EAClBT,MAAM,CAACU,UAAU,EACjBV,MAAM,CAACW,UAAU,EACjBX,MAAM,CAACY,QAAQ,EACfZ,MAAM,CAACa,aAAa,CACrB;EACD,CAACd,KAAK,CAACe,aAAa,GAAG,CACrBd,MAAM,CAACM,UAAU,EACjBN,MAAM,CAACO,QAAQ,EACfP,MAAM,CAACQ,QAAQ,EACfR,MAAM,CAACS,WAAW,CACnB;EACD,CAACV,KAAK,CAACgB,WAAW,GAAG,CAACf,MAAM,CAACQ,QAAQ,EAAER,MAAM,CAACO,QAAQ,EAAEP,MAAM,CAACM,UAAU;AAC3E,CAAC;AAED,OAAO,MAAMU,SAAS,GAAG;EACvB,CAACjB,KAAK,CAACG,UAAU,GAAG,YAAY;EAChC,CAACH,KAAK,CAACM,KAAK,GAAG,OAAO;EACtB,CAACN,KAAK,CAACe,aAAa,GAAG,gBAAgB;EACvC,CAACf,KAAK,CAACgB,WAAW,GAAG;AACvB,CAAC;;AAED;AACA;AACA;AACA,OAAO,SAASE,gBAAgBA,CAACC,KAAc,EAAE;EAC/C,MAAMC,QAAQ,GAAG,IAAIC,GAAG,CAAS,CAAC;EAClCF,KAAK,CAACG,OAAO,CAAEC,IAAI,IAAK;IACtB,MAAMC,MAAM,GAAGtB,UAAU,CAACqB,IAAI,CAAC;IAC/BC,MAAM,CAACF,OAAO,CAAEG,KAAK,IAAK;MACxBL,QAAQ,CAACM,GAAG,CAACD,KAAK,CAAC;IACrB,CAAC,CAAC;EACJ,CAAC,CAAC;EACF,OAAOE,KAAK,CAACC,IAAI,CAACR,QAAQ,CAAC;AAC7B","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/manage/types.ts"],"sourcesContent":["/**\n * Interface for `EntitlementRole`\n */\nexport interface EntitlementRole {\n /**\n * The display name\n */\n name: string\n\n /**\n * The code value\n */\n code: string\n\n /**\n * The description\n */\n description: string\n}\n\n/**\n * Interface for `ManageUser`\n */\nexport interface ManageUser {\n /**\n * The object id of the user\n */\n userId: string\n\n /**\n * The email address of the user\n */\n emailAddress: string\n\n /**\n * The role assigned to the user\n */\n userRole: string\n\n /**\n * The full name of the user for display\n */\n displayName?: string\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/manage/types.ts"],"sourcesContent":["import { type Roles } from '~/src/manage/roles.js'\n\n/**\n * Interface for `ManageUser`\n */\nexport interface ManageUser {\n /**\n * The object id of the user\n */\n userId: string\n\n /**\n * The email address of the user\n */\n emailAddress: string\n\n /**\n * The role assigned to the user\n */\n userRole: Roles\n\n /**\n * The full name of the user for display\n */\n displayName?: string\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"users.js","names":[],"sources":["../../../src/manage/users.ts"],"sourcesContent":["export interface EntitlementUser {\n /**\n * The id of the user\n */\n userId: string\n\n /**\n * The display name (full name) of the user\n */\n displayName: string\n\n /**\n * The email addresss of the user\n */\n email: string\n\n /**\n * The roles assigned to the user\n */\n roles: string[]\n\n /**\n * The scopes assigned to the user\n */\n scopes: string[]\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"users.js","names":[],"sources":["../../../src/manage/users.ts"],"sourcesContent":["import { type Roles, type Scopes } from '~/src/manage/roles.js'\n\nexport interface EntitlementUser {\n /**\n * The id of the user\n */\n userId: string\n\n /**\n * The display name (full name) of the user\n */\n displayName: string\n\n /**\n * The email addresss of the user\n */\n email: string\n\n /**\n * The roles assigned to the user\n */\n roles: Roles[]\n\n /**\n * The scopes assigned to the user\n */\n scopes: Scopes[]\n}\n"],"mappings":"","ignoreList":[]}
@@ -22,8 +22,14 @@ export declare const RoleScopes: {
22
22
  "form-publisher": Scopes[];
23
23
  "form-creator": Scopes[];
24
24
  };
25
+ export declare const RoleNames: {
26
+ superadmin: string;
27
+ admin: string;
28
+ "form-publisher": string;
29
+ "form-creator": string;
30
+ };
25
31
  /**
26
32
  * Return a unique list of scopes based on the array of roles passed in
27
33
  */
28
- export declare function mapScopesToRoles(roles: Roles[]): string[];
34
+ export declare function mapScopesToRoles(roles: Roles[]): Scopes[];
29
35
  //# sourceMappingURL=roles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"roles.d.ts","sourceRoot":"","sources":["../../../src/manage/roles.ts"],"names":[],"mappings":"AAAA,oBAAY,KAAK;IACf,UAAU,eAAe;IACzB,KAAK,UAAU;IACf,aAAa,mBAAmB;IAChC,WAAW,iBAAiB;CAC7B;AAED,oBAAY,MAAM;IAChB,UAAU,gBAAgB;IAC1B,QAAQ,cAAc;IACtB,QAAQ,cAAc;IACtB,WAAW,iBAAiB;IAC5B,UAAU,gBAAgB;IAC1B,UAAU,gBAAgB;IAC1B,QAAQ,cAAc;IACtB,aAAa,mBAAmB;IAChC,WAAW,iBAAiB;IAC5B,gBAAgB,wBAAwB;CACzC;AAED,eAAO,MAAM,UAAU;;;;;CAmBtB,CAAA;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,YAS9C"}
1
+ {"version":3,"file":"roles.d.ts","sourceRoot":"","sources":["../../../src/manage/roles.ts"],"names":[],"mappings":"AAAA,oBAAY,KAAK;IACf,UAAU,eAAe;IACzB,KAAK,UAAU;IACf,aAAa,mBAAmB;IAChC,WAAW,iBAAiB;CAC7B;AAED,oBAAY,MAAM;IAChB,UAAU,gBAAgB;IAC1B,QAAQ,cAAc;IACtB,QAAQ,cAAc;IACtB,WAAW,iBAAiB;IAC5B,UAAU,gBAAgB;IAC1B,UAAU,gBAAgB;IAC1B,QAAQ,cAAc;IACtB,aAAa,mBAAmB;IAChC,WAAW,iBAAiB;IAC5B,gBAAgB,wBAAwB;CACzC;AAED,eAAO,MAAM,UAAU;;;;;CAmBtB,CAAA;AAED,eAAO,MAAM,SAAS;;;;;CAKrB,CAAA;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,YAS9C"}
@@ -1,20 +1,4 @@
1
- /**
2
- * Interface for `EntitlementRole`
3
- */
4
- export interface EntitlementRole {
5
- /**
6
- * The display name
7
- */
8
- name: string;
9
- /**
10
- * The code value
11
- */
12
- code: string;
13
- /**
14
- * The description
15
- */
16
- description: string;
17
- }
1
+ import { type Roles } from '../manage/roles.js';
18
2
  /**
19
3
  * Interface for `ManageUser`
20
4
  */
@@ -30,7 +14,7 @@ export interface ManageUser {
30
14
  /**
31
15
  * The role assigned to the user
32
16
  */
33
- userRole: string;
17
+ userRole: Roles;
34
18
  /**
35
19
  * The full name of the user for display
36
20
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/manage/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,YAAY,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/manage/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAElD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,YAAY,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAA;IAEf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB"}
@@ -1,3 +1,4 @@
1
+ import { type Roles, type Scopes } from '../manage/roles.js';
1
2
  export interface EntitlementUser {
2
3
  /**
3
4
  * The id of the user
@@ -14,10 +15,10 @@ export interface EntitlementUser {
14
15
  /**
15
16
  * The roles assigned to the user
16
17
  */
17
- roles: string[];
18
+ roles: Roles[];
18
19
  /**
19
20
  * The scopes assigned to the user
20
21
  */
21
- scopes: string[];
22
+ scopes: Scopes[];
22
23
  }
23
24
  //# sourceMappingURL=users.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../../src/manage/users.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IAEnB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IAEb;;OAEG;IACH,KAAK,EAAE,MAAM,EAAE,CAAA;IAEf;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB"}
1
+ {"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../../src/manage/users.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAE/D,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IAEnB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IAEb;;OAEG;IACH,KAAK,EAAE,KAAK,EAAE,CAAA;IAEd;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/forms-model",
3
- "version": "3.0.624",
3
+ "version": "3.0.626",
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",
@@ -103,7 +103,6 @@
103
103
  "privacyNoticeType": {
104
104
  "type": "string",
105
105
  "description": "Type of privacy notice content",
106
- "default": "link",
107
106
  "enum": [
108
107
  "text",
109
108
  "link"
@@ -103,7 +103,6 @@
103
103
  "privacyNoticeType": {
104
104
  "type": "string",
105
105
  "description": "Type of privacy notice content",
106
- "default": "link",
107
106
  "enum": [
108
107
  "text",
109
108
  "link"
@@ -159,7 +159,7 @@ export const formMetadataInputKeys = {
159
159
  teamEmail: teamEmailSchema,
160
160
  contact: contactSchema,
161
161
  submissionGuidance: submissionGuidanceSchema,
162
- privacyNoticeType: privacyNoticeTypeSchema.default('link'),
162
+ privacyNoticeType: privacyNoticeTypeSchema,
163
163
  privacyNoticeText: Joi.when('privacyNoticeType', {
164
164
  is: 'text',
165
165
  then: privacyNoticeTextSchema,
@@ -39,11 +39,18 @@ export const RoleScopes = {
39
39
  [Roles.FormCreator]: [Scopes.FormRead, Scopes.FormEdit, Scopes.FormDelete]
40
40
  }
41
41
 
42
+ export const RoleNames = {
43
+ [Roles.Superadmin]: 'Superadmin',
44
+ [Roles.Admin]: 'Admin',
45
+ [Roles.FormPublisher]: 'Form publisher',
46
+ [Roles.FormCreator]: 'Form creator'
47
+ }
48
+
42
49
  /**
43
50
  * Return a unique list of scopes based on the array of roles passed in
44
51
  */
45
52
  export function mapScopesToRoles(roles: Roles[]) {
46
- const scopeSet = new Set<string>()
53
+ const scopeSet = new Set<Scopes>()
47
54
  roles.forEach((role) => {
48
55
  const scopes = RoleScopes[role]
49
56
  scopes.forEach((scope) => {
@@ -1,22 +1,4 @@
1
- /**
2
- * Interface for `EntitlementRole`
3
- */
4
- export interface EntitlementRole {
5
- /**
6
- * The display name
7
- */
8
- name: string
9
-
10
- /**
11
- * The code value
12
- */
13
- code: string
14
-
15
- /**
16
- * The description
17
- */
18
- description: string
19
- }
1
+ import { type Roles } from '~/src/manage/roles.js'
20
2
 
21
3
  /**
22
4
  * Interface for `ManageUser`
@@ -35,7 +17,7 @@ export interface ManageUser {
35
17
  /**
36
18
  * The role assigned to the user
37
19
  */
38
- userRole: string
20
+ userRole: Roles
39
21
 
40
22
  /**
41
23
  * The full name of the user for display
@@ -1,3 +1,5 @@
1
+ import { type Roles, type Scopes } from '~/src/manage/roles.js'
2
+
1
3
  export interface EntitlementUser {
2
4
  /**
3
5
  * The id of the user
@@ -17,10 +19,10 @@ export interface EntitlementUser {
17
19
  /**
18
20
  * The roles assigned to the user
19
21
  */
20
- roles: string[]
22
+ roles: Roles[]
21
23
 
22
24
  /**
23
25
  * The scopes assigned to the user
24
26
  */
25
- scopes: string[]
27
+ scopes: Scopes[]
26
28
  }