@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,175 @@
|
|
|
1
|
+
import { RegisterClass } from '@memberjunction/global';
|
|
2
|
+
import { SurveyMonkeyBaseAction } from '../surveymonkey-base.action';
|
|
3
|
+
import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
4
|
+
import { BaseAction } from '@memberjunction/actions';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Action to export SurveyMonkey responses as CSV format
|
|
8
|
+
*
|
|
9
|
+
* Security: Uses secure credential lookup via CompanyID instead of accepting tokens directly.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* await runAction({
|
|
14
|
+
* ActionName: 'Export SurveyMonkey Responses to CSV',
|
|
15
|
+
* Params: [{
|
|
16
|
+
* Name: 'CompanyID',
|
|
17
|
+
* Value: 'your-company-id'
|
|
18
|
+
* }, {
|
|
19
|
+
* Name: 'SurveyID',
|
|
20
|
+
* Value: 'abc123'
|
|
21
|
+
* }, {
|
|
22
|
+
* Name: 'IncludeMetadata',
|
|
23
|
+
* Value: true
|
|
24
|
+
* }]
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
@RegisterClass(BaseAction, 'Export SurveyMonkey Responses to CSV')
|
|
29
|
+
export class ExportSurveyMonkeyCSVAction extends SurveyMonkeyBaseAction {
|
|
30
|
+
|
|
31
|
+
public get Description(): string {
|
|
32
|
+
return 'Exports SurveyMonkey responses to CSV format for use in spreadsheets, data analysis tools, or archival. Supports custom delimiters, date range filtering, and optional metadata columns.';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
|
|
36
|
+
try {
|
|
37
|
+
const contextUser = params.ContextUser;
|
|
38
|
+
if (!contextUser) {
|
|
39
|
+
return {
|
|
40
|
+
Success: false,
|
|
41
|
+
ResultCode: 'MISSING_CONTEXT_USER',
|
|
42
|
+
Message: 'Context user is required for SurveyMonkey API calls'
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const companyId = this.getParamValue(params.Params, 'CompanyID');
|
|
47
|
+
|
|
48
|
+
const surveyId = this.getParamValue(params.Params, 'SurveyID');
|
|
49
|
+
if (!surveyId) {
|
|
50
|
+
return {
|
|
51
|
+
Success: false,
|
|
52
|
+
ResultCode: 'MISSING_SURVEY_ID',
|
|
53
|
+
Message: 'SurveyID parameter is required'
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const accessToken = await this.getSecureAPIToken(companyId, contextUser);
|
|
58
|
+
|
|
59
|
+
const startCreatedAt = this.getParamValue(params.Params, 'StartCreatedAt');
|
|
60
|
+
const endCreatedAt = this.getParamValue(params.Params, 'EndCreatedAt');
|
|
61
|
+
const includeMetadata = this.getParamValue(params.Params, 'IncludeMetadata') !== false;
|
|
62
|
+
const delimiter = this.getParamValue(params.Params, 'Delimiter') || ',';
|
|
63
|
+
const maxResponses = this.getParamValue(params.Params, 'MaxResponses') || 10000;
|
|
64
|
+
|
|
65
|
+
const smResponses = await this.getAllSurveyMonkeyResponses(surveyId, accessToken, {
|
|
66
|
+
start_created_at: startCreatedAt,
|
|
67
|
+
end_created_at: endCreatedAt,
|
|
68
|
+
maxResponses
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
if (smResponses.length === 0) {
|
|
72
|
+
return {
|
|
73
|
+
Success: true,
|
|
74
|
+
ResultCode: 'NO_DATA',
|
|
75
|
+
Message: 'No responses found matching the criteria'
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const responses = smResponses.map(r => this.normalizeSurveyMonkeyResponse(r));
|
|
80
|
+
|
|
81
|
+
const { csv, headers } = this.convertToCSV(responses, includeMetadata, delimiter);
|
|
82
|
+
|
|
83
|
+
const outputParams: ActionParam[] = [
|
|
84
|
+
{
|
|
85
|
+
Name: 'CSVData',
|
|
86
|
+
Type: 'Output',
|
|
87
|
+
Value: csv
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
Name: 'RowCount',
|
|
91
|
+
Type: 'Output',
|
|
92
|
+
Value: responses.length
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
Name: 'Headers',
|
|
96
|
+
Type: 'Output',
|
|
97
|
+
Value: headers
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
Name: 'ColumnCount',
|
|
101
|
+
Type: 'Output',
|
|
102
|
+
Value: headers.length
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
Name: 'FileSize',
|
|
106
|
+
Type: 'Output',
|
|
107
|
+
Value: Buffer.byteLength(csv, 'utf8')
|
|
108
|
+
}
|
|
109
|
+
];
|
|
110
|
+
|
|
111
|
+
for (const outputParam of outputParams) {
|
|
112
|
+
const existingParam = params.Params.find(p => p.Name === outputParam.Name);
|
|
113
|
+
if (existingParam) {
|
|
114
|
+
existingParam.Value = outputParam.Value;
|
|
115
|
+
} else {
|
|
116
|
+
params.Params.push(outputParam);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
Success: true,
|
|
122
|
+
ResultCode: 'SUCCESS',
|
|
123
|
+
Message: `Successfully exported ${responses.length} responses to CSV (${headers.length} columns, ${Buffer.byteLength(csv, 'utf8')} bytes)`
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
} catch (error) {
|
|
127
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
128
|
+
return {
|
|
129
|
+
Success: false,
|
|
130
|
+
ResultCode: 'ERROR',
|
|
131
|
+
Message: this.buildFormErrorMessage('Export SurveyMonkey to CSV', errorMessage, error)
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
public get Params(): ActionParam[] {
|
|
137
|
+
return [
|
|
138
|
+
{
|
|
139
|
+
Name: 'CompanyID',
|
|
140
|
+
Type: 'Input',
|
|
141
|
+
Value: null
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
Name: 'SurveyID',
|
|
145
|
+
Type: 'Input',
|
|
146
|
+
Value: null
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
Name: 'StartCreatedAt',
|
|
150
|
+
Type: 'Input',
|
|
151
|
+
Value: null
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
Name: 'EndCreatedAt',
|
|
155
|
+
Type: 'Input',
|
|
156
|
+
Value: null
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
Name: 'IncludeMetadata',
|
|
160
|
+
Type: 'Input',
|
|
161
|
+
Value: true
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
Name: 'Delimiter',
|
|
165
|
+
Type: 'Input',
|
|
166
|
+
Value: ','
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
Name: 'MaxResponses',
|
|
170
|
+
Type: 'Input',
|
|
171
|
+
Value: 10000
|
|
172
|
+
}
|
|
173
|
+
];
|
|
174
|
+
}
|
|
175
|
+
}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { RegisterClass } from '@memberjunction/global';
|
|
2
|
+
import { SurveyMonkeyBaseAction } from '../surveymonkey-base.action';
|
|
3
|
+
import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
4
|
+
import { BaseAction } from '@memberjunction/actions';
|
|
5
|
+
import { FormResponse } from '../../../base/base-form-builder.action';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Action to retrieve responses from a SurveyMonkey survey with comprehensive filtering options
|
|
9
|
+
*
|
|
10
|
+
* Security: Uses secure credential lookup via CompanyID instead of accepting tokens directly.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* await runAction({
|
|
15
|
+
* ActionName: 'Get SurveyMonkey Responses',
|
|
16
|
+
* Params: [{
|
|
17
|
+
* Name: 'CompanyID',
|
|
18
|
+
* Value: 'your-company-id'
|
|
19
|
+
* }, {
|
|
20
|
+
* Name: 'SurveyID',
|
|
21
|
+
* Value: '12345678'
|
|
22
|
+
* }, {
|
|
23
|
+
* Name: 'StartCreatedAt',
|
|
24
|
+
* Value: '2024-01-01T00:00:00Z'
|
|
25
|
+
* }, {
|
|
26
|
+
* Name: 'Status',
|
|
27
|
+
* Value: 'completed'
|
|
28
|
+
* }]
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
@RegisterClass(BaseAction, 'Get SurveyMonkey Responses')
|
|
33
|
+
export class GetSurveyMonkeyResponsesAction extends SurveyMonkeyBaseAction {
|
|
34
|
+
|
|
35
|
+
public get Description(): string {
|
|
36
|
+
return 'Retrieves responses from a SurveyMonkey survey with filtering, pagination, and sorting capabilities. Supports date ranges, completion status, and response status filtering.';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
|
|
40
|
+
try {
|
|
41
|
+
const contextUser = params.ContextUser;
|
|
42
|
+
if (!contextUser) {
|
|
43
|
+
return {
|
|
44
|
+
Success: false,
|
|
45
|
+
ResultCode: 'MISSING_CONTEXT_USER',
|
|
46
|
+
Message: 'Context user is required for SurveyMonkey API calls'
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const companyId = this.getParamValue(params.Params, 'CompanyID');
|
|
51
|
+
|
|
52
|
+
const surveyId = this.getParamValue(params.Params, 'SurveyID');
|
|
53
|
+
if (!surveyId) {
|
|
54
|
+
return {
|
|
55
|
+
Success: false,
|
|
56
|
+
ResultCode: 'MISSING_SURVEY_ID',
|
|
57
|
+
Message: 'SurveyID parameter is required'
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const accessToken = await this.getSecureAPIToken(companyId, contextUser);
|
|
62
|
+
|
|
63
|
+
const pageSize = this.getParamValue(params.Params, 'PageSize') || 100;
|
|
64
|
+
const page = this.getParamValue(params.Params, 'Page');
|
|
65
|
+
const startCreatedAt = this.getParamValue(params.Params, 'StartCreatedAt');
|
|
66
|
+
const endCreatedAt = this.getParamValue(params.Params, 'EndCreatedAt');
|
|
67
|
+
const startModifiedAt = this.getParamValue(params.Params, 'StartModifiedAt');
|
|
68
|
+
const endModifiedAt = this.getParamValue(params.Params, 'EndModifiedAt');
|
|
69
|
+
const sortOrder = this.getParamValue(params.Params, 'SortOrder') as 'ASC' | 'DESC' | undefined;
|
|
70
|
+
const sortBy = this.getParamValue(params.Params, 'SortBy') as 'date_modified' | 'date_created' | undefined;
|
|
71
|
+
const status = this.getParamValue(params.Params, 'Status') as 'completed' | 'partial' | 'overquota' | 'disqualified' | undefined;
|
|
72
|
+
const getAllPages = this.getParamValue(params.Params, 'GetAllPages') === true;
|
|
73
|
+
|
|
74
|
+
let responses: FormResponse[];
|
|
75
|
+
let totalResponses: number;
|
|
76
|
+
let currentPage: number;
|
|
77
|
+
let totalPages: number;
|
|
78
|
+
let hasMore: boolean;
|
|
79
|
+
|
|
80
|
+
if (getAllPages) {
|
|
81
|
+
const maxResponses = this.getParamValue(params.Params, 'MaxResponses') || 10000;
|
|
82
|
+
const smResponses = await this.getAllSurveyMonkeyResponses(surveyId, accessToken, {
|
|
83
|
+
start_created_at: startCreatedAt,
|
|
84
|
+
end_created_at: endCreatedAt,
|
|
85
|
+
start_modified_at: startModifiedAt,
|
|
86
|
+
end_modified_at: endModifiedAt,
|
|
87
|
+
sort_order: sortOrder,
|
|
88
|
+
sort_by: sortBy,
|
|
89
|
+
status,
|
|
90
|
+
maxResponses
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
responses = smResponses.map(r => this.normalizeSurveyMonkeyResponse(r));
|
|
94
|
+
totalResponses = responses.length;
|
|
95
|
+
currentPage = 1;
|
|
96
|
+
totalPages = 1;
|
|
97
|
+
hasMore = false;
|
|
98
|
+
} else {
|
|
99
|
+
const result = await this.getSurveyMonkeyResponses(surveyId, accessToken, {
|
|
100
|
+
per_page: Math.min(pageSize, 100),
|
|
101
|
+
page,
|
|
102
|
+
start_created_at: startCreatedAt,
|
|
103
|
+
end_created_at: endCreatedAt,
|
|
104
|
+
start_modified_at: startModifiedAt,
|
|
105
|
+
end_modified_at: endModifiedAt,
|
|
106
|
+
sort_order: sortOrder,
|
|
107
|
+
sort_by: sortBy,
|
|
108
|
+
status
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
responses = result.data.map(r => this.normalizeSurveyMonkeyResponse(r));
|
|
112
|
+
totalResponses = result.total;
|
|
113
|
+
currentPage = result.page;
|
|
114
|
+
totalPages = Math.ceil(result.total / result.per_page);
|
|
115
|
+
hasMore = !!result.links.next;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const outputParams: ActionParam[] = [
|
|
119
|
+
{
|
|
120
|
+
Name: 'Responses',
|
|
121
|
+
Type: 'Output',
|
|
122
|
+
Value: responses
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
Name: 'TotalResponses',
|
|
126
|
+
Type: 'Output',
|
|
127
|
+
Value: totalResponses
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
Name: 'Count',
|
|
131
|
+
Type: 'Output',
|
|
132
|
+
Value: responses.length
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
Name: 'CurrentPage',
|
|
136
|
+
Type: 'Output',
|
|
137
|
+
Value: currentPage
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
Name: 'TotalPages',
|
|
141
|
+
Type: 'Output',
|
|
142
|
+
Value: totalPages
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
Name: 'HasMore',
|
|
146
|
+
Type: 'Output',
|
|
147
|
+
Value: hasMore
|
|
148
|
+
}
|
|
149
|
+
];
|
|
150
|
+
|
|
151
|
+
for (const outputParam of outputParams) {
|
|
152
|
+
const existingParam = params.Params.find(p => p.Name === outputParam.Name);
|
|
153
|
+
if (existingParam) {
|
|
154
|
+
existingParam.Value = outputParam.Value;
|
|
155
|
+
} else {
|
|
156
|
+
params.Params.push(outputParam);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return {
|
|
161
|
+
Success: true,
|
|
162
|
+
ResultCode: 'SUCCESS',
|
|
163
|
+
Message: `Successfully retrieved ${responses.length} responses from SurveyMonkey${getAllPages ? '' : ` (page ${currentPage} of ${totalPages}, ${totalResponses} total)`}`
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
} catch (error) {
|
|
167
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
168
|
+
return {
|
|
169
|
+
Success: false,
|
|
170
|
+
ResultCode: 'ERROR',
|
|
171
|
+
Message: this.buildFormErrorMessage('Get SurveyMonkey Responses', errorMessage, error)
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
public get Params(): ActionParam[] {
|
|
177
|
+
return [
|
|
178
|
+
{
|
|
179
|
+
Name: 'CompanyID',
|
|
180
|
+
Type: 'Input',
|
|
181
|
+
Value: null
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
Name: 'SurveyID',
|
|
185
|
+
Type: 'Input',
|
|
186
|
+
Value: null
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
Name: 'PageSize',
|
|
190
|
+
Type: 'Input',
|
|
191
|
+
Value: 100
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
Name: 'Page',
|
|
195
|
+
Type: 'Input',
|
|
196
|
+
Value: null
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
Name: 'StartCreatedAt',
|
|
200
|
+
Type: 'Input',
|
|
201
|
+
Value: null
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
Name: 'EndCreatedAt',
|
|
205
|
+
Type: 'Input',
|
|
206
|
+
Value: null
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
Name: 'StartModifiedAt',
|
|
210
|
+
Type: 'Input',
|
|
211
|
+
Value: null
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
Name: 'EndModifiedAt',
|
|
215
|
+
Type: 'Input',
|
|
216
|
+
Value: null
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
Name: 'SortOrder',
|
|
220
|
+
Type: 'Input',
|
|
221
|
+
Value: null
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
Name: 'SortBy',
|
|
225
|
+
Type: 'Input',
|
|
226
|
+
Value: null
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
Name: 'Status',
|
|
230
|
+
Type: 'Input',
|
|
231
|
+
Value: null
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
Name: 'GetAllPages',
|
|
235
|
+
Type: 'Input',
|
|
236
|
+
Value: false
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
Name: 'MaxResponses',
|
|
240
|
+
Type: 'Input',
|
|
241
|
+
Value: 10000
|
|
242
|
+
}
|
|
243
|
+
];
|
|
244
|
+
}
|
|
245
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { RegisterClass } from '@memberjunction/global';
|
|
2
|
+
import { SurveyMonkeyBaseAction } from '../surveymonkey-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 SurveyMonkey by response ID
|
|
8
|
+
*
|
|
9
|
+
* Security: Uses secure credential lookup via CompanyID instead of accepting tokens directly.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* await runAction({
|
|
14
|
+
* ActionName: 'Get Single SurveyMonkey Response',
|
|
15
|
+
* Params: [{
|
|
16
|
+
* Name: 'CompanyID',
|
|
17
|
+
* Value: 'your-company-id'
|
|
18
|
+
* }, {
|
|
19
|
+
* Name: 'SurveyID',
|
|
20
|
+
* Value: '123456789'
|
|
21
|
+
* }, {
|
|
22
|
+
* Name: 'ResponseID',
|
|
23
|
+
* Value: '987654321'
|
|
24
|
+
* }]
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
@RegisterClass(BaseAction, 'Get Single SurveyMonkey Response')
|
|
29
|
+
export class GetSingleSurveyMonkeyResponseAction extends SurveyMonkeyBaseAction {
|
|
30
|
+
|
|
31
|
+
public get Description(): string {
|
|
32
|
+
return 'Retrieves details of a specific SurveyMonkey response by its unique response ID. Includes all answers, metadata, response status, and submission timing information.';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
|
|
36
|
+
try {
|
|
37
|
+
const contextUser = params.ContextUser;
|
|
38
|
+
if (!contextUser) {
|
|
39
|
+
return {
|
|
40
|
+
Success: false,
|
|
41
|
+
ResultCode: 'MISSING_CONTEXT_USER',
|
|
42
|
+
Message: 'Context user is required for SurveyMonkey API calls'
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const companyId = this.getParamValue(params.Params, 'CompanyID');
|
|
47
|
+
|
|
48
|
+
const surveyId = this.getParamValue(params.Params, 'SurveyID');
|
|
49
|
+
if (!surveyId) {
|
|
50
|
+
return {
|
|
51
|
+
Success: false,
|
|
52
|
+
ResultCode: 'MISSING_SURVEY_ID',
|
|
53
|
+
Message: 'SurveyID parameter is required'
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const responseId = this.getParamValue(params.Params, 'ResponseID');
|
|
58
|
+
if (!responseId) {
|
|
59
|
+
return {
|
|
60
|
+
Success: false,
|
|
61
|
+
ResultCode: 'MISSING_RESPONSE_ID',
|
|
62
|
+
Message: 'ResponseID parameter is required'
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const accessToken = await this.getSecureAPIToken(companyId, contextUser);
|
|
67
|
+
|
|
68
|
+
const smResponse = await this.getSingleSurveyMonkeyResponse(surveyId, responseId, accessToken);
|
|
69
|
+
const normalizedResponse = this.normalizeSurveyMonkeyResponse(smResponse);
|
|
70
|
+
|
|
71
|
+
const outputParams: ActionParam[] = [
|
|
72
|
+
{
|
|
73
|
+
Name: 'Response',
|
|
74
|
+
Type: 'Output',
|
|
75
|
+
Value: normalizedResponse
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
Name: 'ResponseID',
|
|
79
|
+
Type: 'Output',
|
|
80
|
+
Value: normalizedResponse.responseId
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
Name: 'Status',
|
|
84
|
+
Type: 'Output',
|
|
85
|
+
Value: smResponse.response_status
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
Name: 'SubmittedAt',
|
|
89
|
+
Type: 'Output',
|
|
90
|
+
Value: normalizedResponse.submittedAt
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
Name: 'Answers',
|
|
94
|
+
Type: 'Output',
|
|
95
|
+
Value: normalizedResponse.answers
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
Name: 'Metadata',
|
|
99
|
+
Type: 'Output',
|
|
100
|
+
Value: normalizedResponse.metadata
|
|
101
|
+
}
|
|
102
|
+
];
|
|
103
|
+
|
|
104
|
+
for (const outputParam of outputParams) {
|
|
105
|
+
const existingParam = params.Params.find(p => p.Name === outputParam.Name);
|
|
106
|
+
if (existingParam) {
|
|
107
|
+
existingParam.Value = outputParam.Value;
|
|
108
|
+
} else {
|
|
109
|
+
params.Params.push(outputParam);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return {
|
|
114
|
+
Success: true,
|
|
115
|
+
ResultCode: 'SUCCESS',
|
|
116
|
+
Message: `Successfully retrieved response ${responseId} from SurveyMonkey`
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
} catch (error) {
|
|
120
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
121
|
+
return {
|
|
122
|
+
Success: false,
|
|
123
|
+
ResultCode: 'ERROR',
|
|
124
|
+
Message: this.buildFormErrorMessage('Get Single SurveyMonkey Response', errorMessage, error)
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
public get Params(): ActionParam[] {
|
|
130
|
+
return [
|
|
131
|
+
{
|
|
132
|
+
Name: 'CompanyID',
|
|
133
|
+
Type: 'Input',
|
|
134
|
+
Value: null
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
Name: 'SurveyID',
|
|
138
|
+
Type: 'Input',
|
|
139
|
+
Value: null
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
Name: 'ResponseID',
|
|
143
|
+
Type: 'Input',
|
|
144
|
+
Value: null
|
|
145
|
+
}
|
|
146
|
+
];
|
|
147
|
+
}
|
|
148
|
+
}
|