@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,151 @@
1
+ import { RegisterClass } from '@memberjunction/global';
2
+ import { GoogleFormsBaseAction } from '../googleforms-base.action';
3
+ import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
4
+ import { BaseAction } from '@memberjunction/actions';
5
+
6
+ /**
7
+ * Action to retrieve complete details of a Google Form including all questions, settings, and configuration
8
+ *
9
+ * Security: This action uses secure credential lookup via Company Integrations.
10
+ * API credentials are retrieved from environment variables or the database based on CompanyID.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * await runAction({
15
+ * ActionName: 'Get Google Forms Details',
16
+ * Params: [{
17
+ * Name: 'CompanyID',
18
+ * Value: 'company-uuid-here'
19
+ * }, {
20
+ * Name: 'FormID',
21
+ * Value: '1FAIpQLSe...'
22
+ * }]
23
+ * });
24
+ * ```
25
+ */
26
+ @RegisterClass(BaseAction, 'Get Google Forms Details')
27
+ export class GetGoogleFormAction extends GoogleFormsBaseAction {
28
+
29
+ public get Description(): string {
30
+ return 'Retrieves complete details of a Google Form including title, questions, logic, settings, and metadata. Use this to inspect form configurations, analyze form structure, and backup form data.';
31
+ }
32
+
33
+ protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
34
+ try {
35
+ const contextUser = params.ContextUser;
36
+ if (!contextUser) {
37
+ return {
38
+ Success: false,
39
+ ResultCode: 'MISSING_CONTEXT_USER',
40
+ Message: 'Context user is required for Google Forms API calls'
41
+ };
42
+ }
43
+
44
+ const companyId = this.getParamValue(params.Params, 'CompanyID');
45
+
46
+ const formId = this.getParamValue(params.Params, 'FormID');
47
+ if (!formId) {
48
+ return {
49
+ Success: false,
50
+ ResultCode: 'MISSING_FORM_ID',
51
+ Message: 'FormID parameter is required'
52
+ };
53
+ }
54
+
55
+ const accessToken = await this.getSecureAPIToken(companyId, contextUser);
56
+
57
+ // Fetch form details from Google Forms API
58
+ const form = await this.getGoogleFormsDetails(formId, accessToken);
59
+
60
+ // Extract form information
61
+ const questionCount = form.items?.filter(item => item.questionItem).length || 0;
62
+ const title = form.info.title || '';
63
+ const description = form.info.description || '';
64
+ const documentTitle = form.info.documentTitle || title;
65
+
66
+ // Build comprehensive form details object
67
+ const formOutput = {
68
+ formId: form.formId,
69
+ info: form.info,
70
+ items: form.items,
71
+ settings: form.settings,
72
+ revisionId: form.revisionId,
73
+ responderUri: form.responderUri,
74
+ linkedSheetId: form.linkedSheetId
75
+ };
76
+
77
+ // Prepare output parameters
78
+ const outputParams: ActionParam[] = [
79
+ {
80
+ Name: 'Form',
81
+ Type: 'Output',
82
+ Value: formOutput
83
+ },
84
+ {
85
+ Name: 'FormID',
86
+ Type: 'Output',
87
+ Value: form.formId
88
+ },
89
+ {
90
+ Name: 'Title',
91
+ Type: 'Output',
92
+ Value: title
93
+ },
94
+ {
95
+ Name: 'Description',
96
+ Type: 'Output',
97
+ Value: description
98
+ },
99
+ {
100
+ Name: 'QuestionCount',
101
+ Type: 'Output',
102
+ Value: questionCount
103
+ },
104
+ {
105
+ Name: 'DocumentTitle',
106
+ Type: 'Output',
107
+ Value: documentTitle
108
+ }
109
+ ];
110
+
111
+ // Update params with output values
112
+ for (const outputParam of outputParams) {
113
+ const existingParam = params.Params.find(p => p.Name === outputParam.Name);
114
+ if (existingParam) {
115
+ existingParam.Value = outputParam.Value;
116
+ } else {
117
+ params.Params.push(outputParam);
118
+ }
119
+ }
120
+
121
+ return {
122
+ Success: true,
123
+ ResultCode: 'SUCCESS',
124
+ Message: `Successfully retrieved Google Form "${title}" with ${questionCount} questions`
125
+ };
126
+
127
+ } catch (error) {
128
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
129
+ return {
130
+ Success: false,
131
+ ResultCode: 'ERROR',
132
+ Message: this.buildFormErrorMessage('Get Google Forms Details', errorMessage, error)
133
+ };
134
+ }
135
+ }
136
+
137
+ public get Params(): ActionParam[] {
138
+ return [
139
+ {
140
+ Name: 'CompanyID',
141
+ Type: 'Input',
142
+ Value: null,
143
+ },
144
+ {
145
+ Name: 'FormID',
146
+ Type: 'Input',
147
+ Value: null,
148
+ }
149
+ ];
150
+ }
151
+ }
@@ -0,0 +1,150 @@
1
+ import { RegisterClass } from '@memberjunction/global';
2
+ import { GoogleFormsBaseAction } from '../googleforms-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 response from Google Forms by response ID
8
+ *
9
+ * Security: This action uses secure credential lookup via Company Integrations.
10
+ * API credentials are retrieved from environment variables or the database based on CompanyID.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * await runAction({
15
+ * ActionName: 'Get Single Google Forms Response',
16
+ * Params: [{
17
+ * Name: 'CompanyID',
18
+ * Value: 'company-uuid-here'
19
+ * }, {
20
+ * Name: 'FormID',
21
+ * Value: 'abc123xyz'
22
+ * }, {
23
+ * Name: 'ResponseID',
24
+ * Value: 'ACYDBNhVXdW3lFGH...'
25
+ * }]
26
+ * });
27
+ * ```
28
+ */
29
+ @RegisterClass(BaseAction, 'Get Single Google Forms Response')
30
+ export class GetSingleGoogleFormsResponseAction extends GoogleFormsBaseAction {
31
+
32
+ public get Description(): string {
33
+ return 'Retrieves details of a specific Google Forms response by its unique response ID. Includes all answers, metadata, submission timing information, and respondent email if available.';
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 Google Forms API calls'
44
+ };
45
+ }
46
+
47
+ const companyId = this.getParamValue(params.Params, 'CompanyID');
48
+
49
+ const formId = this.getParamValue(params.Params, 'FormID');
50
+ if (!formId) {
51
+ return {
52
+ Success: false,
53
+ ResultCode: 'MISSING_FORM_ID',
54
+ Message: 'FormID parameter is required'
55
+ };
56
+ }
57
+
58
+ const responseId = this.getParamValue(params.Params, 'ResponseID');
59
+ if (!responseId) {
60
+ return {
61
+ Success: false,
62
+ ResultCode: 'MISSING_RESPONSE_ID',
63
+ Message: 'ResponseID parameter is required'
64
+ };
65
+ }
66
+
67
+ const accessToken = await this.getSecureAPIToken(companyId, contextUser);
68
+
69
+ const gfResponse = await this.getSingleGoogleFormsResponse(formId, responseId, accessToken);
70
+ const normalizedResponse = this.normalizeGoogleFormsResponse(gfResponse);
71
+
72
+ // Build respondent object with email if available
73
+ const respondent: { email?: string } = {};
74
+ if (gfResponse.respondentEmail) {
75
+ respondent.email = gfResponse.respondentEmail;
76
+ }
77
+
78
+ const outputParams: ActionParam[] = [
79
+ {
80
+ Name: 'Response',
81
+ Type: 'Output',
82
+ Value: normalizedResponse
83
+ },
84
+ {
85
+ Name: 'ResponseID',
86
+ Type: 'Output',
87
+ Value: normalizedResponse.responseId
88
+ },
89
+ {
90
+ Name: 'SubmittedAt',
91
+ Type: 'Output',
92
+ Value: normalizedResponse.submittedAt
93
+ },
94
+ {
95
+ Name: 'Answers',
96
+ Type: 'Output',
97
+ Value: normalizedResponse.answers
98
+ },
99
+ {
100
+ Name: 'Respondent',
101
+ Type: 'Output',
102
+ Value: respondent
103
+ }
104
+ ];
105
+
106
+ for (const outputParam of outputParams) {
107
+ const existingParam = params.Params.find(p => p.Name === outputParam.Name);
108
+ if (existingParam) {
109
+ existingParam.Value = outputParam.Value;
110
+ } else {
111
+ params.Params.push(outputParam);
112
+ }
113
+ }
114
+
115
+ return {
116
+ Success: true,
117
+ ResultCode: 'SUCCESS',
118
+ Message: `Successfully retrieved response ${responseId} from Google Forms`
119
+ };
120
+
121
+ } catch (error) {
122
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
123
+ return {
124
+ Success: false,
125
+ ResultCode: 'ERROR',
126
+ Message: this.buildFormErrorMessage('Get Single Google Forms Response', errorMessage, error)
127
+ };
128
+ }
129
+ }
130
+
131
+ public get Params(): ActionParam[] {
132
+ return [
133
+ {
134
+ Name: 'CompanyID',
135
+ Type: 'Input',
136
+ Value: null,
137
+ },
138
+ {
139
+ Name: 'FormID',
140
+ Type: 'Input',
141
+ Value: null,
142
+ },
143
+ {
144
+ Name: 'ResponseID',
145
+ Type: 'Input',
146
+ Value: null,
147
+ }
148
+ ];
149
+ }
150
+ }
@@ -0,0 +1,273 @@
1
+ import { RegisterClass } from '@memberjunction/global';
2
+ import { GoogleFormsBaseAction } from '../googleforms-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 Google Forms responses
9
+ *
10
+ * Security: This action uses secure credential lookup via Company Integrations.
11
+ * API credentials are retrieved from environment variables or the database based on CompanyID.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * await runAction({
16
+ * ActionName: 'Get Google Forms Response Statistics',
17
+ * Params: [{
18
+ * Name: 'CompanyID',
19
+ * Value: 'company-uuid-here'
20
+ * }, {
21
+ * Name: 'FormID',
22
+ * Value: '1a2b3c4d5e'
23
+ * }]
24
+ * });
25
+ * ```
26
+ */
27
+ @RegisterClass(BaseAction, 'Get Google Forms Response Statistics')
28
+ export class GetGoogleFormsStatisticsAction extends GoogleFormsBaseAction {
29
+
30
+ public get Description(): string {
31
+ return 'Calculates comprehensive statistics from Google Forms responses including completion rates, response trends, popular answers, and time-based analytics. Useful for dashboards and reporting.';
32
+ }
33
+
34
+ protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
35
+ try {
36
+ const contextUser = params.ContextUser;
37
+ if (!contextUser) {
38
+ return {
39
+ Success: false,
40
+ ResultCode: 'MISSING_CONTEXT_USER',
41
+ Message: 'Context user is required for Google Forms API calls'
42
+ };
43
+ }
44
+
45
+ const companyId = this.getParamValue(params.Params, 'CompanyID');
46
+
47
+ const formId = this.getParamValue(params.Params, 'FormID');
48
+ if (!formId) {
49
+ return {
50
+ Success: false,
51
+ ResultCode: 'MISSING_FORM_ID',
52
+ Message: 'FormID parameter is required'
53
+ };
54
+ }
55
+
56
+ const accessToken = await this.getSecureAPIToken(companyId, contextUser);
57
+
58
+ const maxResponses = this.getParamValue(params.Params, 'MaxResponses') || 10000;
59
+ const includeTopAnswers = this.getParamValue(params.Params, 'IncludeTopAnswers') !== false;
60
+ const topAnswersLimit = this.getParamValue(params.Params, 'TopAnswersLimit') || 10;
61
+
62
+ // Get all responses from Google Forms
63
+ const gfResponses = await this.getAllGoogleFormsResponses(formId, accessToken, {
64
+ maxResponses
65
+ });
66
+
67
+ // Normalize responses to common format
68
+ const responses = gfResponses.map(r => this.normalizeGoogleFormsResponse(r));
69
+
70
+ // Calculate statistics
71
+ const completedResponses = responses.filter(r => r.completed);
72
+ const partialResponses = responses.filter(r => !r.completed);
73
+ const completionRate = this.calculateCompletionRate(
74
+ completedResponses.length,
75
+ responses.length
76
+ );
77
+
78
+ const responsesByDate = this.groupResponsesByDate(responses);
79
+
80
+ const statistics: FormStatistics = {
81
+ totalResponses: responses.length,
82
+ completedResponses: completedResponses.length,
83
+ partialResponses: partialResponses.length,
84
+ completionRate,
85
+ averageCompletionTime: this.calculateAverageCompletionTime(responses),
86
+ responsesByDate
87
+ };
88
+
89
+ // Calculate top answers if requested
90
+ if (includeTopAnswers && responses.length > 0) {
91
+ const topAnswers: Record<string, Array<{ answer: string; count: number }>> = {};
92
+ const allFieldIds = new Set<string>();
93
+
94
+ for (const response of responses) {
95
+ for (const answer of response.answers) {
96
+ allFieldIds.add(answer.fieldId);
97
+ }
98
+ }
99
+
100
+ for (const fieldId of allFieldIds) {
101
+ const fieldTopAnswers = this.findTopAnswers(responses, fieldId, topAnswersLimit);
102
+ if (fieldTopAnswers.length > 0) {
103
+ topAnswers[fieldId] = fieldTopAnswers;
104
+ }
105
+ }
106
+
107
+ statistics.topAnswers = topAnswers;
108
+ }
109
+
110
+ // Calculate time-based breakdowns
111
+ const dailyBreakdown = this.calculateDailyBreakdown(responses);
112
+ const hourlyDistribution = this.calculateHourlyDistribution(responses);
113
+
114
+ // Build output parameters
115
+ const outputParams: ActionParam[] = [
116
+ {
117
+ Name: 'Statistics',
118
+ Type: 'Output',
119
+ Value: statistics
120
+ },
121
+ {
122
+ Name: 'TotalResponses',
123
+ Type: 'Output',
124
+ Value: statistics.totalResponses
125
+ },
126
+ {
127
+ Name: 'CompletedResponses',
128
+ Type: 'Output',
129
+ Value: statistics.completedResponses
130
+ },
131
+ {
132
+ Name: 'PartialResponses',
133
+ Type: 'Output',
134
+ Value: statistics.partialResponses
135
+ },
136
+ {
137
+ Name: 'CompletionRate',
138
+ Type: 'Output',
139
+ Value: statistics.completionRate
140
+ },
141
+ {
142
+ Name: 'AverageCompletionTime',
143
+ Type: 'Output',
144
+ Value: statistics.averageCompletionTime
145
+ },
146
+ {
147
+ Name: 'ResponsesByDate',
148
+ Type: 'Output',
149
+ Value: statistics.responsesByDate
150
+ },
151
+ {
152
+ Name: 'DailyBreakdown',
153
+ Type: 'Output',
154
+ Value: dailyBreakdown
155
+ },
156
+ {
157
+ Name: 'HourlyDistribution',
158
+ Type: 'Output',
159
+ Value: hourlyDistribution
160
+ }
161
+ ];
162
+
163
+ if (includeTopAnswers) {
164
+ outputParams.push({
165
+ Name: 'TopAnswers',
166
+ Type: 'Output',
167
+ Value: statistics.topAnswers
168
+ });
169
+ }
170
+
171
+ // Update params with output values
172
+ for (const outputParam of outputParams) {
173
+ const existingParam = params.Params.find(p => p.Name === outputParam.Name);
174
+ if (existingParam) {
175
+ existingParam.Value = outputParam.Value;
176
+ } else {
177
+ params.Params.push(outputParam);
178
+ }
179
+ }
180
+
181
+ return {
182
+ Success: true,
183
+ ResultCode: 'SUCCESS',
184
+ Message: `Successfully calculated statistics from ${responses.length} Google Forms responses (${completionRate}% completion rate)`
185
+ };
186
+
187
+ } catch (error) {
188
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
189
+ return {
190
+ Success: false,
191
+ ResultCode: 'ERROR',
192
+ Message: this.buildFormErrorMessage('Get Google Forms Statistics', errorMessage, error)
193
+ };
194
+ }
195
+ }
196
+
197
+ /**
198
+ * Calculate daily breakdown of responses
199
+ */
200
+ private calculateDailyBreakdown(responses: any[]): Array<{ date: string; count: number; completed: number; partial: number }> {
201
+ const daily: Record<string, { count: number; completed: number; partial: number }> = {};
202
+
203
+ for (const response of responses) {
204
+ const dateKey = response.submittedAt.toISOString().split('T')[0];
205
+ if (!daily[dateKey]) {
206
+ daily[dateKey] = { count: 0, completed: 0, partial: 0 };
207
+ }
208
+ daily[dateKey].count++;
209
+ if (response.completed) {
210
+ daily[dateKey].completed++;
211
+ } else {
212
+ daily[dateKey].partial++;
213
+ }
214
+ }
215
+
216
+ return Object.entries(daily)
217
+ .map(([date, stats]) => ({ date, ...stats }))
218
+ .sort((a, b) => a.date.localeCompare(b.date));
219
+ }
220
+
221
+ /**
222
+ * Calculate hourly distribution of responses
223
+ */
224
+ private calculateHourlyDistribution(responses: any[]): Array<{ hour: number; count: number }> {
225
+ const hourly: Record<number, number> = {};
226
+
227
+ // Initialize all hours
228
+ for (let i = 0; i < 24; i++) {
229
+ hourly[i] = 0;
230
+ }
231
+
232
+ // Count responses by hour
233
+ for (const response of responses) {
234
+ const hour = response.submittedAt.getHours();
235
+ hourly[hour]++;
236
+ }
237
+
238
+ return Object.entries(hourly).map(([hour, count]) => ({
239
+ hour: parseInt(hour),
240
+ count
241
+ }));
242
+ }
243
+
244
+ public get Params(): ActionParam[] {
245
+ return [
246
+ {
247
+ Name: 'CompanyID',
248
+ Type: 'Input',
249
+ Value: null
250
+ },
251
+ {
252
+ Name: 'FormID',
253
+ Type: 'Input',
254
+ Value: null
255
+ },
256
+ {
257
+ Name: 'MaxResponses',
258
+ Type: 'Input',
259
+ Value: 10000
260
+ },
261
+ {
262
+ Name: 'IncludeTopAnswers',
263
+ Type: 'Input',
264
+ Value: true
265
+ },
266
+ {
267
+ Name: 'TopAnswersLimit',
268
+ Type: 'Input',
269
+ Value: 10
270
+ }
271
+ ];
272
+ }
273
+ }
@@ -0,0 +1,7 @@
1
+ // Google Forms Response Actions
2
+ export * from './get-single-response.action';
3
+ export * from './get-statistics.action';
4
+ export * from './export-csv.action';
5
+
6
+ // Google Forms Form Management Actions
7
+ export * from './get-form.action';