@defra/forms-model 3.0.615 → 3.0.616
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/consolidation.js +11 -6
- package/dist/module/form/form-audit/consolidation.js.map +1 -1
- package/dist/types/form/form-audit/consolidation.d.ts +8 -3
- package/dist/types/form/form-audit/consolidation.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/form/form-audit/consolidation.ts +22 -17
|
@@ -6,7 +6,7 @@ import { AuditEventMessageType } from "./enums.js";
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Audit field that comprises multiple fields - configuration for change detection.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -24,11 +24,11 @@ function createFieldConfig(label, verb, fieldName) {
|
|
|
24
24
|
/**
|
|
25
25
|
* Creates a support contact field configuration.
|
|
26
26
|
*/
|
|
27
|
-
function
|
|
27
|
+
function createMultiField(label, contactPath) {
|
|
28
28
|
return {
|
|
29
29
|
label,
|
|
30
|
-
prevPath: `changes.previous
|
|
31
|
-
newPath: `changes.new
|
|
30
|
+
prevPath: `changes.previous.${contactPath}`,
|
|
31
|
+
newPath: `changes.new.${contactPath}`
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -42,7 +42,6 @@ export const fieldConfigs = {
|
|
|
42
42
|
[AuditEventMessageType.FORM_TEAM_NAME_UPDATED]: createFieldConfig('the team name', 'Changed', 'teamName'),
|
|
43
43
|
[AuditEventMessageType.FORM_TEAM_EMAIL_UPDATED]: createFieldConfig('the shared team address', 'Updated', 'teamEmail'),
|
|
44
44
|
[AuditEventMessageType.FORM_NOTIFICATION_EMAIL_UPDATED]: createFieldConfig('where submitted forms are sent', 'Updated', 'notificationEmail'),
|
|
45
|
-
[AuditEventMessageType.FORM_PRIVACY_NOTICE_UPDATED]: createFieldConfig('the privacy notice link', 'Updated', 'privacyNoticeUrl'),
|
|
46
45
|
[AuditEventMessageType.FORM_SUBMISSION_GUIDANCE_UPDATED]: createFieldConfig('the next steps guidance', 'Updated', 'submissionGuidance'),
|
|
47
46
|
[AuditEventMessageType.FORM_SUPPORT_PHONE_UPDATED]: createFieldConfig('the support phone number', 'Updated', 'phone'),
|
|
48
47
|
[AuditEventMessageType.FORM_SUPPORT_EMAIL_UPDATED]: createFieldConfig('the support email address', 'Updated', 'address'),
|
|
@@ -53,7 +52,13 @@ export const fieldConfigs = {
|
|
|
53
52
|
* Support contact field configurations for change detection.
|
|
54
53
|
* Used when checking FORM_SUPPORT_CONTACT_UPDATED events.
|
|
55
54
|
*/
|
|
56
|
-
export const supportContactFields = [
|
|
55
|
+
export const supportContactFields = [createMultiField('phone number', 'contact.phone'), createMultiField('email address', 'contact.email.address'), createMultiField('email response time', 'contact.email.responseTime'), createMultiField('online contact link', 'contact.online.url'), createMultiField('online contact text', 'contact.online.text')];
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Privacy notice field configurations for change detection.
|
|
59
|
+
* Used when checking FORM_PRIVACY_NOTICE_UPDATED events.
|
|
60
|
+
*/
|
|
61
|
+
export const privacyNoticeFields = [createMultiField('privacy notice type', 'privacyNoticeType'), createMultiField('privacy notice text', 'privacyNoticeText'), createMultiField('privacy notice url', 'privacyNoticeUrl')];
|
|
57
62
|
|
|
58
63
|
/**
|
|
59
64
|
* Event types that are always considered valid (don't need change comparison).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consolidation.js","names":["AuditEventMessageType","createFieldConfig","label","verb","fieldName","prevPath","newPath","
|
|
1
|
+
{"version":3,"file":"consolidation.js","names":["AuditEventMessageType","createFieldConfig","label","verb","fieldName","prevPath","newPath","createMultiField","contactPath","fieldConfigs","FORM_TITLE_UPDATED","FORM_ORGANISATION_UPDATED","FORM_TEAM_NAME_UPDATED","FORM_TEAM_EMAIL_UPDATED","FORM_NOTIFICATION_EMAIL_UPDATED","FORM_SUBMISSION_GUIDANCE_UPDATED","FORM_SUPPORT_PHONE_UPDATED","FORM_SUPPORT_EMAIL_UPDATED","FORM_SUPPORT_ONLINE_UPDATED","supportContactFields","privacyNoticeFields","alwaysValidEvents","Set","FORM_CREATED","FORM_UPDATED","FORM_LIVE_CREATED_FROM_DRAFT","FORM_DRAFT_CREATED_FROM_LIVE","FORM_DRAFT_DELETED","FORM_MIGRATED","FORM_JSON_UPLOADED","FORM_JSON_DOWNLOADED","FORM_SUBMISSION_EXCEL_REQUESTED","FORM_CSAT_EXCEL_REQUESTED","isConsolidatedRecord","record","consolidatedCount"],"sources":["../../../../src/form/form-audit/consolidation.ts"],"sourcesContent":["import { AuditEventMessageType } from '~/src/form/form-audit/enums.js'\nimport {\n type AuditRecord,\n type ConsolidatedAuditRecord\n} from '~/src/form/form-audit/types.js'\n\n/**\n * Field configuration for audit events with change tracking.\n * Used by change detection logic to compare previous and new values.\n */\nexport interface FieldConfig {\n label: string\n verb: 'Updated' | 'Changed'\n prevPath: string\n newPath: string\n}\n\n/**\n * Audit field that comprises multiple fields - configuration for change detection.\n */\nexport interface MultiAuditFieldConfig {\n label: string\n prevPath: string\n newPath: string\n}\n\n/**\n * Creates a field configuration for audit events.\n */\nfunction createFieldConfig(\n label: string,\n verb: 'Updated' | 'Changed',\n fieldName: string\n): FieldConfig {\n return {\n label,\n verb,\n prevPath: `changes.previous.${fieldName}`,\n newPath: `changes.new.${fieldName}`\n }\n}\n\n/**\n * Creates a support contact field configuration.\n */\nfunction createMultiField(\n label: string,\n contactPath: string\n): MultiAuditFieldConfig {\n return {\n label,\n prevPath: `changes.previous.${contactPath}`,\n newPath: `changes.new.${contactPath}`\n }\n}\n\n/**\n * Field configurations for audit events with change tracking.\n * Maps event types to their data paths and display labels.\n */\nexport const fieldConfigs: Record<string, FieldConfig> = {\n [AuditEventMessageType.FORM_TITLE_UPDATED]: createFieldConfig(\n 'the form name',\n 'Updated',\n 'title'\n ),\n [AuditEventMessageType.FORM_ORGANISATION_UPDATED]: createFieldConfig(\n 'the lead organisation',\n 'Changed',\n 'organisation'\n ),\n [AuditEventMessageType.FORM_TEAM_NAME_UPDATED]: createFieldConfig(\n 'the team name',\n 'Changed',\n 'teamName'\n ),\n [AuditEventMessageType.FORM_TEAM_EMAIL_UPDATED]: createFieldConfig(\n 'the shared team address',\n 'Updated',\n 'teamEmail'\n ),\n [AuditEventMessageType.FORM_NOTIFICATION_EMAIL_UPDATED]: createFieldConfig(\n 'where submitted forms are sent',\n 'Updated',\n 'notificationEmail'\n ),\n [AuditEventMessageType.FORM_SUBMISSION_GUIDANCE_UPDATED]: createFieldConfig(\n 'the next steps guidance',\n 'Updated',\n 'submissionGuidance'\n ),\n [AuditEventMessageType.FORM_SUPPORT_PHONE_UPDATED]: createFieldConfig(\n 'the support phone number',\n 'Updated',\n 'phone'\n ),\n [AuditEventMessageType.FORM_SUPPORT_EMAIL_UPDATED]: createFieldConfig(\n 'the support email address',\n 'Updated',\n 'address'\n ),\n [AuditEventMessageType.FORM_SUPPORT_ONLINE_UPDATED]: createFieldConfig(\n 'the support contact link',\n 'Updated',\n 'url'\n )\n}\n\n/**\n * Support contact field configurations for change detection.\n * Used when checking FORM_SUPPORT_CONTACT_UPDATED events.\n */\nexport const supportContactFields: MultiAuditFieldConfig[] = [\n createMultiField('phone number', 'contact.phone'),\n createMultiField('email address', 'contact.email.address'),\n createMultiField('email response time', 'contact.email.responseTime'),\n createMultiField('online contact link', 'contact.online.url'),\n createMultiField('online contact text', 'contact.online.text')\n]\n\n/**\n * Privacy notice field configurations for change detection.\n * Used when checking FORM_PRIVACY_NOTICE_UPDATED events.\n */\nexport const privacyNoticeFields: MultiAuditFieldConfig[] = [\n createMultiField('privacy notice type', 'privacyNoticeType'),\n createMultiField('privacy notice text', 'privacyNoticeText'),\n createMultiField('privacy notice url', 'privacyNoticeUrl')\n]\n\n/**\n * Event types that are always considered valid (don't need change comparison).\n * These events represent actions rather than field updates.\n */\nexport const alwaysValidEvents = new Set<string>([\n AuditEventMessageType.FORM_CREATED,\n AuditEventMessageType.FORM_UPDATED,\n AuditEventMessageType.FORM_LIVE_CREATED_FROM_DRAFT,\n AuditEventMessageType.FORM_DRAFT_CREATED_FROM_LIVE,\n AuditEventMessageType.FORM_DRAFT_DELETED,\n AuditEventMessageType.FORM_MIGRATED,\n AuditEventMessageType.FORM_JSON_UPLOADED,\n AuditEventMessageType.FORM_JSON_DOWNLOADED,\n AuditEventMessageType.FORM_SUBMISSION_EXCEL_REQUESTED,\n AuditEventMessageType.FORM_CSAT_EXCEL_REQUESTED\n])\n\n/**\n * Type guard to check if an audit record is consolidated.\n * @param record - The audit record to check\n * @returns True if the record has consolidation metadata with count > 1\n */\nexport function isConsolidatedRecord(\n record: AuditRecord | ConsolidatedAuditRecord\n): record is ConsolidatedAuditRecord {\n return (\n 'consolidatedCount' in record &&\n typeof record.consolidatedCount === 'number' &&\n record.consolidatedCount > 1\n )\n}\n"],"mappings":"AAAA,SAASA,qBAAqB;;AAM9B;AACA;AACA;AACA;;AAQA;AACA;AACA;;AAOA;AACA;AACA;AACA,SAASC,iBAAiBA,CACxBC,KAAa,EACbC,IAA2B,EAC3BC,SAAiB,EACJ;EACb,OAAO;IACLF,KAAK;IACLC,IAAI;IACJE,QAAQ,EAAE,oBAAoBD,SAAS,EAAE;IACzCE,OAAO,EAAE,eAAeF,SAAS;EACnC,CAAC;AACH;;AAEA;AACA;AACA;AACA,SAASG,gBAAgBA,CACvBL,KAAa,EACbM,WAAmB,EACI;EACvB,OAAO;IACLN,KAAK;IACLG,QAAQ,EAAE,oBAAoBG,WAAW,EAAE;IAC3CF,OAAO,EAAE,eAAeE,WAAW;EACrC,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA,OAAO,MAAMC,YAAyC,GAAG;EACvD,CAACT,qBAAqB,CAACU,kBAAkB,GAAGT,iBAAiB,CAC3D,eAAe,EACf,SAAS,EACT,OACF,CAAC;EACD,CAACD,qBAAqB,CAACW,yBAAyB,GAAGV,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;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMc,iBAAiB,GAAG,IAAIC,GAAG,CAAS,CAC/CtB,qBAAqB,CAACuB,YAAY,EAClCvB,qBAAqB,CAACwB,YAAY,EAClCxB,qBAAqB,CAACyB,4BAA4B,EAClDzB,qBAAqB,CAAC0B,4BAA4B,EAClD1B,qBAAqB,CAAC2B,kBAAkB,EACxC3B,qBAAqB,CAAC4B,aAAa,EACnC5B,qBAAqB,CAAC6B,kBAAkB,EACxC7B,qBAAqB,CAAC8B,oBAAoB,EAC1C9B,qBAAqB,CAAC+B,+BAA+B,EACrD/B,qBAAqB,CAACgC,yBAAyB,CAChD,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAClCC,MAA6C,EACV;EACnC,OACE,mBAAmB,IAAIA,MAAM,IAC7B,OAAOA,MAAM,CAACC,iBAAiB,KAAK,QAAQ,IAC5CD,MAAM,CAACC,iBAAiB,GAAG,CAAC;AAEhC","ignoreList":[]}
|
|
@@ -10,9 +10,9 @@ export interface FieldConfig {
|
|
|
10
10
|
newPath: string;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Audit field that comprises multiple fields - configuration for change detection.
|
|
14
14
|
*/
|
|
15
|
-
export interface
|
|
15
|
+
export interface MultiAuditFieldConfig {
|
|
16
16
|
label: string;
|
|
17
17
|
prevPath: string;
|
|
18
18
|
newPath: string;
|
|
@@ -26,7 +26,12 @@ export declare const fieldConfigs: Record<string, FieldConfig>;
|
|
|
26
26
|
* Support contact field configurations for change detection.
|
|
27
27
|
* Used when checking FORM_SUPPORT_CONTACT_UPDATED events.
|
|
28
28
|
*/
|
|
29
|
-
export declare const supportContactFields:
|
|
29
|
+
export declare const supportContactFields: MultiAuditFieldConfig[];
|
|
30
|
+
/**
|
|
31
|
+
* Privacy notice field configurations for change detection.
|
|
32
|
+
* Used when checking FORM_PRIVACY_NOTICE_UPDATED events.
|
|
33
|
+
*/
|
|
34
|
+
export declare const privacyNoticeFields: MultiAuditFieldConfig[];
|
|
30
35
|
/**
|
|
31
36
|
* Event types that are always considered valid (don't need change comparison).
|
|
32
37
|
* These events represent actions rather than field updates.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consolidation.d.ts","sourceRoot":"","sources":["../../../../src/form/form-audit/consolidation.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,uBAAuB,EAC7B,MAAM,gCAAgC,CAAA;AAEvC;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,SAAS,GAAG,SAAS,CAAA;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"consolidation.d.ts","sourceRoot":"","sources":["../../../../src/form/form-audit/consolidation.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,uBAAuB,EAC7B,MAAM,gCAAgC,CAAA;AAEvC;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,SAAS,GAAG,SAAS,CAAA;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;CAChB;AAgCD;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CA8CpD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,qBAAqB,EAMvD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,qBAAqB,EAItD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,aAW5B,CAAA;AAEF;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,WAAW,GAAG,uBAAuB,GAC5C,MAAM,IAAI,uBAAuB,CAMnC"}
|
package/package.json
CHANGED
|
@@ -16,9 +16,9 @@ export interface FieldConfig {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* Audit field that comprises multiple fields - configuration for change detection.
|
|
20
20
|
*/
|
|
21
|
-
export interface
|
|
21
|
+
export interface MultiAuditFieldConfig {
|
|
22
22
|
label: string
|
|
23
23
|
prevPath: string
|
|
24
24
|
newPath: string
|
|
@@ -43,14 +43,14 @@ function createFieldConfig(
|
|
|
43
43
|
/**
|
|
44
44
|
* Creates a support contact field configuration.
|
|
45
45
|
*/
|
|
46
|
-
function
|
|
46
|
+
function createMultiField(
|
|
47
47
|
label: string,
|
|
48
48
|
contactPath: string
|
|
49
|
-
):
|
|
49
|
+
): MultiAuditFieldConfig {
|
|
50
50
|
return {
|
|
51
51
|
label,
|
|
52
|
-
prevPath: `changes.previous
|
|
53
|
-
newPath: `changes.new
|
|
52
|
+
prevPath: `changes.previous.${contactPath}`,
|
|
53
|
+
newPath: `changes.new.${contactPath}`
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -84,11 +84,6 @@ export const fieldConfigs: Record<string, FieldConfig> = {
|
|
|
84
84
|
'Updated',
|
|
85
85
|
'notificationEmail'
|
|
86
86
|
),
|
|
87
|
-
[AuditEventMessageType.FORM_PRIVACY_NOTICE_UPDATED]: createFieldConfig(
|
|
88
|
-
'the privacy notice link',
|
|
89
|
-
'Updated',
|
|
90
|
-
'privacyNoticeUrl'
|
|
91
|
-
),
|
|
92
87
|
[AuditEventMessageType.FORM_SUBMISSION_GUIDANCE_UPDATED]: createFieldConfig(
|
|
93
88
|
'the next steps guidance',
|
|
94
89
|
'Updated',
|
|
@@ -115,12 +110,22 @@ export const fieldConfigs: Record<string, FieldConfig> = {
|
|
|
115
110
|
* Support contact field configurations for change detection.
|
|
116
111
|
* Used when checking FORM_SUPPORT_CONTACT_UPDATED events.
|
|
117
112
|
*/
|
|
118
|
-
export const supportContactFields:
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
113
|
+
export const supportContactFields: MultiAuditFieldConfig[] = [
|
|
114
|
+
createMultiField('phone number', 'contact.phone'),
|
|
115
|
+
createMultiField('email address', 'contact.email.address'),
|
|
116
|
+
createMultiField('email response time', 'contact.email.responseTime'),
|
|
117
|
+
createMultiField('online contact link', 'contact.online.url'),
|
|
118
|
+
createMultiField('online contact text', 'contact.online.text')
|
|
119
|
+
]
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Privacy notice field configurations for change detection.
|
|
123
|
+
* Used when checking FORM_PRIVACY_NOTICE_UPDATED events.
|
|
124
|
+
*/
|
|
125
|
+
export const privacyNoticeFields: MultiAuditFieldConfig[] = [
|
|
126
|
+
createMultiField('privacy notice type', 'privacyNoticeType'),
|
|
127
|
+
createMultiField('privacy notice text', 'privacyNoticeText'),
|
|
128
|
+
createMultiField('privacy notice url', 'privacyNoticeUrl')
|
|
124
129
|
]
|
|
125
130
|
|
|
126
131
|
/**
|