@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,269 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.JotFormBaseAction = void 0;
|
|
13
|
+
const global_1 = require("@memberjunction/global");
|
|
14
|
+
const base_form_builder_action_1 = require("../../base/base-form-builder.action");
|
|
15
|
+
const core_1 = require("@memberjunction/core");
|
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
|
17
|
+
const actions_1 = require("@memberjunction/actions");
|
|
18
|
+
/**
|
|
19
|
+
* Base class for all JotForm actions.
|
|
20
|
+
* Handles JotForm-specific authentication and API interaction patterns.
|
|
21
|
+
*/
|
|
22
|
+
let JotFormBaseAction = class JotFormBaseAction extends base_form_builder_action_1.BaseFormBuilderAction {
|
|
23
|
+
get formPlatform() {
|
|
24
|
+
return 'JotForm';
|
|
25
|
+
}
|
|
26
|
+
get integrationName() {
|
|
27
|
+
return 'JotForm';
|
|
28
|
+
}
|
|
29
|
+
get apiBaseUrl() {
|
|
30
|
+
return 'https://api.jotform.com';
|
|
31
|
+
}
|
|
32
|
+
axiosInstance = null;
|
|
33
|
+
currentAPIKey = null;
|
|
34
|
+
/**
|
|
35
|
+
* Get axios instance with JotForm authentication
|
|
36
|
+
*/
|
|
37
|
+
getAxiosInstance(apiKey, region) {
|
|
38
|
+
const baseURL = this.getRegionalBaseUrl(region);
|
|
39
|
+
if (!this.axiosInstance || this.currentAPIKey !== apiKey) {
|
|
40
|
+
this.currentAPIKey = apiKey;
|
|
41
|
+
this.axiosInstance = axios_1.default.create({
|
|
42
|
+
baseURL,
|
|
43
|
+
timeout: 60000,
|
|
44
|
+
headers: {
|
|
45
|
+
'Accept': 'application/json',
|
|
46
|
+
'Content-Type': 'application/json'
|
|
47
|
+
},
|
|
48
|
+
params: {
|
|
49
|
+
apiKey // JotForm uses API key in query params
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
this.axiosInstance.interceptors.response.use((response) => {
|
|
53
|
+
return response;
|
|
54
|
+
}, async (error) => {
|
|
55
|
+
if (error.response?.status === 429) {
|
|
56
|
+
(0, core_1.LogStatus)('JotForm rate limit hit. Waiting 60 seconds...');
|
|
57
|
+
await this.sleep(60000);
|
|
58
|
+
return this.axiosInstance.request(error.config);
|
|
59
|
+
}
|
|
60
|
+
return Promise.reject(error);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return this.axiosInstance;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get regional base URL
|
|
67
|
+
*/
|
|
68
|
+
getRegionalBaseUrl(region) {
|
|
69
|
+
switch (region) {
|
|
70
|
+
case 'eu':
|
|
71
|
+
return 'https://eu-api.jotform.com';
|
|
72
|
+
case 'hipaa':
|
|
73
|
+
return 'https://hipaa-api.jotform.com';
|
|
74
|
+
default:
|
|
75
|
+
return 'https://api.jotform.com';
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get submissions from a JotForm
|
|
80
|
+
*/
|
|
81
|
+
async getJotFormSubmissions(formId, apiKey, options) {
|
|
82
|
+
try {
|
|
83
|
+
const params = {
|
|
84
|
+
apiKey,
|
|
85
|
+
limit: options?.limit || 100,
|
|
86
|
+
offset: options?.offset || 0
|
|
87
|
+
};
|
|
88
|
+
if (options?.filter) {
|
|
89
|
+
params.filter = JSON.stringify(options.filter);
|
|
90
|
+
}
|
|
91
|
+
if (options?.orderby) {
|
|
92
|
+
params.orderby = options.orderby;
|
|
93
|
+
}
|
|
94
|
+
const response = await this.getAxiosInstance(apiKey, options?.region).get(`/form/${formId}/submissions`, { params });
|
|
95
|
+
return response.data;
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
(0, core_1.LogError)('Failed to get JotForm submissions:', error);
|
|
99
|
+
throw this.handleJotFormError(error);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Get all submissions with automatic pagination
|
|
104
|
+
*/
|
|
105
|
+
async getAllJotFormSubmissions(formId, apiKey, options) {
|
|
106
|
+
const allSubmissions = [];
|
|
107
|
+
let offset = 0;
|
|
108
|
+
const limit = 1000;
|
|
109
|
+
const maxSubmissions = options?.maxSubmissions || 10000;
|
|
110
|
+
try {
|
|
111
|
+
while (true) {
|
|
112
|
+
const result = await this.getJotFormSubmissions(formId, apiKey, {
|
|
113
|
+
limit: Math.min(limit, maxSubmissions - allSubmissions.length),
|
|
114
|
+
offset,
|
|
115
|
+
filter: options?.filter,
|
|
116
|
+
orderby: options?.orderby,
|
|
117
|
+
region: options?.region
|
|
118
|
+
});
|
|
119
|
+
if (result.content && result.content.length > 0) {
|
|
120
|
+
allSubmissions.push(...result.content);
|
|
121
|
+
if (allSubmissions.length >= maxSubmissions) {
|
|
122
|
+
(0, core_1.LogStatus)(`Reached max submissions limit of ${maxSubmissions}`);
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
if (result.content.length < limit) {
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
offset += limit;
|
|
129
|
+
await this.sleep(100);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
(0, core_1.LogStatus)(`Retrieved ${allSubmissions.length} submissions from JotForm`);
|
|
136
|
+
return allSubmissions;
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
(0, core_1.LogError)('Failed to get all JotForm submissions:', error);
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Get a single submission by ID
|
|
145
|
+
*/
|
|
146
|
+
async getSingleJotFormSubmission(submissionId, apiKey, region) {
|
|
147
|
+
try {
|
|
148
|
+
const response = await this.getAxiosInstance(apiKey, region).get(`/submission/${submissionId}`, { params: { apiKey } });
|
|
149
|
+
return response.data.content;
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
(0, core_1.LogError)('Failed to get single JotForm submission:', error);
|
|
153
|
+
throw this.handleJotFormError(error);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Get form details
|
|
158
|
+
*/
|
|
159
|
+
async getJotFormDetails(formId, apiKey, region) {
|
|
160
|
+
try {
|
|
161
|
+
const response = await this.getAxiosInstance(apiKey, region).get(`/form/${formId}`, { params: { apiKey } });
|
|
162
|
+
return response.data.content;
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
(0, core_1.LogError)('Failed to get JotForm details:', error);
|
|
166
|
+
throw this.handleJotFormError(error);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Get form questions/fields
|
|
171
|
+
*/
|
|
172
|
+
async getJotFormQuestions(formId, apiKey, region) {
|
|
173
|
+
try {
|
|
174
|
+
const response = await this.getAxiosInstance(apiKey, region).get(`/form/${formId}/questions`, { params: { apiKey } });
|
|
175
|
+
return response.data.content;
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
(0, core_1.LogError)('Failed to get JotForm questions:', error);
|
|
179
|
+
throw this.handleJotFormError(error);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Create a new submission
|
|
184
|
+
*/
|
|
185
|
+
async createJotFormSubmission(formId, apiKey, submissionData, region) {
|
|
186
|
+
try {
|
|
187
|
+
const params = { apiKey };
|
|
188
|
+
// Add submission data to params
|
|
189
|
+
Object.entries(submissionData).forEach(([fieldId, value]) => {
|
|
190
|
+
params[`submission[${fieldId}]`] = value;
|
|
191
|
+
});
|
|
192
|
+
const response = await this.getAxiosInstance(apiKey, region).post(`/form/${formId}/submissions`, null, { params });
|
|
193
|
+
return response.data;
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
(0, core_1.LogError)('Failed to create JotForm submission:', error);
|
|
197
|
+
throw this.handleJotFormError(error);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Normalize JotForm submission to common format
|
|
202
|
+
*/
|
|
203
|
+
normalizeJotFormSubmission(jfSubmission) {
|
|
204
|
+
const answers = Object.entries(jfSubmission.answers || {}).map(([fieldId, answerData]) => {
|
|
205
|
+
let answerValue = answerData.answer;
|
|
206
|
+
// Handle array answers
|
|
207
|
+
if (Array.isArray(answerValue)) {
|
|
208
|
+
answerValue = answerValue.filter(v => v !== '');
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
fieldId,
|
|
212
|
+
fieldType: answerData.type,
|
|
213
|
+
question: answerData.text || answerData.name,
|
|
214
|
+
answer: answerValue || answerData.prettyFormat,
|
|
215
|
+
choices: Array.isArray(answerValue) ? answerValue : undefined
|
|
216
|
+
};
|
|
217
|
+
});
|
|
218
|
+
const submittedAt = new Date(jfSubmission.created_at);
|
|
219
|
+
const completed = jfSubmission.status === 'ACTIVE';
|
|
220
|
+
return {
|
|
221
|
+
responseId: jfSubmission.id,
|
|
222
|
+
formId: jfSubmission.form_id,
|
|
223
|
+
submittedAt,
|
|
224
|
+
completed,
|
|
225
|
+
answers,
|
|
226
|
+
metadata: {
|
|
227
|
+
userAgent: jfSubmission.ip,
|
|
228
|
+
platform: 'JotForm'
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Handle JotForm-specific errors
|
|
234
|
+
*/
|
|
235
|
+
handleJotFormError(error) {
|
|
236
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
237
|
+
const axiosError = error;
|
|
238
|
+
const status = axiosError.response?.status;
|
|
239
|
+
const data = axiosError.response?.data;
|
|
240
|
+
if (status === 401) {
|
|
241
|
+
return new Error('Invalid JotForm API key. Please check your authentication.');
|
|
242
|
+
}
|
|
243
|
+
else if (status === 403) {
|
|
244
|
+
return new Error('Insufficient permissions to access this JotForm resource.');
|
|
245
|
+
}
|
|
246
|
+
else if (status === 404) {
|
|
247
|
+
return new Error('JotForm form or submission not found.');
|
|
248
|
+
}
|
|
249
|
+
else if (status === 429) {
|
|
250
|
+
return new Error('JotForm API rate limit exceeded. Please try again later.');
|
|
251
|
+
}
|
|
252
|
+
else if (data?.message) {
|
|
253
|
+
return new Error(`JotForm API error: ${data.message}`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Sleep helper for rate limiting
|
|
260
|
+
*/
|
|
261
|
+
sleep(ms) {
|
|
262
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
exports.JotFormBaseAction = JotFormBaseAction;
|
|
266
|
+
exports.JotFormBaseAction = JotFormBaseAction = __decorate([
|
|
267
|
+
(0, global_1.RegisterClass)(actions_1.BaseAction, 'JotFormBaseAction')
|
|
268
|
+
], JotFormBaseAction);
|
|
269
|
+
//# sourceMappingURL=jotform-base.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jotform-base.action.js","sourceRoot":"","sources":["../../../src/providers/jotform/jotform-base.action.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAuD;AACvD,kFAAsG;AACtG,+CAAqE;AACrE,kDAAyD;AACzD,qDAAqD;AA+BrD;;;GAGG;AAEI,IAAe,iBAAiB,GAAhC,MAAe,iBAAkB,SAAQ,gDAAqB;IACjE,IAAc,YAAY;QACtB,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,IAAc,eAAe;QACzB,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,IAAc,UAAU;QACpB,OAAO,yBAAyB,CAAC;IACrC,CAAC;IAEO,aAAa,GAAyB,IAAI,CAAC;IAC3C,aAAa,GAAkB,IAAI,CAAC;IAE5C;;OAEG;IACO,gBAAgB,C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,CAAC,uCAAuC,CAAC,CAAC;YAC9D,CAAC;iBAAM,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;gBACxB,OAAO,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;YACjF,CAAC;iBAAM,IAAI,IAAI,EAAE,OAAO,EAAE,CAAC;gBACvB,OAAO,IAAI,KAAK,CAAC,sBAAsB,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;YAC3D,CAAC;QACL,CAAC;QAED,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACrE,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,EAAU;QACtB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;CACJ,CAAA;AApUqB,8CAAiB;4BAAjB,iBAAiB;IADtC,IAAA,sBAAa,EAAC,oBAAU,EAAE,mBAAmB,CAAC;GACzB,iBAAiB,CAoUtC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { SurveyMonkeyBaseAction } from '../surveymonkey-base.action';
|
|
2
|
+
import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
3
|
+
/**
|
|
4
|
+
* Action to create a new SurveyMonkey survey programmatically
|
|
5
|
+
*
|
|
6
|
+
* Security: Uses secure credential lookup via CompanyID instead of accepting tokens directly.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* await runAction({
|
|
11
|
+
* ActionName: 'Create SurveyMonkey',
|
|
12
|
+
* Params: [{
|
|
13
|
+
* Name: 'CompanyID',
|
|
14
|
+
* Value: 'your-company-id'
|
|
15
|
+
* }, {
|
|
16
|
+
* Name: 'Title',
|
|
17
|
+
* Value: 'Customer Satisfaction Survey'
|
|
18
|
+
* }, {
|
|
19
|
+
* Name: 'Pages',
|
|
20
|
+
* Value: [{
|
|
21
|
+
* title: 'Page 1',
|
|
22
|
+
* questions: [{
|
|
23
|
+
* family: 'single_choice',
|
|
24
|
+
* subtype: 'vertical',
|
|
25
|
+
* heading: 'How satisfied are you with our service?',
|
|
26
|
+
* answers: {
|
|
27
|
+
* choices: [
|
|
28
|
+
* { text: 'Very Satisfied' },
|
|
29
|
+
* { text: 'Satisfied' },
|
|
30
|
+
* { text: 'Neutral' },
|
|
31
|
+
* { text: 'Dissatisfied' }
|
|
32
|
+
* ]
|
|
33
|
+
* }
|
|
34
|
+
* }]
|
|
35
|
+
* }]
|
|
36
|
+
* }, {
|
|
37
|
+
* Name: 'Language',
|
|
38
|
+
* Value: 'en'
|
|
39
|
+
* }]
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare class CreateSurveyMonkeyAction extends SurveyMonkeyBaseAction {
|
|
44
|
+
get Description(): string;
|
|
45
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
46
|
+
get Params(): ActionParam[];
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=create-survey.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-survey.action.d.ts","sourceRoot":"","sources":["../../../../src/providers/surveymonkey/actions/create-survey.action.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAGhG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,qBACa,wBAAyB,SAAQ,sBAAsB;IAEhE,IAAW,WAAW,IAAI,MAAM,CAE/B;cAEe,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAkHvF,IAAW,MAAM,IAAI,WAAW,EAAE,CA4BjC;CACJ"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.CreateSurveyMonkeyAction = void 0;
|
|
10
|
+
const global_1 = require("@memberjunction/global");
|
|
11
|
+
const surveymonkey_base_action_1 = require("../surveymonkey-base.action");
|
|
12
|
+
const actions_1 = require("@memberjunction/actions");
|
|
13
|
+
/**
|
|
14
|
+
* Action to create a new SurveyMonkey survey programmatically
|
|
15
|
+
*
|
|
16
|
+
* Security: Uses secure credential lookup via CompanyID instead of accepting tokens directly.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* await runAction({
|
|
21
|
+
* ActionName: 'Create SurveyMonkey',
|
|
22
|
+
* Params: [{
|
|
23
|
+
* Name: 'CompanyID',
|
|
24
|
+
* Value: 'your-company-id'
|
|
25
|
+
* }, {
|
|
26
|
+
* Name: 'Title',
|
|
27
|
+
* Value: 'Customer Satisfaction Survey'
|
|
28
|
+
* }, {
|
|
29
|
+
* Name: 'Pages',
|
|
30
|
+
* Value: [{
|
|
31
|
+
* title: 'Page 1',
|
|
32
|
+
* questions: [{
|
|
33
|
+
* family: 'single_choice',
|
|
34
|
+
* subtype: 'vertical',
|
|
35
|
+
* heading: 'How satisfied are you with our service?',
|
|
36
|
+
* answers: {
|
|
37
|
+
* choices: [
|
|
38
|
+
* { text: 'Very Satisfied' },
|
|
39
|
+
* { text: 'Satisfied' },
|
|
40
|
+
* { text: 'Neutral' },
|
|
41
|
+
* { text: 'Dissatisfied' }
|
|
42
|
+
* ]
|
|
43
|
+
* }
|
|
44
|
+
* }]
|
|
45
|
+
* }]
|
|
46
|
+
* }, {
|
|
47
|
+
* Name: 'Language',
|
|
48
|
+
* Value: 'en'
|
|
49
|
+
* }]
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
let CreateSurveyMonkeyAction = class CreateSurveyMonkeyAction extends surveymonkey_base_action_1.SurveyMonkeyBaseAction {
|
|
54
|
+
get Description() {
|
|
55
|
+
return 'Creates a new SurveyMonkey survey with specified title, pages, and questions. Supports all question families including single_choice, multiple_choice, matrix, open_ended, demographic, datetime, and presentation. Returns the new survey ID, URLs, and page count.';
|
|
56
|
+
}
|
|
57
|
+
async InternalRunAction(params) {
|
|
58
|
+
try {
|
|
59
|
+
const contextUser = params.ContextUser;
|
|
60
|
+
if (!contextUser) {
|
|
61
|
+
return {
|
|
62
|
+
Success: false,
|
|
63
|
+
ResultCode: 'MISSING_CONTEXT_USER',
|
|
64
|
+
Message: 'Context user is required for SurveyMonkey API calls'
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const companyId = this.getParamValue(params.Params, 'CompanyID');
|
|
68
|
+
const accessToken = await this.getSecureAPIToken(companyId, contextUser);
|
|
69
|
+
const title = this.getParamValue(params.Params, 'Title');
|
|
70
|
+
if (!title) {
|
|
71
|
+
return {
|
|
72
|
+
Success: false,
|
|
73
|
+
ResultCode: 'MISSING_TITLE',
|
|
74
|
+
Message: 'Title parameter is required'
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const pages = this.getParamValue(params.Params, 'Pages');
|
|
78
|
+
if (!pages || !Array.isArray(pages) || pages.length === 0) {
|
|
79
|
+
return {
|
|
80
|
+
Success: false,
|
|
81
|
+
ResultCode: 'MISSING_PAGES',
|
|
82
|
+
Message: 'Pages parameter is required and must be a non-empty array'
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const surveyData = {
|
|
86
|
+
title,
|
|
87
|
+
pages
|
|
88
|
+
};
|
|
89
|
+
const language = this.getParamValue(params.Params, 'Language');
|
|
90
|
+
if (language) {
|
|
91
|
+
surveyData.language = language;
|
|
92
|
+
}
|
|
93
|
+
const buttonsText = this.getParamValue(params.Params, 'ButtonsText');
|
|
94
|
+
if (buttonsText && typeof buttonsText === 'object') {
|
|
95
|
+
surveyData.buttons_text = buttonsText;
|
|
96
|
+
}
|
|
97
|
+
const response = await this.getAxiosInstance(accessToken).post('/surveys', surveyData);
|
|
98
|
+
const createdSurvey = response.data;
|
|
99
|
+
const surveyDetails = await this.getSurveyMonkeyDetails(createdSurvey.id, accessToken);
|
|
100
|
+
const surveyUrl = surveyDetails.collect_url || `https://www.surveymonkey.com/r/${createdSurvey.id}`;
|
|
101
|
+
const editUrl = surveyDetails.edit_url || `https://www.surveymonkey.com/create/?sm=${createdSurvey.id}`;
|
|
102
|
+
const outputParams = [
|
|
103
|
+
{
|
|
104
|
+
Name: 'Survey',
|
|
105
|
+
Type: 'Output',
|
|
106
|
+
Value: surveyDetails
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
Name: 'SurveyID',
|
|
110
|
+
Type: 'Output',
|
|
111
|
+
Value: createdSurvey.id
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
Name: 'Title',
|
|
115
|
+
Type: 'Output',
|
|
116
|
+
Value: surveyDetails.title
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
Name: 'SurveyURL',
|
|
120
|
+
Type: 'Output',
|
|
121
|
+
Value: surveyUrl
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
Name: 'EditURL',
|
|
125
|
+
Type: 'Output',
|
|
126
|
+
Value: editUrl
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
Name: 'PageCount',
|
|
130
|
+
Type: 'Output',
|
|
131
|
+
Value: surveyDetails.page_count
|
|
132
|
+
}
|
|
133
|
+
];
|
|
134
|
+
for (const outputParam of outputParams) {
|
|
135
|
+
const existingParam = params.Params.find(p => p.Name === outputParam.Name);
|
|
136
|
+
if (existingParam) {
|
|
137
|
+
existingParam.Value = outputParam.Value;
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
params.Params.push(outputParam);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
Success: true,
|
|
145
|
+
ResultCode: 'SUCCESS',
|
|
146
|
+
Message: `Successfully created survey "${surveyDetails.title}" (ID: ${createdSurvey.id}). View at: ${surveyUrl}`
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
151
|
+
return {
|
|
152
|
+
Success: false,
|
|
153
|
+
ResultCode: 'ERROR',
|
|
154
|
+
Message: this.buildFormErrorMessage('Create SurveyMonkey Survey', errorMessage, error)
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
get Params() {
|
|
159
|
+
return [
|
|
160
|
+
{
|
|
161
|
+
Name: 'CompanyID',
|
|
162
|
+
Type: 'Input',
|
|
163
|
+
Value: null
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
Name: 'Title',
|
|
167
|
+
Type: 'Input',
|
|
168
|
+
Value: null
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
Name: 'Pages',
|
|
172
|
+
Type: 'Input',
|
|
173
|
+
Value: null
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
Name: 'Language',
|
|
177
|
+
Type: 'Input',
|
|
178
|
+
Value: null
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
Name: 'ButtonsText',
|
|
182
|
+
Type: 'Input',
|
|
183
|
+
Value: null
|
|
184
|
+
}
|
|
185
|
+
];
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
exports.CreateSurveyMonkeyAction = CreateSurveyMonkeyAction;
|
|
189
|
+
exports.CreateSurveyMonkeyAction = CreateSurveyMonkeyAction = __decorate([
|
|
190
|
+
(0, global_1.RegisterClass)(actions_1.BaseAction, 'Create SurveyMonkey')
|
|
191
|
+
], CreateSurveyMonkeyAction);
|
|
192
|
+
//# sourceMappingURL=create-survey.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-survey.action.js","sourceRoot":"","sources":["../../../../src/providers/surveymonkey/actions/create-survey.action.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mDAAuD;AACvD,0EAAqE;AAErE,qDAAqD;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEI,IAAM,wBAAwB,GAA9B,MAAM,wBAAyB,SAAQ,iDAAsB;IAEhE,IAAW,WAAW;QAClB,OAAO,sQAAsQ,CAAC;IAClR,CAAC;IAES,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,IAAI,CAAC;YACD,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;YACvC,IAAI,CAAC,WAAW,EAAE,CAAC;gBACf,OAAO;oBACH,OAAO,EAAE,KAAK;oBACd,UAAU,EAAE,sBAAsB;oBAClC,OAAO,EAAE,qDAAqD;iBACjE,CAAC;YACN,CAAC;YAED,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;YAEjE,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;YAEzE,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACzD,IAAI,CAAC,KAAK,EAAE,CAAC;gBACT,OAAO;oBACH,OAAO,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AAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB,CAAC;YACvF,OAAO;gBACH,OAAO,EAAE,KAAK;gBACd,UAAU,EAAE,OAAO;gBACnB,OAAO,EAAE,IAAI,CAAC,qBAAqB,CAAC,4BAA4B,EAAE,YAAY,EAAE,KAAK,CAAC;aACzF,CAAC;QACN,CAAC;IACL,CAAC;IAED,IAAW,MAAM;QACb,OAAO;YACH;gBACI,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,IAAI;aACd;YACD;gBACI,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,IAAI;aACd;YACD;gBACI,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,IAAI;aACd;YACD;gBACI,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,IAAI;aACd;YACD;gBACI,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,IAAI;aACd;SACJ,CAAC;IACN,CAAC;CACJ,CAAA;AArJY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,sBAAa,EAAC,oBAAU,EAAE,qBAAqB,CAAC;GACpC,wBAAwB,CAqJpC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SurveyMonkeyBaseAction } from '../surveymonkey-base.action';
|
|
2
|
+
import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
3
|
+
/**
|
|
4
|
+
* Action to export SurveyMonkey responses as CSV format
|
|
5
|
+
*
|
|
6
|
+
* Security: Uses secure credential lookup via CompanyID instead of accepting tokens directly.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* await runAction({
|
|
11
|
+
* ActionName: 'Export SurveyMonkey Responses to CSV',
|
|
12
|
+
* Params: [{
|
|
13
|
+
* Name: 'CompanyID',
|
|
14
|
+
* Value: 'your-company-id'
|
|
15
|
+
* }, {
|
|
16
|
+
* Name: 'SurveyID',
|
|
17
|
+
* Value: 'abc123'
|
|
18
|
+
* }, {
|
|
19
|
+
* Name: 'IncludeMetadata',
|
|
20
|
+
* Value: true
|
|
21
|
+
* }]
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare class ExportSurveyMonkeyCSVAction extends SurveyMonkeyBaseAction {
|
|
26
|
+
get Description(): string;
|
|
27
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
28
|
+
get Params(): ActionParam[];
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=export-csv.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export-csv.action.d.ts","sourceRoot":"","sources":["../../../../src/providers/surveymonkey/actions/export-csv.action.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAGhG;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBACa,2BAA4B,SAAQ,sBAAsB;IAEnE,IAAW,WAAW,IAAI,MAAM,CAE/B;cAEe,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAqGvF,IAAW,MAAM,IAAI,WAAW,EAAE,CAsCjC;CACJ"}
|