@unvired/turboforms-embed-sdk 2.0.47 → 2.0.49
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/index.d.ts +268 -0
- package/dist/turboforms.esm.js +13 -11
- package/dist/turboforms.html +14 -2
- package/dist/turboforms.js +13 -11
- package/package.json +1 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
// TypeScript definitions for unvired-forms-lib
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export interface loadFormOptions {
|
|
5
|
+
nestedFormData?: any[];
|
|
6
|
+
masterData?: any[];
|
|
7
|
+
|
|
8
|
+
mode?: "pdf" | "readOnly" | "form" | "render" | "print" | string;
|
|
9
|
+
platform?: "android" | "web" | "ios" | string;
|
|
10
|
+
permission?: "writemultiple" | "writesingle" | "read" | string;
|
|
11
|
+
language?: string;
|
|
12
|
+
privateExternal?: string | boolean;
|
|
13
|
+
title?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
|
|
16
|
+
translations?: any;
|
|
17
|
+
themeData?: any;
|
|
18
|
+
userData?: any;
|
|
19
|
+
controlData?: any;
|
|
20
|
+
|
|
21
|
+
commentsData?: any[];
|
|
22
|
+
vobArr?: any[];
|
|
23
|
+
appData?: any[];
|
|
24
|
+
environmentVariable?: any[];
|
|
25
|
+
|
|
26
|
+
showComments?: boolean;
|
|
27
|
+
showDocuments?: boolean;
|
|
28
|
+
showHelp?: boolean;
|
|
29
|
+
showBackButton?: boolean;
|
|
30
|
+
showLoader?: boolean;
|
|
31
|
+
showMoreButton?: boolean;
|
|
32
|
+
showFooter?: boolean;
|
|
33
|
+
showHeader?: boolean;
|
|
34
|
+
|
|
35
|
+
showCompleteAlways?: boolean;
|
|
36
|
+
requireCompleteForm?: boolean;
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Event Types
|
|
41
|
+
export const FORM_EVENTS: {
|
|
42
|
+
FORM_RENDER: "FORM_RENDER";
|
|
43
|
+
SAVE: "FORM_SAVE";
|
|
44
|
+
SUBMIT: "FORM_SUBMIT";
|
|
45
|
+
SUBMIT_ERROR: "FORM_SUBMIT_ERROR";
|
|
46
|
+
BACK_NAVIGATION: "FORM_BACK_NAVIGATION";
|
|
47
|
+
ONCHANGE: "FORM_ONCHANGE";
|
|
48
|
+
ACTION: "ACTION";
|
|
49
|
+
GET_ATTACHMENT: "GET_ATTACHMENT";
|
|
50
|
+
FORM_LOADED: "FORM_LOADED";
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// Event Structures
|
|
54
|
+
export interface SuccessEvent {
|
|
55
|
+
type:
|
|
56
|
+
| "FORM_RENDER"
|
|
57
|
+
| "FORM_SAVE"
|
|
58
|
+
| "FORM_SUBMIT"
|
|
59
|
+
| "FORM_BACK_NAVIGATION"
|
|
60
|
+
| "FORM_ONCHANGE"
|
|
61
|
+
| "ACTION"
|
|
62
|
+
| "OPEN_CAMERA"
|
|
63
|
+
| "BARCODE_SCAN"
|
|
64
|
+
| "LOCATION_REQUEST"
|
|
65
|
+
| "GET_ATTACHMENT";
|
|
66
|
+
message: string;
|
|
67
|
+
data: {
|
|
68
|
+
formData?: any;
|
|
69
|
+
templateData?: any;
|
|
70
|
+
completeFlag?: boolean;
|
|
71
|
+
completionPercentage?: number;
|
|
72
|
+
result?: any;
|
|
73
|
+
controlId?: string;
|
|
74
|
+
scannedValue?: string;
|
|
75
|
+
location?: string;
|
|
76
|
+
coordinates?: { lat: number; lng: number };
|
|
77
|
+
fileName?: string;
|
|
78
|
+
missingFiles?: Array<{ fileId: string; field: string }>;
|
|
79
|
+
[key: string]: any;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface ErrorEvent {
|
|
84
|
+
type: "ERROR"
|
|
85
|
+
errorMessage: string;
|
|
86
|
+
data: {
|
|
87
|
+
technicalError?: any;
|
|
88
|
+
reason?: string;
|
|
89
|
+
error?: any;
|
|
90
|
+
formData?: any;
|
|
91
|
+
completeFlag?: boolean;
|
|
92
|
+
completionPercentage?: number;
|
|
93
|
+
[key: string]: any;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export type FormEvent = SuccessEvent | ErrorEvent;
|
|
98
|
+
|
|
99
|
+
// Error Codes Reference
|
|
100
|
+
export const ERROR_CODES: {
|
|
101
|
+
"001": "Invalid formsData JSON";
|
|
102
|
+
"002": "Nested form validation error";
|
|
103
|
+
"003": "Master data validation error";
|
|
104
|
+
"004": "User Data not Provided";
|
|
105
|
+
"005": "Formio not rendered the forms";
|
|
106
|
+
"006": "Formio not submit the form";
|
|
107
|
+
"008": "Location permission denied";
|
|
108
|
+
"009": "Location unavailable";
|
|
109
|
+
"010": "Location request timeout";
|
|
110
|
+
"011": "Location unknown error";
|
|
111
|
+
"012": "Camera access error";
|
|
112
|
+
"013": "Attachments missing from storage";
|
|
113
|
+
"014": "Failed to validate attachments";
|
|
114
|
+
"015": "File not found in IndexedDB during processing";
|
|
115
|
+
"016": "Formio library not loaded";
|
|
116
|
+
"017": "Document not found";
|
|
117
|
+
"018": "Invalid file format";
|
|
118
|
+
"019": "File is corrupted (invalid base64)";
|
|
119
|
+
"020": "File is empty";
|
|
120
|
+
"021": "File is corrupted (invalid encoding)";
|
|
121
|
+
"022": "Failed to process file";
|
|
122
|
+
"023": "File is empty";
|
|
123
|
+
"024": "No downloadable content found";
|
|
124
|
+
"025": "Failed to load documents";
|
|
125
|
+
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// Event Callback Function
|
|
129
|
+
export type EventCallback = (event: FormEvent) => void;
|
|
130
|
+
|
|
131
|
+
// Main Function Interface
|
|
132
|
+
export interface loadFormParams {
|
|
133
|
+
formsData: string | any;
|
|
134
|
+
submissionData?: any;
|
|
135
|
+
eventCallback?: EventCallback;
|
|
136
|
+
container?: HTMLElement;
|
|
137
|
+
options?: loadFormOptions;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface AttachmentInfo {
|
|
141
|
+
id: string;
|
|
142
|
+
name: string;
|
|
143
|
+
originalName: string;
|
|
144
|
+
size: number;
|
|
145
|
+
type: string;
|
|
146
|
+
url: string;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export interface FormInstance {
|
|
150
|
+
sendAction: (action: any) => void;
|
|
151
|
+
getAttachments?: () => Promise<AttachmentInfo[]>;
|
|
152
|
+
clearAttachments?: () => Promise<boolean>;
|
|
153
|
+
validateAttachments?: (formData: any) => void;
|
|
154
|
+
deleteAttachment?: (fileId: string) => Promise<boolean>;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function loadForm(params: loadFormParams): FormInstance;
|
|
158
|
+
|
|
159
|
+
export function getBuildVersion(): string;
|
|
160
|
+
|
|
161
|
+
// Events that will be triggered:
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* SUCCESS EVENTS:
|
|
165
|
+
*
|
|
166
|
+
* 1. FORM_RENDER - Form rendered successfully
|
|
167
|
+
* { type: "FORM_RENDER", message: "Success: Form rendered successfully.", data: {} }
|
|
168
|
+
*
|
|
169
|
+
* 2. FORM_ONCHANGE - Form data changed
|
|
170
|
+
* { type: "FORM_ONCHANGE", message: "Success: Form onchange triggered.", data: { formData: submission, templateData: template } }
|
|
171
|
+
*
|
|
172
|
+
* 3. FORM_SUBMIT - Form submitted successfully
|
|
173
|
+
* { type: "FORM_SUBMIT", message: "Success: Form submitted successfully.", data: { formData: currentData, completeFlag, completionPercentage, result } }
|
|
174
|
+
*
|
|
175
|
+
* 4. FORM_SAVE - Form data saved
|
|
176
|
+
* { type: "FORM_SAVE", message: "Success: Data saved successfully.", data: { formData: updatedData, completeFlag, completionPercentage } }
|
|
177
|
+
*
|
|
178
|
+
* 5. FORM_BACK_NAVIGATION - Back navigation triggered
|
|
179
|
+
* { type: "FORM_BACK_NAVIGATION", message: "Back navigation triggered.", data: {} }
|
|
180
|
+
*
|
|
181
|
+
* 6. OPEN_CAMERA - Photo captured successfully
|
|
182
|
+
* { type: "OPEN_CAMERA", message: "Photo captured successfully", data: { controlId: "id", fileName: "photo.jpg" } }
|
|
183
|
+
*
|
|
184
|
+
* 7. BARCODE_SCAN - Barcode scanned successfully
|
|
185
|
+
* { type: "BARCODE_SCAN", message: "Barcode scanned successfully", data: { controlId: "id", scannedValue: "value" } }
|
|
186
|
+
*
|
|
187
|
+
* 8. LOCATION_REQUEST - Location retrieved successfully
|
|
188
|
+
* { type: "LOCATION_REQUEST", message: "Location retrieved successfully", data: { controlId: "id", location: "lat,lng", coordinates: { lat: 0, lng: 0 } } }
|
|
189
|
+
*
|
|
190
|
+
* 9. GET_ATTACHMENT - Request missing attachments from middleware
|
|
191
|
+
* { type: "GET_ATTACHMENT", message: "Requesting missing attachments from middleware", data: { missingFiles: [{fileId: "id", field: "fieldName"}] } }
|
|
192
|
+
*
|
|
193
|
+
* ERROR EVENTS:
|
|
194
|
+
*
|
|
195
|
+
* 1. ERROR Code 001 - Invalid formsData JSON
|
|
196
|
+
* { type: "ERROR", errorMessage: "ErrorCode : 001, Invalid formsData JSON", data: { error: e } }
|
|
197
|
+
*
|
|
198
|
+
* 2. ERROR Code 002 - Nested form validation error
|
|
199
|
+
* { type: "ERROR", errorMessage: "ErrorCode : 002, Nested form validation error", data: { technicalError: nestedFormError } }
|
|
200
|
+
*
|
|
201
|
+
* 3. ERROR Code 003 - Master data validation error
|
|
202
|
+
* { type: "ERROR", errorMessage: "ErrorCode : 003, Master data validation error", data: { technicalError: masterdataError } }
|
|
203
|
+
*
|
|
204
|
+
* 4. ERROR Code 004 - User Data not Provided
|
|
205
|
+
* { type: "ERROR", errorMessage: "ErrorCode : 004, User Data not Provided", data: { reason: "User Data not Provided" } }
|
|
206
|
+
*
|
|
207
|
+
* 5. ERROR Code 005 - Formio not rendered the forms
|
|
208
|
+
* { type: "ERROR", errorMessage: "ErrorCode : 005, Formio not rendered the forms", data: { technicalError: error } }
|
|
209
|
+
*
|
|
210
|
+
* 6. ERROR Code 006 - Formio not submit the form
|
|
211
|
+
* { type: "ERROR", errorMessage: "ErrorCode : 006, Formio not submit the form", data: { formData: currentData, completeFlag, completionPercentage, technicalError: error } }
|
|
212
|
+
*
|
|
213
|
+
* 8. ERROR Code 008 - Location permission denied
|
|
214
|
+
* { type: "ERROR", errorMessage: "ErrorCode : 008, Location permission denied", data: { technicalError: error, reason: "Location permission denied" } }
|
|
215
|
+
*
|
|
216
|
+
* 9. ERROR Code 009 - Location unavailable
|
|
217
|
+
* { type: "ERROR", errorMessage: "ErrorCode : 009, Location unavailable", data: { technicalError: error, reason: "Location unavailable" } }
|
|
218
|
+
*
|
|
219
|
+
* 10. ERROR Code 010 - Location request timeout
|
|
220
|
+
* { type: "ERROR", errorMessage: "ErrorCode : 010, Location request timeout", data: { technicalError: error, reason: "Location timeout" } }
|
|
221
|
+
*
|
|
222
|
+
* 11. ERROR Code 011 - Location unknown error
|
|
223
|
+
* { type: "ERROR", errorMessage: "ErrorCode : 011, Location unknown error", data: { technicalError: error, reason: "Location unknown error" } }
|
|
224
|
+
*
|
|
225
|
+
* 12. ERROR Code 012 - Camera access error
|
|
226
|
+
* { type: "ERROR", errorMessage: "ErrorCode : 012, Camera access error", data: { technicalError: error, reason: "Camera access error" } }
|
|
227
|
+
*
|
|
228
|
+
* 13. ERROR Code 013 - Attachments missing from storage
|
|
229
|
+
* { type: "ERROR", errorMessage: "ErrorCode : 013, Attachments missing from storage", data: { reason: "Some attachments are missing from storage", missingFiles: [] } }
|
|
230
|
+
*
|
|
231
|
+
* 14. ERROR Code 014 - Failed to validate attachments
|
|
232
|
+
* { type: "ERROR", errorMessage: "ErrorCode : 014, Failed to validate attachments", data: { reason: "Failed to validate attachments", technicalError: error } }
|
|
233
|
+
*
|
|
234
|
+
* 15. ERROR Code 015 - File not found in IndexedDB during processing
|
|
235
|
+
* { type: "ERROR", errorMessage: "ErrorCode : 015, File not found in IndexedDB during processing", data: { reason: "File not found in IndexedDB: fileId", fileId: "id", field: "fieldName" } }
|
|
236
|
+
*
|
|
237
|
+
* 16. ERROR Code 016 - Formio library not loaded
|
|
238
|
+
* { type: "ERROR", errorMessage: "ErrorCode : 016, Formio library not loaded", data: { reason: "Formio library not loaded" } }
|
|
239
|
+
*
|
|
240
|
+
* 17. ERROR Code 017 - Document not found
|
|
241
|
+
* { type: "ERROR", errorMessage: "ErrorCode : 017, Document not found", data: { reason: "Document not found" } }
|
|
242
|
+
*
|
|
243
|
+
* 18. ERROR Code 018 - Invalid file format
|
|
244
|
+
* { type: "ERROR", errorMessage: "ErrorCode : 018, Invalid file format", data: { reason: "Invalid file format" } }
|
|
245
|
+
*
|
|
246
|
+
* 19. ERROR Code 019 - File is corrupted (invalid base64)
|
|
247
|
+
* { type: "ERROR", errorMessage: "ErrorCode : 019, File is corrupted (invalid base64)", data: { reason: "File is corrupted (invalid base64)" } }
|
|
248
|
+
*
|
|
249
|
+
* 20. ERROR Code 020 - File is empty
|
|
250
|
+
* { type: "ERROR", errorMessage: "ErrorCode : 020, File is empty", data: { reason: "File is empty" } }
|
|
251
|
+
*
|
|
252
|
+
* 21. ERROR Code 021 - File is corrupted (invalid encoding)
|
|
253
|
+
* { type: "ERROR", errorMessage: "ErrorCode : 021, File is corrupted (invalid encoding)", data: { reason: "File is corrupted (invalid encoding)", technicalError: error } }
|
|
254
|
+
*
|
|
255
|
+
* 22. ERROR Code 022 - Failed to process file
|
|
256
|
+
* { type: "ERROR", errorMessage: "ErrorCode : 022, Failed to process file", data: { reason: "Failed to process file", technicalError: error } }
|
|
257
|
+
*
|
|
258
|
+
* 23. ERROR Code 023 - File is empty
|
|
259
|
+
* { type: "ERROR", errorMessage: "ErrorCode : 023, File is empty", data: { reason: "File is empty" } }
|
|
260
|
+
*
|
|
261
|
+
* 24. ERROR Code 024 - No downloadable content found
|
|
262
|
+
* { type: "ERROR", errorMessage: "ErrorCode : 024, No downloadable content found", data: { reason: "No downloadable content found" } }
|
|
263
|
+
*
|
|
264
|
+
* 25. ERROR Code 025 - Failed to load documents
|
|
265
|
+
* { type: "ERROR", errorMessage: "ErrorCode : 025, Failed to load documents", data: { reason: "Failed to load documents", technicalError: error } }
|
|
266
|
+
*
|
|
267
|
+
|
|
268
|
+
*/
|