@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,254 @@
|
|
|
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 update an existing JotForm
|
|
8
|
+
*
|
|
9
|
+
* IMPORTANT: JotForm uses separate endpoints for properties and questions.
|
|
10
|
+
* Use the MergeWithExisting parameter to safely update only specified properties
|
|
11
|
+
* while preserving existing ones.
|
|
12
|
+
*
|
|
13
|
+
* Security: API credentials are retrieved securely from Company Integrations
|
|
14
|
+
* instead of being passed as parameters.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* await runAction({
|
|
19
|
+
* ActionName: 'Update JotForm',
|
|
20
|
+
* Params: [{
|
|
21
|
+
* Name: 'CompanyID',
|
|
22
|
+
* Value: 'your-company-id'
|
|
23
|
+
* }, {
|
|
24
|
+
* Name: 'FormID',
|
|
25
|
+
* Value: '123456789'
|
|
26
|
+
* }, {
|
|
27
|
+
* Name: 'Title',
|
|
28
|
+
* Value: 'Updated Survey Title'
|
|
29
|
+
* }, {
|
|
30
|
+
* Name: 'MergeWithExisting',
|
|
31
|
+
* Value: true
|
|
32
|
+
* }]
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
@RegisterClass(BaseAction, 'Update JotForm')
|
|
37
|
+
export class UpdateJotFormAction extends JotFormBaseAction {
|
|
38
|
+
|
|
39
|
+
public get Description(): string {
|
|
40
|
+
return 'Updates an existing JotForm. Set MergeWithExisting=true (default) to safely update only specified properties while preserving others. Set to false to replace entire form data (not recommended).';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
|
|
44
|
+
try {
|
|
45
|
+
const contextUser = params.ContextUser;
|
|
46
|
+
if (!contextUser) {
|
|
47
|
+
return {
|
|
48
|
+
Success: false,
|
|
49
|
+
ResultCode: 'MISSING_CONTEXT_USER',
|
|
50
|
+
Message: 'Context user is required for JotForm API calls'
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const companyId = this.getParamValue(params.Params, 'CompanyID');
|
|
55
|
+
|
|
56
|
+
const formId = this.getParamValue(params.Params, 'FormID');
|
|
57
|
+
if (!formId) {
|
|
58
|
+
return {
|
|
59
|
+
Success: false,
|
|
60
|
+
ResultCode: 'MISSING_FORM_ID',
|
|
61
|
+
Message: 'FormID parameter is required'
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const apiToken = await this.getSecureAPIToken(companyId, contextUser);
|
|
66
|
+
|
|
67
|
+
const mergeWithExisting = this.getParamValue(params.Params, 'MergeWithExisting') !== false;
|
|
68
|
+
const region = this.getParamValue(params.Params, 'Region') as 'us' | 'eu' | 'hipaa' | undefined;
|
|
69
|
+
|
|
70
|
+
const title = this.getParamValue(params.Params, 'Title');
|
|
71
|
+
const questions = this.getParamValue(params.Params, 'Questions');
|
|
72
|
+
const properties = this.getParamValue(params.Params, 'Properties');
|
|
73
|
+
|
|
74
|
+
// Check if any updates are provided
|
|
75
|
+
if (!title && !questions && !properties) {
|
|
76
|
+
return {
|
|
77
|
+
Success: false,
|
|
78
|
+
ResultCode: 'NO_CHANGES_PROVIDED',
|
|
79
|
+
Message: 'At least one of Title, Questions, or Properties must be provided'
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const updatedFields: string[] = [];
|
|
84
|
+
let existingForm: any = null;
|
|
85
|
+
|
|
86
|
+
// Get existing form if merging
|
|
87
|
+
if (mergeWithExisting) {
|
|
88
|
+
existingForm = await this.getJotFormDetails(formId, apiToken, region);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const axiosInstance = this.getAxiosInstance(apiToken, region);
|
|
92
|
+
|
|
93
|
+
// Update properties (including title)
|
|
94
|
+
if (title || properties) {
|
|
95
|
+
let propertiesToUpdate: Record<string, any> = {};
|
|
96
|
+
|
|
97
|
+
// Start with existing properties if merging
|
|
98
|
+
if (mergeWithExisting && existingForm?.properties) {
|
|
99
|
+
propertiesToUpdate = { ...existingForm.properties };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Add title if provided
|
|
103
|
+
if (title) {
|
|
104
|
+
propertiesToUpdate.title = title;
|
|
105
|
+
updatedFields.push('title');
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Merge additional properties if provided
|
|
109
|
+
if (properties) {
|
|
110
|
+
const propsToMerge = typeof properties === 'string' ? JSON.parse(properties) : properties;
|
|
111
|
+
propertiesToUpdate = { ...propertiesToUpdate, ...propsToMerge };
|
|
112
|
+
updatedFields.push('properties');
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Update properties via PUT endpoint
|
|
116
|
+
await axiosInstance.put(
|
|
117
|
+
`/form/${formId}/properties`,
|
|
118
|
+
{ properties: propertiesToUpdate }
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Update questions if provided
|
|
123
|
+
if (questions) {
|
|
124
|
+
let questionsToUpdate = Array.isArray(questions) ? questions :
|
|
125
|
+
typeof questions === 'string' ? JSON.parse(questions) : questions;
|
|
126
|
+
|
|
127
|
+
// If merging, get existing questions and merge
|
|
128
|
+
if (mergeWithExisting) {
|
|
129
|
+
const existingQuestions = await this.getJotFormQuestions(formId, apiToken, region);
|
|
130
|
+
|
|
131
|
+
// Merge questions by ID or order
|
|
132
|
+
const mergedQuestions: Record<string, any> = { ...existingQuestions };
|
|
133
|
+
|
|
134
|
+
if (Array.isArray(questionsToUpdate)) {
|
|
135
|
+
// If questions array is provided, update by index/ID
|
|
136
|
+
questionsToUpdate.forEach((question: any, index: number) => {
|
|
137
|
+
const questionId = question.qid || Object.keys(existingQuestions)[index];
|
|
138
|
+
if (questionId) {
|
|
139
|
+
mergedQuestions[questionId] = { ...mergedQuestions[questionId], ...question };
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
} else {
|
|
143
|
+
// If questions object is provided, merge directly
|
|
144
|
+
Object.assign(mergedQuestions, questionsToUpdate);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
questionsToUpdate = mergedQuestions;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Update questions via POST endpoint
|
|
151
|
+
await axiosInstance.post(
|
|
152
|
+
`/form/${formId}/questions`,
|
|
153
|
+
{ questions: questionsToUpdate }
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
updatedFields.push('questions');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Get updated form details
|
|
160
|
+
const updatedForm = await this.getJotFormDetails(formId, apiToken, region);
|
|
161
|
+
|
|
162
|
+
// Construct form URL
|
|
163
|
+
const formUrl = updatedForm.url || `https://form.jotform.com/${formId}`;
|
|
164
|
+
|
|
165
|
+
// Build output parameters
|
|
166
|
+
const outputParams: ActionParam[] = [
|
|
167
|
+
{
|
|
168
|
+
Name: 'FormID',
|
|
169
|
+
Type: 'Output',
|
|
170
|
+
Value: formId
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
Name: 'FormURL',
|
|
174
|
+
Type: 'Output',
|
|
175
|
+
Value: formUrl
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
Name: 'UpdatedFields',
|
|
179
|
+
Type: 'Output',
|
|
180
|
+
Value: updatedFields
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
Name: 'FormDetails',
|
|
184
|
+
Type: 'Output',
|
|
185
|
+
Value: updatedForm
|
|
186
|
+
}
|
|
187
|
+
];
|
|
188
|
+
|
|
189
|
+
// Add output params to result
|
|
190
|
+
for (const outputParam of outputParams) {
|
|
191
|
+
const existingParam = params.Params.find(p => p.Name === outputParam.Name);
|
|
192
|
+
if (existingParam) {
|
|
193
|
+
existingParam.Value = outputParam.Value;
|
|
194
|
+
} else {
|
|
195
|
+
params.Params.push(outputParam);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return {
|
|
200
|
+
Success: true,
|
|
201
|
+
ResultCode: 'SUCCESS',
|
|
202
|
+
Message: `Successfully updated JotForm "${updatedForm.title || formId}". Updated fields: ${updatedFields.join(', ')}`
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
} catch (error) {
|
|
206
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
207
|
+
return {
|
|
208
|
+
Success: false,
|
|
209
|
+
ResultCode: 'ERROR',
|
|
210
|
+
Message: this.buildFormErrorMessage('Update JotForm', errorMessage, error)
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
public get Params(): ActionParam[] {
|
|
216
|
+
return [
|
|
217
|
+
{
|
|
218
|
+
Name: 'CompanyID',
|
|
219
|
+
Type: 'Input',
|
|
220
|
+
Value: null
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
Name: 'FormID',
|
|
224
|
+
Type: 'Input',
|
|
225
|
+
Value: null
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
Name: 'MergeWithExisting',
|
|
229
|
+
Type: 'Input',
|
|
230
|
+
Value: true
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
Name: 'Title',
|
|
234
|
+
Type: 'Input',
|
|
235
|
+
Value: null
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
Name: 'Questions',
|
|
239
|
+
Type: 'Input',
|
|
240
|
+
Value: null
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
Name: 'Properties',
|
|
244
|
+
Type: 'Input',
|
|
245
|
+
Value: null
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
Name: 'Region',
|
|
249
|
+
Type: 'Input',
|
|
250
|
+
Value: 'us'
|
|
251
|
+
}
|
|
252
|
+
];
|
|
253
|
+
}
|
|
254
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
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 watch for new JotForm submissions since last check
|
|
8
|
+
* Useful for workflow automation and real-time notifications
|
|
9
|
+
*
|
|
10
|
+
* Security: API credentials are retrieved securely from Company Integrations
|
|
11
|
+
* instead of being passed as parameters.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* await runAction({
|
|
16
|
+
* ActionName: 'Watch for New JotForm Submissions',
|
|
17
|
+
* Params: [{
|
|
18
|
+
* Name: 'CompanyID',
|
|
19
|
+
* Value: 'your-company-id'
|
|
20
|
+
* }, {
|
|
21
|
+
* Name: 'FormID',
|
|
22
|
+
* Value: '123456789'
|
|
23
|
+
* }, {
|
|
24
|
+
* Name: 'LastCheckedTimestamp',
|
|
25
|
+
* Value: '2024-01-01T12:00:00Z'
|
|
26
|
+
* }]
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
@RegisterClass(BaseAction, 'Watch for New JotForm Submissions')
|
|
31
|
+
export class WatchNewJotFormSubmissionsAction extends JotFormBaseAction {
|
|
32
|
+
|
|
33
|
+
public get Description(): string {
|
|
34
|
+
return 'Polls JotForm for new submissions since the last check. Returns only new submissions and updates the last checked timestamp. Perfect for triggering workflows, sending notifications, or syncing data to other systems.';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
|
|
38
|
+
try {
|
|
39
|
+
const contextUser = params.ContextUser;
|
|
40
|
+
if (!contextUser) {
|
|
41
|
+
return {
|
|
42
|
+
Success: false,
|
|
43
|
+
ResultCode: 'MISSING_CONTEXT_USER',
|
|
44
|
+
Message: 'Context user is required for JotForm API calls'
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const companyId = this.getParamValue(params.Params, 'CompanyID');
|
|
49
|
+
|
|
50
|
+
const formId = this.getParamValue(params.Params, 'FormID');
|
|
51
|
+
if (!formId) {
|
|
52
|
+
return {
|
|
53
|
+
Success: false,
|
|
54
|
+
ResultCode: 'MISSING_FORM_ID',
|
|
55
|
+
Message: 'FormID parameter is required'
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const apiToken = await this.getSecureAPIToken(companyId, contextUser);
|
|
60
|
+
|
|
61
|
+
let lastChecked = this.getParamValue(params.Params, 'LastCheckedTimestamp');
|
|
62
|
+
const onlyCompleted = this.getParamValue(params.Params, 'OnlyCompleted') === true;
|
|
63
|
+
const region = this.getParamValue(params.Params, 'Region') as 'us' | 'eu' | 'hipaa' | undefined;
|
|
64
|
+
const maxSubmissions = this.getParamValue(params.Params, 'MaxSubmissions') || 1000;
|
|
65
|
+
|
|
66
|
+
if (!lastChecked) {
|
|
67
|
+
const defaultLookback = this.getParamValue(params.Params, 'DefaultLookbackMinutes') || 60;
|
|
68
|
+
const lookbackDate = new Date();
|
|
69
|
+
lookbackDate.setMinutes(lookbackDate.getMinutes() - defaultLookback);
|
|
70
|
+
lastChecked = lookbackDate.toISOString();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const currentTimestamp = new Date().toISOString();
|
|
74
|
+
|
|
75
|
+
// Build filter for JotForm API
|
|
76
|
+
// JotForm uses created_at field with "gt:" prefix for greater than
|
|
77
|
+
const filter: Record<string, string> = {
|
|
78
|
+
created_at: `gt:${lastChecked}`
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
if (onlyCompleted) {
|
|
82
|
+
filter.status = 'ACTIVE';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const jfSubmissions = await this.getAllJotFormSubmissions(formId, apiToken, {
|
|
86
|
+
filter,
|
|
87
|
+
orderby: 'created_at',
|
|
88
|
+
maxSubmissions,
|
|
89
|
+
region
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const newSubmissions = jfSubmissions.map(s => this.normalizeJotFormSubmission(s));
|
|
93
|
+
|
|
94
|
+
const completedCount = newSubmissions.filter(s => s.completed).length;
|
|
95
|
+
const partialCount = newSubmissions.filter(s => !s.completed).length;
|
|
96
|
+
|
|
97
|
+
// Group submissions by field type for analysis
|
|
98
|
+
const submissionsByType: Record<string, any[]> = {};
|
|
99
|
+
if (newSubmissions.length > 0) {
|
|
100
|
+
const firstSubmission = newSubmissions[0];
|
|
101
|
+
for (const answer of firstSubmission.answers) {
|
|
102
|
+
submissionsByType[answer.fieldType] = [];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
for (const submission of newSubmissions) {
|
|
106
|
+
for (const answer of submission.answers) {
|
|
107
|
+
if (!submissionsByType[answer.fieldType]) {
|
|
108
|
+
submissionsByType[answer.fieldType] = [];
|
|
109
|
+
}
|
|
110
|
+
submissionsByType[answer.fieldType].push({
|
|
111
|
+
submissionId: submission.responseId,
|
|
112
|
+
question: answer.question,
|
|
113
|
+
answer: answer.answer,
|
|
114
|
+
submittedAt: submission.submittedAt
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const emails = this.extractEmailFromResponses(newSubmissions);
|
|
121
|
+
|
|
122
|
+
const outputParams: ActionParam[] = [
|
|
123
|
+
{
|
|
124
|
+
Name: 'NewSubmissions',
|
|
125
|
+
Type: 'Output',
|
|
126
|
+
Value: newSubmissions
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
Name: 'Count',
|
|
130
|
+
Type: 'Output',
|
|
131
|
+
Value: newSubmissions.length
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
Name: 'CompletedCount',
|
|
135
|
+
Type: 'Output',
|
|
136
|
+
Value: completedCount
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
Name: 'PartialCount',
|
|
140
|
+
Type: 'Output',
|
|
141
|
+
Value: partialCount
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
Name: 'LastChecked',
|
|
145
|
+
Type: 'Output',
|
|
146
|
+
Value: currentTimestamp
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
Name: 'PreviouslyChecked',
|
|
150
|
+
Type: 'Output',
|
|
151
|
+
Value: lastChecked
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
Name: 'SubmissionsByType',
|
|
155
|
+
Type: 'Output',
|
|
156
|
+
Value: submissionsByType
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
Name: 'ExtractedEmails',
|
|
160
|
+
Type: 'Output',
|
|
161
|
+
Value: emails
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
Name: 'HasNewSubmissions',
|
|
165
|
+
Type: 'Output',
|
|
166
|
+
Value: newSubmissions.length > 0
|
|
167
|
+
}
|
|
168
|
+
];
|
|
169
|
+
|
|
170
|
+
for (const outputParam of outputParams) {
|
|
171
|
+
const existingParam = params.Params.find(p => p.Name === outputParam.Name);
|
|
172
|
+
if (existingParam) {
|
|
173
|
+
existingParam.Value = outputParam.Value;
|
|
174
|
+
} else {
|
|
175
|
+
params.Params.push(outputParam);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const message = newSubmissions.length > 0
|
|
180
|
+
? `Found ${newSubmissions.length} new submissions (${completedCount} completed, ${partialCount} partial) since ${new Date(lastChecked).toLocaleString()}`
|
|
181
|
+
: `No new submissions since ${new Date(lastChecked).toLocaleString()}`;
|
|
182
|
+
|
|
183
|
+
return {
|
|
184
|
+
Success: true,
|
|
185
|
+
ResultCode: newSubmissions.length > 0 ? 'NEW_SUBMISSIONS' : 'NO_NEW_SUBMISSIONS',
|
|
186
|
+
Message: message
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
} catch (error) {
|
|
190
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
191
|
+
return {
|
|
192
|
+
Success: false,
|
|
193
|
+
ResultCode: 'ERROR',
|
|
194
|
+
Message: this.buildFormErrorMessage('Watch New JotForm Submissions', errorMessage, error)
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
public get Params(): ActionParam[] {
|
|
200
|
+
return [
|
|
201
|
+
{
|
|
202
|
+
Name: 'CompanyID',
|
|
203
|
+
Type: 'Input',
|
|
204
|
+
Value: null
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
Name: 'FormID',
|
|
208
|
+
Type: 'Input',
|
|
209
|
+
Value: null
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
Name: 'LastCheckedTimestamp',
|
|
213
|
+
Type: 'Input',
|
|
214
|
+
Value: null
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
Name: 'DefaultLookbackMinutes',
|
|
218
|
+
Type: 'Input',
|
|
219
|
+
Value: 60
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
Name: 'OnlyCompleted',
|
|
223
|
+
Type: 'Input',
|
|
224
|
+
Value: false
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
Name: 'Region',
|
|
228
|
+
Type: 'Input',
|
|
229
|
+
Value: 'us'
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
Name: 'MaxSubmissions',
|
|
233
|
+
Type: 'Input',
|
|
234
|
+
Value: 1000
|
|
235
|
+
}
|
|
236
|
+
];
|
|
237
|
+
}
|
|
238
|
+
}
|