@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.
- package/IMPLEMENTATION_PLAN.md +311 -0
- package/README.md +498 -0
- package/dist/base/base-form-builder.action.d.ts +153 -0
- package/dist/base/base-form-builder.action.d.ts.map +1 -0
- package/dist/base/base-form-builder.action.js +301 -0
- package/dist/base/base-form-builder.action.js.map +1 -0
- package/dist/base/index.d.ts +2 -0
- package/dist/base/index.d.ts.map +1 -0
- package/dist/base/index.js +18 -0
- package/dist/base/index.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/google-forms/actions/export-csv.action.d.ts +31 -0
- package/dist/providers/google-forms/actions/export-csv.action.d.ts.map +1 -0
- package/dist/providers/google-forms/actions/export-csv.action.js +165 -0
- package/dist/providers/google-forms/actions/export-csv.action.js.map +1 -0
- package/dist/providers/google-forms/actions/get-form.action.d.ts +28 -0
- package/dist/providers/google-forms/actions/get-form.action.d.ts.map +1 -0
- package/dist/providers/google-forms/actions/get-form.action.js +151 -0
- package/dist/providers/google-forms/actions/get-form.action.js.map +1 -0
- package/dist/providers/google-forms/actions/get-single-response.action.d.ts +31 -0
- package/dist/providers/google-forms/actions/get-single-response.action.d.ts.map +1 -0
- package/dist/providers/google-forms/actions/get-single-response.action.js +150 -0
- package/dist/providers/google-forms/actions/get-single-response.action.js.map +1 -0
- package/dist/providers/google-forms/actions/get-statistics.action.d.ts +36 -0
- package/dist/providers/google-forms/actions/get-statistics.action.d.ts.map +1 -0
- package/dist/providers/google-forms/actions/get-statistics.action.js +254 -0
- package/dist/providers/google-forms/actions/get-statistics.action.js.map +1 -0
- package/dist/providers/google-forms/actions/index.d.ts +5 -0
- package/dist/providers/google-forms/actions/index.d.ts.map +1 -0
- package/dist/providers/google-forms/actions/index.js +23 -0
- package/dist/providers/google-forms/actions/index.js.map +1 -0
- package/dist/providers/google-forms/googleforms-base.action.d.ts +197 -0
- package/dist/providers/google-forms/googleforms-base.action.d.ts.map +1 -0
- package/dist/providers/google-forms/googleforms-base.action.js +352 -0
- package/dist/providers/google-forms/googleforms-base.action.js.map +1 -0
- package/dist/providers/google-forms/index.d.ts +3 -0
- package/dist/providers/google-forms/index.d.ts.map +1 -0
- package/dist/providers/google-forms/index.js +21 -0
- package/dist/providers/google-forms/index.js.map +1 -0
- package/dist/providers/jotform/actions/create-form.action.d.ts +61 -0
- package/dist/providers/jotform/actions/create-form.action.d.ts.map +1 -0
- package/dist/providers/jotform/actions/create-form.action.js +259 -0
- package/dist/providers/jotform/actions/create-form.action.js.map +1 -0
- package/dist/providers/jotform/actions/export-csv.action.d.ts +31 -0
- package/dist/providers/jotform/actions/export-csv.action.d.ts.map +1 -0
- package/dist/providers/jotform/actions/export-csv.action.js +187 -0
- package/dist/providers/jotform/actions/export-csv.action.js.map +1 -0
- package/dist/providers/jotform/actions/get-form.action.d.ts +31 -0
- package/dist/providers/jotform/actions/get-form.action.d.ts.map +1 -0
- package/dist/providers/jotform/actions/get-form.action.js +188 -0
- package/dist/providers/jotform/actions/get-form.action.js.map +1 -0
- package/dist/providers/jotform/actions/get-single-submission.action.d.ts +31 -0
- package/dist/providers/jotform/actions/get-single-submission.action.d.ts.map +1 -0
- package/dist/providers/jotform/actions/get-single-submission.action.js +138 -0
- package/dist/providers/jotform/actions/get-single-submission.action.js.map +1 -0
- package/dist/providers/jotform/actions/get-statistics.action.d.ts +39 -0
- package/dist/providers/jotform/actions/get-statistics.action.d.ts.map +1 -0
- package/dist/providers/jotform/actions/get-statistics.action.js +290 -0
- package/dist/providers/jotform/actions/get-statistics.action.js.map +1 -0
- package/dist/providers/jotform/actions/get-submissions.action.d.ts +34 -0
- package/dist/providers/jotform/actions/get-submissions.action.d.ts.map +1 -0
- package/dist/providers/jotform/actions/get-submissions.action.js +218 -0
- package/dist/providers/jotform/actions/get-submissions.action.js.map +1 -0
- package/dist/providers/jotform/actions/index.d.ts +9 -0
- package/dist/providers/jotform/actions/index.d.ts.map +1 -0
- package/dist/providers/jotform/actions/index.js +27 -0
- package/dist/providers/jotform/actions/index.js.map +1 -0
- package/dist/providers/jotform/actions/update-form.action.d.ts +38 -0
- package/dist/providers/jotform/actions/update-form.action.d.ts.map +1 -0
- package/dist/providers/jotform/actions/update-form.action.js +232 -0
- package/dist/providers/jotform/actions/update-form.action.js.map +1 -0
- package/dist/providers/jotform/actions/watch-new-submissions.action.d.ts +32 -0
- package/dist/providers/jotform/actions/watch-new-submissions.action.d.ts.map +1 -0
- package/dist/providers/jotform/actions/watch-new-submissions.action.js +229 -0
- package/dist/providers/jotform/actions/watch-new-submissions.action.js.map +1 -0
- package/dist/providers/jotform/index.d.ts +3 -0
- package/dist/providers/jotform/index.d.ts.map +1 -0
- package/dist/providers/jotform/index.js +21 -0
- package/dist/providers/jotform/index.js.map +1 -0
- package/dist/providers/jotform/jotform-base.action.d.ts +96 -0
- package/dist/providers/jotform/jotform-base.action.d.ts.map +1 -0
- package/dist/providers/jotform/jotform-base.action.js +269 -0
- package/dist/providers/jotform/jotform-base.action.js.map +1 -0
- package/dist/providers/surveymonkey/actions/create-survey.action.d.ts +48 -0
- package/dist/providers/surveymonkey/actions/create-survey.action.d.ts.map +1 -0
- package/dist/providers/surveymonkey/actions/create-survey.action.js +192 -0
- package/dist/providers/surveymonkey/actions/create-survey.action.js.map +1 -0
- package/dist/providers/surveymonkey/actions/export-csv.action.d.ts +30 -0
- package/dist/providers/surveymonkey/actions/export-csv.action.d.ts.map +1 -0
- package/dist/providers/surveymonkey/actions/export-csv.action.js +173 -0
- package/dist/providers/surveymonkey/actions/export-csv.action.js.map +1 -0
- package/dist/providers/surveymonkey/actions/get-responses.action.d.ts +33 -0
- package/dist/providers/surveymonkey/actions/get-responses.action.d.ts.map +1 -0
- package/dist/providers/surveymonkey/actions/get-responses.action.js +243 -0
- package/dist/providers/surveymonkey/actions/get-responses.action.js.map +1 -0
- package/dist/providers/surveymonkey/actions/get-single-response.action.d.ts +30 -0
- package/dist/providers/surveymonkey/actions/get-single-response.action.d.ts.map +1 -0
- package/dist/providers/surveymonkey/actions/get-single-response.action.js +149 -0
- package/dist/providers/surveymonkey/actions/get-single-response.action.js.map +1 -0
- package/dist/providers/surveymonkey/actions/get-statistics.action.d.ts +38 -0
- package/dist/providers/surveymonkey/actions/get-statistics.action.d.ts.map +1 -0
- package/dist/providers/surveymonkey/actions/get-statistics.action.js +261 -0
- package/dist/providers/surveymonkey/actions/get-statistics.action.js.map +1 -0
- package/dist/providers/surveymonkey/actions/get-survey.action.d.ts +27 -0
- package/dist/providers/surveymonkey/actions/get-survey.action.d.ts.map +1 -0
- package/dist/providers/surveymonkey/actions/get-survey.action.js +180 -0
- package/dist/providers/surveymonkey/actions/get-survey.action.js.map +1 -0
- package/dist/providers/surveymonkey/actions/index.d.ts +9 -0
- package/dist/providers/surveymonkey/actions/index.d.ts.map +1 -0
- package/dist/providers/surveymonkey/actions/index.js +27 -0
- package/dist/providers/surveymonkey/actions/index.js.map +1 -0
- package/dist/providers/surveymonkey/actions/update-survey.action.d.ts +39 -0
- package/dist/providers/surveymonkey/actions/update-survey.action.d.ts.map +1 -0
- package/dist/providers/surveymonkey/actions/update-survey.action.js +217 -0
- package/dist/providers/surveymonkey/actions/update-survey.action.js.map +1 -0
- package/dist/providers/surveymonkey/actions/watch-new-responses.action.d.ts +31 -0
- package/dist/providers/surveymonkey/actions/watch-new-responses.action.d.ts.map +1 -0
- package/dist/providers/surveymonkey/actions/watch-new-responses.action.js +214 -0
- package/dist/providers/surveymonkey/actions/watch-new-responses.action.js.map +1 -0
- package/dist/providers/surveymonkey/index.d.ts +3 -0
- package/dist/providers/surveymonkey/index.d.ts.map +1 -0
- package/dist/providers/surveymonkey/index.js +21 -0
- package/dist/providers/surveymonkey/index.js.map +1 -0
- package/dist/providers/surveymonkey/surveymonkey-base.action.d.ts +193 -0
- package/dist/providers/surveymonkey/surveymonkey-base.action.d.ts.map +1 -0
- package/dist/providers/surveymonkey/surveymonkey-base.action.js +329 -0
- package/dist/providers/surveymonkey/surveymonkey-base.action.js.map +1 -0
- package/dist/providers/typeform/actions/create-form.action.d.ts +40 -0
- package/dist/providers/typeform/actions/create-form.action.d.ts.map +1 -0
- package/dist/providers/typeform/actions/create-form.action.js +205 -0
- package/dist/providers/typeform/actions/create-form.action.js.map +1 -0
- package/dist/providers/typeform/actions/export-csv.action.d.ts +31 -0
- package/dist/providers/typeform/actions/export-csv.action.d.ts.map +1 -0
- package/dist/providers/typeform/actions/export-csv.action.js +182 -0
- package/dist/providers/typeform/actions/export-csv.action.js.map +1 -0
- package/dist/providers/typeform/actions/get-form.action.d.ts +28 -0
- package/dist/providers/typeform/actions/get-form.action.d.ts.map +1 -0
- package/dist/providers/typeform/actions/get-form.action.js +172 -0
- package/dist/providers/typeform/actions/get-form.action.js.map +1 -0
- package/dist/providers/typeform/actions/get-responses.action.d.ts +34 -0
- package/dist/providers/typeform/actions/get-responses.action.d.ts.map +1 -0
- package/dist/providers/typeform/actions/get-responses.action.js +238 -0
- package/dist/providers/typeform/actions/get-responses.action.js.map +1 -0
- package/dist/providers/typeform/actions/get-single-response.action.d.ts +31 -0
- package/dist/providers/typeform/actions/get-single-response.action.d.ts.map +1 -0
- package/dist/providers/typeform/actions/get-single-response.action.js +161 -0
- package/dist/providers/typeform/actions/get-single-response.action.js.map +1 -0
- package/dist/providers/typeform/actions/get-statistics.action.d.ts +33 -0
- package/dist/providers/typeform/actions/get-statistics.action.d.ts.map +1 -0
- package/dist/providers/typeform/actions/get-statistics.action.js +257 -0
- package/dist/providers/typeform/actions/get-statistics.action.js.map +1 -0
- package/dist/providers/typeform/actions/index.d.ts +9 -0
- package/dist/providers/typeform/actions/index.d.ts.map +1 -0
- package/dist/providers/typeform/actions/index.js +27 -0
- package/dist/providers/typeform/actions/index.js.map +1 -0
- package/dist/providers/typeform/actions/update-form.action.d.ts +38 -0
- package/dist/providers/typeform/actions/update-form.action.d.ts.map +1 -0
- package/dist/providers/typeform/actions/update-form.action.js +228 -0
- package/dist/providers/typeform/actions/update-form.action.js.map +1 -0
- package/dist/providers/typeform/actions/watch-new-responses.action.d.ts +32 -0
- package/dist/providers/typeform/actions/watch-new-responses.action.d.ts.map +1 -0
- package/dist/providers/typeform/actions/watch-new-responses.action.js +215 -0
- package/dist/providers/typeform/actions/watch-new-responses.action.js.map +1 -0
- package/dist/providers/typeform/index.d.ts +3 -0
- package/dist/providers/typeform/index.d.ts.map +1 -0
- package/dist/providers/typeform/index.js +21 -0
- package/dist/providers/typeform/index.js.map +1 -0
- package/dist/providers/typeform/typeform-base.action.d.ts +121 -0
- package/dist/providers/typeform/typeform-base.action.d.ts.map +1 -0
- package/dist/providers/typeform/typeform-base.action.js +292 -0
- package/dist/providers/typeform/typeform-base.action.js.map +1 -0
- package/package.json +41 -0
- package/src/base/base-form-builder.action.ts +403 -0
- package/src/base/index.ts +1 -0
- package/src/index.ts +18 -0
- package/src/providers/google-forms/actions/export-csv.action.ts +167 -0
- package/src/providers/google-forms/actions/get-form.action.ts +151 -0
- package/src/providers/google-forms/actions/get-single-response.action.ts +150 -0
- package/src/providers/google-forms/actions/get-statistics.action.ts +273 -0
- package/src/providers/google-forms/actions/index.ts +7 -0
- package/src/providers/google-forms/googleforms-base.action.ts +517 -0
- package/src/providers/google-forms/index.ts +5 -0
- package/src/providers/jotform/actions/create-form.action.ts +281 -0
- package/src/providers/jotform/actions/export-csv.action.ts +189 -0
- package/src/providers/jotform/actions/get-form.action.ts +189 -0
- package/src/providers/jotform/actions/get-single-submission.action.ts +137 -0
- package/src/providers/jotform/actions/get-statistics.action.ts +308 -0
- package/src/providers/jotform/actions/get-submissions.action.ts +220 -0
- package/src/providers/jotform/actions/index.ts +11 -0
- package/src/providers/jotform/actions/update-form.action.ts +254 -0
- package/src/providers/jotform/actions/watch-new-submissions.action.ts +238 -0
- package/src/providers/jotform/index.ts +5 -0
- package/src/providers/jotform/jotform-base.action.ts +365 -0
- package/src/providers/surveymonkey/actions/create-survey.action.ts +196 -0
- package/src/providers/surveymonkey/actions/export-csv.action.ts +175 -0
- package/src/providers/surveymonkey/actions/get-responses.action.ts +245 -0
- package/src/providers/surveymonkey/actions/get-single-response.action.ts +148 -0
- package/src/providers/surveymonkey/actions/get-statistics.action.ts +280 -0
- package/src/providers/surveymonkey/actions/get-survey.action.ts +181 -0
- package/src/providers/surveymonkey/actions/index.ts +11 -0
- package/src/providers/surveymonkey/actions/update-survey.action.ts +234 -0
- package/src/providers/surveymonkey/actions/watch-new-responses.action.ts +221 -0
- package/src/providers/surveymonkey/index.ts +5 -0
- package/src/providers/surveymonkey/surveymonkey-base.action.ts +505 -0
- package/src/providers/typeform/actions/create-form.action.ts +211 -0
- package/src/providers/typeform/actions/export-csv.action.ts +184 -0
- package/src/providers/typeform/actions/get-form.action.ts +173 -0
- package/src/providers/typeform/actions/get-responses.action.ts +242 -0
- package/src/providers/typeform/actions/get-single-response.action.ts +160 -0
- package/src/providers/typeform/actions/get-statistics.action.ts +276 -0
- package/src/providers/typeform/actions/index.ts +11 -0
- package/src/providers/typeform/actions/update-form.action.ts +235 -0
- package/src/providers/typeform/actions/watch-new-responses.action.ts +222 -0
- package/src/providers/typeform/index.ts +5 -0
- package/src/providers/typeform/typeform-base.action.ts +387 -0
- 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
|
+
}
|