@memberjunction/actions-bizapps-formbuilders 2.112.0-beta

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 (219) hide show
  1. package/IMPLEMENTATION_PLAN.md +311 -0
  2. package/README.md +498 -0
  3. package/dist/base/base-form-builder.action.d.ts +153 -0
  4. package/dist/base/base-form-builder.action.d.ts.map +1 -0
  5. package/dist/base/base-form-builder.action.js +301 -0
  6. package/dist/base/base-form-builder.action.js.map +1 -0
  7. package/dist/base/index.d.ts +2 -0
  8. package/dist/base/index.d.ts.map +1 -0
  9. package/dist/base/index.js +18 -0
  10. package/dist/base/index.js.map +1 -0
  11. package/dist/index.d.ts +8 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +31 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/providers/google-forms/actions/export-csv.action.d.ts +31 -0
  16. package/dist/providers/google-forms/actions/export-csv.action.d.ts.map +1 -0
  17. package/dist/providers/google-forms/actions/export-csv.action.js +165 -0
  18. package/dist/providers/google-forms/actions/export-csv.action.js.map +1 -0
  19. package/dist/providers/google-forms/actions/get-form.action.d.ts +28 -0
  20. package/dist/providers/google-forms/actions/get-form.action.d.ts.map +1 -0
  21. package/dist/providers/google-forms/actions/get-form.action.js +151 -0
  22. package/dist/providers/google-forms/actions/get-form.action.js.map +1 -0
  23. package/dist/providers/google-forms/actions/get-single-response.action.d.ts +31 -0
  24. package/dist/providers/google-forms/actions/get-single-response.action.d.ts.map +1 -0
  25. package/dist/providers/google-forms/actions/get-single-response.action.js +150 -0
  26. package/dist/providers/google-forms/actions/get-single-response.action.js.map +1 -0
  27. package/dist/providers/google-forms/actions/get-statistics.action.d.ts +36 -0
  28. package/dist/providers/google-forms/actions/get-statistics.action.d.ts.map +1 -0
  29. package/dist/providers/google-forms/actions/get-statistics.action.js +254 -0
  30. package/dist/providers/google-forms/actions/get-statistics.action.js.map +1 -0
  31. package/dist/providers/google-forms/actions/index.d.ts +5 -0
  32. package/dist/providers/google-forms/actions/index.d.ts.map +1 -0
  33. package/dist/providers/google-forms/actions/index.js +23 -0
  34. package/dist/providers/google-forms/actions/index.js.map +1 -0
  35. package/dist/providers/google-forms/googleforms-base.action.d.ts +197 -0
  36. package/dist/providers/google-forms/googleforms-base.action.d.ts.map +1 -0
  37. package/dist/providers/google-forms/googleforms-base.action.js +352 -0
  38. package/dist/providers/google-forms/googleforms-base.action.js.map +1 -0
  39. package/dist/providers/google-forms/index.d.ts +3 -0
  40. package/dist/providers/google-forms/index.d.ts.map +1 -0
  41. package/dist/providers/google-forms/index.js +21 -0
  42. package/dist/providers/google-forms/index.js.map +1 -0
  43. package/dist/providers/jotform/actions/create-form.action.d.ts +61 -0
  44. package/dist/providers/jotform/actions/create-form.action.d.ts.map +1 -0
  45. package/dist/providers/jotform/actions/create-form.action.js +259 -0
  46. package/dist/providers/jotform/actions/create-form.action.js.map +1 -0
  47. package/dist/providers/jotform/actions/export-csv.action.d.ts +31 -0
  48. package/dist/providers/jotform/actions/export-csv.action.d.ts.map +1 -0
  49. package/dist/providers/jotform/actions/export-csv.action.js +187 -0
  50. package/dist/providers/jotform/actions/export-csv.action.js.map +1 -0
  51. package/dist/providers/jotform/actions/get-form.action.d.ts +31 -0
  52. package/dist/providers/jotform/actions/get-form.action.d.ts.map +1 -0
  53. package/dist/providers/jotform/actions/get-form.action.js +188 -0
  54. package/dist/providers/jotform/actions/get-form.action.js.map +1 -0
  55. package/dist/providers/jotform/actions/get-single-submission.action.d.ts +31 -0
  56. package/dist/providers/jotform/actions/get-single-submission.action.d.ts.map +1 -0
  57. package/dist/providers/jotform/actions/get-single-submission.action.js +138 -0
  58. package/dist/providers/jotform/actions/get-single-submission.action.js.map +1 -0
  59. package/dist/providers/jotform/actions/get-statistics.action.d.ts +39 -0
  60. package/dist/providers/jotform/actions/get-statistics.action.d.ts.map +1 -0
  61. package/dist/providers/jotform/actions/get-statistics.action.js +290 -0
  62. package/dist/providers/jotform/actions/get-statistics.action.js.map +1 -0
  63. package/dist/providers/jotform/actions/get-submissions.action.d.ts +34 -0
  64. package/dist/providers/jotform/actions/get-submissions.action.d.ts.map +1 -0
  65. package/dist/providers/jotform/actions/get-submissions.action.js +218 -0
  66. package/dist/providers/jotform/actions/get-submissions.action.js.map +1 -0
  67. package/dist/providers/jotform/actions/index.d.ts +9 -0
  68. package/dist/providers/jotform/actions/index.d.ts.map +1 -0
  69. package/dist/providers/jotform/actions/index.js +27 -0
  70. package/dist/providers/jotform/actions/index.js.map +1 -0
  71. package/dist/providers/jotform/actions/update-form.action.d.ts +38 -0
  72. package/dist/providers/jotform/actions/update-form.action.d.ts.map +1 -0
  73. package/dist/providers/jotform/actions/update-form.action.js +232 -0
  74. package/dist/providers/jotform/actions/update-form.action.js.map +1 -0
  75. package/dist/providers/jotform/actions/watch-new-submissions.action.d.ts +32 -0
  76. package/dist/providers/jotform/actions/watch-new-submissions.action.d.ts.map +1 -0
  77. package/dist/providers/jotform/actions/watch-new-submissions.action.js +229 -0
  78. package/dist/providers/jotform/actions/watch-new-submissions.action.js.map +1 -0
  79. package/dist/providers/jotform/index.d.ts +3 -0
  80. package/dist/providers/jotform/index.d.ts.map +1 -0
  81. package/dist/providers/jotform/index.js +21 -0
  82. package/dist/providers/jotform/index.js.map +1 -0
  83. package/dist/providers/jotform/jotform-base.action.d.ts +96 -0
  84. package/dist/providers/jotform/jotform-base.action.d.ts.map +1 -0
  85. package/dist/providers/jotform/jotform-base.action.js +269 -0
  86. package/dist/providers/jotform/jotform-base.action.js.map +1 -0
  87. package/dist/providers/surveymonkey/actions/create-survey.action.d.ts +48 -0
  88. package/dist/providers/surveymonkey/actions/create-survey.action.d.ts.map +1 -0
  89. package/dist/providers/surveymonkey/actions/create-survey.action.js +192 -0
  90. package/dist/providers/surveymonkey/actions/create-survey.action.js.map +1 -0
  91. package/dist/providers/surveymonkey/actions/export-csv.action.d.ts +30 -0
  92. package/dist/providers/surveymonkey/actions/export-csv.action.d.ts.map +1 -0
  93. package/dist/providers/surveymonkey/actions/export-csv.action.js +173 -0
  94. package/dist/providers/surveymonkey/actions/export-csv.action.js.map +1 -0
  95. package/dist/providers/surveymonkey/actions/get-responses.action.d.ts +33 -0
  96. package/dist/providers/surveymonkey/actions/get-responses.action.d.ts.map +1 -0
  97. package/dist/providers/surveymonkey/actions/get-responses.action.js +243 -0
  98. package/dist/providers/surveymonkey/actions/get-responses.action.js.map +1 -0
  99. package/dist/providers/surveymonkey/actions/get-single-response.action.d.ts +30 -0
  100. package/dist/providers/surveymonkey/actions/get-single-response.action.d.ts.map +1 -0
  101. package/dist/providers/surveymonkey/actions/get-single-response.action.js +149 -0
  102. package/dist/providers/surveymonkey/actions/get-single-response.action.js.map +1 -0
  103. package/dist/providers/surveymonkey/actions/get-statistics.action.d.ts +38 -0
  104. package/dist/providers/surveymonkey/actions/get-statistics.action.d.ts.map +1 -0
  105. package/dist/providers/surveymonkey/actions/get-statistics.action.js +261 -0
  106. package/dist/providers/surveymonkey/actions/get-statistics.action.js.map +1 -0
  107. package/dist/providers/surveymonkey/actions/get-survey.action.d.ts +27 -0
  108. package/dist/providers/surveymonkey/actions/get-survey.action.d.ts.map +1 -0
  109. package/dist/providers/surveymonkey/actions/get-survey.action.js +180 -0
  110. package/dist/providers/surveymonkey/actions/get-survey.action.js.map +1 -0
  111. package/dist/providers/surveymonkey/actions/index.d.ts +9 -0
  112. package/dist/providers/surveymonkey/actions/index.d.ts.map +1 -0
  113. package/dist/providers/surveymonkey/actions/index.js +27 -0
  114. package/dist/providers/surveymonkey/actions/index.js.map +1 -0
  115. package/dist/providers/surveymonkey/actions/update-survey.action.d.ts +39 -0
  116. package/dist/providers/surveymonkey/actions/update-survey.action.d.ts.map +1 -0
  117. package/dist/providers/surveymonkey/actions/update-survey.action.js +217 -0
  118. package/dist/providers/surveymonkey/actions/update-survey.action.js.map +1 -0
  119. package/dist/providers/surveymonkey/actions/watch-new-responses.action.d.ts +31 -0
  120. package/dist/providers/surveymonkey/actions/watch-new-responses.action.d.ts.map +1 -0
  121. package/dist/providers/surveymonkey/actions/watch-new-responses.action.js +214 -0
  122. package/dist/providers/surveymonkey/actions/watch-new-responses.action.js.map +1 -0
  123. package/dist/providers/surveymonkey/index.d.ts +3 -0
  124. package/dist/providers/surveymonkey/index.d.ts.map +1 -0
  125. package/dist/providers/surveymonkey/index.js +21 -0
  126. package/dist/providers/surveymonkey/index.js.map +1 -0
  127. package/dist/providers/surveymonkey/surveymonkey-base.action.d.ts +193 -0
  128. package/dist/providers/surveymonkey/surveymonkey-base.action.d.ts.map +1 -0
  129. package/dist/providers/surveymonkey/surveymonkey-base.action.js +329 -0
  130. package/dist/providers/surveymonkey/surveymonkey-base.action.js.map +1 -0
  131. package/dist/providers/typeform/actions/create-form.action.d.ts +40 -0
  132. package/dist/providers/typeform/actions/create-form.action.d.ts.map +1 -0
  133. package/dist/providers/typeform/actions/create-form.action.js +205 -0
  134. package/dist/providers/typeform/actions/create-form.action.js.map +1 -0
  135. package/dist/providers/typeform/actions/export-csv.action.d.ts +31 -0
  136. package/dist/providers/typeform/actions/export-csv.action.d.ts.map +1 -0
  137. package/dist/providers/typeform/actions/export-csv.action.js +182 -0
  138. package/dist/providers/typeform/actions/export-csv.action.js.map +1 -0
  139. package/dist/providers/typeform/actions/get-form.action.d.ts +28 -0
  140. package/dist/providers/typeform/actions/get-form.action.d.ts.map +1 -0
  141. package/dist/providers/typeform/actions/get-form.action.js +172 -0
  142. package/dist/providers/typeform/actions/get-form.action.js.map +1 -0
  143. package/dist/providers/typeform/actions/get-responses.action.d.ts +34 -0
  144. package/dist/providers/typeform/actions/get-responses.action.d.ts.map +1 -0
  145. package/dist/providers/typeform/actions/get-responses.action.js +238 -0
  146. package/dist/providers/typeform/actions/get-responses.action.js.map +1 -0
  147. package/dist/providers/typeform/actions/get-single-response.action.d.ts +31 -0
  148. package/dist/providers/typeform/actions/get-single-response.action.d.ts.map +1 -0
  149. package/dist/providers/typeform/actions/get-single-response.action.js +161 -0
  150. package/dist/providers/typeform/actions/get-single-response.action.js.map +1 -0
  151. package/dist/providers/typeform/actions/get-statistics.action.d.ts +33 -0
  152. package/dist/providers/typeform/actions/get-statistics.action.d.ts.map +1 -0
  153. package/dist/providers/typeform/actions/get-statistics.action.js +257 -0
  154. package/dist/providers/typeform/actions/get-statistics.action.js.map +1 -0
  155. package/dist/providers/typeform/actions/index.d.ts +9 -0
  156. package/dist/providers/typeform/actions/index.d.ts.map +1 -0
  157. package/dist/providers/typeform/actions/index.js +27 -0
  158. package/dist/providers/typeform/actions/index.js.map +1 -0
  159. package/dist/providers/typeform/actions/update-form.action.d.ts +38 -0
  160. package/dist/providers/typeform/actions/update-form.action.d.ts.map +1 -0
  161. package/dist/providers/typeform/actions/update-form.action.js +228 -0
  162. package/dist/providers/typeform/actions/update-form.action.js.map +1 -0
  163. package/dist/providers/typeform/actions/watch-new-responses.action.d.ts +32 -0
  164. package/dist/providers/typeform/actions/watch-new-responses.action.d.ts.map +1 -0
  165. package/dist/providers/typeform/actions/watch-new-responses.action.js +215 -0
  166. package/dist/providers/typeform/actions/watch-new-responses.action.js.map +1 -0
  167. package/dist/providers/typeform/index.d.ts +3 -0
  168. package/dist/providers/typeform/index.d.ts.map +1 -0
  169. package/dist/providers/typeform/index.js +21 -0
  170. package/dist/providers/typeform/index.js.map +1 -0
  171. package/dist/providers/typeform/typeform-base.action.d.ts +121 -0
  172. package/dist/providers/typeform/typeform-base.action.d.ts.map +1 -0
  173. package/dist/providers/typeform/typeform-base.action.js +292 -0
  174. package/dist/providers/typeform/typeform-base.action.js.map +1 -0
  175. package/package.json +41 -0
  176. package/src/base/base-form-builder.action.ts +403 -0
  177. package/src/base/index.ts +1 -0
  178. package/src/index.ts +18 -0
  179. package/src/providers/google-forms/actions/export-csv.action.ts +167 -0
  180. package/src/providers/google-forms/actions/get-form.action.ts +151 -0
  181. package/src/providers/google-forms/actions/get-single-response.action.ts +150 -0
  182. package/src/providers/google-forms/actions/get-statistics.action.ts +273 -0
  183. package/src/providers/google-forms/actions/index.ts +7 -0
  184. package/src/providers/google-forms/googleforms-base.action.ts +517 -0
  185. package/src/providers/google-forms/index.ts +5 -0
  186. package/src/providers/jotform/actions/create-form.action.ts +281 -0
  187. package/src/providers/jotform/actions/export-csv.action.ts +189 -0
  188. package/src/providers/jotform/actions/get-form.action.ts +189 -0
  189. package/src/providers/jotform/actions/get-single-submission.action.ts +137 -0
  190. package/src/providers/jotform/actions/get-statistics.action.ts +308 -0
  191. package/src/providers/jotform/actions/get-submissions.action.ts +220 -0
  192. package/src/providers/jotform/actions/index.ts +11 -0
  193. package/src/providers/jotform/actions/update-form.action.ts +254 -0
  194. package/src/providers/jotform/actions/watch-new-submissions.action.ts +238 -0
  195. package/src/providers/jotform/index.ts +5 -0
  196. package/src/providers/jotform/jotform-base.action.ts +365 -0
  197. package/src/providers/surveymonkey/actions/create-survey.action.ts +196 -0
  198. package/src/providers/surveymonkey/actions/export-csv.action.ts +175 -0
  199. package/src/providers/surveymonkey/actions/get-responses.action.ts +245 -0
  200. package/src/providers/surveymonkey/actions/get-single-response.action.ts +148 -0
  201. package/src/providers/surveymonkey/actions/get-statistics.action.ts +280 -0
  202. package/src/providers/surveymonkey/actions/get-survey.action.ts +181 -0
  203. package/src/providers/surveymonkey/actions/index.ts +11 -0
  204. package/src/providers/surveymonkey/actions/update-survey.action.ts +234 -0
  205. package/src/providers/surveymonkey/actions/watch-new-responses.action.ts +221 -0
  206. package/src/providers/surveymonkey/index.ts +5 -0
  207. package/src/providers/surveymonkey/surveymonkey-base.action.ts +505 -0
  208. package/src/providers/typeform/actions/create-form.action.ts +211 -0
  209. package/src/providers/typeform/actions/export-csv.action.ts +184 -0
  210. package/src/providers/typeform/actions/get-form.action.ts +173 -0
  211. package/src/providers/typeform/actions/get-responses.action.ts +242 -0
  212. package/src/providers/typeform/actions/get-single-response.action.ts +160 -0
  213. package/src/providers/typeform/actions/get-statistics.action.ts +276 -0
  214. package/src/providers/typeform/actions/index.ts +11 -0
  215. package/src/providers/typeform/actions/update-form.action.ts +235 -0
  216. package/src/providers/typeform/actions/watch-new-responses.action.ts +222 -0
  217. package/src/providers/typeform/index.ts +5 -0
  218. package/src/providers/typeform/typeform-base.action.ts +387 -0
  219. package/tsconfig.json +18 -0
@@ -0,0 +1,137 @@
1
+ import { RegisterClass } from '@memberjunction/global';
2
+ import { JotFormBaseAction } from '../jotform-base.action';
3
+ import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
4
+ import { BaseAction } from '@memberjunction/actions';
5
+
6
+ /**
7
+ * Action to retrieve a specific submission from JotForm by submission ID
8
+ *
9
+ * Security: API credentials are retrieved securely from Company Integrations
10
+ * instead of being passed as parameters.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * await runAction({
15
+ * ActionName: 'Get Single JotForm Submission',
16
+ * Params: [{
17
+ * Name: 'CompanyID',
18
+ * Value: 'your-company-id'
19
+ * }, {
20
+ * Name: 'SubmissionID',
21
+ * Value: '1234567890'
22
+ * }, {
23
+ * Name: 'Region',
24
+ * Value: 'us'
25
+ * }]
26
+ * });
27
+ * ```
28
+ */
29
+ @RegisterClass(BaseAction, 'Get Single JotForm Submission')
30
+ export class GetSingleJotFormSubmissionAction extends JotFormBaseAction {
31
+
32
+ public get Description(): string {
33
+ return 'Retrieves details of a specific JotForm submission by its unique submission ID. Includes all answers, metadata, IP address, and submission status.';
34
+ }
35
+
36
+ protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
37
+ try {
38
+ const contextUser = params.ContextUser;
39
+ if (!contextUser) {
40
+ return {
41
+ Success: false,
42
+ ResultCode: 'MISSING_CONTEXT_USER',
43
+ Message: 'Context user is required for JotForm API calls'
44
+ };
45
+ }
46
+
47
+ const companyId = this.getParamValue(params.Params, 'CompanyID');
48
+
49
+ const submissionId = this.getParamValue(params.Params, 'SubmissionID');
50
+ if (!submissionId) {
51
+ return {
52
+ Success: false,
53
+ ResultCode: 'MISSING_SUBMISSION_ID',
54
+ Message: 'SubmissionID parameter is required'
55
+ };
56
+ }
57
+
58
+ const apiKey = await this.getSecureAPIToken(companyId, contextUser);
59
+
60
+ const region = this.getParamValue(params.Params, 'Region') as 'us' | 'eu' | 'hipaa' | undefined;
61
+
62
+ const jfSubmission = await this.getSingleJotFormSubmission(submissionId, apiKey, region);
63
+ const normalizedSubmission = this.normalizeJotFormSubmission(jfSubmission);
64
+
65
+ const outputParams: ActionParam[] = [
66
+ {
67
+ Name: 'Submission',
68
+ Type: 'Output',
69
+ Value: normalizedSubmission
70
+ },
71
+ {
72
+ Name: 'SubmissionID',
73
+ Type: 'Output',
74
+ Value: normalizedSubmission.responseId
75
+ },
76
+ {
77
+ Name: 'SubmittedAt',
78
+ Type: 'Output',
79
+ Value: normalizedSubmission.submittedAt
80
+ },
81
+ {
82
+ Name: 'Status',
83
+ Type: 'Output',
84
+ Value: jfSubmission.status
85
+ },
86
+ {
87
+ Name: 'Answers',
88
+ Type: 'Output',
89
+ Value: normalizedSubmission.answers
90
+ }
91
+ ];
92
+
93
+ for (const outputParam of outputParams) {
94
+ const existingParam = params.Params.find(p => p.Name === outputParam.Name);
95
+ if (existingParam) {
96
+ existingParam.Value = outputParam.Value;
97
+ } else {
98
+ params.Params.push(outputParam);
99
+ }
100
+ }
101
+
102
+ return {
103
+ Success: true,
104
+ ResultCode: 'SUCCESS',
105
+ Message: `Successfully retrieved submission ${submissionId} from JotForm`
106
+ };
107
+
108
+ } catch (error) {
109
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
110
+ return {
111
+ Success: false,
112
+ ResultCode: 'ERROR',
113
+ Message: this.buildFormErrorMessage('Get Single JotForm Submission', errorMessage, error)
114
+ };
115
+ }
116
+ }
117
+
118
+ public get Params(): ActionParam[] {
119
+ return [
120
+ {
121
+ Name: 'CompanyID',
122
+ Type: 'Input',
123
+ Value: null
124
+ },
125
+ {
126
+ Name: 'SubmissionID',
127
+ Type: 'Input',
128
+ Value: null
129
+ },
130
+ {
131
+ Name: 'Region',
132
+ Type: 'Input',
133
+ Value: null
134
+ }
135
+ ];
136
+ }
137
+ }
@@ -0,0 +1,308 @@
1
+ import { RegisterClass } from '@memberjunction/global';
2
+ import { JotFormBaseAction } from '../jotform-base.action';
3
+ import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
4
+ import { BaseAction } from '@memberjunction/actions';
5
+ import { FormStatistics } from '../../../base/base-form-builder.action';
6
+
7
+ /**
8
+ * Action to calculate aggregate statistics from JotForm submissions
9
+ *
10
+ * Security: API credentials are retrieved securely from Company Integrations
11
+ * instead of being passed as parameters.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * await runAction({
16
+ * ActionName: 'Get JotForm Submission Statistics',
17
+ * Params: [{
18
+ * Name: 'CompanyID',
19
+ * Value: 'your-company-id'
20
+ * }, {
21
+ * Name: 'FormID',
22
+ * Value: '123456789'
23
+ * }, {
24
+ * Name: 'Region',
25
+ * Value: 'us'
26
+ * }]
27
+ * });
28
+ * ```
29
+ */
30
+ @RegisterClass(BaseAction, 'Get JotForm Submission Statistics')
31
+ export class GetJotFormStatisticsAction extends JotFormBaseAction {
32
+
33
+ public get Description(): string {
34
+ return 'Calculates comprehensive statistics from JotForm submissions including completion rates, submission trends, popular answers, and time-based analytics. Useful for dashboards and reporting.';
35
+ }
36
+
37
+ protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
38
+ try {
39
+ const contextUser = params.ContextUser;
40
+ if (!contextUser) {
41
+ return {
42
+ Success: false,
43
+ ResultCode: 'MISSING_CONTEXT_USER',
44
+ Message: 'Context user is required for JotForm API calls'
45
+ };
46
+ }
47
+
48
+ const companyId = this.getParamValue(params.Params, 'CompanyID');
49
+
50
+ const formId = this.getParamValue(params.Params, 'FormID');
51
+ if (!formId) {
52
+ return {
53
+ Success: false,
54
+ ResultCode: 'MISSING_FORM_ID',
55
+ Message: 'FormID parameter is required'
56
+ };
57
+ }
58
+
59
+ const apiKey = await this.getSecureAPIToken(companyId, contextUser);
60
+
61
+ const region = this.getParamValue(params.Params, 'Region') as 'us' | 'eu' | 'hipaa' | undefined;
62
+ const filterParam = this.getParamValue(params.Params, 'Filter');
63
+ const maxSubmissions = this.getParamValue(params.Params, 'MaxSubmissions') || 10000;
64
+ const includeTopAnswers = this.getParamValue(params.Params, 'IncludeTopAnswers') !== false;
65
+ const topAnswersLimit = this.getParamValue(params.Params, 'TopAnswersLimit') || 10;
66
+
67
+ // Parse filter if provided as string
68
+ let filter: Record<string, string> | undefined;
69
+ if (filterParam) {
70
+ if (typeof filterParam === 'string') {
71
+ try {
72
+ filter = JSON.parse(filterParam);
73
+ } catch (error) {
74
+ return {
75
+ Success: false,
76
+ ResultCode: 'INVALID_FILTER',
77
+ Message: 'Filter parameter must be a valid JSON object'
78
+ };
79
+ }
80
+ } else {
81
+ filter = filterParam;
82
+ }
83
+ }
84
+
85
+ // Get all submissions from JotForm
86
+ const jfSubmissions = await this.getAllJotFormSubmissions(formId, apiKey, {
87
+ filter,
88
+ maxSubmissions,
89
+ region
90
+ });
91
+
92
+ // Normalize submissions to common format
93
+ const submissions = jfSubmissions.map(s => this.normalizeJotFormSubmission(s));
94
+
95
+ // Calculate statistics
96
+ const completedSubmissions = submissions.filter(s => s.completed);
97
+ const partialSubmissions = submissions.filter(s => !s.completed);
98
+ const completionRate = this.calculateCompletionRate(
99
+ completedSubmissions.length,
100
+ submissions.length
101
+ );
102
+
103
+ const responsesByDate = this.groupResponsesByDate(submissions);
104
+
105
+ const statistics: FormStatistics = {
106
+ totalResponses: submissions.length,
107
+ completedResponses: completedSubmissions.length,
108
+ partialResponses: partialSubmissions.length,
109
+ completionRate,
110
+ averageCompletionTime: this.calculateAverageCompletionTime(submissions),
111
+ responsesByDate
112
+ };
113
+
114
+ // Calculate top answers if requested
115
+ if (includeTopAnswers && submissions.length > 0) {
116
+ const topAnswers: Record<string, Array<{ answer: string; count: number }>> = {};
117
+ const allFieldIds = new Set<string>();
118
+
119
+ for (const submission of submissions) {
120
+ for (const answer of submission.answers) {
121
+ allFieldIds.add(answer.fieldId);
122
+ }
123
+ }
124
+
125
+ for (const fieldId of allFieldIds) {
126
+ const fieldTopAnswers = this.findTopAnswers(submissions, fieldId, topAnswersLimit);
127
+ if (fieldTopAnswers.length > 0) {
128
+ topAnswers[fieldId] = fieldTopAnswers;
129
+ }
130
+ }
131
+
132
+ statistics.topAnswers = topAnswers;
133
+ }
134
+
135
+ // Calculate time-based breakdowns
136
+ const dailyBreakdown = this.calculateDailyBreakdown(submissions);
137
+ const hourlyDistribution = this.calculateHourlyDistribution(submissions);
138
+
139
+ // Build output parameters
140
+ const outputParams: ActionParam[] = [
141
+ {
142
+ Name: 'Statistics',
143
+ Type: 'Output',
144
+ Value: statistics
145
+ },
146
+ {
147
+ Name: 'TotalSubmissions',
148
+ Type: 'Output',
149
+ Value: statistics.totalResponses
150
+ },
151
+ {
152
+ Name: 'CompletedSubmissions',
153
+ Type: 'Output',
154
+ Value: statistics.completedResponses
155
+ },
156
+ {
157
+ Name: 'PartialSubmissions',
158
+ Type: 'Output',
159
+ Value: statistics.partialResponses
160
+ },
161
+ {
162
+ Name: 'CompletionRate',
163
+ Type: 'Output',
164
+ Value: statistics.completionRate
165
+ },
166
+ {
167
+ Name: 'AverageCompletionTime',
168
+ Type: 'Output',
169
+ Value: statistics.averageCompletionTime
170
+ },
171
+ {
172
+ Name: 'ResponsesByDate',
173
+ Type: 'Output',
174
+ Value: statistics.responsesByDate
175
+ },
176
+ {
177
+ Name: 'DailyBreakdown',
178
+ Type: 'Output',
179
+ Value: dailyBreakdown
180
+ },
181
+ {
182
+ Name: 'HourlyDistribution',
183
+ Type: 'Output',
184
+ Value: hourlyDistribution
185
+ }
186
+ ];
187
+
188
+ if (includeTopAnswers) {
189
+ outputParams.push({
190
+ Name: 'TopAnswers',
191
+ Type: 'Output',
192
+ Value: statistics.topAnswers
193
+ });
194
+ }
195
+
196
+ // Update params with output values
197
+ for (const outputParam of outputParams) {
198
+ const existingParam = params.Params.find(p => p.Name === outputParam.Name);
199
+ if (existingParam) {
200
+ existingParam.Value = outputParam.Value;
201
+ } else {
202
+ params.Params.push(outputParam);
203
+ }
204
+ }
205
+
206
+ return {
207
+ Success: true,
208
+ ResultCode: 'SUCCESS',
209
+ Message: `Successfully calculated statistics from ${submissions.length} JotForm submissions (${completionRate}% completion rate)`
210
+ };
211
+
212
+ } catch (error) {
213
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
214
+ return {
215
+ Success: false,
216
+ ResultCode: 'ERROR',
217
+ Message: this.buildFormErrorMessage('Get JotForm Statistics', errorMessage, error)
218
+ };
219
+ }
220
+ }
221
+
222
+ /**
223
+ * Calculate daily breakdown of submissions
224
+ */
225
+ private calculateDailyBreakdown(submissions: any[]): Array<{ date: string; count: number; completed: number; partial: number }> {
226
+ const daily: Record<string, { count: number; completed: number; partial: number }> = {};
227
+
228
+ for (const submission of submissions) {
229
+ const dateKey = submission.submittedAt.toISOString().split('T')[0];
230
+ if (!daily[dateKey]) {
231
+ daily[dateKey] = { count: 0, completed: 0, partial: 0 };
232
+ }
233
+ daily[dateKey].count++;
234
+ if (submission.completed) {
235
+ daily[dateKey].completed++;
236
+ } else {
237
+ daily[dateKey].partial++;
238
+ }
239
+ }
240
+
241
+ return Object.entries(daily)
242
+ .map(([date, stats]) => ({ date, ...stats }))
243
+ .sort((a, b) => a.date.localeCompare(b.date));
244
+ }
245
+
246
+ /**
247
+ * Calculate hourly distribution of submissions
248
+ */
249
+ private calculateHourlyDistribution(submissions: any[]): Array<{ hour: number; count: number }> {
250
+ const hourly: Record<number, number> = {};
251
+
252
+ // Initialize all hours
253
+ for (let i = 0; i < 24; i++) {
254
+ hourly[i] = 0;
255
+ }
256
+
257
+ // Count submissions by hour
258
+ for (const submission of submissions) {
259
+ const hour = submission.submittedAt.getHours();
260
+ hourly[hour]++;
261
+ }
262
+
263
+ return Object.entries(hourly).map(([hour, count]) => ({
264
+ hour: parseInt(hour),
265
+ count
266
+ }));
267
+ }
268
+
269
+ public get Params(): ActionParam[] {
270
+ return [
271
+ {
272
+ Name: 'CompanyID',
273
+ Type: 'Input',
274
+ Value: null
275
+ },
276
+ {
277
+ Name: 'FormID',
278
+ Type: 'Input',
279
+ Value: null
280
+ },
281
+ {
282
+ Name: 'Region',
283
+ Type: 'Input',
284
+ Value: 'us'
285
+ },
286
+ {
287
+ Name: 'Filter',
288
+ Type: 'Input',
289
+ Value: null
290
+ },
291
+ {
292
+ Name: 'MaxSubmissions',
293
+ Type: 'Input',
294
+ Value: 10000
295
+ },
296
+ {
297
+ Name: 'IncludeTopAnswers',
298
+ Type: 'Input',
299
+ Value: true
300
+ },
301
+ {
302
+ Name: 'TopAnswersLimit',
303
+ Type: 'Input',
304
+ Value: 10
305
+ }
306
+ ];
307
+ }
308
+ }
@@ -0,0 +1,220 @@
1
+ import { RegisterClass } from '@memberjunction/global';
2
+ import { JotFormBaseAction } from '../jotform-base.action';
3
+ import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
4
+ import { BaseAction } from '@memberjunction/actions';
5
+ import { FormResponse } from '../../../base/base-form-builder.action';
6
+
7
+ /**
8
+ * Action to retrieve submissions from a JotForm with comprehensive filtering options
9
+ *
10
+ * Security: API credentials are retrieved securely from Company Integrations
11
+ * instead of being passed as parameters.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * await runAction({
16
+ * ActionName: 'Get JotForm Submissions',
17
+ * Params: [{
18
+ * Name: 'CompanyID',
19
+ * Value: 'your-company-id'
20
+ * }, {
21
+ * Name: 'FormID',
22
+ * Value: '123456789'
23
+ * }, {
24
+ * Name: 'Filter',
25
+ * Value: JSON.stringify({ status: 'ACTIVE', created_at: 'gt:2024-01-01' })
26
+ * }, {
27
+ * Name: 'GetAllPages',
28
+ * Value: true
29
+ * }]
30
+ * });
31
+ * ```
32
+ */
33
+ @RegisterClass(BaseAction, 'Get JotForm Submissions')
34
+ export class GetJotFormSubmissionsAction extends JotFormBaseAction {
35
+
36
+ public get Description(): string {
37
+ return 'Retrieves submissions from a JotForm with filtering, pagination, and ordering capabilities. Supports date ranges, status filtering, and custom field filters.';
38
+ }
39
+
40
+ protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
41
+ try {
42
+ const contextUser = params.ContextUser;
43
+ if (!contextUser) {
44
+ return {
45
+ Success: false,
46
+ ResultCode: 'MISSING_CONTEXT_USER',
47
+ Message: 'Context user is required for JotForm API calls'
48
+ };
49
+ }
50
+
51
+ const companyId = this.getParamValue(params.Params, 'CompanyID');
52
+
53
+ const formId = this.getParamValue(params.Params, 'FormID');
54
+ if (!formId) {
55
+ return {
56
+ Success: false,
57
+ ResultCode: 'MISSING_FORM_ID',
58
+ Message: 'FormID parameter is required'
59
+ };
60
+ }
61
+
62
+ const apiKey = await this.getSecureAPIToken(companyId, contextUser);
63
+
64
+ const limit = this.getParamValue(params.Params, 'Limit') || 100;
65
+ const offset = this.getParamValue(params.Params, 'Offset') || 0;
66
+ const filterParam = this.getParamValue(params.Params, 'Filter');
67
+ const orderby = this.getParamValue(params.Params, 'OrderBy');
68
+ const region = this.getParamValue(params.Params, 'Region') as 'us' | 'eu' | 'hipaa' | undefined;
69
+ const getAllPages = this.getParamValue(params.Params, 'GetAllPages') === true;
70
+
71
+ // Parse filter if provided (expects JSON string)
72
+ let filter: Record<string, string> | undefined;
73
+ if (filterParam) {
74
+ try {
75
+ filter = typeof filterParam === 'string' ? JSON.parse(filterParam) : filterParam;
76
+ } catch (error) {
77
+ return {
78
+ Success: false,
79
+ ResultCode: 'INVALID_FILTER',
80
+ Message: 'Filter parameter must be a valid JSON object'
81
+ };
82
+ }
83
+ }
84
+
85
+ let submissions: FormResponse[];
86
+ let totalCount: number;
87
+ let actualLimit: number;
88
+ let actualOffset: number;
89
+
90
+ if (getAllPages) {
91
+ const maxSubmissions = this.getParamValue(params.Params, 'MaxSubmissions') || 10000;
92
+ const jfSubmissions = await this.getAllJotFormSubmissions(formId, apiKey, {
93
+ filter,
94
+ orderby,
95
+ maxSubmissions,
96
+ region
97
+ });
98
+
99
+ submissions = jfSubmissions.map(s => this.normalizeJotFormSubmission(s));
100
+ totalCount = submissions.length;
101
+ actualLimit = submissions.length;
102
+ actualOffset = 0;
103
+ } else {
104
+ const result = await this.getJotFormSubmissions(formId, apiKey, {
105
+ limit: Math.min(limit, 1000),
106
+ offset,
107
+ filter,
108
+ orderby,
109
+ region
110
+ });
111
+
112
+ submissions = result.content.map(s => this.normalizeJotFormSubmission(s));
113
+ totalCount = submissions.length; // JotForm doesn't return total count in API
114
+ actualLimit = result.limit;
115
+ actualOffset = result.offset;
116
+ }
117
+
118
+ const outputParams: ActionParam[] = [
119
+ {
120
+ Name: 'Submissions',
121
+ Type: 'Output',
122
+ Value: submissions
123
+ },
124
+ {
125
+ Name: 'TotalCount',
126
+ Type: 'Output',
127
+ Value: totalCount
128
+ },
129
+ {
130
+ Name: 'Limit',
131
+ Type: 'Output',
132
+ Value: actualLimit
133
+ },
134
+ {
135
+ Name: 'Offset',
136
+ Type: 'Output',
137
+ Value: actualOffset
138
+ },
139
+ {
140
+ Name: 'Count',
141
+ Type: 'Output',
142
+ Value: submissions.length
143
+ }
144
+ ];
145
+
146
+ for (const outputParam of outputParams) {
147
+ const existingParam = params.Params.find(p => p.Name === outputParam.Name);
148
+ if (existingParam) {
149
+ existingParam.Value = outputParam.Value;
150
+ } else {
151
+ params.Params.push(outputParam);
152
+ }
153
+ }
154
+
155
+ return {
156
+ Success: true,
157
+ ResultCode: 'SUCCESS',
158
+ Message: `Successfully retrieved ${submissions.length} submissions from JotForm${getAllPages ? '' : ` (offset: ${actualOffset}, limit: ${actualLimit})`}`
159
+ };
160
+
161
+ } catch (error) {
162
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
163
+ return {
164
+ Success: false,
165
+ ResultCode: 'ERROR',
166
+ Message: this.buildFormErrorMessage('Get JotForm Submissions', errorMessage, error)
167
+ };
168
+ }
169
+ }
170
+
171
+ public get Params(): ActionParam[] {
172
+ return [
173
+ {
174
+ Name: 'CompanyID',
175
+ Type: 'Input',
176
+ Value: null
177
+ },
178
+ {
179
+ Name: 'FormID',
180
+ Type: 'Input',
181
+ Value: null
182
+ },
183
+ {
184
+ Name: 'Region',
185
+ Type: 'Input',
186
+ Value: 'us'
187
+ },
188
+ {
189
+ Name: 'Limit',
190
+ Type: 'Input',
191
+ Value: 100
192
+ },
193
+ {
194
+ Name: 'Offset',
195
+ Type: 'Input',
196
+ Value: 0
197
+ },
198
+ {
199
+ Name: 'Filter',
200
+ Type: 'Input',
201
+ Value: null
202
+ },
203
+ {
204
+ Name: 'OrderBy',
205
+ Type: 'Input',
206
+ Value: null
207
+ },
208
+ {
209
+ Name: 'GetAllPages',
210
+ Type: 'Input',
211
+ Value: false
212
+ },
213
+ {
214
+ Name: 'MaxSubmissions',
215
+ Type: 'Input',
216
+ Value: 10000
217
+ }
218
+ ];
219
+ }
220
+ }
@@ -0,0 +1,11 @@
1
+ // JotForm Form Actions
2
+ export * from './create-form.action';
3
+ export * from './get-form.action';
4
+ export * from './update-form.action';
5
+
6
+ // JotForm Submission Actions
7
+ export * from './get-submissions.action';
8
+ export * from './get-single-submission.action';
9
+ export * from './get-statistics.action';
10
+ export * from './export-csv.action';
11
+ export * from './watch-new-submissions.action';