@defra/forms-model 3.0.703 → 3.0.704
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module/form/form-audit/index.js +12 -0
- package/dist/module/form/form-audit/index.js.map +1 -1
- package/dist/module/form/form-definition/helpers.js +20 -0
- package/dist/module/form/form-definition/helpers.js.map +1 -1
- package/dist/module/form/form-definition/index.js +29 -17
- package/dist/module/form/form-definition/index.js.map +1 -1
- package/dist/module/form/form-definition/types.js.map +1 -1
- package/dist/module/form/form-manager/errors.js +6 -1
- package/dist/module/form/form-manager/errors.js.map +1 -1
- package/dist/module/form/form-manager/types.js +13 -0
- package/dist/module/form/form-manager/types.js.map +1 -1
- package/dist/module/form/form-submission/enums.js +25 -0
- package/dist/module/form/form-submission/enums.js.map +1 -1
- package/dist/module/form/form-submission/index.js +21 -1
- package/dist/module/form/form-submission/index.js.map +1 -1
- package/dist/module/form/form-submission/types.js.map +1 -1
- package/dist/types/form/form-audit/index.d.ts +7 -0
- package/dist/types/form/form-audit/index.d.ts.map +1 -1
- package/dist/types/form/form-definition/helpers.d.ts +15 -1
- package/dist/types/form/form-definition/helpers.d.ts.map +1 -1
- package/dist/types/form/form-definition/index.d.ts.map +1 -1
- package/dist/types/form/form-definition/types.d.ts +5 -0
- package/dist/types/form/form-definition/types.d.ts.map +1 -1
- package/dist/types/form/form-manager/errors.d.ts.map +1 -1
- package/dist/types/form/form-manager/types.d.ts +2 -0
- package/dist/types/form/form-manager/types.d.ts.map +1 -1
- package/dist/types/form/form-submission/enums.d.ts +23 -0
- package/dist/types/form/form-submission/enums.d.ts.map +1 -1
- package/dist/types/form/form-submission/index.d.ts +11 -1
- package/dist/types/form/form-submission/index.d.ts.map +1 -1
- package/dist/types/form/form-submission/types.d.ts +46 -1
- package/dist/types/form/form-submission/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/schemas/form-definition-schema.json +2 -0
- package/schemas/form-definition-v2-schema.json +63 -36
- package/src/form/form-audit/index.ts +32 -0
- package/src/form/form-definition/helpers.ts +32 -1
- package/src/form/form-definition/index.ts +66 -21
- package/src/form/form-definition/types.ts +5 -0
- package/src/form/form-manager/errors.ts +7 -1
- package/src/form/form-manager/types.ts +13 -0
- package/src/form/form-submission/enums.ts +26 -0
- package/src/form/form-submission/index.ts +49 -0
- package/src/form/form-submission/types.ts +54 -0
|
@@ -18,6 +18,18 @@ export const formDefinitionS3Meta = Joi.object().keys({
|
|
|
18
18
|
filename: Joi.string().required(),
|
|
19
19
|
s3Key: Joi.string().required()
|
|
20
20
|
}).description('Schema for form data S3 object in message');
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Stands apart from the definition's own output schema, which resolves a
|
|
24
|
+
* condition against the sibling `conditions` array - a lookup that has no
|
|
25
|
+
* meaning on an audit message carrying the output on its own.
|
|
26
|
+
*/
|
|
27
|
+
export const formOutputMessageData = Joi.object().keys({
|
|
28
|
+
emailAddress: emailAddressNoUnicodeSchema.required().description('Email address the submission is sent to'),
|
|
29
|
+
audience: Joi.string().trim().valid('human', 'machine').required().description('Whether the submission is sent human readable or machine processable'),
|
|
30
|
+
version: Joi.string().trim().required().description('Version identifier of the output format'),
|
|
31
|
+
condition: Joi.string().trim().allow('').optional().description('Id of the condition determining whether the submission is sent to this address')
|
|
32
|
+
}).description('A submission email target as recorded on an audit event');
|
|
21
33
|
export const formUpdatedMessageData = formMessageDataBase.append({
|
|
22
34
|
requestType: Joi.string().valid(...Object.values(FormDefinitionRequestType)).required(),
|
|
23
35
|
s3Meta: formDefinitionS3Meta.optional()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Joi","AuditEventMessageCategory","AuditEventMessageSchemaVersion","AuditEventMessageSource","AuditEventMessageType","FormDefinitionRequestType","emailAddressNoUnicodeSchema","contactSchema","emailResponseTimeSchema","idSchema","notificationEmailAddressSchema","offlineSchema","onlineTextSchema","onlineUrlSchema","organisationSchema","phoneSchema","privacyNoticeTextSchema","privacyNoticeTypeSchema","privacyNoticeUrlSchema","slugSchema","submissionGuidanceSchema","teamEmailSchema","teamNameSchema","termsAndConditionsAgreedSchema","titleSchema","formMessageDataBase","object","formId","slug","payload","optional","required","description","formCreatedMessageData","append","title","organisation","teamName","teamEmail","formDefinitionS3Meta","keys","fileId","string","filename","s3Key","formUpdatedMessageData","requestType","valid","Object","values","s3Meta","formsBackupRequestedMessageData","totalForms","number","integer","min","durationMs","formsSecretDeletedMessageData","secretName","formsSecretSavedMessageData","dlqActionMessageData","action","messageId","beforeJson","afterJson","formTitleChanges","formOrganisationChanges","formTeamNameChanges","formTeamEmailChanges","formSupportContactChanges","contact","formSupportPhoneChanges","phone","formSupportOnlineChanges","url","text","formSupportEmailChanges","address","responseTime","formPrivacyNoticeChanges","privacyNoticeType","privacyNoticeText","when","is","then","otherwise","allow","privacyNoticeUrl","formTermsAndConditionsChanges","termsAndConditionsAgreed","formNotificationEmailChanges","notificationEmail","formSubmissionGuidanceChanges","submissionGuidance","formUploadedChanges","value","formOfflineChanges","offline","entitlementMessageData","userId","displayName","email","roles","array","items","formFileDownloadedMessageData","fileLink","excelGenerationMessageData","formName","authenticationMessageData","auditUserSchema","id","formChangesMessageData","schema","changes","previous","new","messageSchema","schemaVersion","category","source","type","entityId","traceId","createdAt","date","createdBy","data","switch","trim","FORM_CREATED","FORM_TITLE_UPDATED","FORM_ORGANISATION_UPDATED","FORM_TEAM_NAME_UPDATED","FORM_TEAM_EMAIL_UPDATED","FORM_SUPPORT_CONTACT_UPDATED","FORM_SUPPORT_PHONE_UPDATED","FORM_SUPPORT_EMAIL_UPDATED","FORM_SUPPORT_ONLINE_UPDATED","FORM_PRIVACY_NOTICE_UPDATED","FORM_TERMS_AND_CONDITIONS_AGREED","FORM_NOTIFICATION_EMAIL_UPDATED","FORM_SUBMISSION_GUIDANCE_UPDATED","FORM_JSON_UPLOADED","FORM_UPDATED","ENTITLEMENT_CREATED","ENTITLEMENT_UPDATED","ENTITLEMENT_DELETED","FORM_DRAFT_DELETED","FORM_JSON_DOWNLOADED","AUTHENTICATION_LOGIN","AUTHENTICATION_LOGOUT_MANUAL","AUTHENTICATION_LOGOUT_AUTO","AUTHENTICATION_LOGOUT_DIFFERENT_DEVICE","FORM_FILE_DOWNLOAD_SUCCESS","FORM_FILE_DOWNLOAD_FAILURE","FORM_SUBMISSION_EXCEL_REQUESTED","FORM_CSAT_EXCEL_REQUESTED","PLATFORM_CSAT_EXCEL_REQUESTED","FORMS_BACKUP_REQUESTED","FORM_SECRET_DELETED","FORM_SECRET_SAVED","DLQ_ACTION","FORM_OFFLINE_UPDATED","forbidden","messageCreatedAt","auditEvent","message","auditRecord","uuid","recordCreatedAt"],"sources":["../../../../src/form/form-audit/index.ts"],"sourcesContent":["import Joi, { type ObjectSchema } from 'joi'\n\nimport {\n AuditEventMessageCategory,\n AuditEventMessageSchemaVersion,\n AuditEventMessageSource,\n AuditEventMessageType,\n FormDefinitionRequestType\n} from '~/src/form/form-audit/enums.js'\nimport {\n type AuditEvent,\n type AuditMessage,\n type AuditRecord,\n type AuditUser,\n type AuthenticationMessageData,\n type ChangesMessageData,\n type DlqActionMessageData,\n type EntitlementMessageData,\n type ExcelGenerationMessageData,\n type FormCreatedMessageData,\n type FormDefinitionS3Meta,\n type FormFileDownloadedMessageData,\n type FormMessageChangesData,\n type FormMessageDataBase,\n type FormNotificationEmailChanges,\n type FormNotificationEmailUpdatedMessageData,\n type FormOfflineChanges,\n type FormOfflineUpdatedMessageData,\n type FormOrganisationChanges,\n type FormOrganisationUpdatedMessageData,\n type FormPrivacyNoticeChanges,\n type FormPrivacyNoticeUpdatedMessageData,\n type FormSecretBaseMessageData,\n type FormSubmissionGuidanceChanges,\n type FormSubmissionGuidanceUpdatedMessageData,\n type FormSupportContactChanges,\n type FormSupportContactUpdatedMessageData,\n type FormSupportEmailChanges,\n type FormSupportEmailUpdatedMessageData,\n type FormSupportOnlineChanges,\n type FormSupportOnlineUpdatedMessageData,\n type FormSupportPhoneChanges,\n type FormSupportPhoneUpdatedMessageData,\n type FormTeamEmailChanges,\n type FormTeamEmailUpdatedMessageData,\n type FormTeamNameChanges,\n type FormTeamNameUpdatedMessageData,\n type FormTermsAndConditionsAgreedMessageData,\n type FormTermsAndConditionsChanges,\n type FormTitleChanges,\n type FormTitleUpdatedMessageData,\n type FormUpdatedMessageData,\n type FormUploadedChanges,\n type FormUploadedMessageData,\n type FormsBackupRequestedMessageData\n} from '~/src/form/form-audit/types.js'\nimport { emailAddressNoUnicodeSchema } from '~/src/form/form-editor/index.js'\nimport {\n contactSchema,\n emailResponseTimeSchema,\n idSchema,\n notificationEmailAddressSchema,\n offlineSchema,\n onlineTextSchema,\n onlineUrlSchema,\n organisationSchema,\n phoneSchema,\n privacyNoticeTextSchema,\n privacyNoticeTypeSchema,\n privacyNoticeUrlSchema,\n slugSchema,\n submissionGuidanceSchema,\n teamEmailSchema,\n teamNameSchema,\n termsAndConditionsAgreedSchema,\n titleSchema\n} from '~/src/form/form-metadata/index.js'\n\nexport const formMessageDataBase = Joi.object<FormMessageDataBase>({\n formId: idSchema,\n slug: slugSchema,\n payload: Joi.object().optional()\n})\n .required()\n .description('The base data object for Form Messages')\n\nexport const formCreatedMessageData = formMessageDataBase\n .append<FormCreatedMessageData>({\n title: titleSchema,\n organisation: organisationSchema,\n teamName: teamNameSchema,\n teamEmail: teamEmailSchema\n })\n .required()\n .description('Message data schema for when a form is created')\n\nexport const formDefinitionS3Meta = Joi.object<FormDefinitionS3Meta>()\n .keys({\n fileId: Joi.string().required(),\n filename: Joi.string().required(),\n s3Key: Joi.string().required()\n })\n .description('Schema for form data S3 object in message')\n\nexport const formUpdatedMessageData = formMessageDataBase\n .append<FormUpdatedMessageData>({\n requestType: Joi.string()\n .valid(...Object.values(FormDefinitionRequestType))\n .required(),\n s3Meta: formDefinitionS3Meta.optional()\n })\n .required()\n\nexport const formsBackupRequestedMessageData =\n Joi.object<FormsBackupRequestedMessageData>().keys({\n totalForms: Joi.number().integer().min(0).required(),\n durationMs: Joi.number().min(0).required()\n })\n\nexport const formsSecretDeletedMessageData =\n formMessageDataBase.append<FormSecretBaseMessageData>({\n secretName: Joi.string().required()\n })\n\nexport const formsSecretSavedMessageData =\n formMessageDataBase.append<FormSecretBaseMessageData>({\n secretName: Joi.string().required()\n })\n\nexport const dlqActionMessageData = Joi.object<DlqActionMessageData>().keys({\n action: Joi.string()\n .valid('redrive', 'delete', 'modify-and-resubmit')\n .required(),\n messageId: Joi.string().optional(),\n beforeJson: Joi.string().optional(),\n afterJson: Joi.string().optional()\n})\n\nexport const formTitleChanges = Joi.object<FormTitleChanges>()\n .keys({\n title: titleSchema\n })\n .required()\n .description('Changes schema for FORM_TITLE_UPDATED event')\n\nexport const formOrganisationChanges = Joi.object<FormOrganisationChanges>()\n .keys({\n organisation: organisationSchema\n })\n .required()\n .description('Changes schema for FORM_ORGANISATION_UPDATED event')\n\nexport const formTeamNameChanges = Joi.object<FormTeamNameChanges>()\n .keys({\n teamName: teamNameSchema\n })\n .required()\n .description('Changes schema for FORM_TEAM_NAME_UPDATED event')\n\nexport const formTeamEmailChanges = Joi.object<FormTeamEmailChanges>()\n .keys({\n teamEmail: teamEmailSchema\n })\n .required()\n .description('Changes schema for FORM_TEAM_EMAIL_UPDATED event')\n\nexport const formSupportContactChanges = Joi.object<FormSupportContactChanges>()\n .keys({\n contact: contactSchema\n })\n .required()\n .description('Changes schema for FORM_SUPPORT_CONTACT_UPDATED event')\n\nexport const formSupportPhoneChanges = Joi.object<FormSupportPhoneChanges>()\n .keys({\n phone: phoneSchema\n })\n .required()\n .description('Changes schema for FORM_SUPPORT_PHONE_UPDATED event')\n\nexport const formSupportOnlineChanges = Joi.object<FormSupportOnlineChanges>()\n .keys({\n url: onlineUrlSchema.optional(),\n text: onlineTextSchema.optional()\n })\n .required()\n .description('Changes schema for FORM_SUPPORT_ONLINE_UPDATED event')\n\nexport const formSupportEmailChanges = Joi.object<FormSupportEmailChanges>()\n .keys({\n address: emailAddressNoUnicodeSchema.optional(),\n responseTime: emailResponseTimeSchema.optional()\n })\n .description('Changes schema for FORM_SUPPORT_EMAIL_UPDATED event')\n\nexport const formPrivacyNoticeChanges = Joi.object<FormPrivacyNoticeChanges>()\n .keys({\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 })\n .required()\n .description('Changes schema for FORM_PRIVACY_NOTICE_UPDATED event')\n\nexport const formTermsAndConditionsChanges =\n Joi.object<FormTermsAndConditionsChanges>()\n .keys({\n termsAndConditionsAgreed: termsAndConditionsAgreedSchema\n })\n .required()\n .description('Changes schema for FORM_TERMS_AND_CONDITIONS_AGREED event')\n\nexport const formNotificationEmailChanges =\n Joi.object<FormNotificationEmailChanges>()\n .keys({\n notificationEmail: notificationEmailAddressSchema\n })\n .required()\n .description('Changes schema for FORM_NOTIFICATION_EMAIL_UPDATED event')\n\nexport const formSubmissionGuidanceChanges =\n Joi.object<FormSubmissionGuidanceChanges>()\n .keys({\n submissionGuidance: submissionGuidanceSchema\n })\n .required()\n .description('Changes schema for FORM_SUBMISSION_GUIDANCE_UPDATED event')\n\nexport const formUploadedChanges = Joi.object<FormUploadedChanges>()\n .keys({\n value: Joi.string().required()\n })\n .required()\n .description('Changes schema for FORM_JSON_UPLOADED event')\n\nexport const formOfflineChanges = Joi.object<FormOfflineChanges>()\n .keys({\n offline: offlineSchema\n })\n .required()\n .description('Changes schema for FORM_OFFLINE_UPDATED event')\n\nexport const entitlementMessageData = Joi.object<EntitlementMessageData>().keys(\n {\n userId: Joi.string().required(),\n displayName: Joi.string().required(),\n email: emailAddressNoUnicodeSchema.required(),\n roles: Joi.array().items(Joi.string())\n }\n)\n\nexport const formFileDownloadedMessageData =\n Joi.object<FormFileDownloadedMessageData>()\n .keys({\n fileId: Joi.string().required(),\n filename: Joi.string().required(),\n fileLink: Joi.string().required()\n })\n .required()\n .description(\n 'Schema for FORM_FILE_DOWNLOAD_SUCCESS and FORM_FILE_DOWNLOAD_FAILURE events'\n )\n\nexport const excelGenerationMessageData =\n Joi.object<ExcelGenerationMessageData>()\n .keys({\n formId: Joi.string().required(),\n formName: Joi.string().required(),\n notificationEmail: emailAddressNoUnicodeSchema.required()\n })\n .required()\n .description(\n 'Schema for Excel generation audit events (submissions and CSAT)'\n )\n\nexport const authenticationMessageData =\n Joi.object<AuthenticationMessageData>().keys({\n userId: Joi.string().required(),\n displayName: Joi.string().required()\n })\n\nexport const auditUserSchema = Joi.object<AuditUser>()\n .keys({\n id: Joi.string().required(),\n displayName: Joi.string().required()\n })\n .description('Schema for CREATED_BY audit event')\n\nexport function formChangesMessageData<T, U extends FormMessageChangesData>(\n schema: ObjectSchema<T>\n): ObjectSchema<U> {\n return formMessageDataBase.append<U>({\n changes: Joi.object<ChangesMessageData<T>>()\n .keys({\n previous: schema,\n new: schema\n })\n .description('Changes schema')\n })\n}\n\nexport const messageSchema = Joi.object<AuditMessage>()\n .keys({\n schemaVersion: Joi.string()\n .valid(...Object.values(AuditEventMessageSchemaVersion))\n .required()\n .description(\n 'The version of the AuditMessage - bumped with breaking changes'\n ),\n category: Joi.string()\n .valid(...Object.values(AuditEventMessageCategory))\n .required()\n .description('The message category - what does the entityId represent?'),\n source: Joi.string()\n .valid(...Object.values(AuditEventMessageSource))\n .required()\n .description('Source of the message - which service?'),\n type: Joi.string()\n .valid(...Object.values(AuditEventMessageType))\n .description('Event type'),\n entityId: Joi.string()\n .required()\n .description('The id of the entity the category relates to'),\n traceId: Joi.string()\n .optional()\n .description(\n 'Trace id of the event - to link events across multiple services'\n ),\n createdAt: Joi.date()\n .required()\n .description(\n 'The ISO timestamp where the action took place - should be the same as updated_at field in DB'\n ),\n createdBy: auditUserSchema\n .required()\n .description('The user who performed the action being audited'),\n data: Joi.when('type', {\n switch: [\n {\n is: Joi.string().trim().valid(AuditEventMessageType.FORM_CREATED),\n then: formCreatedMessageData\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_TITLE_UPDATED),\n then: formChangesMessageData<\n FormTitleChanges,\n FormTitleUpdatedMessageData\n >(formTitleChanges)\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_ORGANISATION_UPDATED),\n then: formChangesMessageData<\n FormOrganisationChanges,\n FormOrganisationUpdatedMessageData\n >(formOrganisationChanges)\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_TEAM_NAME_UPDATED),\n then: formChangesMessageData<\n FormTeamNameChanges,\n FormTeamNameUpdatedMessageData\n >(formTeamNameChanges)\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_TEAM_EMAIL_UPDATED),\n then: formChangesMessageData<\n FormTeamEmailChanges,\n FormTeamEmailUpdatedMessageData\n >(formTeamEmailChanges)\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_SUPPORT_CONTACT_UPDATED),\n then: formChangesMessageData<\n FormSupportContactChanges,\n FormSupportContactUpdatedMessageData\n >(formSupportContactChanges)\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_SUPPORT_PHONE_UPDATED),\n then: formChangesMessageData<\n FormSupportPhoneChanges,\n FormSupportPhoneUpdatedMessageData\n >(formSupportPhoneChanges)\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_SUPPORT_EMAIL_UPDATED),\n then: formChangesMessageData<\n FormSupportEmailChanges,\n FormSupportEmailUpdatedMessageData\n >(formSupportEmailChanges)\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_SUPPORT_ONLINE_UPDATED),\n then: formChangesMessageData<\n FormSupportOnlineChanges,\n FormSupportOnlineUpdatedMessageData\n >(formSupportOnlineChanges)\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_PRIVACY_NOTICE_UPDATED),\n then: formChangesMessageData<\n FormPrivacyNoticeChanges,\n FormPrivacyNoticeUpdatedMessageData\n >(formPrivacyNoticeChanges)\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_TERMS_AND_CONDITIONS_AGREED),\n then: formChangesMessageData<\n FormTermsAndConditionsChanges,\n FormTermsAndConditionsAgreedMessageData\n >(formTermsAndConditionsChanges)\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_NOTIFICATION_EMAIL_UPDATED),\n then: formChangesMessageData<\n FormNotificationEmailChanges,\n FormNotificationEmailUpdatedMessageData\n >(formNotificationEmailChanges)\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_SUBMISSION_GUIDANCE_UPDATED),\n then: formChangesMessageData<\n FormSubmissionGuidanceChanges,\n FormSubmissionGuidanceUpdatedMessageData\n >(formSubmissionGuidanceChanges)\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_JSON_UPLOADED),\n then: formChangesMessageData<\n FormUploadedChanges,\n FormUploadedMessageData\n >(formUploadedChanges)\n },\n {\n is: Joi.string().trim().valid(AuditEventMessageType.FORM_UPDATED),\n then: formUpdatedMessageData\n },\n {\n is: Joi.string()\n .trim()\n .valid(\n AuditEventMessageType.ENTITLEMENT_CREATED,\n AuditEventMessageType.ENTITLEMENT_UPDATED,\n AuditEventMessageType.ENTITLEMENT_DELETED\n ),\n then: entitlementMessageData\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_DRAFT_DELETED),\n then: formMessageDataBase\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_JSON_DOWNLOADED),\n then: formMessageDataBase\n },\n {\n is: Joi.string()\n .trim()\n .valid(\n AuditEventMessageType.AUTHENTICATION_LOGIN,\n AuditEventMessageType.AUTHENTICATION_LOGOUT_MANUAL,\n AuditEventMessageType.AUTHENTICATION_LOGOUT_AUTO,\n AuditEventMessageType.AUTHENTICATION_LOGOUT_DIFFERENT_DEVICE\n ),\n then: authenticationMessageData\n },\n {\n is: Joi.string()\n .trim()\n .valid(\n AuditEventMessageType.FORM_FILE_DOWNLOAD_SUCCESS,\n AuditEventMessageType.FORM_FILE_DOWNLOAD_FAILURE\n ),\n then: formFileDownloadedMessageData\n },\n {\n is: Joi.string()\n .trim()\n .valid(\n AuditEventMessageType.FORM_SUBMISSION_EXCEL_REQUESTED,\n AuditEventMessageType.FORM_CSAT_EXCEL_REQUESTED,\n AuditEventMessageType.PLATFORM_CSAT_EXCEL_REQUESTED\n ),\n then: excelGenerationMessageData\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORMS_BACKUP_REQUESTED),\n then: formsBackupRequestedMessageData\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_SECRET_DELETED),\n then: formsSecretDeletedMessageData\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_SECRET_SAVED),\n then: formsSecretSavedMessageData\n },\n {\n is: Joi.string().trim().valid(AuditEventMessageType.DLQ_ACTION),\n then: dlqActionMessageData\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_OFFLINE_UPDATED),\n then: formChangesMessageData<\n FormOfflineChanges,\n FormOfflineUpdatedMessageData\n >(formOfflineChanges)\n }\n ],\n otherwise: Joi.forbidden()\n }).description('The data/payload of the audit message'),\n messageCreatedAt: Joi.date()\n .required()\n .description('ISO timestamp when the message was published')\n })\n .required()\n .description('The audit message issued by the publishing service')\n\nexport const auditEvent = Joi.object<AuditEvent>()\n .keys({\n message: messageSchema\n })\n .description('The Body of the audit event')\n\nexport const auditRecord = messageSchema\n .append<AuditRecord>({\n id: idSchema,\n messageId: Joi.string().uuid().required(),\n entityId: Joi.string().required(),\n recordCreatedAt: Joi.date().required()\n })\n .description('The audit record persisted into the DB')\n"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tK,GAAG,CAAC0B,MAAM,CAAa,CAAC,CAC/Cc,IAAI,CAAC;EACJ+H,OAAO,EAAElD;AACX,CAAC,CAAC,CACDrF,WAAW,CAAC,6BAA6B,CAAC;AAE7C,OAAO,MAAMwI,WAAW,GAAGnD,aAAa,CACrCnF,MAAM,CAAc;EACnB6E,EAAE,EAAEtG,QAAQ;EACZqD,SAAS,EAAE9D,GAAG,CAAC0C,MAAM,CAAC,CAAC,CAAC+H,IAAI,CAAC,CAAC,CAAC1I,QAAQ,CAAC,CAAC;EACzC2F,QAAQ,EAAE1H,GAAG,CAAC0C,MAAM,CAAC,CAAC,CAACX,QAAQ,CAAC,CAAC;EACjC2I,eAAe,EAAE1K,GAAG,CAAC6H,IAAI,CAAC,CAAC,CAAC9F,QAAQ,CAAC;AACvC,CAAC,CAAC,CACDC,WAAW,CAAC,wCAAwC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["Joi","AuditEventMessageCategory","AuditEventMessageSchemaVersion","AuditEventMessageSource","AuditEventMessageType","FormDefinitionRequestType","emailAddressNoUnicodeSchema","contactSchema","emailResponseTimeSchema","idSchema","notificationEmailAddressSchema","offlineSchema","onlineTextSchema","onlineUrlSchema","organisationSchema","phoneSchema","privacyNoticeTextSchema","privacyNoticeTypeSchema","privacyNoticeUrlSchema","slugSchema","submissionGuidanceSchema","teamEmailSchema","teamNameSchema","termsAndConditionsAgreedSchema","titleSchema","formMessageDataBase","object","formId","slug","payload","optional","required","description","formCreatedMessageData","append","title","organisation","teamName","teamEmail","formDefinitionS3Meta","keys","fileId","string","filename","s3Key","formOutputMessageData","emailAddress","audience","trim","valid","version","condition","allow","formUpdatedMessageData","requestType","Object","values","s3Meta","formsBackupRequestedMessageData","totalForms","number","integer","min","durationMs","formsSecretDeletedMessageData","secretName","formsSecretSavedMessageData","dlqActionMessageData","action","messageId","beforeJson","afterJson","formTitleChanges","formOrganisationChanges","formTeamNameChanges","formTeamEmailChanges","formSupportContactChanges","contact","formSupportPhoneChanges","phone","formSupportOnlineChanges","url","text","formSupportEmailChanges","address","responseTime","formPrivacyNoticeChanges","privacyNoticeType","privacyNoticeText","when","is","then","otherwise","privacyNoticeUrl","formTermsAndConditionsChanges","termsAndConditionsAgreed","formNotificationEmailChanges","notificationEmail","formSubmissionGuidanceChanges","submissionGuidance","formUploadedChanges","value","formOfflineChanges","offline","entitlementMessageData","userId","displayName","email","roles","array","items","formFileDownloadedMessageData","fileLink","excelGenerationMessageData","formName","authenticationMessageData","auditUserSchema","id","formChangesMessageData","schema","changes","previous","new","messageSchema","schemaVersion","category","source","type","entityId","traceId","createdAt","date","createdBy","data","switch","FORM_CREATED","FORM_TITLE_UPDATED","FORM_ORGANISATION_UPDATED","FORM_TEAM_NAME_UPDATED","FORM_TEAM_EMAIL_UPDATED","FORM_SUPPORT_CONTACT_UPDATED","FORM_SUPPORT_PHONE_UPDATED","FORM_SUPPORT_EMAIL_UPDATED","FORM_SUPPORT_ONLINE_UPDATED","FORM_PRIVACY_NOTICE_UPDATED","FORM_TERMS_AND_CONDITIONS_AGREED","FORM_NOTIFICATION_EMAIL_UPDATED","FORM_SUBMISSION_GUIDANCE_UPDATED","FORM_JSON_UPLOADED","FORM_UPDATED","ENTITLEMENT_CREATED","ENTITLEMENT_UPDATED","ENTITLEMENT_DELETED","FORM_DRAFT_DELETED","FORM_JSON_DOWNLOADED","AUTHENTICATION_LOGIN","AUTHENTICATION_LOGOUT_MANUAL","AUTHENTICATION_LOGOUT_AUTO","AUTHENTICATION_LOGOUT_DIFFERENT_DEVICE","FORM_FILE_DOWNLOAD_SUCCESS","FORM_FILE_DOWNLOAD_FAILURE","FORM_SUBMISSION_EXCEL_REQUESTED","FORM_CSAT_EXCEL_REQUESTED","PLATFORM_CSAT_EXCEL_REQUESTED","FORMS_BACKUP_REQUESTED","FORM_SECRET_DELETED","FORM_SECRET_SAVED","DLQ_ACTION","FORM_OFFLINE_UPDATED","forbidden","messageCreatedAt","auditEvent","message","auditRecord","uuid","recordCreatedAt"],"sources":["../../../../src/form/form-audit/index.ts"],"sourcesContent":["import Joi, { type ObjectSchema } from 'joi'\n\nimport {\n AuditEventMessageCategory,\n AuditEventMessageSchemaVersion,\n AuditEventMessageSource,\n AuditEventMessageType,\n FormDefinitionRequestType\n} from '~/src/form/form-audit/enums.js'\nimport {\n type AuditEvent,\n type AuditMessage,\n type AuditRecord,\n type AuditUser,\n type AuthenticationMessageData,\n type ChangesMessageData,\n type DlqActionMessageData,\n type EntitlementMessageData,\n type ExcelGenerationMessageData,\n type FormCreatedMessageData,\n type FormDefinitionS3Meta,\n type FormFileDownloadedMessageData,\n type FormMessageChangesData,\n type FormMessageDataBase,\n type FormNotificationEmailChanges,\n type FormNotificationEmailUpdatedMessageData,\n type FormOfflineChanges,\n type FormOfflineUpdatedMessageData,\n type FormOrganisationChanges,\n type FormOrganisationUpdatedMessageData,\n type FormPrivacyNoticeChanges,\n type FormPrivacyNoticeUpdatedMessageData,\n type FormSecretBaseMessageData,\n type FormSubmissionGuidanceChanges,\n type FormSubmissionGuidanceUpdatedMessageData,\n type FormSupportContactChanges,\n type FormSupportContactUpdatedMessageData,\n type FormSupportEmailChanges,\n type FormSupportEmailUpdatedMessageData,\n type FormSupportOnlineChanges,\n type FormSupportOnlineUpdatedMessageData,\n type FormSupportPhoneChanges,\n type FormSupportPhoneUpdatedMessageData,\n type FormTeamEmailChanges,\n type FormTeamEmailUpdatedMessageData,\n type FormTeamNameChanges,\n type FormTeamNameUpdatedMessageData,\n type FormTermsAndConditionsAgreedMessageData,\n type FormTermsAndConditionsChanges,\n type FormTitleChanges,\n type FormTitleUpdatedMessageData,\n type FormUpdatedMessageData,\n type FormUploadedChanges,\n type FormUploadedMessageData,\n type FormsBackupRequestedMessageData\n} from '~/src/form/form-audit/types.js'\nimport { type Output } from '~/src/form/form-definition/types.js'\nimport { emailAddressNoUnicodeSchema } from '~/src/form/form-editor/index.js'\nimport {\n contactSchema,\n emailResponseTimeSchema,\n idSchema,\n notificationEmailAddressSchema,\n offlineSchema,\n onlineTextSchema,\n onlineUrlSchema,\n organisationSchema,\n phoneSchema,\n privacyNoticeTextSchema,\n privacyNoticeTypeSchema,\n privacyNoticeUrlSchema,\n slugSchema,\n submissionGuidanceSchema,\n teamEmailSchema,\n teamNameSchema,\n termsAndConditionsAgreedSchema,\n titleSchema\n} from '~/src/form/form-metadata/index.js'\n\nexport const formMessageDataBase = Joi.object<FormMessageDataBase>({\n formId: idSchema,\n slug: slugSchema,\n payload: Joi.object().optional()\n})\n .required()\n .description('The base data object for Form Messages')\n\nexport const formCreatedMessageData = formMessageDataBase\n .append<FormCreatedMessageData>({\n title: titleSchema,\n organisation: organisationSchema,\n teamName: teamNameSchema,\n teamEmail: teamEmailSchema\n })\n .required()\n .description('Message data schema for when a form is created')\n\nexport const formDefinitionS3Meta = Joi.object<FormDefinitionS3Meta>()\n .keys({\n fileId: Joi.string().required(),\n filename: Joi.string().required(),\n s3Key: Joi.string().required()\n })\n .description('Schema for form data S3 object in message')\n\n/**\n * Stands apart from the definition's own output schema, which resolves a\n * condition against the sibling `conditions` array - a lookup that has no\n * meaning on an audit message carrying the output on its own.\n */\nexport const formOutputMessageData = Joi.object<Output>()\n .keys({\n emailAddress: emailAddressNoUnicodeSchema\n .required()\n .description('Email address the submission is sent to'),\n audience: Joi.string()\n .trim()\n .valid('human', 'machine')\n .required()\n .description(\n 'Whether the submission is sent human readable or machine processable'\n ),\n version: Joi.string()\n .trim()\n .required()\n .description('Version identifier of the output format'),\n condition: Joi.string()\n .trim()\n .allow('')\n .optional()\n .description(\n 'Id of the condition determining whether the submission is sent to this address'\n )\n })\n .description('A submission email target as recorded on an audit event')\n\nexport const formUpdatedMessageData = formMessageDataBase\n .append<FormUpdatedMessageData>({\n requestType: Joi.string()\n .valid(...Object.values(FormDefinitionRequestType))\n .required(),\n s3Meta: formDefinitionS3Meta.optional()\n })\n .required()\n\nexport const formsBackupRequestedMessageData =\n Joi.object<FormsBackupRequestedMessageData>().keys({\n totalForms: Joi.number().integer().min(0).required(),\n durationMs: Joi.number().min(0).required()\n })\n\nexport const formsSecretDeletedMessageData =\n formMessageDataBase.append<FormSecretBaseMessageData>({\n secretName: Joi.string().required()\n })\n\nexport const formsSecretSavedMessageData =\n formMessageDataBase.append<FormSecretBaseMessageData>({\n secretName: Joi.string().required()\n })\n\nexport const dlqActionMessageData = Joi.object<DlqActionMessageData>().keys({\n action: Joi.string()\n .valid('redrive', 'delete', 'modify-and-resubmit')\n .required(),\n messageId: Joi.string().optional(),\n beforeJson: Joi.string().optional(),\n afterJson: Joi.string().optional()\n})\n\nexport const formTitleChanges = Joi.object<FormTitleChanges>()\n .keys({\n title: titleSchema\n })\n .required()\n .description('Changes schema for FORM_TITLE_UPDATED event')\n\nexport const formOrganisationChanges = Joi.object<FormOrganisationChanges>()\n .keys({\n organisation: organisationSchema\n })\n .required()\n .description('Changes schema for FORM_ORGANISATION_UPDATED event')\n\nexport const formTeamNameChanges = Joi.object<FormTeamNameChanges>()\n .keys({\n teamName: teamNameSchema\n })\n .required()\n .description('Changes schema for FORM_TEAM_NAME_UPDATED event')\n\nexport const formTeamEmailChanges = Joi.object<FormTeamEmailChanges>()\n .keys({\n teamEmail: teamEmailSchema\n })\n .required()\n .description('Changes schema for FORM_TEAM_EMAIL_UPDATED event')\n\nexport const formSupportContactChanges = Joi.object<FormSupportContactChanges>()\n .keys({\n contact: contactSchema\n })\n .required()\n .description('Changes schema for FORM_SUPPORT_CONTACT_UPDATED event')\n\nexport const formSupportPhoneChanges = Joi.object<FormSupportPhoneChanges>()\n .keys({\n phone: phoneSchema\n })\n .required()\n .description('Changes schema for FORM_SUPPORT_PHONE_UPDATED event')\n\nexport const formSupportOnlineChanges = Joi.object<FormSupportOnlineChanges>()\n .keys({\n url: onlineUrlSchema.optional(),\n text: onlineTextSchema.optional()\n })\n .required()\n .description('Changes schema for FORM_SUPPORT_ONLINE_UPDATED event')\n\nexport const formSupportEmailChanges = Joi.object<FormSupportEmailChanges>()\n .keys({\n address: emailAddressNoUnicodeSchema.optional(),\n responseTime: emailResponseTimeSchema.optional()\n })\n .description('Changes schema for FORM_SUPPORT_EMAIL_UPDATED event')\n\nexport const formPrivacyNoticeChanges = Joi.object<FormPrivacyNoticeChanges>()\n .keys({\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 })\n .required()\n .description('Changes schema for FORM_PRIVACY_NOTICE_UPDATED event')\n\nexport const formTermsAndConditionsChanges =\n Joi.object<FormTermsAndConditionsChanges>()\n .keys({\n termsAndConditionsAgreed: termsAndConditionsAgreedSchema\n })\n .required()\n .description('Changes schema for FORM_TERMS_AND_CONDITIONS_AGREED event')\n\nexport const formNotificationEmailChanges =\n Joi.object<FormNotificationEmailChanges>()\n .keys({\n notificationEmail: notificationEmailAddressSchema\n })\n .required()\n .description('Changes schema for FORM_NOTIFICATION_EMAIL_UPDATED event')\n\nexport const formSubmissionGuidanceChanges =\n Joi.object<FormSubmissionGuidanceChanges>()\n .keys({\n submissionGuidance: submissionGuidanceSchema\n })\n .required()\n .description('Changes schema for FORM_SUBMISSION_GUIDANCE_UPDATED event')\n\nexport const formUploadedChanges = Joi.object<FormUploadedChanges>()\n .keys({\n value: Joi.string().required()\n })\n .required()\n .description('Changes schema for FORM_JSON_UPLOADED event')\n\nexport const formOfflineChanges = Joi.object<FormOfflineChanges>()\n .keys({\n offline: offlineSchema\n })\n .required()\n .description('Changes schema for FORM_OFFLINE_UPDATED event')\n\nexport const entitlementMessageData = Joi.object<EntitlementMessageData>().keys(\n {\n userId: Joi.string().required(),\n displayName: Joi.string().required(),\n email: emailAddressNoUnicodeSchema.required(),\n roles: Joi.array().items(Joi.string())\n }\n)\n\nexport const formFileDownloadedMessageData =\n Joi.object<FormFileDownloadedMessageData>()\n .keys({\n fileId: Joi.string().required(),\n filename: Joi.string().required(),\n fileLink: Joi.string().required()\n })\n .required()\n .description(\n 'Schema for FORM_FILE_DOWNLOAD_SUCCESS and FORM_FILE_DOWNLOAD_FAILURE events'\n )\n\nexport const excelGenerationMessageData =\n Joi.object<ExcelGenerationMessageData>()\n .keys({\n formId: Joi.string().required(),\n formName: Joi.string().required(),\n notificationEmail: emailAddressNoUnicodeSchema.required()\n })\n .required()\n .description(\n 'Schema for Excel generation audit events (submissions and CSAT)'\n )\n\nexport const authenticationMessageData =\n Joi.object<AuthenticationMessageData>().keys({\n userId: Joi.string().required(),\n displayName: Joi.string().required()\n })\n\nexport const auditUserSchema = Joi.object<AuditUser>()\n .keys({\n id: Joi.string().required(),\n displayName: Joi.string().required()\n })\n .description('Schema for CREATED_BY audit event')\n\nexport function formChangesMessageData<T, U extends FormMessageChangesData>(\n schema: ObjectSchema<T>\n): ObjectSchema<U> {\n return formMessageDataBase.append<U>({\n changes: Joi.object<ChangesMessageData<T>>()\n .keys({\n previous: schema,\n new: schema\n })\n .description('Changes schema')\n })\n}\n\nexport const messageSchema = Joi.object<AuditMessage>()\n .keys({\n schemaVersion: Joi.string()\n .valid(...Object.values(AuditEventMessageSchemaVersion))\n .required()\n .description(\n 'The version of the AuditMessage - bumped with breaking changes'\n ),\n category: Joi.string()\n .valid(...Object.values(AuditEventMessageCategory))\n .required()\n .description('The message category - what does the entityId represent?'),\n source: Joi.string()\n .valid(...Object.values(AuditEventMessageSource))\n .required()\n .description('Source of the message - which service?'),\n type: Joi.string()\n .valid(...Object.values(AuditEventMessageType))\n .description('Event type'),\n entityId: Joi.string()\n .required()\n .description('The id of the entity the category relates to'),\n traceId: Joi.string()\n .optional()\n .description(\n 'Trace id of the event - to link events across multiple services'\n ),\n createdAt: Joi.date()\n .required()\n .description(\n 'The ISO timestamp where the action took place - should be the same as updated_at field in DB'\n ),\n createdBy: auditUserSchema\n .required()\n .description('The user who performed the action being audited'),\n data: Joi.when('type', {\n switch: [\n {\n is: Joi.string().trim().valid(AuditEventMessageType.FORM_CREATED),\n then: formCreatedMessageData\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_TITLE_UPDATED),\n then: formChangesMessageData<\n FormTitleChanges,\n FormTitleUpdatedMessageData\n >(formTitleChanges)\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_ORGANISATION_UPDATED),\n then: formChangesMessageData<\n FormOrganisationChanges,\n FormOrganisationUpdatedMessageData\n >(formOrganisationChanges)\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_TEAM_NAME_UPDATED),\n then: formChangesMessageData<\n FormTeamNameChanges,\n FormTeamNameUpdatedMessageData\n >(formTeamNameChanges)\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_TEAM_EMAIL_UPDATED),\n then: formChangesMessageData<\n FormTeamEmailChanges,\n FormTeamEmailUpdatedMessageData\n >(formTeamEmailChanges)\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_SUPPORT_CONTACT_UPDATED),\n then: formChangesMessageData<\n FormSupportContactChanges,\n FormSupportContactUpdatedMessageData\n >(formSupportContactChanges)\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_SUPPORT_PHONE_UPDATED),\n then: formChangesMessageData<\n FormSupportPhoneChanges,\n FormSupportPhoneUpdatedMessageData\n >(formSupportPhoneChanges)\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_SUPPORT_EMAIL_UPDATED),\n then: formChangesMessageData<\n FormSupportEmailChanges,\n FormSupportEmailUpdatedMessageData\n >(formSupportEmailChanges)\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_SUPPORT_ONLINE_UPDATED),\n then: formChangesMessageData<\n FormSupportOnlineChanges,\n FormSupportOnlineUpdatedMessageData\n >(formSupportOnlineChanges)\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_PRIVACY_NOTICE_UPDATED),\n then: formChangesMessageData<\n FormPrivacyNoticeChanges,\n FormPrivacyNoticeUpdatedMessageData\n >(formPrivacyNoticeChanges)\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_TERMS_AND_CONDITIONS_AGREED),\n then: formChangesMessageData<\n FormTermsAndConditionsChanges,\n FormTermsAndConditionsAgreedMessageData\n >(formTermsAndConditionsChanges)\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_NOTIFICATION_EMAIL_UPDATED),\n then: formChangesMessageData<\n FormNotificationEmailChanges,\n FormNotificationEmailUpdatedMessageData\n >(formNotificationEmailChanges)\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_SUBMISSION_GUIDANCE_UPDATED),\n then: formChangesMessageData<\n FormSubmissionGuidanceChanges,\n FormSubmissionGuidanceUpdatedMessageData\n >(formSubmissionGuidanceChanges)\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_JSON_UPLOADED),\n then: formChangesMessageData<\n FormUploadedChanges,\n FormUploadedMessageData\n >(formUploadedChanges)\n },\n {\n is: Joi.string().trim().valid(AuditEventMessageType.FORM_UPDATED),\n then: formUpdatedMessageData\n },\n {\n is: Joi.string()\n .trim()\n .valid(\n AuditEventMessageType.ENTITLEMENT_CREATED,\n AuditEventMessageType.ENTITLEMENT_UPDATED,\n AuditEventMessageType.ENTITLEMENT_DELETED\n ),\n then: entitlementMessageData\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_DRAFT_DELETED),\n then: formMessageDataBase\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_JSON_DOWNLOADED),\n then: formMessageDataBase\n },\n {\n is: Joi.string()\n .trim()\n .valid(\n AuditEventMessageType.AUTHENTICATION_LOGIN,\n AuditEventMessageType.AUTHENTICATION_LOGOUT_MANUAL,\n AuditEventMessageType.AUTHENTICATION_LOGOUT_AUTO,\n AuditEventMessageType.AUTHENTICATION_LOGOUT_DIFFERENT_DEVICE\n ),\n then: authenticationMessageData\n },\n {\n is: Joi.string()\n .trim()\n .valid(\n AuditEventMessageType.FORM_FILE_DOWNLOAD_SUCCESS,\n AuditEventMessageType.FORM_FILE_DOWNLOAD_FAILURE\n ),\n then: formFileDownloadedMessageData\n },\n {\n is: Joi.string()\n .trim()\n .valid(\n AuditEventMessageType.FORM_SUBMISSION_EXCEL_REQUESTED,\n AuditEventMessageType.FORM_CSAT_EXCEL_REQUESTED,\n AuditEventMessageType.PLATFORM_CSAT_EXCEL_REQUESTED\n ),\n then: excelGenerationMessageData\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORMS_BACKUP_REQUESTED),\n then: formsBackupRequestedMessageData\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_SECRET_DELETED),\n then: formsSecretDeletedMessageData\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_SECRET_SAVED),\n then: formsSecretSavedMessageData\n },\n {\n is: Joi.string().trim().valid(AuditEventMessageType.DLQ_ACTION),\n then: dlqActionMessageData\n },\n {\n is: Joi.string()\n .trim()\n .valid(AuditEventMessageType.FORM_OFFLINE_UPDATED),\n then: formChangesMessageData<\n FormOfflineChanges,\n FormOfflineUpdatedMessageData\n >(formOfflineChanges)\n }\n ],\n otherwise: Joi.forbidden()\n }).description('The data/payload of the audit message'),\n messageCreatedAt: Joi.date()\n .required()\n .description('ISO timestamp when the message was published')\n })\n .required()\n .description('The audit message issued by the publishing service')\n\nexport const auditEvent = Joi.object<AuditEvent>()\n .keys({\n message: messageSchema\n })\n .description('The Body of the audit event')\n\nexport const auditRecord = messageSchema\n .append<AuditRecord>({\n id: idSchema,\n messageId: Joi.string().uuid().required(),\n entityId: Joi.string().required(),\n recordCreatedAt: Joi.date().required()\n })\n .description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[]}
|
|
@@ -55,6 +55,26 @@ export function getHiddenFields(definition) {
|
|
|
55
55
|
return totalHiddenFields;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Builds the key identifying a submission email target. Two outputs sharing a
|
|
60
|
+
* key would send the same format of the same submission to the same inbox in
|
|
61
|
+
* the same circumstances, so one of them is redundant. Addresses are compared
|
|
62
|
+
* case-insensitively and a missing condition is treated as an empty one.
|
|
63
|
+
* @param output - submission email target
|
|
64
|
+
*/
|
|
65
|
+
export function getOutputKey(output) {
|
|
66
|
+
return [output.emailAddress?.trim().toLowerCase() ?? '', output.condition?.trim() ?? '', output.audience ?? '', output.version?.trim() ?? ''].join('|');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Whether two submission email targets are duplicates of one another
|
|
71
|
+
* @param output - submission email target
|
|
72
|
+
* @param otherOutput - submission email target to compare against
|
|
73
|
+
*/
|
|
74
|
+
export function isDuplicateOutput(output, otherOutput) {
|
|
75
|
+
return getOutputKey(output) === getOutputKey(otherOutput);
|
|
76
|
+
}
|
|
77
|
+
|
|
58
78
|
/**
|
|
59
79
|
* @param definition - form definition
|
|
60
80
|
* @returns {boolean}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","names":["ComponentType","hasComponents","isFormDefinition","definition","isConditionListItemRefValueData","conditionValueData","getConditionListItemIds","value","itemId","Array","isArray","getHiddenFields","pages","length","totalHiddenFields","page","hiddenFields","components","filter","comp","type","HiddenField","push","isFeedbackForm","feedback","some","p","controller"],"sources":["../../../../src/form/form-definition/helpers.ts"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { type ComponentDef } from '~/src/components/types.js'\nimport { type ConditionListItemRefValueDataV2 } from '~/src/conditions/types.js'\nimport {
|
|
1
|
+
{"version":3,"file":"helpers.js","names":["ComponentType","hasComponents","isFormDefinition","definition","isConditionListItemRefValueData","conditionValueData","getConditionListItemIds","value","itemId","Array","isArray","getHiddenFields","pages","length","totalHiddenFields","page","hiddenFields","components","filter","comp","type","HiddenField","push","getOutputKey","output","emailAddress","trim","toLowerCase","condition","audience","version","join","isDuplicateOutput","otherOutput","isFeedbackForm","feedback","some","p","controller"],"sources":["../../../../src/form/form-definition/helpers.ts"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { type ComponentDef } from '~/src/components/types.js'\nimport { type ConditionListItemRefValueDataV2 } from '~/src/conditions/types.js'\nimport {\n type FormDefinition,\n type Output\n} from '~/src/form/form-definition/types.js'\nimport { type ControllerType } from '~/src/pages/enums.js'\nimport { hasComponents } from '~/src/pages/helpers.js'\n\n/**\n * TypeGuard to check if something is a FormDefinition\n * @param { unknown } definition\n * @returns { definition is FormDefinition }\n */\nexport function isFormDefinition(\n definition: unknown\n): definition is FormDefinition {\n if (!definition) {\n return false\n }\n\n return (\n typeof definition === 'object' &&\n 'name' in definition &&\n 'pages' in definition &&\n 'conditions' in definition\n )\n}\n\n/**\n * TypeGuard to check if something is a ConditionListItemRefValueDataV2\n * @param { unknown } conditionValueData\n * @returns { conditionValueData is ConditionListItemRefValueDataV2 }\n */\nexport function isConditionListItemRefValueData(\n conditionValueData: unknown\n): conditionValueData is ConditionListItemRefValueDataV2 {\n if (!conditionValueData) {\n return false\n }\n\n return (\n typeof conditionValueData === 'object' &&\n 'listId' in conditionValueData &&\n 'itemId' in conditionValueData\n )\n}\n\n/**\n * Normalises a list item ref condition value to an array of item ids. `itemId`\n * is normally an array, but may be a bare string for legacy conditions saved\n * before multi-select support.\n * @param { ConditionListItemRefValueDataV2 | undefined } value\n * @returns { string[] }\n */\nexport function getConditionListItemIds(\n value: ConditionListItemRefValueDataV2 | undefined\n): string[] {\n if (!value?.itemId) {\n return []\n }\n\n return Array.isArray(value.itemId) ? value.itemId : [value.itemId]\n}\n\n/**\n * Returns an array of all hidden fields in a form\n * @param definition - form definition\n */\nexport function getHiddenFields(definition: FormDefinition) {\n if (definition.pages.length === 0) {\n return []\n }\n const totalHiddenFields = [] as ComponentDef[]\n for (const page of definition.pages) {\n const hiddenFields = hasComponents(page)\n ? page.components.filter(\n (comp) => comp.type === ComponentType.HiddenField\n )\n : []\n totalHiddenFields.push(...hiddenFields)\n }\n return totalHiddenFields\n}\n\n/**\n * Builds the key identifying a submission email target. Two outputs sharing a\n * key would send the same format of the same submission to the same inbox in\n * the same circumstances, so one of them is redundant. Addresses are compared\n * case-insensitively and a missing condition is treated as an empty one.\n * @param output - submission email target\n */\nexport function getOutputKey(output: Partial<Output>): string {\n return [\n output.emailAddress?.trim().toLowerCase() ?? '',\n output.condition?.trim() ?? '',\n output.audience ?? '',\n output.version?.trim() ?? ''\n ].join('|')\n}\n\n/**\n * Whether two submission email targets are duplicates of one another\n * @param output - submission email target\n * @param otherOutput - submission email target to compare against\n */\nexport function isDuplicateOutput(\n output: Partial<Output>,\n otherOutput: Partial<Output>\n): boolean {\n return getOutputKey(output) === getOutputKey(otherOutput)\n}\n\n/**\n * @param definition - form definition\n * @returns {boolean}\n */\nexport function isFeedbackForm(definition: FormDefinition | undefined) {\n const feedback = 'FeedbackPageController' as ControllerType\n return definition?.pages\n ? definition.pages.some((p) => p.controller === feedback)\n : false\n}\n"],"mappings":"AAAA,SAASA,aAAa;AAQtB,SAASC,aAAa;;AAEtB;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAC9BC,UAAmB,EACW;EAC9B,IAAI,CAACA,UAAU,EAAE;IACf,OAAO,KAAK;EACd;EAEA,OACE,OAAOA,UAAU,KAAK,QAAQ,IAC9B,MAAM,IAAIA,UAAU,IACpB,OAAO,IAAIA,UAAU,IACrB,YAAY,IAAIA,UAAU;AAE9B;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,+BAA+BA,CAC7CC,kBAA2B,EAC4B;EACvD,IAAI,CAACA,kBAAkB,EAAE;IACvB,OAAO,KAAK;EACd;EAEA,OACE,OAAOA,kBAAkB,KAAK,QAAQ,IACtC,QA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;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAC/BR,MAAuB,EACvBS,WAA4B,EACnB;EACT,OAAOV,YAAY,CAACC,MAAM,CAAC,KAAKD,YAAY,CAACU,WAAW,CAAC;AAC3D;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAAC/B,UAAsC,EAAE;EACrE,MAAMgC,QAAQ,GAAG,wBAA0C;EAC3D,OAAOhC,UAAU,EAAES,KAAK,GACpBT,UAAU,CAACS,KAAK,CAACwB,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACC,UAAU,KAAKH,QAAQ,CAAC,GACvD,KAAK;AACX","ignoreList":[]}
|
|
@@ -6,7 +6,7 @@ import { ComponentType, GeospatialFieldGeometryTypesEnum, GeospatialFieldOptions
|
|
|
6
6
|
import { isConditionalType } from "../../components/helpers.js";
|
|
7
7
|
import { ConditionType, Coordinator, OperatorName } from "../../conditions/enums.js";
|
|
8
8
|
import { MAX_NUMBER_OF_REPEAT_ITEMS, MIN_NUMBER_OF_REPEAT_ITEMS } from "./constants.js";
|
|
9
|
-
import { isConditionListItemRefValueData, isFormDefinition } from "./helpers.js";
|
|
9
|
+
import { isConditionListItemRefValueData, isDuplicateOutput, isFormDefinition } from "./helpers.js";
|
|
10
10
|
import { SchemaVersion } from "./types.js";
|
|
11
11
|
import { emailAddressNoUnicodeSchema } from "../form-editor/index.js";
|
|
12
12
|
import { checkErrors } from "../form-manager/errors.js";
|
|
@@ -447,6 +447,29 @@ const outputSchema = Joi.object().description('Configuration for form submission
|
|
|
447
447
|
audience: Joi.string().trim().valid('human', 'machine').required().description('Target audience for the output (human readable or machine processable)'),
|
|
448
448
|
version: Joi.string().trim().required().description('Version identifier for the output format')
|
|
449
449
|
});
|
|
450
|
+
const outputsItemSchema = Joi.object().description('Configuration for a single submission email target').keys({
|
|
451
|
+
emailAddress: emailAddressNoUnicodeSchema.description('Email address where form submissions are sent'),
|
|
452
|
+
audience: Joi.string().trim().valid('human', 'machine').required().description('Target audience for the output (human readable or machine processable)'),
|
|
453
|
+
version: Joi.string().trim().required().description('Version identifier for the output format')
|
|
454
|
+
});
|
|
455
|
+
const outputsItemSchemaV2 = outputsItemSchema.keys({
|
|
456
|
+
condition: Joi.string().trim().allow('').optional().when('/conditions', {
|
|
457
|
+
is: Joi.exist(),
|
|
458
|
+
then: Joi.valid('', conditionIdRef)
|
|
459
|
+
}).description('Optional condition that determines if submissions are sent to this output').error(checkErrors(FormDefinitionError.RefOutputCondition))
|
|
460
|
+
});
|
|
461
|
+
const outputsSchema = Joi.array().items(outputsItemSchema).unique(isDuplicateOutput)
|
|
462
|
+
// Without this the raw Joi message names the array index, eg `"outputs[4]"
|
|
463
|
+
// contains a duplicate value`, which means nothing to a form author
|
|
464
|
+
.messages({
|
|
465
|
+
'array.unique': 'Email address {{#value.emailAddress}} is already receiving the same submissions'
|
|
466
|
+
}).optional().description('One or more email targets/types for submission emails').error(checkErrors(FormDefinitionError.UniqueOutput));
|
|
467
|
+
const outputsSchemaV2 = Joi.array().items(outputsItemSchemaV2).unique(isDuplicateOutput)
|
|
468
|
+
// Without this the raw Joi message names the array index, eg `"outputs[4]"
|
|
469
|
+
// contains a duplicate value`, which means nothing to a form author
|
|
470
|
+
.messages({
|
|
471
|
+
'array.unique': 'Email address {{#value.emailAddress}} is already receiving the same submissions'
|
|
472
|
+
}).optional().description('Outputs schema for V2 forms').error(checkErrors(FormDefinitionError.UniqueOutput));
|
|
450
473
|
|
|
451
474
|
/**
|
|
452
475
|
* Joi schema for `FormDefinition` interface
|
|
@@ -469,28 +492,17 @@ export const formDefinitionSchema = Joi.object().description('Complete form defi
|
|
|
469
492
|
skipSummary: Joi.any().strip().description('option to skip the summary page'),
|
|
470
493
|
phaseBanner: phaseBannerSchema.optional().description('Phase banner configuration'),
|
|
471
494
|
options: optionsSchema.optional().description('Options for the form'),
|
|
472
|
-
outputEmail: emailAddressNoUnicodeSchema.
|
|
473
|
-
tlds: {
|
|
474
|
-
allow: ['uk']
|
|
475
|
-
}
|
|
476
|
-
}).optional().description('Email address where form submissions are sent'),
|
|
495
|
+
outputEmail: emailAddressNoUnicodeSchema.optional().description('Email address where form submissions are sent'),
|
|
477
496
|
output: outputSchema.optional().description('Configuration for submission output format'),
|
|
478
|
-
outputs:
|
|
479
|
-
emailAddress: emailAddressNoUnicodeSchema.email({
|
|
480
|
-
tlds: {
|
|
481
|
-
allow: ['uk']
|
|
482
|
-
}
|
|
483
|
-
}).description('Email address where form submissions are sent'),
|
|
484
|
-
audience: Joi.string().trim().valid('human', 'machine').required().description('Target audience for the output (human readable or machine processable)'),
|
|
485
|
-
version: Joi.string().trim().required().description('Version identifier for the output format')
|
|
486
|
-
}).optional().description('One or more email targets/types for submission emails')
|
|
497
|
+
outputs: outputsSchema
|
|
487
498
|
});
|
|
488
499
|
export const formDefinitionV2Schema = formDefinitionSchema.keys({
|
|
489
|
-
schema: Joi.number().integer().valid(SchemaVersion.V2).description('Form schema version to use (2)'),
|
|
500
|
+
schema: Joi.number().integer().valid(SchemaVersion.V2).required().description('Form schema version to use (2)'),
|
|
490
501
|
pages: Joi.array().items(pageSchemaV2).required().unique('id').unique('path').description('Pages schema for V2 forms').error(checkErrors([FormDefinitionError.UniquePageId, FormDefinitionError.UniquePagePath])),
|
|
491
502
|
lists: Joi.array().items(listSchemaV2).unique('id').unique('name').unique('title').description('Lists schema for V2 forms').error(checkErrors([FormDefinitionError.UniqueListId, FormDefinitionError.UniqueListName, FormDefinitionError.UniqueListTitle])),
|
|
492
503
|
conditions: Joi.array().items(conditionWrapperSchemaV2).unique('id').unique('displayName').description('Named conditions used for form logic').error(checkErrors([FormDefinitionError.UniqueConditionId, FormDefinitionError.UniqueConditionDisplayName])),
|
|
493
|
-
sections: Joi.array().items(sectionsSchemaV2).unique('id').unique('name').unique('title').required().description('Sections schema for V2 forms').error(checkErrors([FormDefinitionError.UniqueSectionId, FormDefinitionError.UniqueSectionName, FormDefinitionError.UniqueSectionTitle]))
|
|
504
|
+
sections: Joi.array().items(sectionsSchemaV2).unique('id').unique('name').unique('title').required().description('Sections schema for V2 forms').error(checkErrors([FormDefinitionError.UniqueSectionId, FormDefinitionError.UniqueSectionName, FormDefinitionError.UniqueSectionTitle])),
|
|
505
|
+
outputs: outputsSchemaV2
|
|
494
506
|
}).description('Form definition schema for V2');
|
|
495
507
|
export { MAX_NUMBER_OF_REPEAT_ITEMS, MIN_NUMBER_OF_REPEAT_ITEMS } from "./constants.js";
|
|
496
508
|
|