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