-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtypes.ts
More file actions
71 lines (65 loc) · 2.09 KB
/
types.ts
File metadata and controls
71 lines (65 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import {
type FormDefinition,
type FormMetadata,
type SubmitPayload,
type SubmitResponsePayload
} from '@defra/forms-model'
import { type Server } from '@hapi/hapi'
import { type FormModel } from '~/src/server/plugins/engine/models/index.js'
import { type DetailItem } from '~/src/server/plugins/engine/models/types.js'
import { type PageController } from '~/src/server/plugins/engine/pageControllers/PageController.js'
import {
type FormContext,
type OnRequestCallback,
type PluginOptions,
type PreparePageEventRequestOptions
} from '~/src/server/plugins/engine/types.js'
import {
type FormRequestPayload,
type FormStatus
} from '~/src/server/routes/types.js'
import { type CacheService } from '~/src/server/services/cacheService.js'
export interface FormsService {
getFormMetadata: (slug: string) => Promise<FormMetadata>
getFormMetadataById: (id: string) => Promise<FormMetadata>
getFormDefinition: (
id: string,
state: FormStatus
) => Promise<FormDefinition | undefined>
}
export interface FormSubmissionService {
persistFiles: (
files: { fileId: string; initiatedRetrievalKey: string }[],
persistedRetrievalKey: string
) => Promise<object>
submit: (data: SubmitPayload) => Promise<SubmitResponsePayload | undefined>
}
export interface Services {
formsService: FormsService
formSubmissionService: FormSubmissionService
outputService: OutputService
}
export interface RouteConfig {
formFileName?: string
formFilePath?: string
enforceCsrf?: boolean
services?: Services
controllers?: Record<string, typeof PageController>
preparePageEventRequestOptions?: PreparePageEventRequestOptions
onRequest?: OnRequestCallback
saveAndExit?: PluginOptions['saveAndExit']
cacheServiceCreator?: (server: Server) => CacheService
ordnanceSurveyApiKey?: string
ordnanceSurveyApiSecret?: string
}
export interface OutputService {
submit: (
context: FormContext,
request: FormRequestPayload,
model: FormModel,
emailAddress: string,
items: DetailItem[],
submitResponse: SubmitResponsePayload,
formMetadata?: FormMetadata
) => Promise<void>
}