@defra/forms-model 3.0.93 → 3.0.95
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-definition/types.js.map +1 -1
- package/dist/module/form/form-metadata/index.js +25 -3
- package/dist/module/form/form-metadata/index.js.map +1 -1
- package/dist/module/form/form-metadata/types.js.map +1 -1
- package/dist/types/form/form-definition/types.d.ts +1 -1
- package/dist/types/form/form-definition/types.d.ts.map +1 -1
- package/dist/types/form/form-metadata/index.d.ts +13 -1
- package/dist/types/form/form-metadata/index.d.ts.map +1 -1
- package/dist/types/form/form-metadata/types.d.ts +22 -1
- package/dist/types/form/form-metadata/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/form/form-definition/types.ts +1 -1
- package/src/form/form-metadata/index.ts +30 -4
- package/src/form/form-metadata/types.ts +29 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/form/form-definition/types.ts"],"sourcesContent":["import { type ComponentDef } from '~/src/components/types.js'\nimport { type Condition } from '~/src/conditions/condition.js'\nimport { type OutputType } from '~/src/data-model/enums.js'\nimport { formDefinitionSchema } from '~/src/form/form-definition/index.js'\n\ntype Toggleable<T> = boolean | T\n\nexport interface Next {\n path: string\n condition?: string\n redirect?: string\n}\n\nexport type Link = Next\n\nexport interface Page {\n title: string\n path: string\n controller?: string\n components?: ComponentDef[]\n section
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/form/form-definition/types.ts"],"sourcesContent":["import { type ComponentDef } from '~/src/components/types.js'\nimport { type Condition } from '~/src/conditions/condition.js'\nimport { type OutputType } from '~/src/data-model/enums.js'\nimport { formDefinitionSchema } from '~/src/form/form-definition/index.js'\n\ntype Toggleable<T> = boolean | T\n\nexport interface Next {\n path: string\n condition?: string\n redirect?: string\n}\n\nexport type Link = Next\n\nexport interface Page {\n title: string\n path: string\n controller?: string\n components?: ComponentDef[]\n section?: string // the section ID\n next?: Next[]\n repeatField?: string\n backLinkFallback?: string\n}\n\nexport interface RepeatingFieldPage extends Page {\n controller: 'RepeatingFieldPageController'\n options: {\n summaryDisplayMode?: {\n samePage?: boolean\n separatePage?: boolean\n hideRowTitles?: boolean\n }\n customText?: {\n separatePageTitle?: string\n }\n }\n}\n\nexport interface Section {\n name: string\n title: string\n hideTitle?: boolean\n}\n\nexport interface Item {\n text: string\n value: string | number | boolean\n description?: string\n conditional?: { components: ComponentDef[] } | null\n condition?: string | null\n}\n\nexport interface List {\n name: string\n title: string\n type: 'string' | 'number' | 'boolean'\n items: Item[]\n}\n\nexport interface Feedback {\n feedbackForm?: boolean\n url?: string\n emailAddress?: string\n}\n\nexport interface PhaseBanner {\n phase?: 'alpha' | 'beta'\n feedbackUrl?: string\n}\n\nexport interface MultipleApiKeys {\n test?: string\n production?: string\n}\n\nexport interface EmailOutputConfiguration {\n emailAddress: string\n}\n\nexport interface NotifyOutputConfiguration {\n apiKey: string\n templateId: string\n emailField: string\n personalisation: string[]\n personalisationFieldCustomisation?: Record<string, string[]>\n addReferencesToPersonalisation?: boolean\n emailReplyToIdConfiguration?: {\n emailReplyToId: string\n condition?: string\n }[]\n}\n\nexport interface WebhookOutputConfiguration {\n url: string\n allowRetry?: boolean\n}\n\nexport type OutputConfiguration =\n | EmailOutputConfiguration\n | NotifyOutputConfiguration\n | WebhookOutputConfiguration\n\nexport interface Output {\n name: string\n title: string\n type: OutputType\n outputConfiguration: OutputConfiguration\n}\n\nexport interface ConfirmationPage {\n customText: {\n title: string\n paymentSkipped: Toggleable<string>\n nextSteps: Toggleable<string>\n }\n components: ComponentDef[]\n}\n\nexport interface PaymentSkippedWarningPage {\n customText: {\n title: string\n caption: string\n body: string\n }\n}\n\nexport interface SpecialPages {\n confirmationPage?: ConfirmationPage\n paymentSkippedWarningPage?: PaymentSkippedWarningPage\n}\n\nexport interface Fee {\n description: string\n amount: number\n multiplier?: string\n condition?: string\n prefix?: string\n}\n\nexport interface FeeOptions {\n payApiKey?: string | MultipleApiKeys\n paymentReferenceFormat?: string\n payReturnUrl?: string\n allowSubmissionWithoutPayment: boolean\n maxAttempts: number\n customPayErrorMessage?: string\n showPaymentSkippedWarningPage: boolean\n}\n\nexport type ConditionWrapperValue =\n | string\n | {\n name: string\n conditions: Condition[]\n }\n\nexport interface ConditionRawData {\n name: string\n displayName: string\n value: ConditionWrapperValue\n}\n\n/**\n * Interface for `formDefinitionSchema` Joi schema\n * @see {@link formDefinitionSchema}\n */\nexport interface FormDefinition {\n pages: (Page | RepeatingFieldPage)[]\n conditions: ConditionRawData[]\n lists: List[]\n sections: Section[]\n startPage?: Page['path']\n name?: string\n feedback?: Feedback\n phaseBanner?: PhaseBanner\n fees: Fee[]\n skipSummary?: boolean\n outputs: Output[]\n declaration?: string\n metadata?: Record<string, unknown>\n payApiKey?: string | MultipleApiKeys\n specialPages?: SpecialPages\n paymentReferenceFormat?: string\n feeOptions?: FeeOptions\n version?: number\n}\n"],"mappings":"","ignoreList":[]}
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import Joi from 'joi';
|
2
2
|
export const organisations = ['Animal and Plant Health Agency – APHA', 'Centre for Environment, Fisheries and Aquaculture Science – Cefas', 'Defra', 'Environment Agency', 'Forestry Commission', 'Marine Management Organisation – MMO', 'Natural England', 'Rural Payments Agency – RPA', 'Veterinary Medicines Directorate – VMD'];
|
3
|
+
export const idSchema = Joi.string().hex().length(24).required();
|
3
4
|
export const titleSchema = Joi.string().max(250).trim().required();
|
5
|
+
export const slugSchema = Joi.string().required();
|
4
6
|
export const organisationSchema = Joi.string().valid(...organisations).required();
|
5
7
|
export const teamNameSchema = Joi.string().max(100).trim().required();
|
6
8
|
export const teamEmailSchema = Joi.string().email({
|
@@ -10,13 +12,33 @@ export const teamEmailSchema = Joi.string().email({
|
|
10
12
|
}).trim().required();
|
11
13
|
|
12
14
|
/**
|
13
|
-
* Joi schema for `
|
14
|
-
* @see {@link
|
15
|
+
* Joi schema for `FormMetadataInput` interface
|
16
|
+
* @see {@link FormMetadataInput}
|
15
17
|
*/
|
16
|
-
export const
|
18
|
+
export const formMetadataInputSchema = Joi.object().keys({
|
17
19
|
title: titleSchema,
|
18
20
|
organisation: organisationSchema,
|
19
21
|
teamName: teamNameSchema,
|
20
22
|
teamEmail: teamEmailSchema
|
21
23
|
}).required();
|
24
|
+
|
25
|
+
/**
|
26
|
+
* Joi schema for `FormMetadataState` interface
|
27
|
+
* @see {@link FormMetadataState}
|
28
|
+
*/
|
29
|
+
export const formMetadataStateSchema = Joi.object().keys({
|
30
|
+
createdAt: Joi.date().iso().required(),
|
31
|
+
updatedAt: Joi.date().iso().required()
|
32
|
+
});
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Joi schema for `FormMetadata` interface
|
36
|
+
* @see {@link FormMetadata}
|
37
|
+
*/
|
38
|
+
export const formMetadataSchema = formMetadataInputSchema.append({
|
39
|
+
id: idSchema,
|
40
|
+
slug: slugSchema,
|
41
|
+
draft: formMetadataStateSchema.required(),
|
42
|
+
live: formMetadataStateSchema
|
43
|
+
});
|
22
44
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","names":["Joi","organisations","
|
1
|
+
{"version":3,"file":"index.js","names":["Joi","organisations","idSchema","string","hex","length","required","titleSchema","max","trim","slugSchema","organisationSchema","valid","teamNameSchema","teamEmailSchema","email","tlds","allow","formMetadataInputSchema","object","keys","title","organisation","teamName","teamEmail","formMetadataStateSchema","createdAt","date","iso","updatedAt","formMetadataSchema","append","id","slug","draft","live"],"sources":["../../../../src/form/form-metadata/index.ts"],"sourcesContent":["import Joi from 'joi'\n\nimport {\n type FormMetadataState,\n type FormMetadata,\n type FormMetadataInput\n} from '~/src/form/form-metadata/types.js'\n\nexport const organisations = [\n 'Animal and Plant Health Agency – APHA',\n 'Centre for Environment, Fisheries and Aquaculture Science – Cefas',\n 'Defra',\n 'Environment Agency',\n 'Forestry Commission',\n 'Marine Management Organisation – MMO',\n 'Natural England',\n 'Rural Payments Agency – RPA',\n 'Veterinary Medicines Directorate – VMD'\n]\n\nexport const idSchema = Joi.string().hex().length(24).required()\nexport const titleSchema = Joi.string().max(250).trim().required()\nexport const slugSchema = Joi.string().required()\nexport const organisationSchema = Joi.string()\n .valid(...organisations)\n .required()\nexport const teamNameSchema = Joi.string().max(100).trim().required()\nexport const teamEmailSchema = Joi.string()\n .email({ tlds: { allow: ['uk'] } })\n .trim()\n .required()\n\n/**\n * Joi schema for `FormMetadataInput` interface\n * @see {@link FormMetadataInput}\n */\nexport const formMetadataInputSchema = Joi.object<FormMetadataInput>()\n .keys({\n title: titleSchema,\n organisation: organisationSchema,\n teamName: teamNameSchema,\n teamEmail: teamEmailSchema\n })\n .required()\n\n/**\n * Joi schema for `FormMetadataState` interface\n * @see {@link FormMetadataState}\n */\nexport const formMetadataStateSchema = Joi.object<FormMetadataState>().keys({\n createdAt: Joi.date().iso().required(),\n updatedAt: Joi.date().iso().required()\n})\n\n/**\n * Joi schema for `FormMetadata` interface\n * @see {@link FormMetadata}\n */\nexport const formMetadataSchema = formMetadataInputSchema.append<FormMetadata>({\n id: idSchema,\n slug: slugSchema,\n draft: formMetadataStateSchema.required(),\n live: formMetadataStateSchema\n})\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,KAAK;AAQrB,OAAO,MAAMC,aAAa,GAAG,CAC3B,uCAAuC,EACvC,mEAAmE,EACnE,OAAO,EACP,oBAAoB,EACpB,qBAAqB,EACrB,sCAAsC,EACtC,iBAAiB,EACjB,6BAA6B,EAC7B,wCAAwC,CACzC;AAED,OAAO,MAAMC,QAAQ,GAAGF,GAAG,CAACG,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAACC,MAAM,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC;AAChE,OAAO,MAAMC,WAAW,GAAGP,GAAG,CAACG,MAAM,CAAC,CAAC,CAACK,GAAG,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC,CAAC,CAAC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uBAAuB,CAACa,MAAM,CAAe;EAC7EC,EAAE,EAAE9B,QAAQ;EACZ+B,IAAI,EAAEvB,UAAU;EAChBwB,KAAK,EAAET,uBAAuB,CAACnB,QAAQ,CAAC,CAAC;EACzC6B,IAAI,EAAEV;AACR,CAAC,CAAC","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/form/form-metadata/types.ts"],"sourcesContent":["import { formMetadataSchema } from '~/src/form/form-metadata/index.js'\n\n/**\n * Interface for `formMetadataSchema` Joi schema\n * @see {@link formMetadataSchema}\n */\nexport interface FormMetadata {\n /**\n * The id of the form\n */\n id: string\n\n /**\n * The human-readable slug id of the form\n */\n slug: string\n\n /**\n * The human-readable title of the form\n */\n title: string\n\n /**\n * The organisation this form belongs to\n */\n organisation: string\n\n /**\n * The name of the team who own this form\n */\n teamName: string\n\n /**\n * The email of the team who own this form\n */\n teamEmail: string\n}\n\nexport type FormByIdInput = Pick<FormMetadata, 'id'>\nexport type FormBySlugInput = Pick<FormMetadata, 'slug'>\nexport type FormMetadataDocument = Omit<FormMetadata, 'id'>\nexport type FormMetadataInput = Omit
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/form/form-metadata/types.ts"],"sourcesContent":["import { formMetadataSchema } from '~/src/form/form-metadata/index.js'\n\n/**\n * Interface for metadata state (draft & live)\n */\nexport interface FormMetadataState {\n /**\n * The date the form state was created\n */\n createdAt: Date\n\n /**\n * The date the form state was last updated\n */\n updatedAt: Date\n}\n\n/**\n * Interface for `formMetadataSchema` Joi schema\n * @see {@link formMetadataSchema}\n */\nexport interface FormMetadata {\n /**\n * The id of the form\n */\n id: string\n\n /**\n * The human-readable slug id of the form\n */\n slug: string\n\n /**\n * The human-readable title of the form\n */\n title: string\n\n /**\n * The organisation this form belongs to\n */\n organisation: string\n\n /**\n * The name of the team who own this form\n */\n teamName: string\n\n /**\n * The email of the team who own this form\n */\n teamEmail: string\n\n /**\n * The draft state of the form\n */\n draft: FormMetadataState\n\n /**\n * The live state of the form\n */\n live?: FormMetadataState\n}\n\nexport type FormByIdInput = Pick<FormMetadata, 'id'>\nexport type FormBySlugInput = Pick<FormMetadata, 'slug'>\nexport type FormMetadataDocument = Omit<FormMetadata, 'id'>\nexport type FormMetadataInput = Omit<\n FormMetadata,\n 'id' | 'slug' | 'draft' | 'live'\n>\n"],"mappings":"","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/form/form-definition/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAC9D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAG3D,KAAK,UAAU,CAAC,CAAC,IAAI,OAAO,GAAG,CAAC,CAAA;AAEhC,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,MAAM,IAAI,GAAG,IAAI,CAAA;AAEvB,MAAM,WAAW,IAAI;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,YAAY,EAAE,CAAA;IAC3B,OAAO,EAAE,MAAM,CAAA;
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/form/form-definition/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAC9D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAG3D,K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AgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,qBAAqB,CAAA;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,CAAC,IAAI,GAAG,kBAAkB,CAAC,EAAE,CAAA;IACpC,UAAU,EAAE,gBAAgB,EAAE,CAAA;IAC9B,KAAK,EAAE,IAAI,EAAE,CAAA;IACb,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,SAAS,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IACxB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,IAAI,EAAE,GAAG,EAAE,CAAA;IACX,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAClC,SAAS,CAAC,EAAE,MAAM,GAAG,eAAe,CAAA;IACpC,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB"}
|
@@ -1,10 +1,22 @@
|
|
1
1
|
import Joi from 'joi';
|
2
|
-
import { type FormMetadata } from '../../form/form-metadata/types.js';
|
2
|
+
import { type FormMetadataState, type FormMetadata, type FormMetadataInput } from '../../form/form-metadata/types.js';
|
3
3
|
export declare const organisations: string[];
|
4
|
+
export declare const idSchema: Joi.StringSchema<string>;
|
4
5
|
export declare const titleSchema: Joi.StringSchema<string>;
|
6
|
+
export declare const slugSchema: Joi.StringSchema<string>;
|
5
7
|
export declare const organisationSchema: Joi.StringSchema<string>;
|
6
8
|
export declare const teamNameSchema: Joi.StringSchema<string>;
|
7
9
|
export declare const teamEmailSchema: Joi.StringSchema<string>;
|
10
|
+
/**
|
11
|
+
* Joi schema for `FormMetadataInput` interface
|
12
|
+
* @see {@link FormMetadataInput}
|
13
|
+
*/
|
14
|
+
export declare const formMetadataInputSchema: Joi.ObjectSchema<FormMetadataInput>;
|
15
|
+
/**
|
16
|
+
* Joi schema for `FormMetadataState` interface
|
17
|
+
* @see {@link FormMetadataState}
|
18
|
+
*/
|
19
|
+
export declare const formMetadataStateSchema: Joi.ObjectSchema<FormMetadataState>;
|
8
20
|
/**
|
9
21
|
* Joi schema for `FormMetadata` interface
|
10
22
|
* @see {@link FormMetadata}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/form/form-metadata/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AAErB,OAAO,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/form/form-metadata/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AAErB,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACvB,MAAM,mCAAmC,CAAA;AAE1C,eAAO,MAAM,aAAa,UAUzB,CAAA;AAED,eAAO,MAAM,QAAQ,0BAA2C,CAAA;AAChE,eAAO,MAAM,WAAW,0BAA0C,CAAA;AAClE,eAAO,MAAM,UAAU,0BAA0B,CAAA;AACjD,eAAO,MAAM,kBAAkB,0BAElB,CAAA;AACb,eAAO,MAAM,cAAc,0BAA0C,CAAA;AACrE,eAAO,MAAM,eAAe,0BAGf,CAAA;AAEb;;;GAGG;AACH,eAAO,MAAM,uBAAuB,qCAOvB,CAAA;AAEb;;;GAGG;AACH,eAAO,MAAM,uBAAuB,qCAGlC,CAAA;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,gCAK7B,CAAA"}
|
@@ -1,3 +1,16 @@
|
|
1
|
+
/**
|
2
|
+
* Interface for metadata state (draft & live)
|
3
|
+
*/
|
4
|
+
export interface FormMetadataState {
|
5
|
+
/**
|
6
|
+
* The date the form state was created
|
7
|
+
*/
|
8
|
+
createdAt: Date;
|
9
|
+
/**
|
10
|
+
* The date the form state was last updated
|
11
|
+
*/
|
12
|
+
updatedAt: Date;
|
13
|
+
}
|
1
14
|
/**
|
2
15
|
* Interface for `formMetadataSchema` Joi schema
|
3
16
|
* @see {@link formMetadataSchema}
|
@@ -27,9 +40,17 @@ export interface FormMetadata {
|
|
27
40
|
* The email of the team who own this form
|
28
41
|
*/
|
29
42
|
teamEmail: string;
|
43
|
+
/**
|
44
|
+
* The draft state of the form
|
45
|
+
*/
|
46
|
+
draft: FormMetadataState;
|
47
|
+
/**
|
48
|
+
* The live state of the form
|
49
|
+
*/
|
50
|
+
live?: FormMetadataState;
|
30
51
|
}
|
31
52
|
export type FormByIdInput = Pick<FormMetadata, 'id'>;
|
32
53
|
export type FormBySlugInput = Pick<FormMetadata, 'slug'>;
|
33
54
|
export type FormMetadataDocument = Omit<FormMetadata, 'id'>;
|
34
|
-
export type FormMetadataInput = Omit<FormMetadata, 'id' | 'slug'>;
|
55
|
+
export type FormMetadataInput = Omit<FormMetadata, 'id' | 'slug' | 'draft' | 'live'>;
|
35
56
|
//# sourceMappingURL=types.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/form/form-metadata/types.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAA;IAEV;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IAEb;;OAEG;IACH,YAAY,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAA;
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/form/form-metadata/types.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,SAAS,EAAE,IAAI,CAAA;IAEf;;OAEG;IACH,SAAS,EAAE,IAAI,CAAA;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAA;IAEV;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IAEb;;OAEG;IACH,YAAY,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAA;IAEjB;;OAEG;IACH,KAAK,EAAE,iBAAiB,CAAA;IAExB;;OAEG;IACH,IAAI,CAAC,EAAE,iBAAiB,CAAA;CACzB;AAED,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAA;AACpD,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,CAAA;AACxD,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAA;AAC3D,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,YAAY,EACZ,IAAI,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CACjC,CAAA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@defra/forms-model",
|
3
|
-
"version": "3.0.
|
3
|
+
"version": "3.0.95",
|
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
|
"repository": {
|
@@ -20,7 +20,7 @@
|
|
20
20
|
"test:watch": "jest --color --watch"
|
21
21
|
},
|
22
22
|
"devDependencies": {
|
23
|
-
"joi": "^17.13.
|
23
|
+
"joi": "^17.13.1",
|
24
24
|
"nanoid": "^3.3.7"
|
25
25
|
},
|
26
26
|
"peerDependencies": {
|
@@ -1,6 +1,10 @@
|
|
1
1
|
import Joi from 'joi'
|
2
2
|
|
3
|
-
import {
|
3
|
+
import {
|
4
|
+
type FormMetadataState,
|
5
|
+
type FormMetadata,
|
6
|
+
type FormMetadataInput
|
7
|
+
} from '~/src/form/form-metadata/types.js'
|
4
8
|
|
5
9
|
export const organisations = [
|
6
10
|
'Animal and Plant Health Agency – APHA',
|
@@ -14,7 +18,9 @@ export const organisations = [
|
|
14
18
|
'Veterinary Medicines Directorate – VMD'
|
15
19
|
]
|
16
20
|
|
21
|
+
export const idSchema = Joi.string().hex().length(24).required()
|
17
22
|
export const titleSchema = Joi.string().max(250).trim().required()
|
23
|
+
export const slugSchema = Joi.string().required()
|
18
24
|
export const organisationSchema = Joi.string()
|
19
25
|
.valid(...organisations)
|
20
26
|
.required()
|
@@ -25,10 +31,10 @@ export const teamEmailSchema = Joi.string()
|
|
25
31
|
.required()
|
26
32
|
|
27
33
|
/**
|
28
|
-
* Joi schema for `
|
29
|
-
* @see {@link
|
34
|
+
* Joi schema for `FormMetadataInput` interface
|
35
|
+
* @see {@link FormMetadataInput}
|
30
36
|
*/
|
31
|
-
export const
|
37
|
+
export const formMetadataInputSchema = Joi.object<FormMetadataInput>()
|
32
38
|
.keys({
|
33
39
|
title: titleSchema,
|
34
40
|
organisation: organisationSchema,
|
@@ -36,3 +42,23 @@ export const formMetadataSchema = Joi.object<FormMetadata>()
|
|
36
42
|
teamEmail: teamEmailSchema
|
37
43
|
})
|
38
44
|
.required()
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Joi schema for `FormMetadataState` interface
|
48
|
+
* @see {@link FormMetadataState}
|
49
|
+
*/
|
50
|
+
export const formMetadataStateSchema = Joi.object<FormMetadataState>().keys({
|
51
|
+
createdAt: Joi.date().iso().required(),
|
52
|
+
updatedAt: Joi.date().iso().required()
|
53
|
+
})
|
54
|
+
|
55
|
+
/**
|
56
|
+
* Joi schema for `FormMetadata` interface
|
57
|
+
* @see {@link FormMetadata}
|
58
|
+
*/
|
59
|
+
export const formMetadataSchema = formMetadataInputSchema.append<FormMetadata>({
|
60
|
+
id: idSchema,
|
61
|
+
slug: slugSchema,
|
62
|
+
draft: formMetadataStateSchema.required(),
|
63
|
+
live: formMetadataStateSchema
|
64
|
+
})
|
@@ -1,5 +1,20 @@
|
|
1
1
|
import { formMetadataSchema } from '~/src/form/form-metadata/index.js'
|
2
2
|
|
3
|
+
/**
|
4
|
+
* Interface for metadata state (draft & live)
|
5
|
+
*/
|
6
|
+
export interface FormMetadataState {
|
7
|
+
/**
|
8
|
+
* The date the form state was created
|
9
|
+
*/
|
10
|
+
createdAt: Date
|
11
|
+
|
12
|
+
/**
|
13
|
+
* The date the form state was last updated
|
14
|
+
*/
|
15
|
+
updatedAt: Date
|
16
|
+
}
|
17
|
+
|
3
18
|
/**
|
4
19
|
* Interface for `formMetadataSchema` Joi schema
|
5
20
|
* @see {@link formMetadataSchema}
|
@@ -34,9 +49,22 @@ export interface FormMetadata {
|
|
34
49
|
* The email of the team who own this form
|
35
50
|
*/
|
36
51
|
teamEmail: string
|
52
|
+
|
53
|
+
/**
|
54
|
+
* The draft state of the form
|
55
|
+
*/
|
56
|
+
draft: FormMetadataState
|
57
|
+
|
58
|
+
/**
|
59
|
+
* The live state of the form
|
60
|
+
*/
|
61
|
+
live?: FormMetadataState
|
37
62
|
}
|
38
63
|
|
39
64
|
export type FormByIdInput = Pick<FormMetadata, 'id'>
|
40
65
|
export type FormBySlugInput = Pick<FormMetadata, 'slug'>
|
41
66
|
export type FormMetadataDocument = Omit<FormMetadata, 'id'>
|
42
|
-
export type FormMetadataInput = Omit<
|
67
|
+
export type FormMetadataInput = Omit<
|
68
|
+
FormMetadata,
|
69
|
+
'id' | 'slug' | 'draft' | 'live'
|
70
|
+
>
|