@defra/forms-model 3.0.544 → 3.0.546

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.
@@ -1,5 +1,7 @@
1
1
  import Joi from 'joi';
2
- import { SubmissionEventMessageCategory, SubmissionEventMessageSchemaVersion, SubmissionEventMessageSource, SubmissionEventMessageType } from "./enums.js";
2
+ import { FormStatus } from "../../common/enums.js";
3
+ import { slugSchema, titleSchema } from "../form-metadata/index.js";
4
+ import { SecurityQuestionsEnum, SubmissionEventMessageCategory, SubmissionEventMessageSchemaVersion, SubmissionEventMessageSource, SubmissionEventMessageType } from "./enums.js";
3
5
  /**
4
6
  * Joi schema for `SubmitRecord` interface
5
7
  * @see {@link SubmitRecord}
@@ -31,10 +33,16 @@ export const formSubmitPayloadSchema = Joi.object().keys({
31
33
  repeaters: Joi.array().items(formSubmitRecordsetSchema).required().description('Repeatable section values from the form')
32
34
  }).required().description('Complete form submission payload structure with all form data');
33
35
  export const saveAndExitMessageData = Joi.object().keys({
34
- formId: Joi.string().required(),
36
+ form: {
37
+ id: Joi.string().required(),
38
+ slug: slugSchema,
39
+ title: titleSchema,
40
+ status: Joi.string().valid(FormStatus.Draft, FormStatus.Live).required(),
41
+ isPreview: Joi.boolean().required()
42
+ },
35
43
  email: Joi.string().required(),
36
44
  security: {
37
- question: Joi.string().required(),
45
+ question: Joi.string().valid(...Object.values(SecurityQuestionsEnum).map(value => value.toString())).required(),
38
46
  answer: Joi.string().required()
39
47
  },
40
48
  state: Joi.object().required()
@@ -44,8 +52,6 @@ export const submissionMessageSchema = Joi.object().keys({
44
52
  category: Joi.string().valid(...Object.values(SubmissionEventMessageCategory)).required().description('The message category - what does the entityId represent?'),
45
53
  source: Joi.string().valid(...Object.values(SubmissionEventMessageSource)).required().description('Source of the message - which service?'),
46
54
  type: Joi.string().valid(...Object.values(SubmissionEventMessageType)).description('Event type'),
47
- entityId: Joi.string().required().description('The id of the entity the category relates to'),
48
- traceId: Joi.string().optional().description('Trace id of the event - to link events across multiple services'),
49
55
  createdAt: Joi.date().required().description('The ISO timestamp where the action took place - should be the same as updated_at field in DB'),
50
56
  messageCreatedAt: Joi.date().required().description('ISO timestamp when the message was published'),
51
57
  data: saveAndExitMessageData
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Joi","SubmissionEventMessageCategory","SubmissionEventMessageSchemaVersion","SubmissionEventMessageSource","SubmissionEventMessageType","formSubmitRecordSchema","object","name","string","required","description","title","value","allow","formSubmitRecordsetSchema","array","items","formSubmitPayloadSchema","keys","retrievalKey","sessionId","main","repeaters","saveAndExitMessageData","formId","email","security","question","answer","state","submissionMessageSchema","schemaVersion","valid","Object","values","category","source","type","entityId","traceId","optional","createdAt","date","messageCreatedAt","data"],"sources":["../../../../src/form/form-submission/index.ts"],"sourcesContent":["import Joi from 'joi'\n\nimport {\n SubmissionEventMessageCategory,\n SubmissionEventMessageSchemaVersion,\n SubmissionEventMessageSource,\n SubmissionEventMessageType\n} from '~/src/form/form-submission/enums.js'\nimport {\n type SaveAndExitMessageData,\n type SubmissionMessage,\n type SubmitPayload,\n type SubmitRecord,\n type SubmitRecordset\n} from '~/src/form/form-submission/types.js'\n\n/**\n * Joi schema for `SubmitRecord` interface\n * @see {@link SubmitRecord}\n */\nexport const formSubmitRecordSchema = Joi.object<SubmitRecord>({\n name: Joi.string()\n .required()\n .description('Field identifier matching the component name'),\n title: Joi.string()\n .required()\n .description('Human-readable label for the field'),\n value: Joi.string()\n .required()\n .allow('')\n .description('User-submitted value for the field, may be empty')\n}).description('Individual field value in a form submission')\n\n/**\n * Joi schema for `SubmitRecordset` interface\n * @see {@link SubmitRecordset}\n */\nexport const formSubmitRecordsetSchema = Joi.object<SubmitRecordset>({\n name: Joi.string()\n .required()\n .description('Identifier for the repeatable section'),\n title: Joi.string()\n .required()\n .description('Human-readable title for the repeatable section'),\n value: Joi.array<SubmitRecord[]>()\n .items(Joi.array<SubmitRecord>().items(formSubmitRecordSchema).required())\n .required()\n .description(\n 'Array of record arrays, each representing a repeated instance'\n )\n}).description('Collection of repeated field values from a repeatable section')\n\n/**\n * Joi schema for `SubmitPayload` interface\n * @see {@link SubmitPayload}\n */\nexport const formSubmitPayloadSchema = Joi.object<SubmitPayload>()\n .keys({\n retrievalKey: Joi.string()\n .required()\n .description('Unique key to retrieve this submission later'),\n sessionId: Joi.string()\n .required()\n .description('User session identifier for tracking and security'),\n main: Joi.array<SubmitRecord>()\n .items(formSubmitRecordSchema)\n .required()\n .description('Main (non-repeating) field values from the form'),\n repeaters: Joi.array<SubmitRecordset>()\n .items(formSubmitRecordsetSchema)\n .required()\n .description('Repeatable section values from the form')\n })\n .required()\n .description('Complete form submission payload structure with all form data')\n\nexport const saveAndExitMessageData = Joi.object<SaveAndExitMessageData>().keys(\n {\n formId: Joi.string().required(),\n email: Joi.string().required(),\n security: {\n question: Joi.string().required(),\n answer: Joi.string().required()\n },\n state: Joi.object().required()\n }\n)\n\nexport const submissionMessageSchema = Joi.object<SubmissionMessage>().keys({\n schemaVersion: Joi.string()\n .valid(...Object.values(SubmissionEventMessageSchemaVersion))\n .required()\n .description(\n 'The version of the SubmissionMessage - bumped with breaking changes'\n ),\n category: Joi.string()\n .valid(...Object.values(SubmissionEventMessageCategory))\n .required()\n .description('The message category - what does the entityId represent?'),\n source: Joi.string()\n .valid(...Object.values(SubmissionEventMessageSource))\n .required()\n .description('Source of the message - which service?'),\n type: Joi.string()\n .valid(...Object.values(SubmissionEventMessageType))\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 messageCreatedAt: Joi.date()\n .required()\n .description('ISO timestamp when the message was published'),\n data: saveAndExitMessageData\n})\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,KAAK;AAErB,SACEC,8BAA8B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estionsEnum","SubmissionEventMessageCategory","SubmissionEventMessageSchemaVersion","SubmissionEventMessageSource","SubmissionEventMessageType","formSubmitRecordSchema","object","name","string","required","description","title","value","allow","formSubmitRecordsetSchema","array","items","formSubmitPayloadSchema","keys","retrievalKey","sessionId","main","repeaters","saveAndExitMessageData","form","id","slug","status","valid","Draft","Live","isPreview","boolean","email","security","question","Object","values","map","toString","answer","state","submissionMessageSchema","schemaVersion","category","source","type","createdAt","date","messageCreatedAt","data"],"sources":["../../../../src/form/form-submission/index.ts"],"sourcesContent":["import Joi from 'joi'\n\nimport { FormStatus } from '~/src/common/enums.js'\nimport { slugSchema, titleSchema } from '~/src/form/form-metadata/index.js'\nimport {\n SecurityQuestionsEnum,\n SubmissionEventMessageCategory,\n SubmissionEventMessageSchemaVersion,\n SubmissionEventMessageSource,\n SubmissionEventMessageType\n} from '~/src/form/form-submission/enums.js'\nimport {\n type SaveAndExitMessage,\n type SaveAndExitMessageData,\n type SubmitPayload,\n type SubmitRecord,\n type SubmitRecordset\n} from '~/src/form/form-submission/types.js'\n\n/**\n * Joi schema for `SubmitRecord` interface\n * @see {@link SubmitRecord}\n */\nexport const formSubmitRecordSchema = Joi.object<SubmitRecord>({\n name: Joi.string()\n .required()\n .description('Field identifier matching the component name'),\n title: Joi.string()\n .required()\n .description('Human-readable label for the field'),\n value: Joi.string()\n .required()\n .allow('')\n .description('User-submitted value for the field, may be empty')\n}).description('Individual field value in a form submission')\n\n/**\n * Joi schema for `SubmitRecordset` interface\n * @see {@link SubmitRecordset}\n */\nexport const formSubmitRecordsetSchema = Joi.object<SubmitRecordset>({\n name: Joi.string()\n .required()\n .description('Identifier for the repeatable section'),\n title: Joi.string()\n .required()\n .description('Human-readable title for the repeatable section'),\n value: Joi.array<SubmitRecord[]>()\n .items(Joi.array<SubmitRecord>().items(formSubmitRecordSchema).required())\n .required()\n .description(\n 'Array of record arrays, each representing a repeated instance'\n )\n}).description('Collection of repeated field values from a repeatable section')\n\n/**\n * Joi schema for `SubmitPayload` interface\n * @see {@link SubmitPayload}\n */\nexport const formSubmitPayloadSchema = Joi.object<SubmitPayload>()\n .keys({\n retrievalKey: Joi.string()\n .required()\n .description('Unique key to retrieve this submission later'),\n sessionId: Joi.string()\n .required()\n .description('User session identifier for tracking and security'),\n main: Joi.array<SubmitRecord>()\n .items(formSubmitRecordSchema)\n .required()\n .description('Main (non-repeating) field values from the form'),\n repeaters: Joi.array<SubmitRecordset>()\n .items(formSubmitRecordsetSchema)\n .required()\n .description('Repeatable section values from the form')\n })\n .required()\n .description('Complete form submission payload structure with all form data')\n\nexport const saveAndExitMessageData = Joi.object<SaveAndExitMessageData>().keys(\n {\n form: {\n id: Joi.string().required(),\n slug: slugSchema,\n title: titleSchema,\n status: Joi.string().valid(FormStatus.Draft, FormStatus.Live).required(),\n isPreview: Joi.boolean().required()\n },\n email: Joi.string().required(),\n security: {\n question: Joi.string()\n .valid(\n ...Object.values(SecurityQuestionsEnum).map((value) =>\n value.toString()\n )\n )\n .required(),\n answer: Joi.string().required()\n },\n state: Joi.object().required()\n }\n)\n\nexport const submissionMessageSchema = Joi.object<SaveAndExitMessage>().keys({\n schemaVersion: Joi.string()\n .valid(...Object.values(SubmissionEventMessageSchemaVersion))\n .required()\n .description(\n 'The version of the SubmissionMessage - bumped with breaking changes'\n ),\n category: Joi.string()\n .valid(...Object.values(SubmissionEventMessageCategory))\n .required()\n .description('The message category - what does the entityId represent?'),\n source: Joi.string()\n .valid(...Object.values(SubmissionEventMessageSource))\n .required()\n .description('Source of the message - which service?'),\n type: Joi.string()\n .valid(...Object.values(SubmissionEventMessageType))\n .description('Event type'),\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 messageCreatedAt: Joi.date()\n .required()\n .description('ISO timestamp when the message was published'),\n data: saveAndExitMessageData\n})\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,KAAK;AAErB,SAASC,UAAU;AACnB,SAASC,UAAU,EAAEC,W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C,CAAC,CACVC,WAAW,CACV,8FACF,CAAC;EACHuC,gBAAgB,EAAErD,GAAG,CAACoD,IAAI,CAAC,CAAC,CACzBvC,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,8CAA8C,CAAC;EAC9DwC,IAAI,EAAE3B;AACR,CAAC,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../src/form/form-submission/types.ts"],"sourcesContent":["import {\n type SubmissionEventMessageCategory,\n type SubmissionEventMessageSchemaVersion,\n type SubmissionEventMessageSource,\n type SubmissionEventMessageType\n} from '~/src/form/form-submission/enums.js'\nimport {\n formSubmitPayloadSchema,\n formSubmitRecordSchema,\n formSubmitRecordsetSchema\n} from '~/src/form/form-submission/index.js'\n\n/**\n * Interface for an individual submit record\n * @see {@link formSubmitRecordSchema}\n */\nexport interface SubmitRecord {\n /**\n * The field name\n */\n name: string\n\n /**\n * The field title\n */\n title: string\n\n /**\n * The field display value\n */\n value: string\n}\n\n/**\n * Interface for an individual submit recordset (e.g. a repeater question set)\n * @see {@link formSubmitRecordsetSchema}\n */\nexport interface SubmitRecordset {\n /**\n * The name of the recordset\n */\n name: string\n\n /**\n * The title of the recordset\n */\n title: string\n\n /**\n * The record items\n */\n value: SubmitRecord[][]\n}\n\n/**\n * Interface for the submission-api `/submit` payload\n * @see {@link formSubmitPayloadSchema}\n */\nexport interface SubmitPayload {\n /**\n * The retrieval key for files created in the submission\n */\n retrievalKey: string\n\n /**\n * The id of the user session\n */\n sessionId: string\n\n /**\n * The main form anwsers\n */\n main: SubmitRecord[]\n\n /**\n * The repeaters form answers\n */\n repeaters: SubmitRecordset[]\n}\n\n/**\n * Interface for the submission-api `/submit` response payload\n */\nexport interface SubmitResponsePayload {\n message: string\n result: {\n files: {\n main: string\n repeaters: Record<string, string>\n }\n }\n}\n\nexport interface SaveAndExitMessageData {\n formId: string\n email: string\n security: {\n question: string\n answer: string\n }\n state: object\n}\n\nexport type SubmissionMessageData = SaveAndExitMessageData\n\nexport interface SubmissionMessage {\n schemaVersion: SubmissionEventMessageSchemaVersion\n category: SubmissionEventMessageCategory\n source: SubmissionEventMessageSource\n type: SubmissionEventMessageType\n entityId: string\n traceId?: string\n createdAt: Date\n messageCreatedAt: Date\n data: SubmissionMessageData\n}\n\nexport interface SaveAndExitMessage extends SubmissionMessage {\n category: SubmissionEventMessageCategory.RUNNER\n type: SubmissionEventMessageType.RUNNER_SAVE_AND_EXIT\n}\n\nexport type RunnerMessage = SaveAndExitMessage\n\nexport interface RunnerRecordBase {\n messageId: string\n recordCreatedAt: Date\n}\n\nexport interface RunnerRecordInputMeta extends RunnerRecordBase {\n id: string\n}\n\nexport type RunnerRecordInput = RunnerMessage & RunnerRecordBase\n\nexport type RunnerRecord = RunnerMessage & RunnerRecordInputMeta\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../src/form/form-submission/types.ts"],"sourcesContent":["import { type FormStatus } from '~/src/common/enums.js'\nimport {\n type SecurityQuestionsEnum,\n type SubmissionEventMessageCategory,\n type SubmissionEventMessageSchemaVersion,\n type SubmissionEventMessageSource,\n type SubmissionEventMessageType\n} from '~/src/form/form-submission/enums.js'\nimport {\n formSubmitPayloadSchema,\n formSubmitRecordSchema,\n formSubmitRecordsetSchema\n} from '~/src/form/form-submission/index.js'\n\n/**\n * Interface for an individual submit record\n * @see {@link formSubmitRecordSchema}\n */\nexport interface SubmitRecord {\n /**\n * The field name\n */\n name: string\n\n /**\n * The field title\n */\n title: string\n\n /**\n * The field display value\n */\n value: string\n}\n\n/**\n * Interface for an individual submit recordset (e.g. a repeater question set)\n * @see {@link formSubmitRecordsetSchema}\n */\nexport interface SubmitRecordset {\n /**\n * The name of the recordset\n */\n name: string\n\n /**\n * The title of the recordset\n */\n title: string\n\n /**\n * The record items\n */\n value: SubmitRecord[][]\n}\n\n/**\n * Interface for the submission-api `/submit` payload\n * @see {@link formSubmitPayloadSchema}\n */\nexport interface SubmitPayload {\n /**\n * The retrieval key for files created in the submission\n */\n retrievalKey: string\n\n /**\n * The id of the user session\n */\n sessionId: string\n\n /**\n * The main form anwsers\n */\n main: SubmitRecord[]\n\n /**\n * The repeaters form answers\n */\n repeaters: SubmitRecordset[]\n}\n\n/**\n * Interface for the submission-api `/submit` response payload\n */\nexport interface SubmitResponsePayload {\n message: string\n result: {\n files: {\n main: string\n repeaters: Record<string, string>\n }\n }\n}\n\nexport interface SaveAndExitMessageData {\n form: {\n id: string\n slug: string\n title: string\n status: FormStatus\n isPreview: boolean\n }\n email: string\n security: {\n question: SecurityQuestionsEnum\n answer: string\n }\n state: object\n}\n\nexport interface SaveAndExitMessage {\n schemaVersion: SubmissionEventMessageSchemaVersion\n source: SubmissionEventMessageSource\n createdAt: Date\n messageCreatedAt: Date\n category: SubmissionEventMessageCategory.RUNNER\n type: SubmissionEventMessageType.RUNNER_SAVE_AND_EXIT\n data: SaveAndExitMessageData\n}\n\nexport type RunnerMessage = SaveAndExitMessage\n\nexport interface RunnerRecordBase {\n messageId: string\n recordCreatedAt: Date\n}\n\nexport interface RunnerRecordInputMeta extends RunnerRecordBase {\n id: string\n}\n\nexport type RunnerRecordInput = RunnerMessage & RunnerRecordBase\n\nexport type RunnerRecord = RunnerMessage & RunnerRecordInputMeta\n"],"mappings":"","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import Joi from 'joi';
2
- import { type SaveAndExitMessageData, type SubmissionMessage, type SubmitPayload, type SubmitRecord, type SubmitRecordset } from '../../form/form-submission/types.js';
2
+ import { type SaveAndExitMessage, type SaveAndExitMessageData, type SubmitPayload, type SubmitRecord, type SubmitRecordset } from '../../form/form-submission/types.js';
3
3
  /**
4
4
  * Joi schema for `SubmitRecord` interface
5
5
  * @see {@link SubmitRecord}
@@ -16,5 +16,5 @@ export declare const formSubmitRecordsetSchema: Joi.ObjectSchema<SubmitRecordset
16
16
  */
17
17
  export declare const formSubmitPayloadSchema: Joi.ObjectSchema<SubmitPayload>;
18
18
  export declare const saveAndExitMessageData: Joi.ObjectSchema<SaveAndExitMessageData>;
19
- export declare const submissionMessageSchema: Joi.ObjectSchema<SubmissionMessage>;
19
+ export declare const submissionMessageSchema: Joi.ObjectSchema<SaveAndExitMessage>;
20
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/form/form-submission/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AAQrB,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,eAAe,EACrB,MAAM,qCAAqC,CAAA;AAE5C;;;GAGG;AACH,eAAO,MAAM,sBAAsB,gCAW0B,CAAA;AAE7D;;;GAGG;AACH,eAAO,MAAM,yBAAyB,mCAayC,CAAA;AAE/E;;;GAGG;AACH,eAAO,MAAM,uBAAuB,iCAkB2C,CAAA;AAE/E,eAAO,MAAM,sBAAsB,0CAUlC,CAAA;AAED,eAAO,MAAM,uBAAuB,qCAmClC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/form/form-submission/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AAWrB,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,eAAe,EACrB,MAAM,qCAAqC,CAAA;AAE5C;;;GAGG;AACH,eAAO,MAAM,sBAAsB,gCAW0B,CAAA;AAE7D;;;GAGG;AACH,eAAO,MAAM,yBAAyB,mCAayC,CAAA;AAE/E;;;GAGG;AACH,eAAO,MAAM,uBAAuB,iCAkB2C,CAAA;AAE/E,eAAO,MAAM,sBAAsB,0CAsBlC,CAAA;AAED,eAAO,MAAM,uBAAuB,sCA2BlC,CAAA"}
@@ -1,4 +1,5 @@
1
- import { type SubmissionEventMessageCategory, type SubmissionEventMessageSchemaVersion, type SubmissionEventMessageSource, type SubmissionEventMessageType } from '../../form/form-submission/enums.js';
1
+ import { type FormStatus } from '../../common/enums.js';
2
+ import { type SecurityQuestionsEnum, type SubmissionEventMessageCategory, type SubmissionEventMessageSchemaVersion, type SubmissionEventMessageSource, type SubmissionEventMessageType } from '../../form/form-submission/enums.js';
2
3
  /**
3
4
  * Interface for an individual submit record
4
5
  * @see {@link formSubmitRecordSchema}
@@ -70,29 +71,28 @@ export interface SubmitResponsePayload {
70
71
  };
71
72
  }
72
73
  export interface SaveAndExitMessageData {
73
- formId: string;
74
+ form: {
75
+ id: string;
76
+ slug: string;
77
+ title: string;
78
+ status: FormStatus;
79
+ isPreview: boolean;
80
+ };
74
81
  email: string;
75
82
  security: {
76
- question: string;
83
+ question: SecurityQuestionsEnum;
77
84
  answer: string;
78
85
  };
79
86
  state: object;
80
87
  }
81
- export type SubmissionMessageData = SaveAndExitMessageData;
82
- export interface SubmissionMessage {
88
+ export interface SaveAndExitMessage {
83
89
  schemaVersion: SubmissionEventMessageSchemaVersion;
84
- category: SubmissionEventMessageCategory;
85
90
  source: SubmissionEventMessageSource;
86
- type: SubmissionEventMessageType;
87
- entityId: string;
88
- traceId?: string;
89
91
  createdAt: Date;
90
92
  messageCreatedAt: Date;
91
- data: SubmissionMessageData;
92
- }
93
- export interface SaveAndExitMessage extends SubmissionMessage {
94
93
  category: SubmissionEventMessageCategory.RUNNER;
95
94
  type: SubmissionEventMessageType.RUNNER_SAVE_AND_EXIT;
95
+ data: SaveAndExitMessageData;
96
96
  }
97
97
  export type RunnerMessage = SaveAndExitMessage;
98
98
  export interface RunnerRecordBase {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/form/form-submission/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,8BAA8B,EACnC,KAAK,mCAAmC,EACxC,KAAK,4BAA4B,EACjC,KAAK,0BAA0B,EAChC,MAAM,qCAA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Ae,EAAE,IAAI,CAAA;CACtB;AAED,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC7D,EAAE,EAAE,MAAM,CAAA;CACX;AAED,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG,gBAAgB,CAAA;AAEhE,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,qBAAqB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/forms-model",
3
- "version": "3.0.544",
3
+ "version": "3.0.546",
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",
@@ -1,14 +1,17 @@
1
1
  import Joi from 'joi'
2
2
 
3
+ import { FormStatus } from '~/src/common/enums.js'
4
+ import { slugSchema, titleSchema } from '~/src/form/form-metadata/index.js'
3
5
  import {
6
+ SecurityQuestionsEnum,
4
7
  SubmissionEventMessageCategory,
5
8
  SubmissionEventMessageSchemaVersion,
6
9
  SubmissionEventMessageSource,
7
10
  SubmissionEventMessageType
8
11
  } from '~/src/form/form-submission/enums.js'
9
12
  import {
13
+ type SaveAndExitMessage,
10
14
  type SaveAndExitMessageData,
11
- type SubmissionMessage,
12
15
  type SubmitPayload,
13
16
  type SubmitRecord,
14
17
  type SubmitRecordset
@@ -76,17 +79,29 @@ export const formSubmitPayloadSchema = Joi.object<SubmitPayload>()
76
79
 
77
80
  export const saveAndExitMessageData = Joi.object<SaveAndExitMessageData>().keys(
78
81
  {
79
- formId: Joi.string().required(),
82
+ form: {
83
+ id: Joi.string().required(),
84
+ slug: slugSchema,
85
+ title: titleSchema,
86
+ status: Joi.string().valid(FormStatus.Draft, FormStatus.Live).required(),
87
+ isPreview: Joi.boolean().required()
88
+ },
80
89
  email: Joi.string().required(),
81
90
  security: {
82
- question: Joi.string().required(),
91
+ question: Joi.string()
92
+ .valid(
93
+ ...Object.values(SecurityQuestionsEnum).map((value) =>
94
+ value.toString()
95
+ )
96
+ )
97
+ .required(),
83
98
  answer: Joi.string().required()
84
99
  },
85
100
  state: Joi.object().required()
86
101
  }
87
102
  )
88
103
 
89
- export const submissionMessageSchema = Joi.object<SubmissionMessage>().keys({
104
+ export const submissionMessageSchema = Joi.object<SaveAndExitMessage>().keys({
90
105
  schemaVersion: Joi.string()
91
106
  .valid(...Object.values(SubmissionEventMessageSchemaVersion))
92
107
  .required()
@@ -104,14 +119,6 @@ export const submissionMessageSchema = Joi.object<SubmissionMessage>().keys({
104
119
  type: Joi.string()
105
120
  .valid(...Object.values(SubmissionEventMessageType))
106
121
  .description('Event type'),
107
- entityId: Joi.string()
108
- .required()
109
- .description('The id of the entity the category relates to'),
110
- traceId: Joi.string()
111
- .optional()
112
- .description(
113
- 'Trace id of the event - to link events across multiple services'
114
- ),
115
122
  createdAt: Joi.date()
116
123
  .required()
117
124
  .description(
@@ -1,4 +1,6 @@
1
+ import { type FormStatus } from '~/src/common/enums.js'
1
2
  import {
3
+ type SecurityQuestionsEnum,
2
4
  type SubmissionEventMessageCategory,
3
5
  type SubmissionEventMessageSchemaVersion,
4
6
  type SubmissionEventMessageSource,
@@ -92,32 +94,29 @@ export interface SubmitResponsePayload {
92
94
  }
93
95
 
94
96
  export interface SaveAndExitMessageData {
95
- formId: string
97
+ form: {
98
+ id: string
99
+ slug: string
100
+ title: string
101
+ status: FormStatus
102
+ isPreview: boolean
103
+ }
96
104
  email: string
97
105
  security: {
98
- question: string
106
+ question: SecurityQuestionsEnum
99
107
  answer: string
100
108
  }
101
109
  state: object
102
110
  }
103
111
 
104
- export type SubmissionMessageData = SaveAndExitMessageData
105
-
106
- export interface SubmissionMessage {
112
+ export interface SaveAndExitMessage {
107
113
  schemaVersion: SubmissionEventMessageSchemaVersion
108
- category: SubmissionEventMessageCategory
109
114
  source: SubmissionEventMessageSource
110
- type: SubmissionEventMessageType
111
- entityId: string
112
- traceId?: string
113
115
  createdAt: Date
114
116
  messageCreatedAt: Date
115
- data: SubmissionMessageData
116
- }
117
-
118
- export interface SaveAndExitMessage extends SubmissionMessage {
119
117
  category: SubmissionEventMessageCategory.RUNNER
120
118
  type: SubmissionEventMessageType.RUNNER_SAVE_AND_EXIT
119
+ data: SaveAndExitMessageData
121
120
  }
122
121
 
123
122
  export type RunnerMessage = SaveAndExitMessage