udp-stencil-component-library 25.18.2-beta.6 → 25.18.2-beta.8

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.
Files changed (73) hide show
  1. package/dist/cjs/index.cjs.js +138 -0
  2. package/dist/cjs/index.cjs.js.map +1 -1
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/stencil-library.cjs.js +1 -1
  5. package/dist/cjs/udp-forms-renderer.cjs.entry.js +591 -603
  6. package/dist/cjs/udp-forms-renderer.entry.cjs.js.map +1 -1
  7. package/dist/cjs/udp-forms-ui.cjs.entry.js +1 -4
  8. package/dist/cjs/udp-forms-ui.entry.cjs.js.map +1 -1
  9. package/dist/collection/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer-ui/udp-forms-ui.js +1 -4
  10. package/dist/collection/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer-ui/udp-forms-ui.js.map +1 -1
  11. package/dist/collection/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer-utils/comments-crud-utils.js +153 -0
  12. package/dist/collection/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer-utils/comments-crud-utils.js.map +1 -0
  13. package/dist/collection/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer-utils/repeated-section-utils.js +104 -0
  14. package/dist/collection/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer-utils/repeated-section-utils.js.map +1 -0
  15. package/dist/collection/components/forms/udp-forms/udp-forms-renderer/{udp-forms-renderer-utils.js → udp-forms-renderer-utils/utils.js} +48 -2
  16. package/dist/collection/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer-utils/utils.js.map +1 -0
  17. package/dist/collection/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer.js +187 -310
  18. package/dist/collection/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer.js.map +1 -1
  19. package/dist/collection/components/forms/udp-forms/udp-forms-utils/form-handler/UdpFormHandler.js +13 -13
  20. package/dist/collection/components/forms/udp-forms/udp-forms-utils/form-handler/UdpFormHandler.js.map +1 -1
  21. package/dist/collection/components/forms/udp-forms/udp-forms-utils/form-submission-handler/FormSubmissionHandler.js +142 -0
  22. package/dist/collection/components/forms/udp-forms/udp-forms-utils/form-submission-handler/FormSubmissionHandler.js.map +1 -0
  23. package/dist/collection/components/forms/udp-forms/udp-forms-utils/form-submission-handler/FormSubmissionHandlerFactory.js +3 -10
  24. package/dist/collection/components/forms/udp-forms/udp-forms-utils/form-submission-handler/FormSubmissionHandlerFactory.js.map +1 -1
  25. package/dist/collection/components/forms/udp-forms/udp-forms-utils/form-submission-handler/IFormSubmissionHandler.js.map +1 -1
  26. package/dist/collection/components/forms/udp-forms/udp-forms-utils/types.js.map +1 -1
  27. package/dist/collection/index.js +1 -0
  28. package/dist/collection/index.js.map +1 -1
  29. package/dist/collection/udp-utilities/udp-websocket-client/udp-websocket-client.js +137 -0
  30. package/dist/collection/udp-utilities/udp-websocket-client/udp-websocket-client.js.map +1 -0
  31. package/dist/components/index.js +138 -1
  32. package/dist/components/index.js.map +1 -1
  33. package/dist/components/udp-forms-renderer.js +593 -608
  34. package/dist/components/udp-forms-renderer.js.map +1 -1
  35. package/dist/components/udp-forms-ui2.js +1 -4
  36. package/dist/components/udp-forms-ui2.js.map +1 -1
  37. package/dist/docs.json +1 -1
  38. package/dist/esm/index.js +138 -1
  39. package/dist/esm/index.js.map +1 -1
  40. package/dist/esm/loader.js +1 -1
  41. package/dist/esm/stencil-library.js +1 -1
  42. package/dist/esm/udp-forms-renderer.entry.js +592 -604
  43. package/dist/esm/udp-forms-renderer.entry.js.map +1 -1
  44. package/dist/esm/udp-forms-ui.entry.js +1 -4
  45. package/dist/esm/udp-forms-ui.entry.js.map +1 -1
  46. package/dist/stencil-library/index.esm.js +1 -1
  47. package/dist/stencil-library/index.esm.js.map +1 -1
  48. package/dist/stencil-library/stencil-library.esm.js +1 -1
  49. package/dist/stencil-library/udp-forms-renderer.entry.esm.js.map +1 -1
  50. package/dist/stencil-library/udp-forms-renderer.entry.js +1 -1
  51. package/dist/stencil-library/udp-forms-renderer.entry.js.map +1 -1
  52. package/dist/stencil-library/udp-forms-ui.entry.esm.js.map +1 -1
  53. package/dist/stencil-library/udp-forms-ui.entry.js +1 -1
  54. package/dist/stencil-library/udp-forms-ui.entry.js.map +1 -1
  55. package/dist/types/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer-utils/comments-crud-utils.d.ts +31 -0
  56. package/dist/types/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer-utils/repeated-section-utils.d.ts +17 -0
  57. package/dist/types/components/forms/udp-forms/udp-forms-renderer/{udp-forms-renderer-utils.d.ts → udp-forms-renderer-utils/utils.d.ts} +4 -0
  58. package/dist/types/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer.d.ts +6 -10
  59. package/dist/types/components/forms/udp-forms/udp-forms-utils/form-handler/UdpFormHandler.d.ts +5 -6
  60. package/dist/types/components/forms/udp-forms/udp-forms-utils/form-submission-handler/FormSubmissionHandler.d.ts +42 -0
  61. package/dist/types/components/forms/udp-forms/udp-forms-utils/form-submission-handler/FormSubmissionHandlerFactory.d.ts +1 -1
  62. package/dist/types/components/forms/udp-forms/udp-forms-utils/form-submission-handler/IFormSubmissionHandler.d.ts +44 -5
  63. package/dist/types/components/forms/udp-forms/udp-forms-utils/types.d.ts +16 -0
  64. package/dist/types/index.d.ts +1 -0
  65. package/dist/types/udp-utilities/udp-websocket-client/udp-websocket-client.d.ts +34 -0
  66. package/package.json +1 -1
  67. package/dist/collection/components/forms/udp-forms/udp-forms-renderer/udp-forms-renderer-utils.js.map +0 -1
  68. package/dist/collection/components/forms/udp-forms/udp-forms-utils/form-submission-handler/PrivateFormSubmissionHandler.js +0 -264
  69. package/dist/collection/components/forms/udp-forms/udp-forms-utils/form-submission-handler/PrivateFormSubmissionHandler.js.map +0 -1
  70. package/dist/collection/components/forms/udp-forms/udp-forms-utils/form-submission-handler/PublicFormSubmissionHandler.js +0 -63
  71. package/dist/collection/components/forms/udp-forms/udp-forms-utils/form-submission-handler/PublicFormSubmissionHandler.js.map +0 -1
  72. package/dist/types/components/forms/udp-forms/udp-forms-utils/form-submission-handler/PrivateFormSubmissionHandler.d.ts +0 -131
  73. package/dist/types/components/forms/udp-forms/udp-forms-utils/form-submission-handler/PublicFormSubmissionHandler.d.ts +0 -15
@@ -1,264 +0,0 @@
1
- import { makeApiCall } from "../../../../../udp-utilities/api/makeApiCall/makeApiCall";
2
- import { SearchBuilder, SearchOperators } from "../../../../../udp-utilities/search";
3
- import { ConfigService } from "../../../../../udp-utilities/api-config/index";
4
- import { UdpFormSubmission } from "../classes/UdpFormSubmission";
5
- import { UdpFormsSubmissionStatusEnum } from "../enums";
6
- /**
7
- * Handles CRUD and submission operations for private UdpFormSubmission records.
8
- */
9
- export class PrivateFormSubmissionHandler {
10
- // =============================
11
- // Fetch Methods
12
- // =============================
13
- /**
14
- * Fetch and refresh an existing UdpFormSubmission instance.
15
- *
16
- * Attempts to load the latest server representation of the provided
17
- * udpFormSubmission. Uses generic fields (generic1/2/3) when present to
18
- * disambiguate records, otherwise falls back to a simple id lookup.
19
- *
20
- * @param udpFormSubmission - local UdpFormSubmission object to refresh
21
- * @returns a new UdpFormSubmission merged with server data, or the original on failure
22
- * @throws network or unexpected errors
23
- */
24
- async fetchAndPopulateUdpFormSubmissionObj(udpFormSubmission) {
25
- if (!(udpFormSubmission === null || udpFormSubmission === void 0 ? void 0 : udpFormSubmission.id)) {
26
- console.warn('Cannot fetch form submission without an ID.');
27
- return udpFormSubmission;
28
- }
29
- try {
30
- const { id, generic1, generic2, generic3 } = udpFormSubmission;
31
- let response = null;
32
- // Prefer the generics-aware lookup if any generic values are present
33
- if (generic1 || generic2 || generic3) {
34
- response = await this.getFormSubmissionByIdAndGenerics(id, generic1 || undefined, generic2 || undefined, generic3 || undefined);
35
- }
36
- else {
37
- response = await this.getFormSubmissionById(id);
38
- }
39
- if (!response) {
40
- console.warn('No form submission found for the provided object.');
41
- return udpFormSubmission;
42
- }
43
- return new UdpFormSubmission(Object.assign(Object.assign({}, udpFormSubmission), response));
44
- }
45
- catch (error) {
46
- console.error('Error fetching form submission:', error);
47
- throw error;
48
- }
49
- }
50
- /**
51
- * Internal helper — lookup a form submission by its unique id.
52
- *
53
- * Performs a minimal search (page size 1) for the given id and returns
54
- * the first match or null if not found. Logs and returns null on errors.
55
- *
56
- * @param id - submission id to query
57
- * @returns UdpFormSubmission or null
58
- */
59
- async getFormSubmissionById(id) {
60
- var _a;
61
- try {
62
- const search = new SearchBuilder(1, 1)
63
- .addFilter('id', id, SearchOperators.EQUALS);
64
- const response = await search.execute('UdpFormSubmission');
65
- return ((_a = response === null || response === void 0 ? void 0 : response.pageList) === null || _a === void 0 ? void 0 : _a[0]) || null;
66
- }
67
- catch (error) {
68
- console.error('Error fetching form submission by ID:', error);
69
- return null;
70
- }
71
- }
72
- /**
73
- * Internal helper — lookup a form submission by id and generic fields.
74
- *
75
- * Adds optional equality filters for generic1/generic2/generic3 when provided,
76
- * then executes a minimal search and returns the first match or null.
77
- *
78
- * @param id - submission id to query
79
- * @param generic1 - optional generic1 value to filter by
80
- * @param generic2 - optional generic2 value to filter by
81
- * @param generic3 - optional generic3 value to filter by
82
- * @returns UdpFormSubmission or null
83
- */
84
- async getFormSubmissionByIdAndGenerics(id, generic1, generic2, generic3) {
85
- var _a;
86
- try {
87
- const search = new SearchBuilder(1, 1)
88
- .addFilter('id', id, SearchOperators.EQUALS);
89
- if (generic1) {
90
- search.addFilter('generic1', generic1, SearchOperators.EQUALS);
91
- }
92
- if (generic2) {
93
- search.addFilter('generic2', generic2, SearchOperators.EQUALS);
94
- }
95
- if (generic3) {
96
- search.addFilter('generic3', generic3, SearchOperators.EQUALS);
97
- }
98
- const response = await search.execute('UdpFormSubmission');
99
- return ((_a = response === null || response === void 0 ? void 0 : response.pageList) === null || _a === void 0 ? void 0 : _a[0]) || null;
100
- }
101
- catch (error) {
102
- console.error('Error fetching form submission by ID:', error);
103
- return null;
104
- }
105
- }
106
- // =============================
107
- // Save & Submit Methods
108
- // =============================
109
- /**
110
- * Create a new follow-up form submission that is linked to an existing submission.
111
- *
112
- * Saves a new UdpFormSubmission in 'in-progress' state without populating field values
113
- * (only metadata/links), and returns the created submission object.
114
- *
115
- * @param udpFormSubmission - template/parent submission to base the new follow-up on
116
- * @returns newly created UdpFormSubmission
117
- */
118
- async createNewLinkedFollowUpFormSubmission(udpFormSubmission) {
119
- const formData = await this.saveFormDataWithoutValues(udpFormSubmission, UdpFormsSubmissionStatusEnum.InProgress);
120
- return formData;
121
- }
122
- /**
123
- * Persist submission metadata (without full field values).
124
- *
125
- * Converts provided udpFormSubmission into formData excluding field values,
126
- * determines whether to POST or PUT based on presence of id, and merges the
127
- * server response into a new UdpFormSubmission instance.
128
- *
129
- * @param udpFormSubmission - the submission to save
130
- * @param status - desired status to save (e.g., 'in-progress' or 'submitted')
131
- * @returns saved UdpFormSubmission (refetches if server returns empty PUT response)
132
- */
133
- async saveFormDataWithoutValues(udpFormSubmission, status) {
134
- try {
135
- const formData = udpFormSubmission.processSubmissionIntoFormDataWithoutValues(status);
136
- const { method, url } = this.getApiRequestInfo(udpFormSubmission);
137
- const response = await makeApiCall(method, url, formData, true);
138
- // PUT returns an empty string; refetch to refresh local data
139
- if (response === '') {
140
- return await this.fetchAndPopulateUdpFormSubmissionObj(udpFormSubmission);
141
- }
142
- return new UdpFormSubmission(Object.assign(Object.assign({}, udpFormSubmission), response));
143
- }
144
- catch (error) {
145
- console.error('Failed to save form udpFormSubmission:', error);
146
- throw error;
147
- }
148
- }
149
- /**
150
- * Save only comment-related fields for a submission.
151
- *
152
- * Delegates to the lower-level saveCommentsToDB helper to persist comment changes
153
- * while preserving existing submission state and metadata.
154
- *
155
- * @param values - comment values to persist
156
- * @param udpFormSubmission - target submission object
157
- * @returns updated UdpFormSubmission
158
- */
159
- async saveFormSubmissionComments(values, udpFormSubmission) {
160
- return this.saveCommentsToDB(values, udpFormSubmission);
161
- }
162
- /**
163
- * Save the current state of the form's data as a draft ('in-progress').
164
- *
165
- * Converts the provided values into the required form payload and persists them.
166
- * Determines POST vs PUT automatically and refreshes local object on empty PUT responses.
167
- *
168
- * @param values - field data to save
169
- * @param udpFormSubmission - submission being updated
170
- * @returns updated UdpFormSubmission
171
- */
172
- async saveCurrentFormSubmissionState(values, udpFormSubmission) {
173
- return this.saveSubmissionToDB(values, udpFormSubmission, UdpFormsSubmissionStatusEnum.InProgress);
174
- }
175
- /**
176
- * Finalize and submit the form (set state to 'submitted').
177
- *
178
- * Persists the provided values and marks the submission as 'submitted'.
179
- *
180
- * @param values - final form values to submit
181
- * @param udpFormSubmission - submission being finalized
182
- * @returns updated UdpFormSubmission
183
- */
184
- async finalizeFormSubmissionState(values, udpFormSubmission) {
185
- return this.saveSubmissionToDB(values, udpFormSubmission, UdpFormsSubmissionStatusEnum.Submitted);
186
- }
187
- // =============================
188
- // Helpers
189
- // =============================
190
- /**
191
- * Determine correct HTTP verb and target URL for saving a UdpFormSubmission.
192
- *
193
- * Uses productV1ApiUrl from ConfigService and returns POST for new submissions
194
- * (no id) or PUT with the resource id for existing submissions.
195
- *
196
- * @param udpFormSubmission - submission to be saved
197
- * @returns object with method ('POST'|'PUT') and full url
198
- */
199
- getApiRequestInfo(udpFormSubmission) {
200
- const baseUrl = `${ConfigService.productV1ApiUrl}/UdpFormSubmission`;
201
- return udpFormSubmission.id
202
- ? { method: 'PUT', url: `${baseUrl}/${udpFormSubmission.id}` }
203
- : { method: 'POST', url: baseUrl };
204
- }
205
- /**
206
- * Persist form values and metadata to the backend.
207
- *
208
- * Builds the form payload using udpFormSubmission.processSubmissionIntoFormData,
209
- * resolves POST vs PUT using getApiRequestInfo, and returns a merged UdpFormSubmission.
210
- * If the server returns an empty string for PUT, the method refetches the record.
211
- *
212
- * @param values - field values to be saved
213
- * @param udpFormSubmission - submission being updated
214
- * @param status - status to persist (e.g., 'in-progress' | 'submitted')
215
- * @returns updated UdpFormSubmission
216
- */
217
- async saveSubmissionToDB(values, udpFormSubmission, status) {
218
- try {
219
- const formData = udpFormSubmission.processSubmissionIntoFormData(values, status);
220
- const { method, url } = this.getApiRequestInfo(udpFormSubmission);
221
- const response = await makeApiCall(method, url, formData, true);
222
- // PUT returns an empty string; refetch to refresh local data
223
- if (response === '') {
224
- return await this.fetchAndPopulateUdpFormSubmissionObj(udpFormSubmission);
225
- }
226
- return new UdpFormSubmission(Object.assign(Object.assign({}, udpFormSubmission), response));
227
- }
228
- catch (error) {
229
- console.error('Failed to save form udpFormSubmission:', error);
230
- throw error;
231
- }
232
- }
233
- /**
234
- * Persist only comment changes for an existing submission via PUT.
235
- *
236
- * Forces a PUT to the specific submission id, builds a form payload containing
237
- * the provided comment values, and returns the updated submission. If the API
238
- * returns an empty string (PUT shorthand), the method refetches the record.
239
- *
240
- * @param values - comment fields to persist
241
- * @param udpFormSubmission - target submission (must have id)
242
- * @returns updated UdpFormSubmission
243
- */
244
- async saveCommentsToDB(values, udpFormSubmission) {
245
- var _a;
246
- try {
247
- const method = 'PUT';
248
- const status = (_a = udpFormSubmission.status) !== null && _a !== void 0 ? _a : UdpFormsSubmissionStatusEnum.Submitted;
249
- const url = `${ConfigService.productV1ApiUrl}/UdpFormSubmission/${udpFormSubmission.id}`;
250
- const formData = udpFormSubmission.processSubmissionIntoFormData(values, status);
251
- const response = await makeApiCall(method, url, formData, true);
252
- // PUT returns an empty string; refetch to refresh local data
253
- if (response === '') {
254
- return await this.fetchAndPopulateUdpFormSubmissionObj(udpFormSubmission);
255
- }
256
- return new UdpFormSubmission(Object.assign(Object.assign({}, udpFormSubmission), response));
257
- }
258
- catch (error) {
259
- console.error('Failed to save form udpFormSubmission:', error);
260
- throw error;
261
- }
262
- }
263
- }
264
- //# sourceMappingURL=PrivateFormSubmissionHandler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PrivateFormSubmissionHandler.js","sourceRoot":"","sources":["../../../../../../src/components/forms/udp-forms/udp-forms-utils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BACpB,OAAO,MAAM,IAAI,CAAC,oCAAoC,CAAC,iBAAiB,CAAC,CAAC;YAC5E,CAAC;YAED,OAAO,IAAI,iBAAiB,iCAAM,iBAAiB,GAAK,QAAQ,EAAG,CAAC;QACtE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,KAAK,CAAC,CAAC;YAC/D,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF","sourcesContent":["import { makeApiCall } from '../../../../../udp-utilities/api/makeApiCall/makeApiCall';\nimport { SearchBuilder, SearchOperators } from '../../../../../udp-utilities/search';\nimport { ConfigService } from 'src/udp-utilities/api-config';\nimport { UdpFormSubmission } from '../classes/UdpFormSubmission';\nimport { IFormSubmissionHandler } from './IFormSubmissionHandler';\nimport { UdpFormsSubmissionStatusEnum } from '../enums';\n\n/**\n * Handles CRUD and submission operations for private UdpFormSubmission records.\n */\nexport class PrivateFormSubmissionHandler implements IFormSubmissionHandler {\n\n // =============================\n // Fetch Methods\n // =============================\n\n /**\n * Fetch and refresh an existing UdpFormSubmission instance.\n *\n * Attempts to load the latest server representation of the provided\n * udpFormSubmission. Uses generic fields (generic1/2/3) when present to\n * disambiguate records, otherwise falls back to a simple id lookup.\n *\n * @param udpFormSubmission - local UdpFormSubmission object to refresh\n * @returns a new UdpFormSubmission merged with server data, or the original on failure\n * @throws network or unexpected errors\n */\n async fetchAndPopulateUdpFormSubmissionObj(udpFormSubmission: UdpFormSubmission): Promise<UdpFormSubmission> {\n if (!udpFormSubmission?.id) {\n console.warn('Cannot fetch form submission without an ID.');\n return udpFormSubmission;\n }\n\n try {\n const { id, generic1, generic2, generic3 } = udpFormSubmission as any;\n let response: UdpFormSubmission | null = null;\n\n // Prefer the generics-aware lookup if any generic values are present\n if (generic1 || generic2 || generic3) {\n response = await this.getFormSubmissionByIdAndGenerics(\n id,\n generic1 || undefined,\n generic2 || undefined,\n generic3 || undefined\n );\n } else {\n response = await this.getFormSubmissionById(id);\n }\n\n if (!response) {\n console.warn('No form submission found for the provided object.');\n return udpFormSubmission;\n }\n\n return new UdpFormSubmission({ ...udpFormSubmission, ...response });\n } catch (error) {\n console.error('Error fetching form submission:', error);\n throw error;\n }\n }\n\n /** \n * Internal helper — lookup a form submission by its unique id.\n *\n * Performs a minimal search (page size 1) for the given id and returns\n * the first match or null if not found. Logs and returns null on errors.\n *\n * @param id - submission id to query\n * @returns UdpFormSubmission or null\n */\n private async getFormSubmissionById(id: string): Promise<UdpFormSubmission | null> {\n try {\n const search = new SearchBuilder(1, 1)\n .addFilter('id', id, SearchOperators.EQUALS)\n\n const response = await search.execute('UdpFormSubmission');\n return response?.pageList?.[0] as UdpFormSubmission || null;\n } catch (error) {\n console.error('Error fetching form submission by ID:', error);\n return null;\n }\n }\n\n /**\n * Internal helper — lookup a form submission by id and generic fields.\n *\n * Adds optional equality filters for generic1/generic2/generic3 when provided,\n * then executes a minimal search and returns the first match or null.\n *\n * @param id - submission id to query\n * @param generic1 - optional generic1 value to filter by\n * @param generic2 - optional generic2 value to filter by\n * @param generic3 - optional generic3 value to filter by\n * @returns UdpFormSubmission or null\n */\n private async getFormSubmissionByIdAndGenerics(id: string, generic1: string, generic2: string, generic3: string): Promise<UdpFormSubmission | null> {\n try {\n const search = new SearchBuilder(1, 1)\n .addFilter('id', id, SearchOperators.EQUALS);\n\n if (generic1) {\n search.addFilter('generic1', generic1, SearchOperators.EQUALS);\n }\n if (generic2) {\n search.addFilter('generic2', generic2, SearchOperators.EQUALS);\n }\n if (generic3) {\n search.addFilter('generic3', generic3, SearchOperators.EQUALS);\n }\n\n const response = await search.execute('UdpFormSubmission');\n return response?.pageList?.[0] as UdpFormSubmission || null;\n } catch (error) {\n console.error('Error fetching form submission by ID:', error);\n return null;\n }\n }\n\n\n // =============================\n // Save & Submit Methods\n // =============================\n\n /**\n * Create a new follow-up form submission that is linked to an existing submission.\n *\n * Saves a new UdpFormSubmission in 'in-progress' state without populating field values\n * (only metadata/links), and returns the created submission object.\n *\n * @param udpFormSubmission - template/parent submission to base the new follow-up on\n * @returns newly created UdpFormSubmission\n */\n async createNewLinkedFollowUpFormSubmission(udpFormSubmission): Promise<UdpFormSubmission> {\n const formData = await this.saveFormDataWithoutValues(udpFormSubmission, UdpFormsSubmissionStatusEnum.InProgress);\n return formData\n }\n\n /**\n * Persist submission metadata (without full field values).\n *\n * Converts provided udpFormSubmission into formData excluding field values,\n * determines whether to POST or PUT based on presence of id, and merges the\n * server response into a new UdpFormSubmission instance.\n *\n * @param udpFormSubmission - the submission to save\n * @param status - desired status to save (e.g., 'in-progress' or 'submitted')\n * @returns saved UdpFormSubmission (refetches if server returns empty PUT response)\n */\n private async saveFormDataWithoutValues(udpFormSubmission: UdpFormSubmission, status: UdpFormsSubmissionStatusEnum): Promise<UdpFormSubmission> {\n try {\n const formData = udpFormSubmission.processSubmissionIntoFormDataWithoutValues(status);\n const { method, url } = this.getApiRequestInfo(udpFormSubmission);\n\n const response = await makeApiCall(method, url, formData, true);\n\n // PUT returns an empty string; refetch to refresh local data\n if (response === '') {\n return await this.fetchAndPopulateUdpFormSubmissionObj(udpFormSubmission);\n }\n\n return new UdpFormSubmission({ ...udpFormSubmission, ...response });\n } catch (error) {\n console.error('Failed to save form udpFormSubmission:', error);\n throw error;\n }\n }\n\n /**\n * Save only comment-related fields for a submission.\n *\n * Delegates to the lower-level saveCommentsToDB helper to persist comment changes\n * while preserving existing submission state and metadata.\n *\n * @param values - comment values to persist\n * @param udpFormSubmission - target submission object\n * @returns updated UdpFormSubmission\n */\n async saveFormSubmissionComments(values: Record<string, any>, udpFormSubmission: UdpFormSubmission): Promise<UdpFormSubmission> {\n return this.saveCommentsToDB(values, udpFormSubmission)\n }\n\n\n /**\n * Save the current state of the form's data as a draft ('in-progress').\n *\n * Converts the provided values into the required form payload and persists them.\n * Determines POST vs PUT automatically and refreshes local object on empty PUT responses.\n *\n * @param values - field data to save\n * @param udpFormSubmission - submission being updated\n * @returns updated UdpFormSubmission\n */\n async saveCurrentFormSubmissionState(values: Record<string, any>, udpFormSubmission: UdpFormSubmission): Promise<UdpFormSubmission> {\n return this.saveSubmissionToDB(values, udpFormSubmission, UdpFormsSubmissionStatusEnum.InProgress)\n }\n\n\n /** \n * Finalize and submit the form (set state to 'submitted').\n *\n * Persists the provided values and marks the submission as 'submitted'.\n *\n * @param values - final form values to submit\n * @param udpFormSubmission - submission being finalized\n * @returns updated UdpFormSubmission\n */\n async finalizeFormSubmissionState(values: Record<string, any>, udpFormSubmission: UdpFormSubmission): Promise<UdpFormSubmission> {\n return this.saveSubmissionToDB(values, udpFormSubmission, UdpFormsSubmissionStatusEnum.Submitted);\n }\n\n // =============================\n // Helpers\n // =============================\n\n /** \n * Determine correct HTTP verb and target URL for saving a UdpFormSubmission.\n *\n * Uses productV1ApiUrl from ConfigService and returns POST for new submissions\n * (no id) or PUT with the resource id for existing submissions.\n *\n * @param udpFormSubmission - submission to be saved\n * @returns object with method ('POST'|'PUT') and full url\n */\n private getApiRequestInfo(udpFormSubmission: UdpFormSubmission): { method: 'POST' | 'PUT'; url: string } {\n const baseUrl = `${ConfigService.productV1ApiUrl}/UdpFormSubmission`;\n\n return udpFormSubmission.id\n ? { method: 'PUT', url: `${baseUrl}/${udpFormSubmission.id}` }\n : { method: 'POST', url: baseUrl };\n }\n\n /**\n * Persist form values and metadata to the backend.\n *\n * Builds the form payload using udpFormSubmission.processSubmissionIntoFormData,\n * resolves POST vs PUT using getApiRequestInfo, and returns a merged UdpFormSubmission.\n * If the server returns an empty string for PUT, the method refetches the record.\n *\n * @param values - field values to be saved\n * @param udpFormSubmission - submission being updated\n * @param status - status to persist (e.g., 'in-progress' | 'submitted')\n * @returns updated UdpFormSubmission\n */\n private async saveSubmissionToDB(values: Record<string, any>, udpFormSubmission: UdpFormSubmission, status: UdpFormsSubmissionStatusEnum): Promise<UdpFormSubmission> {\n try {\n const formData = udpFormSubmission.processSubmissionIntoFormData(values, status);\n const { method, url } = this.getApiRequestInfo(udpFormSubmission);\n\n const response = await makeApiCall(method, url, formData, true);\n\n // PUT returns an empty string; refetch to refresh local data\n if (response === '') {\n return await this.fetchAndPopulateUdpFormSubmissionObj(udpFormSubmission);\n }\n\n return new UdpFormSubmission({ ...udpFormSubmission, ...response });\n } catch (error) {\n console.error('Failed to save form udpFormSubmission:', error);\n throw error;\n }\n }\n\n /**\n * Persist only comment changes for an existing submission via PUT.\n *\n * Forces a PUT to the specific submission id, builds a form payload containing\n * the provided comment values, and returns the updated submission. If the API\n * returns an empty string (PUT shorthand), the method refetches the record.\n *\n * @param values - comment fields to persist\n * @param udpFormSubmission - target submission (must have id)\n * @returns updated UdpFormSubmission\n */\n private async saveCommentsToDB(values: Record<string, any>, udpFormSubmission: UdpFormSubmission): Promise<UdpFormSubmission> {\n try {\n const method = 'PUT';\n const status = udpFormSubmission.status ?? UdpFormsSubmissionStatusEnum.Submitted;\n const url = `${ConfigService.productV1ApiUrl}/UdpFormSubmission/${udpFormSubmission.id}`;\n const formData = udpFormSubmission.processSubmissionIntoFormData(values, status);\n const response = await makeApiCall(method, url, formData, true);\n\n // PUT returns an empty string; refetch to refresh local data\n if (response === '') {\n return await this.fetchAndPopulateUdpFormSubmissionObj(udpFormSubmission);\n }\n\n return new UdpFormSubmission({ ...udpFormSubmission, ...response });\n } catch (error) {\n console.error('Failed to save form udpFormSubmission:', error);\n throw error;\n }\n }\n}\n\n"]}
@@ -1,63 +0,0 @@
1
- import { createFormData } from "../../../../../udp-utilities/api/makeApiCall/makeApiCall";
2
- import { isFileArray } from "./formUtils";
3
- // TODO: This handler needs to be updated with new public form logic.
4
- // ******* THIS HANDLER IS OUTDATED, AND WILL LIKELY NOT WORK *********
5
- /**
6
- * Handles submission for *public* (unauthenticated) forms.
7
- */
8
- export class PublicFormSubmissionHandler {
9
- constructor(formId, formVersion, tenantId) { }
10
- async fetchAndPopulateUdpFormSubmissionObj(submission) {
11
- return submission;
12
- }
13
- objectToFormData(obj) {
14
- var _a, _b;
15
- const files = [];
16
- const formObj = {};
17
- for (const key in obj) {
18
- let value = (_b = (_a = obj[key]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : obj[key];
19
- if (isFileArray(value)) {
20
- if (value.length > 0) {
21
- files.push(value[0]);
22
- formObj[key] = value[0].name;
23
- }
24
- }
25
- else if (Array.isArray(value)) {
26
- formObj[key] = value.map(v => (typeof v === 'string' ? v : v.value)).join(',');
27
- }
28
- else if (value !== null && value !== undefined && value !== '') {
29
- formObj[key] = value;
30
- }
31
- }
32
- return createFormData({
33
- formData: JSON.stringify(formObj),
34
- formFiles: files[0] || null
35
- });
36
- }
37
- async saveCurrentFormSubmissionState(values, submission) {
38
- return submission;
39
- }
40
- async saveFormSubmissionComments(values, submission) {
41
- return submission;
42
- }
43
- async createNewLinkedFollowUpFormSubmission(submission) {
44
- return submission;
45
- }
46
- async finalizeFormSubmissionState(values, submission) {
47
- try {
48
- // const formData = this.objectToFormData(values);
49
- // await makeApiCall(
50
- // 'POST',
51
- // `${ConfigService.productV1ApiUrl}/UdpForm/${this.formId}/${this.formVersion}/submit/public?tenantId=${this.tenantId}`,
52
- // formData,
53
- // true
54
- // );
55
- return submission;
56
- }
57
- catch (error) {
58
- console.error('Public form submission failed:', error);
59
- throw error;
60
- }
61
- }
62
- }
63
- //# sourceMappingURL=PublicFormSubmissionHandler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PublicFormSubmissionHandler.js","sourceRoot":"","sources":["../../../../../../src/components/forms/udp-forms/udp-forms-utils/form-submission-handler/PublicFormSubmissionHandler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,0DAA0D,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1C,qEAAqE;AACrE,uEAAuE;AAEvE;;GAEG;AACH,MAAM,OAAO,2BAA2B;IACtC,YACG,MAAa,EACb,WAAoB,EACpB,QAAe,IACf,CAAC;IAEG,KAAK,CAAC,oCA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C,8BAA8B,CAAC,MAA2B,EAAE,UAA6B;QAC7F,OAAO,UAAU,CAAA;IACnB,CAAC;IAGD,KAAK,CAAC,0BAA0B,CAAC,MAA2B,EAAE,UAA6B;QACzF,OAAO,UAAU,CAAA;IACnB,CAAC;IAED,KAAK,CAAC,qCAAqC,CAAC,UAA6B;QACvE,OAAO,UAAU,CAAA;IACnB,CAAC;IAED,KAAK,CAAC,2BAA2B,CAAC,MAA2B,EAAE,UAA6B;QAC1F,IAAI,CAAC;YACH,kDAAkD;YAElD,qBAAqB;YACrB,YAAY;YACZ,2HAA2H;YAC3H,cAAc;YACd,SAAS;YACT,KAAK;YAEL,OAAO,UAAU,CAAC;QACpB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC;YACvD,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC;CACF","sourcesContent":["// @ts-nocheck\nimport { Guid, UdpFormSubmissionStatus } from '../../types';\nimport { createFormData } from '../../../../../udp-utilities/api/makeApiCall/makeApiCall';\nimport { isFileArray } from './formUtils';\nimport { UdpFormSubmission } from '../classes/UdpFormSubmission';\nimport { IFormSubmissionHandler } from './IFormSubmissionHandler';\n\n\n\n// TODO: This handler needs to be updated with new public form logic.\n// ******* THIS HANDLER IS OUTDATED, AND WILL LIKELY NOT WORK *********\n\n/**\n * Handles submission for *public* (unauthenticated) forms.\n */\nexport class PublicFormSubmissionHandler implements IFormSubmissionHandler {\n constructor(\n formId?: Guid,\n formVersion?: number,\n tenantId?: Guid\n ) {}\n\n public async fetchAndPopulateUdpFormSubmissionObj(submission: UdpFormSubmission) {\n return submission\n }\n\n\n private objectToFormData(obj: Record<string, any>): FormData {\n const files: File[] = [];\n const formObj: Record<string, any> = {};\n\n for (const key in obj) {\n let value = obj[key]?.value ?? obj[key];\n\n if (isFileArray(value)) {\n if (value.length > 0) {\n files.push(value[0]);\n formObj[key] = value[0].name;\n }\n } else if (Array.isArray(value)) {\n formObj[key] = value.map(v => (typeof v === 'string' ? v : v.value)).join(',');\n } else if (value !== null && value !== undefined && value !== '') {\n formObj[key] = value;\n }\n }\n\n return createFormData({\n formData: JSON.stringify(formObj),\n formFiles: files[0] || null\n });\n }\n\n async saveCurrentFormSubmissionState(values: Record<string, any>, submission: UdpFormSubmission): Promise<UdpFormSubmission> {\n return submission\n }\n\n\n async saveFormSubmissionComments(values: Record<string, any>, submission: UdpFormSubmission): Promise<UdpFormSubmission> {\n return submission\n }\n\n async createNewLinkedFollowUpFormSubmission(submission: UdpFormSubmission): Promise<UdpFormSubmission> {\n return submission\n }\n\n async finalizeFormSubmissionState(values: Record<string, any>, submission: UdpFormSubmission) : Promise<UdpFormSubmission> {\n try {\n // const formData = this.objectToFormData(values);\n\n // await makeApiCall(\n // 'POST',\n // `${ConfigService.productV1ApiUrl}/UdpForm/${this.formId}/${this.formVersion}/submit/public?tenantId=${this.tenantId}`,\n // formData,\n // true\n // );\n\n return submission;\n } catch (error) {\n console.error('Public form submission failed:', error);\n throw error\n }\n }\n}\n"]}
@@ -1,131 +0,0 @@
1
- import { UdpFormSubmission } from '../classes/UdpFormSubmission';
2
- import { IFormSubmissionHandler } from './IFormSubmissionHandler';
3
- /**
4
- * Handles CRUD and submission operations for private UdpFormSubmission records.
5
- */
6
- export declare class PrivateFormSubmissionHandler implements IFormSubmissionHandler {
7
- /**
8
- * Fetch and refresh an existing UdpFormSubmission instance.
9
- *
10
- * Attempts to load the latest server representation of the provided
11
- * udpFormSubmission. Uses generic fields (generic1/2/3) when present to
12
- * disambiguate records, otherwise falls back to a simple id lookup.
13
- *
14
- * @param udpFormSubmission - local UdpFormSubmission object to refresh
15
- * @returns a new UdpFormSubmission merged with server data, or the original on failure
16
- * @throws network or unexpected errors
17
- */
18
- fetchAndPopulateUdpFormSubmissionObj(udpFormSubmission: UdpFormSubmission): Promise<UdpFormSubmission>;
19
- /**
20
- * Internal helper — lookup a form submission by its unique id.
21
- *
22
- * Performs a minimal search (page size 1) for the given id and returns
23
- * the first match or null if not found. Logs and returns null on errors.
24
- *
25
- * @param id - submission id to query
26
- * @returns UdpFormSubmission or null
27
- */
28
- private getFormSubmissionById;
29
- /**
30
- * Internal helper — lookup a form submission by id and generic fields.
31
- *
32
- * Adds optional equality filters for generic1/generic2/generic3 when provided,
33
- * then executes a minimal search and returns the first match or null.
34
- *
35
- * @param id - submission id to query
36
- * @param generic1 - optional generic1 value to filter by
37
- * @param generic2 - optional generic2 value to filter by
38
- * @param generic3 - optional generic3 value to filter by
39
- * @returns UdpFormSubmission or null
40
- */
41
- private getFormSubmissionByIdAndGenerics;
42
- /**
43
- * Create a new follow-up form submission that is linked to an existing submission.
44
- *
45
- * Saves a new UdpFormSubmission in 'in-progress' state without populating field values
46
- * (only metadata/links), and returns the created submission object.
47
- *
48
- * @param udpFormSubmission - template/parent submission to base the new follow-up on
49
- * @returns newly created UdpFormSubmission
50
- */
51
- createNewLinkedFollowUpFormSubmission(udpFormSubmission: any): Promise<UdpFormSubmission>;
52
- /**
53
- * Persist submission metadata (without full field values).
54
- *
55
- * Converts provided udpFormSubmission into formData excluding field values,
56
- * determines whether to POST or PUT based on presence of id, and merges the
57
- * server response into a new UdpFormSubmission instance.
58
- *
59
- * @param udpFormSubmission - the submission to save
60
- * @param status - desired status to save (e.g., 'in-progress' or 'submitted')
61
- * @returns saved UdpFormSubmission (refetches if server returns empty PUT response)
62
- */
63
- private saveFormDataWithoutValues;
64
- /**
65
- * Save only comment-related fields for a submission.
66
- *
67
- * Delegates to the lower-level saveCommentsToDB helper to persist comment changes
68
- * while preserving existing submission state and metadata.
69
- *
70
- * @param values - comment values to persist
71
- * @param udpFormSubmission - target submission object
72
- * @returns updated UdpFormSubmission
73
- */
74
- saveFormSubmissionComments(values: Record<string, any>, udpFormSubmission: UdpFormSubmission): Promise<UdpFormSubmission>;
75
- /**
76
- * Save the current state of the form's data as a draft ('in-progress').
77
- *
78
- * Converts the provided values into the required form payload and persists them.
79
- * Determines POST vs PUT automatically and refreshes local object on empty PUT responses.
80
- *
81
- * @param values - field data to save
82
- * @param udpFormSubmission - submission being updated
83
- * @returns updated UdpFormSubmission
84
- */
85
- saveCurrentFormSubmissionState(values: Record<string, any>, udpFormSubmission: UdpFormSubmission): Promise<UdpFormSubmission>;
86
- /**
87
- * Finalize and submit the form (set state to 'submitted').
88
- *
89
- * Persists the provided values and marks the submission as 'submitted'.
90
- *
91
- * @param values - final form values to submit
92
- * @param udpFormSubmission - submission being finalized
93
- * @returns updated UdpFormSubmission
94
- */
95
- finalizeFormSubmissionState(values: Record<string, any>, udpFormSubmission: UdpFormSubmission): Promise<UdpFormSubmission>;
96
- /**
97
- * Determine correct HTTP verb and target URL for saving a UdpFormSubmission.
98
- *
99
- * Uses productV1ApiUrl from ConfigService and returns POST for new submissions
100
- * (no id) or PUT with the resource id for existing submissions.
101
- *
102
- * @param udpFormSubmission - submission to be saved
103
- * @returns object with method ('POST'|'PUT') and full url
104
- */
105
- private getApiRequestInfo;
106
- /**
107
- * Persist form values and metadata to the backend.
108
- *
109
- * Builds the form payload using udpFormSubmission.processSubmissionIntoFormData,
110
- * resolves POST vs PUT using getApiRequestInfo, and returns a merged UdpFormSubmission.
111
- * If the server returns an empty string for PUT, the method refetches the record.
112
- *
113
- * @param values - field values to be saved
114
- * @param udpFormSubmission - submission being updated
115
- * @param status - status to persist (e.g., 'in-progress' | 'submitted')
116
- * @returns updated UdpFormSubmission
117
- */
118
- private saveSubmissionToDB;
119
- /**
120
- * Persist only comment changes for an existing submission via PUT.
121
- *
122
- * Forces a PUT to the specific submission id, builds a form payload containing
123
- * the provided comment values, and returns the updated submission. If the API
124
- * returns an empty string (PUT shorthand), the method refetches the record.
125
- *
126
- * @param values - comment fields to persist
127
- * @param udpFormSubmission - target submission (must have id)
128
- * @returns updated UdpFormSubmission
129
- */
130
- private saveCommentsToDB;
131
- }
@@ -1,15 +0,0 @@
1
- import { Guid } from '../../types';
2
- import { UdpFormSubmission } from '../classes/UdpFormSubmission';
3
- import { IFormSubmissionHandler } from './IFormSubmissionHandler';
4
- /**
5
- * Handles submission for *public* (unauthenticated) forms.
6
- */
7
- export declare class PublicFormSubmissionHandler implements IFormSubmissionHandler {
8
- constructor(formId?: Guid, formVersion?: number, tenantId?: Guid);
9
- fetchAndPopulateUdpFormSubmissionObj(submission: UdpFormSubmission): Promise<UdpFormSubmission>;
10
- private objectToFormData;
11
- saveCurrentFormSubmissionState(values: Record<string, any>, submission: UdpFormSubmission): Promise<UdpFormSubmission>;
12
- saveFormSubmissionComments(values: Record<string, any>, submission: UdpFormSubmission): Promise<UdpFormSubmission>;
13
- createNewLinkedFollowUpFormSubmission(submission: UdpFormSubmission): Promise<UdpFormSubmission>;
14
- finalizeFormSubmissionState(values: Record<string, any>, submission: UdpFormSubmission): Promise<UdpFormSubmission>;
15
- }