@defra/forms-model 3.0.385 → 3.0.387
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/common/pagination/index.js +10 -0
- package/dist/module/common/pagination/index.js.map +1 -0
- package/dist/module/common/pagination/types.js +2 -0
- package/dist/module/common/pagination/types.js.map +1 -0
- package/dist/module/components/types.js.map +1 -1
- package/dist/module/index.js +3 -2
- package/dist/module/index.js.map +1 -1
- package/dist/types/common/pagination/index.d.ts +7 -0
- package/dist/types/common/pagination/index.d.ts.map +1 -0
- package/dist/types/common/pagination/types.d.ts +49 -0
- package/dist/types/common/pagination/types.d.ts.map +1 -0
- package/dist/types/components/types.d.ts +11 -13
- package/dist/types/components/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -2
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/common/pagination/index.ts +12 -0
- package/src/common/pagination/types.ts +57 -0
- package/src/components/types.ts +11 -13
- package/src/index.ts +5 -2
@@ -0,0 +1,10 @@
|
|
1
|
+
import Joi from 'joi';
|
2
|
+
/**
|
3
|
+
* Joi schema for `PaginationOptions` interface
|
4
|
+
* @see {@link PaginationOptions}
|
5
|
+
*/
|
6
|
+
export const paginationOptionsSchema = Joi.object({
|
7
|
+
page: Joi.number().positive().integer().min(1),
|
8
|
+
perPage: Joi.number().positive().integer().min(1).max(200)
|
9
|
+
}).optional();
|
10
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","names":["Joi","paginationOptionsSchema","object","page","number","positive","integer","min","perPage","max","optional"],"sources":["../../../../src/common/pagination/index.ts"],"sourcesContent":["import Joi from 'joi'\n\nimport { type PaginationOptions } from '~/src/common/pagination/types.js'\n\n/**\n * Joi schema for `PaginationOptions` interface\n * @see {@link PaginationOptions}\n */\nexport const paginationOptionsSchema = Joi.object<PaginationOptions>({\n page: Joi.number().positive().integer().min(1),\n perPage: Joi.number().positive().integer().min(1).max(200)\n}).optional()\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,KAAK;AAIrB;AACA;AACA;AACA;AACA,OAAO,MAAMC,uBAAuB,GAAGD,GAAG,CAACE,MAAM,CAAoB;EACnEC,IAAI,EAAEH,GAAG,CAACI,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAAC;EAC9CC,OAAO,EAAER,GAAG,CAACI,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAAC,CAACE,GAAG,CAAC,GAAG;AAC3D,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC","ignoreList":[]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/common/pagination/types.ts"],"sourcesContent":["/**\n * Result of pagination containing page information\n */\nexport interface PaginationResult {\n /**\n * The current page number.\n */\n page: number\n\n /**\n * The number of items per page.\n */\n perPage: number\n\n /**\n * The total number of items available.\n */\n totalItems: number\n\n /**\n * The total number of pages available.\n */\n totalPages: number\n}\n\n/**\n * Options for paginating results\n * Allows partial specification of page and perPage from PaginationResult\n */\nexport type PaginationOptions = Partial<\n Pick<PaginationResult, 'page' | 'perPage'>\n>\n\n/**\n * Metadata containing optional pagination information\n */\nexport interface Meta {\n /**\n * The pagination details\n */\n pagination?: PaginationResult\n}\n\n/**\n * Standard response wrapper for query results with metadata\n */\nexport interface QueryResult<Model> {\n /**\n * The array of data items\n */\n data: Model[]\n\n /**\n * The metadata about the result\n */\n meta: Meta\n}\n"],"mappings":"","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/components/types.ts"],"sourcesContent":["import { type LanguageMessages } from 'joi'\n\nimport { type ComponentType } from '~/src/components/enums.js'\nimport {\n type ListTypeContent,\n type ListTypeOption\n} from '~/src/form/form-definition/types.js'\n\nexport type ConditionalComponentType = Exclude<\n ConditionalComponentsDef['type'],\n ContentComponentsDef\n>\n\n/**\n * Types for Components JSON structure which are expected by engine and turned into actual form input/content/lists\n */\n\ninterface FormFieldBase {\n type: FormComponentsDef['type']\n name: string\n title: string\n hint?: string\n options: {\n required?: boolean\n optionalText?: boolean\n classes?: string\n customValidationMessages?: LanguageMessages\n }\n}\n\ninterface ListFieldBase extends FormFieldBase {\n type:\n | ComponentType.AutocompleteField\n | ComponentType.CheckboxesField\n | ComponentType.RadiosField\n | ComponentType.SelectField\n list: string\n options: FormFieldBase['options'] & {\n type?: ListTypeContent\n }\n}\n\ninterface ContentFieldBase {\n type:\n | ComponentType.Details\n | ComponentType.Html\n | ComponentType.InsetText\n | ComponentType.List\n name: string\n title: string\n}\n\ninterface DateFieldBase {\n type: ComponentType.DatePartsField | ComponentType.MonthYearField\n name: string\n title: string\n hint?: string\n options:
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/components/types.ts"],"sourcesContent":["import { type LanguageMessages } from 'joi'\n\nimport { type ComponentType } from '~/src/components/enums.js'\nimport {\n type ListTypeContent,\n type ListTypeOption\n} from '~/src/form/form-definition/types.js'\n\nexport type ConditionalComponentType = Exclude<\n ConditionalComponentsDef['type'],\n ContentComponentsDef\n>\n\n/**\n * Types for Components JSON structure which are expected by engine and turned into actual form input/content/lists\n */\n\ninterface FormFieldBase {\n type: FormComponentsDef['type']\n name: string\n title: string\n hint?: string\n options: {\n required?: boolean\n optionalText?: boolean\n classes?: string\n customValidationMessages?: LanguageMessages\n }\n}\n\ninterface ListFieldBase extends FormFieldBase {\n type:\n | ComponentType.AutocompleteField\n | ComponentType.CheckboxesField\n | ComponentType.RadiosField\n | ComponentType.SelectField\n list: string\n options: FormFieldBase['options'] & {\n type?: ListTypeContent\n }\n}\n\ninterface ContentFieldBase {\n type:\n | ComponentType.Details\n | ComponentType.Html\n | ComponentType.InsetText\n | ComponentType.List\n name: string\n title: string\n options?: {\n required?: undefined\n optionalText?: undefined\n }\n}\n\ninterface DateFieldBase extends FormFieldBase {\n type: ComponentType.DatePartsField | ComponentType.MonthYearField\n name: string\n title: string\n hint?: string\n options: FormFieldBase['options'] & {\n maxDaysInPast?: number\n maxDaysInFuture?: number\n }\n}\n\n// Text Fields\nexport interface TextFieldComponent extends FormFieldBase {\n type: ComponentType.TextField\n options: FormFieldBase['options'] & {\n autocomplete?: string\n condition?: string\n customValidationMessage?: string\n }\n schema: {\n max?: number\n min?: number\n length?: number\n regex?: string\n }\n}\n\nexport interface EmailAddressFieldComponent extends FormFieldBase {\n type: ComponentType.EmailAddressField\n options: FormFieldBase['options'] & {\n condition?: string\n customValidationMessage?: string\n }\n}\n\nexport interface NumberFieldComponent extends FormFieldBase {\n type: ComponentType.NumberField\n options: FormFieldBase['options'] & {\n prefix?: string\n suffix?: string\n autocomplete?: string\n condition?: string\n customValidationMessage?: string\n }\n schema: {\n max?: number\n min?: number\n precision?: number\n }\n}\n\nexport interface TelephoneNumberFieldComponent extends FormFieldBase {\n type: ComponentType.TelephoneNumberField\n options: FormFieldBase['options'] & {\n condition?: string\n customValidationMessage?: string\n }\n}\n\nexport interface FileUploadFieldComponent extends FormFieldBase {\n type: ComponentType.FileUploadField\n name: string\n title: string\n hint?: string\n options: FormFieldBase['options'] & {\n accept?: string\n }\n schema: {\n max?: number\n min?: number\n length?: number\n }\n}\n\nexport interface YesNoFieldComponent extends FormFieldBase {\n type: ComponentType.YesNoField\n options: FormFieldBase['options'] & {\n condition?: string\n }\n}\n\nexport interface MultilineTextFieldComponent extends FormFieldBase {\n type: ComponentType.MultilineTextField\n options: FormFieldBase['options'] & {\n autocomplete?: string\n condition?: string\n customValidationMessage?: string\n rows?: number\n maxWords?: number\n }\n schema: {\n max?: number\n min?: number\n length?: number\n regex?: string\n }\n}\n\nexport interface UkAddressFieldComponent extends FormFieldBase {\n type: ComponentType.UkAddressField\n options: FormFieldBase['options'] & {\n hideTitle?: boolean\n }\n}\n\n// Date Fields\nexport interface DatePartsFieldComponent extends DateFieldBase {\n type: ComponentType.DatePartsField\n options: DateFieldBase['options'] & {\n condition?: string\n }\n}\n\nexport interface MonthYearFieldComponent extends DateFieldBase {\n type: ComponentType.MonthYearField\n options: DateFieldBase['options'] & {\n customValidationMessage?: string\n }\n}\n\n// Content Fields\nexport interface DetailsComponent extends ContentFieldBase {\n type: ComponentType.Details\n content: string\n options: ContentFieldBase['options'] & {\n condition?: string\n }\n}\n\nexport interface HtmlComponent extends ContentFieldBase {\n type: ComponentType.Html\n content: string\n options: ContentFieldBase['options'] & {\n condition?: string\n }\n}\n\nexport interface InsetTextComponent extends ContentFieldBase {\n type: ComponentType.InsetText\n content: string\n}\n\nexport interface ListComponent extends ContentFieldBase {\n type: ComponentType.List\n hint?: string\n list: string\n options: ContentFieldBase['options'] & {\n type?: ListTypeOption\n classes?: string\n hideTitle?: boolean\n bold?: boolean\n }\n}\n\nexport interface AutocompleteFieldComponent extends ListFieldBase {\n type: ComponentType.AutocompleteField\n options: ListFieldBase['options'] & {\n condition?: string\n }\n}\n\nexport interface CheckboxesFieldComponent extends ListFieldBase {\n type: ComponentType.CheckboxesField\n options: ListFieldBase['options'] & {\n bold?: boolean\n condition?: string\n }\n}\n\nexport interface RadiosFieldComponent extends ListFieldBase {\n type: ComponentType.RadiosField\n options: ListFieldBase['options'] & {\n bold?: boolean\n condition?: string\n }\n}\n\nexport interface SelectFieldComponent extends ListFieldBase {\n type: ComponentType.SelectField\n options: ListFieldBase['options'] & {\n autocomplete?: string\n condition?: string\n }\n}\n\nexport type ComponentDef = FormComponentsDef | ContentComponentsDef\n\n// Components that render form fields\nexport type FormComponentsDef =\n | InputFieldsComponentsDef\n | SelectionComponentsDef\n\n// Components that render inputs\nexport type InputFieldsComponentsDef =\n | TextFieldComponent\n | EmailAddressFieldComponent\n | NumberFieldComponent\n | MultilineTextFieldComponent\n | TelephoneNumberFieldComponent\n | MonthYearFieldComponent\n | DatePartsFieldComponent\n | UkAddressFieldComponent\n | FileUploadFieldComponent\n\n// Components that render content\nexport type ContentComponentsDef =\n | DetailsComponent\n | HtmlComponent\n | InsetTextComponent\n | ListComponent\n\n// Components that render lists\nexport type ListComponentsDef =\n | Exclude<SelectionComponentsDef, YesNoFieldComponent>\n | ListComponent\n\n// Components that have selection fields\nexport type SelectionComponentsDef =\n | AutocompleteFieldComponent\n | CheckboxesFieldComponent\n | RadiosFieldComponent\n | SelectFieldComponent\n | YesNoFieldComponent\n\n// Components that have condition support\nexport type ConditionalComponentsDef = Exclude<\n ComponentDef,\n | InsetTextComponent\n | ListComponent\n | MonthYearFieldComponent\n | UkAddressFieldComponent\n | FileUploadFieldComponent\n>\n"],"mappings":"","ignoreList":[]}
|
package/dist/module/index.js
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
+
export * from "./common/pagination/index.js";
|
2
|
+
export * from "./components/index.js";
|
3
|
+
export * from "./conditions/index.js";
|
1
4
|
export * from "./form/form-definition/index.js";
|
2
5
|
export * from "./form/form-metadata/index.js";
|
3
6
|
export * from "./form/form-submission/index.js";
|
4
7
|
export * from "./form/utils/index.js";
|
5
|
-
export * from "./components/index.js";
|
6
|
-
export * from "./conditions/index.js";
|
7
8
|
export * from "./pages/index.js";
|
8
9
|
export * from "./utils/helpers.js";
|
9
10
|
export * from "./utils/markdown.js";
|
package/dist/module/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["export * from '~/src/
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["export * from '~/src/common/pagination/index.js'\nexport * from '~/src/components/index.js'\nexport * from '~/src/conditions/index.js'\nexport * from '~/src/form/form-definition/index.js'\nexport * from '~/src/form/form-metadata/index.js'\nexport * from '~/src/form/form-submission/index.js'\nexport * from '~/src/form/utils/index.js'\nexport * from '~/src/pages/index.js'\nexport * from '~/src/utils/helpers.js'\nexport * from '~/src/utils/markdown.js'\n\nexport type * from '~/src/common/pagination/types.js'\nexport type * from '~/src/components/types.js'\nexport type * from '~/src/conditions/types.js'\nexport type * from '~/src/form/form-definition/types.js'\nexport type * from '~/src/form/form-metadata/types.js'\nexport type * from '~/src/form/form-submission/types.js'\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import Joi from 'joi';
|
2
|
+
/**
|
3
|
+
* Joi schema for `PaginationOptions` interface
|
4
|
+
* @see {@link PaginationOptions}
|
5
|
+
*/
|
6
|
+
export declare const paginationOptionsSchema: Joi.ObjectSchema<Partial<Pick<import("../../common/pagination/types.js").PaginationResult, "page" | "perPage">>>;
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/common/pagination/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AAIrB;;;GAGG;AACH,eAAO,MAAM,uBAAuB,kHAGvB,CAAA"}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
/**
|
2
|
+
* Result of pagination containing page information
|
3
|
+
*/
|
4
|
+
export interface PaginationResult {
|
5
|
+
/**
|
6
|
+
* The current page number.
|
7
|
+
*/
|
8
|
+
page: number;
|
9
|
+
/**
|
10
|
+
* The number of items per page.
|
11
|
+
*/
|
12
|
+
perPage: number;
|
13
|
+
/**
|
14
|
+
* The total number of items available.
|
15
|
+
*/
|
16
|
+
totalItems: number;
|
17
|
+
/**
|
18
|
+
* The total number of pages available.
|
19
|
+
*/
|
20
|
+
totalPages: number;
|
21
|
+
}
|
22
|
+
/**
|
23
|
+
* Options for paginating results
|
24
|
+
* Allows partial specification of page and perPage from PaginationResult
|
25
|
+
*/
|
26
|
+
export type PaginationOptions = Partial<Pick<PaginationResult, 'page' | 'perPage'>>;
|
27
|
+
/**
|
28
|
+
* Metadata containing optional pagination information
|
29
|
+
*/
|
30
|
+
export interface Meta {
|
31
|
+
/**
|
32
|
+
* The pagination details
|
33
|
+
*/
|
34
|
+
pagination?: PaginationResult;
|
35
|
+
}
|
36
|
+
/**
|
37
|
+
* Standard response wrapper for query results with metadata
|
38
|
+
*/
|
39
|
+
export interface QueryResult<Model> {
|
40
|
+
/**
|
41
|
+
* The array of data items
|
42
|
+
*/
|
43
|
+
data: Model[];
|
44
|
+
/**
|
45
|
+
* The metadata about the result
|
46
|
+
*/
|
47
|
+
meta: Meta;
|
48
|
+
}
|
49
|
+
//# sourceMappingURL=types.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/common/pagination/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IAEf;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;CACnB;AAED;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,CACrC,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC,CAC3C,CAAA;AAED;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB;;OAEG;IACH,UAAU,CAAC,EAAE,gBAAgB,CAAA;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,KAAK;IAChC;;OAEG;IACH,IAAI,EAAE,KAAK,EAAE,CAAA;IAEb;;OAEG;IACH,IAAI,EAAE,IAAI,CAAA;CACX"}
|
@@ -28,16 +28,17 @@ interface ContentFieldBase {
|
|
28
28
|
type: ComponentType.Details | ComponentType.Html | ComponentType.InsetText | ComponentType.List;
|
29
29
|
name: string;
|
30
30
|
title: string;
|
31
|
+
options?: {
|
32
|
+
required?: undefined;
|
33
|
+
optionalText?: undefined;
|
34
|
+
};
|
31
35
|
}
|
32
|
-
interface DateFieldBase {
|
36
|
+
interface DateFieldBase extends FormFieldBase {
|
33
37
|
type: ComponentType.DatePartsField | ComponentType.MonthYearField;
|
34
38
|
name: string;
|
35
39
|
title: string;
|
36
40
|
hint?: string;
|
37
|
-
options: {
|
38
|
-
required?: boolean;
|
39
|
-
optionalText?: boolean;
|
40
|
-
classes?: string;
|
41
|
+
options: FormFieldBase['options'] & {
|
41
42
|
maxDaysInPast?: number;
|
42
43
|
maxDaysInFuture?: number;
|
43
44
|
};
|
@@ -85,15 +86,12 @@ export interface TelephoneNumberFieldComponent extends FormFieldBase {
|
|
85
86
|
customValidationMessage?: string;
|
86
87
|
};
|
87
88
|
}
|
88
|
-
export interface FileUploadFieldComponent {
|
89
|
+
export interface FileUploadFieldComponent extends FormFieldBase {
|
89
90
|
type: ComponentType.FileUploadField;
|
90
91
|
name: string;
|
91
92
|
title: string;
|
92
93
|
hint?: string;
|
93
|
-
options: {
|
94
|
-
required?: boolean;
|
95
|
-
classes?: string;
|
96
|
-
optionalText?: boolean;
|
94
|
+
options: FormFieldBase['options'] & {
|
97
95
|
accept?: string;
|
98
96
|
};
|
99
97
|
schema: {
|
@@ -145,14 +143,14 @@ export interface MonthYearFieldComponent extends DateFieldBase {
|
|
145
143
|
export interface DetailsComponent extends ContentFieldBase {
|
146
144
|
type: ComponentType.Details;
|
147
145
|
content: string;
|
148
|
-
options: {
|
146
|
+
options: ContentFieldBase['options'] & {
|
149
147
|
condition?: string;
|
150
148
|
};
|
151
149
|
}
|
152
150
|
export interface HtmlComponent extends ContentFieldBase {
|
153
151
|
type: ComponentType.Html;
|
154
152
|
content: string;
|
155
|
-
options: {
|
153
|
+
options: ContentFieldBase['options'] & {
|
156
154
|
condition?: string;
|
157
155
|
};
|
158
156
|
}
|
@@ -164,7 +162,7 @@ export interface ListComponent extends ContentFieldBase {
|
|
164
162
|
type: ComponentType.List;
|
165
163
|
hint?: string;
|
166
164
|
list: string;
|
167
|
-
options: {
|
165
|
+
options: ContentFieldBase['options'] & {
|
168
166
|
type?: ListTypeOption;
|
169
167
|
classes?: string;
|
170
168
|
hideTitle?: boolean;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,KAAK,CAAA;AAE3C,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,qCAAqC,CAAA;AAE5C,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAC5C,wBAAwB,CAAC,MAAM,CAAC,EAChC,oBAAoB,CACrB,CAAA;AAED;;GAEG;AAEH,UAAU,aAAa;IACrB,IAAI,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAA;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,EAAE;QACP,QAAQ,CAAC,EAAE,OAAO,CAAA;QAClB,YAAY,CAAC,EAAE,OAAO,CAAA;QACtB,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,wBAAwB,CAAC,EAAE,gBAAgB,CAAA;KAC5C,CAAA;CACF;AAED,UAAU,aAAc,SAAQ,aAAa;IAC3C,IAAI,EACA,aAAa,CAAC,iBAAiB,GAC/B,aAAa,CAAC,eAAe,GAC7B,aAAa,CAAC,WAAW,GACzB,aAAa,CAAC,WAAW,CAAA;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,GAAG;QAClC,IAAI,CAAC,EAAE,eAAe,CAAA;KACvB,CAAA;CACF;AAED,UAAU,gBAAgB;IACxB,IAAI,EACA,aAAa,CAAC,OAAO,GACrB,aAAa,CAAC,IAAI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AAC,SAAS,CAAC,GAAG;QAClC,IAAI,CAAC,EAAE,OAAO,CAAA;QACd,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,CAAA;CACF;AAED,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IACzD,IAAI,EAAE,aAAa,CAAC,WAAW,CAAA;IAC/B,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,GAAG;QAClC,YAAY,CAAC,EAAE,MAAM,CAAA;QACrB,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,CAAA;CACF;AAED,MAAM,MAAM,YAAY,GAAG,iBAAiB,GAAG,oBAAoB,CAAA;AAGnE,MAAM,MAAM,iBAAiB,GACzB,wBAAwB,GACxB,sBAAsB,CAAA;AAG1B,MAAM,MAAM,wBAAwB,GAChC,kBAAkB,GAClB,0BAA0B,GAC1B,oBAAoB,GACpB,2BAA2B,GAC3B,6BAA6B,GAC7B,uBAAuB,GACvB,uBAAuB,GACvB,uBAAuB,GACvB,wBAAwB,CAAA;AAG5B,MAAM,MAAM,oBAAoB,GAC5B,gBAAgB,GAChB,aAAa,GACb,kBAAkB,GAClB,aAAa,CAAA;AAGjB,MAAM,MAAM,iBAAiB,GACzB,OAAO,CAAC,sBAAsB,EAAE,mBAAmB,CAAC,GACpD,aAAa,CAAA;AAGjB,MAAM,MAAM,sBAAsB,GAC9B,0BAA0B,GAC1B,wBAAwB,GACxB,oBAAoB,GACpB,oBAAoB,GACpB,mBAAmB,CAAA;AAGvB,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAC5C,YAAY,EACV,kBAAkB,GAClB,aAAa,GACb,uBAAuB,GACvB,uBAAuB,GACvB,wBAAwB,CAC3B,CAAA"}
|
package/dist/types/index.d.ts
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
+
export * from './common/pagination/index.js';
|
2
|
+
export * from './components/index.js';
|
3
|
+
export * from './conditions/index.js';
|
1
4
|
export * from './form/form-definition/index.js';
|
2
5
|
export * from './form/form-metadata/index.js';
|
3
6
|
export * from './form/form-submission/index.js';
|
4
7
|
export * from './form/utils/index.js';
|
5
|
-
export * from './components/index.js';
|
6
|
-
export * from './conditions/index.js';
|
7
8
|
export * from './pages/index.js';
|
8
9
|
export * from './utils/helpers.js';
|
9
10
|
export * from './utils/markdown.js';
|
11
|
+
export type * from './common/pagination/types.js';
|
10
12
|
export type * from './components/types.js';
|
11
13
|
export type * from './conditions/types.js';
|
12
14
|
export type * from './form/form-definition/types.js';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAA;AAChD,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA;AACzC,cAAc,qCAAqC,CAAA;AACnD,cAAc,mCAAmC,CAAA;AACjD,cAAc,qCAAqC,CAAA;AACnD,cAAc,2BAA2B,CAAA;AACzC,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,yBAAyB,CAAA;AAEvC,mBAAmB,kCAAkC,CAAA;AACrD,mBAAmB,2BAA2B,CAAA;AAC9C,mBAAmB,2BAA2B,CAAA;AAC9C,mBAAmB,qCAAqC,CAAA;AACxD,mBAAmB,mCAAmC,CAAA;AACtD,mBAAmB,qCAAqC,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.387",
|
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": {
|
@@ -21,7 +21,7 @@
|
|
21
21
|
"test:watch": "jest --color --watch"
|
22
22
|
},
|
23
23
|
"dependencies": {
|
24
|
-
"marked": "^15.0.
|
24
|
+
"marked": "^15.0.3",
|
25
25
|
"slug": "^10.0.0"
|
26
26
|
},
|
27
27
|
"devDependencies": {
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import Joi from 'joi'
|
2
|
+
|
3
|
+
import { type PaginationOptions } from '~/src/common/pagination/types.js'
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Joi schema for `PaginationOptions` interface
|
7
|
+
* @see {@link PaginationOptions}
|
8
|
+
*/
|
9
|
+
export const paginationOptionsSchema = Joi.object<PaginationOptions>({
|
10
|
+
page: Joi.number().positive().integer().min(1),
|
11
|
+
perPage: Joi.number().positive().integer().min(1).max(200)
|
12
|
+
}).optional()
|
@@ -0,0 +1,57 @@
|
|
1
|
+
/**
|
2
|
+
* Result of pagination containing page information
|
3
|
+
*/
|
4
|
+
export interface PaginationResult {
|
5
|
+
/**
|
6
|
+
* The current page number.
|
7
|
+
*/
|
8
|
+
page: number
|
9
|
+
|
10
|
+
/**
|
11
|
+
* The number of items per page.
|
12
|
+
*/
|
13
|
+
perPage: number
|
14
|
+
|
15
|
+
/**
|
16
|
+
* The total number of items available.
|
17
|
+
*/
|
18
|
+
totalItems: number
|
19
|
+
|
20
|
+
/**
|
21
|
+
* The total number of pages available.
|
22
|
+
*/
|
23
|
+
totalPages: number
|
24
|
+
}
|
25
|
+
|
26
|
+
/**
|
27
|
+
* Options for paginating results
|
28
|
+
* Allows partial specification of page and perPage from PaginationResult
|
29
|
+
*/
|
30
|
+
export type PaginationOptions = Partial<
|
31
|
+
Pick<PaginationResult, 'page' | 'perPage'>
|
32
|
+
>
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Metadata containing optional pagination information
|
36
|
+
*/
|
37
|
+
export interface Meta {
|
38
|
+
/**
|
39
|
+
* The pagination details
|
40
|
+
*/
|
41
|
+
pagination?: PaginationResult
|
42
|
+
}
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Standard response wrapper for query results with metadata
|
46
|
+
*/
|
47
|
+
export interface QueryResult<Model> {
|
48
|
+
/**
|
49
|
+
* The array of data items
|
50
|
+
*/
|
51
|
+
data: Model[]
|
52
|
+
|
53
|
+
/**
|
54
|
+
* The metadata about the result
|
55
|
+
*/
|
56
|
+
meta: Meta
|
57
|
+
}
|
package/src/components/types.ts
CHANGED
@@ -48,17 +48,18 @@ interface ContentFieldBase {
|
|
48
48
|
| ComponentType.List
|
49
49
|
name: string
|
50
50
|
title: string
|
51
|
+
options?: {
|
52
|
+
required?: undefined
|
53
|
+
optionalText?: undefined
|
54
|
+
}
|
51
55
|
}
|
52
56
|
|
53
|
-
interface DateFieldBase {
|
57
|
+
interface DateFieldBase extends FormFieldBase {
|
54
58
|
type: ComponentType.DatePartsField | ComponentType.MonthYearField
|
55
59
|
name: string
|
56
60
|
title: string
|
57
61
|
hint?: string
|
58
|
-
options: {
|
59
|
-
required?: boolean
|
60
|
-
optionalText?: boolean
|
61
|
-
classes?: string
|
62
|
+
options: FormFieldBase['options'] & {
|
62
63
|
maxDaysInPast?: number
|
63
64
|
maxDaysInFuture?: number
|
64
65
|
}
|
@@ -112,15 +113,12 @@ export interface TelephoneNumberFieldComponent extends FormFieldBase {
|
|
112
113
|
}
|
113
114
|
}
|
114
115
|
|
115
|
-
export interface FileUploadFieldComponent {
|
116
|
+
export interface FileUploadFieldComponent extends FormFieldBase {
|
116
117
|
type: ComponentType.FileUploadField
|
117
118
|
name: string
|
118
119
|
title: string
|
119
120
|
hint?: string
|
120
|
-
options: {
|
121
|
-
required?: boolean
|
122
|
-
classes?: string
|
123
|
-
optionalText?: boolean
|
121
|
+
options: FormFieldBase['options'] & {
|
124
122
|
accept?: string
|
125
123
|
}
|
126
124
|
schema: {
|
@@ -180,7 +178,7 @@ export interface MonthYearFieldComponent extends DateFieldBase {
|
|
180
178
|
export interface DetailsComponent extends ContentFieldBase {
|
181
179
|
type: ComponentType.Details
|
182
180
|
content: string
|
183
|
-
options: {
|
181
|
+
options: ContentFieldBase['options'] & {
|
184
182
|
condition?: string
|
185
183
|
}
|
186
184
|
}
|
@@ -188,7 +186,7 @@ export interface DetailsComponent extends ContentFieldBase {
|
|
188
186
|
export interface HtmlComponent extends ContentFieldBase {
|
189
187
|
type: ComponentType.Html
|
190
188
|
content: string
|
191
|
-
options: {
|
189
|
+
options: ContentFieldBase['options'] & {
|
192
190
|
condition?: string
|
193
191
|
}
|
194
192
|
}
|
@@ -202,7 +200,7 @@ export interface ListComponent extends ContentFieldBase {
|
|
202
200
|
type: ComponentType.List
|
203
201
|
hint?: string
|
204
202
|
list: string
|
205
|
-
options: {
|
203
|
+
options: ContentFieldBase['options'] & {
|
206
204
|
type?: ListTypeOption
|
207
205
|
classes?: string
|
208
206
|
hideTitle?: boolean
|
package/src/index.ts
CHANGED
@@ -1,12 +1,15 @@
|
|
1
|
+
export * from '~/src/common/pagination/index.js'
|
2
|
+
export * from '~/src/components/index.js'
|
3
|
+
export * from '~/src/conditions/index.js'
|
1
4
|
export * from '~/src/form/form-definition/index.js'
|
2
5
|
export * from '~/src/form/form-metadata/index.js'
|
3
6
|
export * from '~/src/form/form-submission/index.js'
|
4
7
|
export * from '~/src/form/utils/index.js'
|
5
|
-
export * from '~/src/components/index.js'
|
6
|
-
export * from '~/src/conditions/index.js'
|
7
8
|
export * from '~/src/pages/index.js'
|
8
9
|
export * from '~/src/utils/helpers.js'
|
9
10
|
export * from '~/src/utils/markdown.js'
|
11
|
+
|
12
|
+
export type * from '~/src/common/pagination/types.js'
|
10
13
|
export type * from '~/src/components/types.js'
|
11
14
|
export type * from '~/src/conditions/types.js'
|
12
15
|
export type * from '~/src/form/form-definition/types.js'
|