-
Notifications
You must be signed in to change notification settings - Fork 0
/
submissions.ts
136 lines (128 loc) · 4.51 KB
/
submissions.ts
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import {
FormTypes,
SubmissionEventTypes,
SubmissionTypes,
ScheduledTasksTypes,
} from '@oneblink/types'
import { FormElement } from '@oneblink/types/typescript/forms'
export { ProgressListener, ProgressListenerEvent } from '@oneblink/storage'
export type BaseFormSubmission = {
/** The submission data */
submission: SubmissionTypes.S3SubmissionData['submission']
/** The form definition when the draft was saved */
definition: FormTypes.Form
}
export type NewDraftSubmission = BaseFormSubmission & {
/**
* Set to true if the submission should be uploaded in the background, false
* or undefined if the submission should be uploaded immediately
*/
backgroundUpload?: boolean
/** The element that was last updated before the draft was saved */
lastElementUpdated?: FormElement
}
export type NewFormSubmission = BaseFormSubmission & {
/** Captcha tokens gathered by a `captcha` Form Element */
captchaTokens: string[]
}
export type DraftSubmission = NewDraftSubmission & {
/** The id of the Forms App submitting for */
formsAppId: number
/**
* The id of the Forms Developer Key used to create the token passed to
* `authService.setFormsKeyToken()`
*/
keyId?: string
}
export type FormSubmission = DraftSubmission &
NewFormSubmission & {
/** The id of the draft to clean up after successful submission */
draftId: string | null
/** The id of the job to submit */
jobId: string | null
/** The id of the Forms App submitting for */
externalId: string | null
/** The id of the prefill data to clean up after successful submission */
preFillFormDataId: string | null
/**
* The id of the previous form submission approval id. Only used when the
* form submission is in response to `CLARIFICATION_REQUIRED` approval.
*/
previousFormSubmissionApprovalId?: string
/**
* Will have a value if the user was attempting to complete a scheduled task
* via a form submission
*/
taskCompletion?: {
/** The task */
task: ScheduledTasksTypes.Task
/** The task action */
taskAction: ScheduledTasksTypes.TaskAction
/** The task group */
taskGroup: ScheduledTasksTypes.TaskGroup | undefined
/** The task group instance */
taskGroupInstance: ScheduledTasksTypes.TaskGroupInstance | undefined
/**
* The URL to redirect the user to after completing the task via form
* submission
*/
redirectUrl: string
}
}
export type FormSubmissionResult = FormSubmission & {
/**
* The identifier that represents the submission. `null` if the form
* submission was unsuccessful
*/
submissionId: string | null
/**
* The timestamp the form was submitted, `null` if the form submission was
* unsuccessful
*/
submissionTimestamp: string | null
/** `null` if the form submission does not require a payment */
payment: {
/** The amount required to pay */
amount: number
/** The URL to redirect the user to after payment to display a receipt */
paymentReceiptUrl: string
/**
* The URL to redirect the user to to make a payment for a form hosted by
* customer instead of payment provider
*/
paymentFormUrl: string | undefined
/** The URL to redirect the user to to complete the payment process */
hostedFormUrl: string
/** The payment submission event */
submissionEvent: SubmissionEventTypes.FormPaymentEvent
} | null
/** `null` if the form submission does not require a booking */
scheduling: {
/** The URL to redirect the user to to complete the booking process */
bookingUrl: string
/** The scheduling submission event */
submissionEvent: SubmissionEventTypes.SchedulingSubmissionEvent
} | null
/**
* `true` if the submission was not submitted yet and was added to the pending
* queue
*/
isInPendingQueue: boolean
/** `true` if the submission was attempted offline */
isOffline: boolean
/** True if the submission was attempted whilst attachments were uploading */
isUploadingAttachments: boolean
/** Exists if the form allows PDF download */
downloadSubmissionPdfUrl?: string
}
export type PendingFormSubmission = Omit<FormSubmission, 'submission'> & {
/** The date and time (in ISO format) the submission was attempted */
pendingTimestamp: string
/** `true` if the submission is currently being processed by the pending queue */
isSubmitting?: boolean
/**
* An error message that might be set while attempting to process the
* submission in the pending queue
*/
error?: string
}