@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,281 @@
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 create a new JotForm programmatically
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: 'Create JotForm',
16
+ * Params: [{
17
+ * Name: 'CompanyID',
18
+ * Value: 'your-company-id'
19
+ * }, {
20
+ * Name: 'Title',
21
+ * Value: 'Customer Feedback Form'
22
+ * }, {
23
+ * Name: 'Questions',
24
+ * Value: [{
25
+ * type: 'control_text',
26
+ * text: 'What is your name?',
27
+ * name: 'name',
28
+ * required: 'Yes'
29
+ * }, {
30
+ * type: 'control_email',
31
+ * text: 'What is your email address?',
32
+ * name: 'email',
33
+ * required: 'Yes'
34
+ * }]
35
+ * }, {
36
+ * Name: 'Properties',
37
+ * Value: {
38
+ * thankYouURL: 'https://example.com/thank-you',
39
+ * requiresPassword: false
40
+ * }
41
+ * }]
42
+ * });
43
+ * ```
44
+ */
45
+ @RegisterClass(BaseAction, 'Create JotForm')
46
+ export class CreateJotFormAction extends JotFormBaseAction {
47
+
48
+ public get Description(): string {
49
+ return 'Creates a new JotForm with specified title, questions, and properties. Supports all question types including text inputs, email, dropdowns, checkboxes, file uploads, and more. Returns the new form ID, public URL, and admin URL.';
50
+ }
51
+
52
+ protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
53
+ try {
54
+ const contextUser = params.ContextUser;
55
+ if (!contextUser) {
56
+ return {
57
+ Success: false,
58
+ ResultCode: 'MISSING_CONTEXT_USER',
59
+ Message: 'Context user is required for JotForm API calls'
60
+ };
61
+ }
62
+
63
+ const companyId = this.getParamValue(params.Params, 'CompanyID');
64
+
65
+ const apiToken = await this.getSecureAPIToken(companyId, contextUser);
66
+
67
+ const title = this.getParamValue(params.Params, 'Title');
68
+ if (!title) {
69
+ return {
70
+ Success: false,
71
+ ResultCode: 'MISSING_TITLE',
72
+ Message: 'Title parameter is required'
73
+ };
74
+ }
75
+
76
+ const questions = this.getParamValue(params.Params, 'Questions');
77
+ if (!questions || !Array.isArray(questions) || questions.length === 0) {
78
+ return {
79
+ Success: false,
80
+ ResultCode: 'MISSING_QUESTIONS',
81
+ Message: 'Questions parameter is required and must be a non-empty array'
82
+ };
83
+ }
84
+
85
+ const region = this.getParamValue(params.Params, 'Region') as 'us' | 'eu' | 'hipaa' | undefined;
86
+
87
+ const formData: Record<string, any> = {
88
+ 'questions': this.buildQuestionsObject(questions),
89
+ 'properties': {
90
+ 'title': title
91
+ }
92
+ };
93
+
94
+ const properties = this.getParamValue(params.Params, 'Properties');
95
+ if (properties && typeof properties === 'object') {
96
+ formData.properties = {
97
+ ...formData.properties,
98
+ ...properties
99
+ };
100
+ }
101
+
102
+ const response = await this.getAxiosInstance(apiToken, region).post('/user/forms', null, {
103
+ params: {
104
+ apiKey: apiToken,
105
+ ...this.flattenFormData(formData)
106
+ }
107
+ });
108
+
109
+ const createdForm = response.data.content;
110
+
111
+ const formUrl = `https://form.jotform.com/${createdForm.id}`;
112
+ const adminUrl = `https://www.jotform.com/build/${createdForm.id}`;
113
+
114
+ const outputParams: ActionParam[] = [
115
+ {
116
+ Name: 'FormDetails',
117
+ Type: 'Output',
118
+ Value: createdForm
119
+ },
120
+ {
121
+ Name: 'FormID',
122
+ Type: 'Output',
123
+ Value: createdForm.id
124
+ },
125
+ {
126
+ Name: 'FormURL',
127
+ Type: 'Output',
128
+ Value: formUrl
129
+ },
130
+ {
131
+ Name: 'AdminURL',
132
+ Type: 'Output',
133
+ Value: adminUrl
134
+ }
135
+ ];
136
+
137
+ for (const outputParam of outputParams) {
138
+ const existingParam = params.Params.find(p => p.Name === outputParam.Name);
139
+ if (existingParam) {
140
+ existingParam.Value = outputParam.Value;
141
+ } else {
142
+ params.Params.push(outputParam);
143
+ }
144
+ }
145
+
146
+ return {
147
+ Success: true,
148
+ ResultCode: 'SUCCESS',
149
+ Message: `Successfully created JotForm "${title}" (ID: ${createdForm.id}). View at: ${formUrl}`
150
+ };
151
+
152
+ } catch (error) {
153
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
154
+ return {
155
+ Success: false,
156
+ ResultCode: 'ERROR',
157
+ Message: this.buildFormErrorMessage('Create JotForm', errorMessage, error)
158
+ };
159
+ }
160
+ }
161
+
162
+ /**
163
+ * Build questions object in JotForm API format
164
+ * JotForm uses numeric keys for questions (1, 2, 3, etc.)
165
+ */
166
+ private buildQuestionsObject(questions: any[]): Record<string, any> {
167
+ const questionsObj: Record<string, any> = {};
168
+
169
+ questions.forEach((question, index) => {
170
+ const questionId = index + 1;
171
+ questionsObj[questionId] = {
172
+ type: question.type,
173
+ text: question.text,
174
+ name: question.name || `question_${questionId}`,
175
+ order: String(questionId),
176
+ ...this.extractQuestionProperties(question)
177
+ };
178
+ });
179
+
180
+ return questionsObj;
181
+ }
182
+
183
+ /**
184
+ * Extract additional question properties (required, validation, options, etc.)
185
+ */
186
+ private extractQuestionProperties(question: any): Record<string, any> {
187
+ const props: Record<string, any> = {};
188
+
189
+ if (question.required != null) {
190
+ props.required = question.required === 'Yes' || question.required === true ? 'Yes' : 'No';
191
+ }
192
+
193
+ if (question.validation) {
194
+ props.validation = question.validation;
195
+ }
196
+
197
+ if (question.sublabel) {
198
+ props.sublabel = question.sublabel;
199
+ }
200
+
201
+ if (question.hint) {
202
+ props.hint = question.hint;
203
+ }
204
+
205
+ if (question.options && Array.isArray(question.options)) {
206
+ props.options = question.options.join('|');
207
+ }
208
+
209
+ if (question.special) {
210
+ props.special = question.special;
211
+ }
212
+
213
+ if (question.size) {
214
+ props.size = question.size;
215
+ }
216
+
217
+ if (question.maxsize) {
218
+ props.maxsize = question.maxsize;
219
+ }
220
+
221
+ if (question.allowTime) {
222
+ props.allowTime = question.allowTime;
223
+ }
224
+
225
+ if (question.payment) {
226
+ props.payment = question.payment;
227
+ }
228
+
229
+ return props;
230
+ }
231
+
232
+ /**
233
+ * Flatten nested form data into JotForm API parameter format
234
+ * JotForm API expects: properties[title]=value, questions[1][type]=value, etc.
235
+ */
236
+ private flattenFormData(data: Record<string, any>, prefix: string = ''): Record<string, any> {
237
+ const flattened: Record<string, any> = {};
238
+
239
+ for (const [key, value] of Object.entries(data)) {
240
+ const paramKey = prefix ? `${prefix}[${key}]` : key;
241
+
242
+ if (value && typeof value === 'object' && !Array.isArray(value)) {
243
+ Object.assign(flattened, this.flattenFormData(value, paramKey));
244
+ } else if (value != null) {
245
+ flattened[paramKey] = value;
246
+ }
247
+ }
248
+
249
+ return flattened;
250
+ }
251
+
252
+ public get Params(): ActionParam[] {
253
+ return [
254
+ {
255
+ Name: 'CompanyID',
256
+ Type: 'Input',
257
+ Value: null
258
+ },
259
+ {
260
+ Name: 'Title',
261
+ Type: 'Input',
262
+ Value: null
263
+ },
264
+ {
265
+ Name: 'Questions',
266
+ Type: 'Input',
267
+ Value: null
268
+ },
269
+ {
270
+ Name: 'Properties',
271
+ Type: 'Input',
272
+ Value: null
273
+ },
274
+ {
275
+ Name: 'Region',
276
+ Type: 'Input',
277
+ Value: null
278
+ }
279
+ ];
280
+ }
281
+ }
@@ -0,0 +1,189 @@
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 export JotForm submissions as CSV format
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: 'Export JotForm Submissions to CSV',
16
+ * Params: [{
17
+ * Name: 'CompanyID',
18
+ * Value: 'your-company-id'
19
+ * }, {
20
+ * Name: 'FormID',
21
+ * Value: '123456789'
22
+ * }, {
23
+ * Name: 'IncludeMetadata',
24
+ * Value: true
25
+ * }]
26
+ * });
27
+ * ```
28
+ */
29
+ @RegisterClass(BaseAction, 'Export JotForm Submissions to CSV')
30
+ export class ExportJotFormCSVAction extends JotFormBaseAction {
31
+
32
+ public get Description(): string {
33
+ return 'Exports JotForm submissions to CSV format for use in spreadsheets, data analysis tools, or archival. Supports custom delimiters, optional metadata columns, and regional API endpoints.';
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 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 apiKey = await this.getSecureAPIToken(companyId, contextUser);
59
+
60
+ const region = this.getParamValue(params.Params, 'Region') as 'us' | 'eu' | 'hipaa' | undefined;
61
+ const filterParam = this.getParamValue(params.Params, 'Filter');
62
+ const includeMetadata = this.getParamValue(params.Params, 'IncludeMetadata') !== false;
63
+ const delimiter = this.getParamValue(params.Params, 'Delimiter') || ',';
64
+ const maxSubmissions = this.getParamValue(params.Params, 'MaxSubmissions') || 10000;
65
+
66
+ let filter: Record<string, string> | undefined = undefined;
67
+ if (filterParam) {
68
+ try {
69
+ filter = typeof filterParam === 'string' ? JSON.parse(filterParam) : filterParam;
70
+ } catch (error) {
71
+ return {
72
+ Success: false,
73
+ ResultCode: 'INVALID_FILTER',
74
+ Message: 'Filter parameter must be valid JSON object'
75
+ };
76
+ }
77
+ }
78
+
79
+ const jfSubmissions = await this.getAllJotFormSubmissions(formId, apiKey, {
80
+ filter,
81
+ maxSubmissions,
82
+ region
83
+ });
84
+
85
+ if (jfSubmissions.length === 0) {
86
+ return {
87
+ Success: true,
88
+ ResultCode: 'NO_DATA',
89
+ Message: 'No submissions found matching the criteria'
90
+ };
91
+ }
92
+
93
+ const submissions = jfSubmissions.map(s => this.normalizeJotFormSubmission(s));
94
+
95
+ const { csv, headers } = this.convertToCSV(submissions, includeMetadata, delimiter);
96
+
97
+ const outputParams: ActionParam[] = [
98
+ {
99
+ Name: 'CSVData',
100
+ Type: 'Output',
101
+ Value: csv
102
+ },
103
+ {
104
+ Name: 'RowCount',
105
+ Type: 'Output',
106
+ Value: submissions.length
107
+ },
108
+ {
109
+ Name: 'Headers',
110
+ Type: 'Output',
111
+ Value: headers
112
+ },
113
+ {
114
+ Name: 'ColumnCount',
115
+ Type: 'Output',
116
+ Value: headers.length
117
+ },
118
+ {
119
+ Name: 'FileSize',
120
+ Type: 'Output',
121
+ Value: Buffer.byteLength(csv, 'utf8')
122
+ }
123
+ ];
124
+
125
+ for (const outputParam of outputParams) {
126
+ const existingParam = params.Params.find(p => p.Name === outputParam.Name);
127
+ if (existingParam) {
128
+ existingParam.Value = outputParam.Value;
129
+ } else {
130
+ params.Params.push(outputParam);
131
+ }
132
+ }
133
+
134
+ return {
135
+ Success: true,
136
+ ResultCode: 'SUCCESS',
137
+ Message: `Successfully exported ${submissions.length} submissions to CSV (${headers.length} columns, ${Buffer.byteLength(csv, 'utf8')} bytes)`
138
+ };
139
+
140
+ } catch (error) {
141
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
142
+ return {
143
+ Success: false,
144
+ ResultCode: 'ERROR',
145
+ Message: this.buildFormErrorMessage('Export JotForm to CSV', errorMessage, error)
146
+ };
147
+ }
148
+ }
149
+
150
+ public get Params(): ActionParam[] {
151
+ return [
152
+ {
153
+ Name: 'CompanyID',
154
+ Type: 'Input',
155
+ Value: null
156
+ },
157
+ {
158
+ Name: 'FormID',
159
+ Type: 'Input',
160
+ Value: null
161
+ },
162
+ {
163
+ Name: 'Region',
164
+ Type: 'Input',
165
+ Value: 'us'
166
+ },
167
+ {
168
+ Name: 'Filter',
169
+ Type: 'Input',
170
+ Value: null
171
+ },
172
+ {
173
+ Name: 'IncludeMetadata',
174
+ Type: 'Input',
175
+ Value: true
176
+ },
177
+ {
178
+ Name: 'Delimiter',
179
+ Type: 'Input',
180
+ Value: ','
181
+ },
182
+ {
183
+ Name: 'MaxSubmissions',
184
+ Type: 'Input',
185
+ Value: 10000
186
+ }
187
+ ];
188
+ }
189
+ }
@@ -0,0 +1,189 @@
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 complete details of a JotForm including questions, properties, and settings
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 JotForm Details',
16
+ * Params: [{
17
+ * Name: 'CompanyID',
18
+ * Value: 'your-company-id'
19
+ * }, {
20
+ * Name: 'FormID',
21
+ * Value: '123456789'
22
+ * }, {
23
+ * Name: 'Region',
24
+ * Value: 'us'
25
+ * }]
26
+ * });
27
+ * ```
28
+ */
29
+ @RegisterClass(BaseAction, 'Get JotForm Details')
30
+ export class GetJotFormAction extends JotFormBaseAction {
31
+
32
+ public get Description(): string {
33
+ return 'Retrieves complete details of a JotForm including title, status, questions, properties, and settings. Use this to inspect or backup form configurations, analyze form structure, and access form metadata.';
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 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 apiToken = await this.getSecureAPIToken(companyId, contextUser);
59
+
60
+ const region = this.getParamValue(params.Params, 'Region') as 'us' | 'eu' | 'hipaa' | undefined;
61
+
62
+ // Fetch form details and questions from JotForm API
63
+ const formDetails = await this.getJotFormDetails(formId, apiToken, region);
64
+ const questions = await this.getJotFormQuestions(formId, apiToken, region);
65
+
66
+ // Extract comprehensive form information
67
+ const questionCount = Object.keys(questions || {}).length;
68
+ const formUrl = formDetails.url || `https://form.jotform.com/${formId}`;
69
+ const createdAt = formDetails.created_at || '';
70
+ const updatedAt = formDetails.updated_at || '';
71
+
72
+ // Build comprehensive form details object
73
+ const formDetailsOutput = {
74
+ id: formDetails.id,
75
+ title: formDetails.title,
76
+ status: formDetails.status,
77
+ questions: questions,
78
+ properties: {
79
+ height: formDetails.height,
80
+ slug: formDetails.slug,
81
+ count: formDetails.count,
82
+ favorite: formDetails.favorite,
83
+ archived: formDetails.archived,
84
+ last: formDetails.last,
85
+ new: formDetails.new
86
+ },
87
+ settings: {
88
+ width: formDetails.width,
89
+ height: formDetails.height,
90
+ created_at: formDetails.created_at,
91
+ updated_at: formDetails.updated_at
92
+ }
93
+ };
94
+
95
+ // Prepare output parameters
96
+ const outputParams: ActionParam[] = [
97
+ {
98
+ Name: 'FormDetails',
99
+ Type: 'Output',
100
+ Value: formDetailsOutput
101
+ },
102
+ {
103
+ Name: 'FormID',
104
+ Type: 'Output',
105
+ Value: formDetails.id
106
+ },
107
+ {
108
+ Name: 'Title',
109
+ Type: 'Output',
110
+ Value: formDetails.title
111
+ },
112
+ {
113
+ Name: 'Status',
114
+ Type: 'Output',
115
+ Value: formDetails.status
116
+ },
117
+ {
118
+ Name: 'FormURL',
119
+ Type: 'Output',
120
+ Value: formUrl
121
+ },
122
+ {
123
+ Name: 'QuestionCount',
124
+ Type: 'Output',
125
+ Value: questionCount
126
+ },
127
+ {
128
+ Name: 'Questions',
129
+ Type: 'Output',
130
+ Value: questions
131
+ },
132
+ {
133
+ Name: 'CreatedAt',
134
+ Type: 'Output',
135
+ Value: createdAt
136
+ },
137
+ {
138
+ Name: 'UpdatedAt',
139
+ Type: 'Output',
140
+ Value: updatedAt
141
+ }
142
+ ];
143
+
144
+ // Update params with output values
145
+ for (const outputParam of outputParams) {
146
+ const existingParam = params.Params.find(p => p.Name === outputParam.Name);
147
+ if (existingParam) {
148
+ existingParam.Value = outputParam.Value;
149
+ } else {
150
+ params.Params.push(outputParam);
151
+ }
152
+ }
153
+
154
+ return {
155
+ Success: true,
156
+ ResultCode: 'SUCCESS',
157
+ Message: `Successfully retrieved form "${formDetails.title}" with ${questionCount} questions`
158
+ };
159
+
160
+ } catch (error) {
161
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
162
+ return {
163
+ Success: false,
164
+ ResultCode: 'ERROR',
165
+ Message: this.buildFormErrorMessage('Get JotForm Details', errorMessage, error)
166
+ };
167
+ }
168
+ }
169
+
170
+ public get Params(): ActionParam[] {
171
+ return [
172
+ {
173
+ Name: 'CompanyID',
174
+ Type: 'Input',
175
+ Value: null
176
+ },
177
+ {
178
+ Name: 'FormID',
179
+ Type: 'Input',
180
+ Value: null
181
+ },
182
+ {
183
+ Name: 'Region',
184
+ Type: 'Input',
185
+ Value: 'us'
186
+ }
187
+ ];
188
+ }
189
+ }