@prismatic-io/components-surveymonkey 0.0.0-stage → 0.0.1

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.
@@ -0,0 +1,2598 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ //#endregion
23
+ let _prismatic_io_spectral = require("@prismatic-io/spectral");
24
+ let _prismatic_io_spectral_http = require("@prismatic-io/spectral/http");
25
+ let node_crypto = require("node:crypto");
26
+ node_crypto = __toESM(node_crypto);
27
+ //#region src/constants.ts
28
+ const REGIONS = {
29
+ us: {
30
+ label: "United States",
31
+ baseUrl: "https://api.surveymonkey.com/v3"
32
+ },
33
+ eu: {
34
+ label: "European Union",
35
+ baseUrl: "https://api.eu.surveymonkey.com/v3"
36
+ },
37
+ ca: {
38
+ label: "Canada",
39
+ baseUrl: "https://api.surveymonkey.ca/v3"
40
+ }
41
+ };
42
+ const WEBHOOK_EVENT_TYPES = [
43
+ {
44
+ label: "Response Completed",
45
+ key: "response_completed"
46
+ },
47
+ {
48
+ label: "Response Created",
49
+ key: "response_created"
50
+ },
51
+ {
52
+ label: "Response Updated",
53
+ key: "response_updated"
54
+ },
55
+ {
56
+ label: "Response Deleted",
57
+ key: "response_deleted"
58
+ },
59
+ {
60
+ label: "Response Disqualified",
61
+ key: "response_disqualified"
62
+ },
63
+ {
64
+ label: "Response Over Quota",
65
+ key: "response_overquota"
66
+ },
67
+ {
68
+ label: "Survey Created",
69
+ key: "survey_created"
70
+ },
71
+ {
72
+ label: "Survey Updated",
73
+ key: "survey_updated"
74
+ },
75
+ {
76
+ label: "Survey Deleted",
77
+ key: "survey_deleted"
78
+ },
79
+ {
80
+ label: "Collector Created",
81
+ key: "collector_created"
82
+ },
83
+ {
84
+ label: "Collector Updated",
85
+ key: "collector_updated"
86
+ },
87
+ {
88
+ label: "Collector Deleted",
89
+ key: "collector_deleted"
90
+ }
91
+ ];
92
+ const LOOK_BACK_DATE_PATTERN = /^(\d{4})-(\d{2})-(\d{2})$/;
93
+ //#endregion
94
+ //#region src/util/pagination.ts
95
+ const paginateResults = async (client, endpoint, fetchAll = false, params = {}) => {
96
+ if (!fetchAll) return (await client.get(endpoint, { params })).data;
97
+ const fetchAllParams = { ...params };
98
+ delete fetchAllParams.page;
99
+ delete fetchAllParams.per_page;
100
+ const firstResponse = await client.get(endpoint, { params: {
101
+ ...fetchAllParams,
102
+ page: 1,
103
+ per_page: 100
104
+ } });
105
+ const allData = [...firstResponse.data.data || []];
106
+ let currentPage = 1;
107
+ let lastResponse = firstResponse;
108
+ while (lastResponse.data.links?.next != null) {
109
+ currentPage++;
110
+ const nextResponse = await client.get(endpoint, { params: {
111
+ ...fetchAllParams,
112
+ page: currentPage,
113
+ per_page: 100
114
+ } });
115
+ const pageData = nextResponse.data.data || [];
116
+ allData.push(...pageData);
117
+ lastResponse = nextResponse;
118
+ }
119
+ delete lastResponse.data.page;
120
+ delete lastResponse.data.per_page;
121
+ delete lastResponse.data.links;
122
+ return {
123
+ ...lastResponse.data,
124
+ data: allData
125
+ };
126
+ };
127
+ var connections_default = [(0, _prismatic_io_spectral.oauth2Connection)({
128
+ key: "surveyMonkeyOAuth",
129
+ display: {
130
+ label: "OAuth 2.0",
131
+ description: "Authenticate using OAuth 2.0"
132
+ },
133
+ oauth2Type: _prismatic_io_spectral.OAuth2Type.AuthorizationCode,
134
+ inputs: {
135
+ region: {
136
+ label: "Region",
137
+ placeholder: "Select region",
138
+ type: "string",
139
+ required: true,
140
+ shown: true,
141
+ default: "us",
142
+ model: [
143
+ {
144
+ label: "United States",
145
+ value: "us"
146
+ },
147
+ {
148
+ label: "European Union",
149
+ value: "eu"
150
+ },
151
+ {
152
+ label: "Canada",
153
+ value: "ca"
154
+ }
155
+ ],
156
+ comments: "The SurveyMonkey region for the account."
157
+ },
158
+ authorizeUrl: {
159
+ label: "Authorize URL",
160
+ placeholder: "Authorize URL",
161
+ type: "string",
162
+ required: true,
163
+ shown: false,
164
+ default: "https://api.surveymonkey.com/oauth/authorize",
165
+ comments: "The OAuth 2.0 Authorization URL for SurveyMonkey."
166
+ },
167
+ tokenUrl: {
168
+ label: "Token URL",
169
+ placeholder: "Token URL",
170
+ type: "string",
171
+ required: true,
172
+ shown: false,
173
+ default: "https://api.surveymonkey.com/oauth/token",
174
+ comments: "The OAuth 2.0 Token URL for SurveyMonkey."
175
+ },
176
+ scopes: {
177
+ label: "Scopes",
178
+ placeholder: "Enter scopes",
179
+ type: "string",
180
+ required: false,
181
+ shown: false,
182
+ default: ""
183
+ },
184
+ clientId: {
185
+ label: "Client ID",
186
+ placeholder: "Enter Client ID",
187
+ type: "string",
188
+ required: true,
189
+ shown: true,
190
+ comments: "The Client ID from the [SurveyMonkey App](https://developer.surveymonkey.com/apps/).",
191
+ example: "xxxxxxxxxxxxxxxxxxxxxxxx"
192
+ },
193
+ clientSecret: {
194
+ label: "Client Secret",
195
+ placeholder: "Enter Client Secret",
196
+ type: "password",
197
+ required: true,
198
+ shown: true,
199
+ comments: "The Client Secret from the SurveyMonkey App."
200
+ }
201
+ }
202
+ }), (0, _prismatic_io_spectral.connection)({
203
+ key: "surveyMonkeyAccessToken",
204
+ display: {
205
+ label: "Access Token",
206
+ description: "Authenticate using an access token"
207
+ },
208
+ inputs: {
209
+ region: {
210
+ label: "Region",
211
+ placeholder: "Select region",
212
+ type: "string",
213
+ required: true,
214
+ shown: true,
215
+ default: "us",
216
+ model: [
217
+ {
218
+ label: "United States",
219
+ value: "us"
220
+ },
221
+ {
222
+ label: "European Union",
223
+ value: "eu"
224
+ },
225
+ {
226
+ label: "Canada",
227
+ value: "ca"
228
+ }
229
+ ],
230
+ comments: "The SurveyMonkey region for the account."
231
+ },
232
+ accessToken: {
233
+ label: "Access Token",
234
+ placeholder: "Enter Access Token",
235
+ type: "password",
236
+ required: true,
237
+ shown: true,
238
+ comments: "The long-lived access token from the [SurveyMonkey Developer Portal](https://developer.surveymonkey.com/apps/). Found in the app's Settings tab.",
239
+ example: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
240
+ },
241
+ apiKey: {
242
+ label: "API Key (Client ID)",
243
+ placeholder: "Enter API Key",
244
+ type: "string",
245
+ required: true,
246
+ shown: true,
247
+ comments: "The app's Client ID, needed for webhook signature verification.",
248
+ example: "xxxxxxxxxxxxxxxxxxxxxxxx"
249
+ },
250
+ apiSecret: {
251
+ label: "API Secret (Client Secret)",
252
+ placeholder: "Enter API Secret",
253
+ type: "password",
254
+ required: true,
255
+ shown: true,
256
+ comments: "The app's Client Secret, needed for webhook signature verification."
257
+ }
258
+ }
259
+ })];
260
+ //#endregion
261
+ //#region src/util/connection.ts
262
+ const validateConnection = (connection) => {
263
+ if (!connections_default.map((c) => c.key).includes(connection.key)) throw new _prismatic_io_spectral.ConnectionError(connection, `Unsupported connection ${connection.key}.`);
264
+ };
265
+ const getBaseUrl = (connection) => {
266
+ return REGIONS[_prismatic_io_spectral.util.types.toString(connection.fields?.region ?? connection.token?.region ?? "us")].baseUrl;
267
+ };
268
+ const getAccessToken = (connection) => {
269
+ if (connection.token?.access_token) return _prismatic_io_spectral.util.types.toString(connection.token.access_token);
270
+ if (connection.fields?.accessToken) return _prismatic_io_spectral.util.types.toString(connection.fields.accessToken);
271
+ throw new Error("No access token found. Please check your connection configuration.");
272
+ };
273
+ //#endregion
274
+ //#region src/util/webhooks.ts
275
+ const getApiKey = (connection) => {
276
+ if (connection.fields?.apiKey) return _prismatic_io_spectral.util.types.toString(connection.fields.apiKey);
277
+ if (connection.fields?.clientId) return _prismatic_io_spectral.util.types.toString(connection.fields.clientId);
278
+ throw new Error("No API key found for webhook signature verification.");
279
+ };
280
+ const getApiSecret = (connection) => {
281
+ if (connection.fields?.apiSecret) return _prismatic_io_spectral.util.types.toString(connection.fields.apiSecret);
282
+ if (connection.fields?.clientSecret) return _prismatic_io_spectral.util.types.toString(connection.fields.clientSecret);
283
+ throw new Error("No API secret found for webhook signature verification.");
284
+ };
285
+ const verifySignature = (rawBody, signature, apiKey, apiSecret) => {
286
+ const signingKey = `${apiKey}&${apiSecret}`;
287
+ return signature === node_crypto.default.createHmac("sha1", signingKey).update(rawBody, "utf8").digest("base64");
288
+ };
289
+ //#endregion
290
+ //#region src/util/cleanInput.ts
291
+ const toOptionalString = (value) => value ? _prismatic_io_spectral.util.types.toString(value) : void 0;
292
+ const toArrayOfStrings = (value) => value ? value : void 0;
293
+ const toSurveyMonkeyDate = (iso) => iso.replace(/\.\d+Z$/, "").replace(/Z$/, "");
294
+ const lookBackDateClean = (value) => {
295
+ if (value === void 0 || value === null || typeof value === "string" && value.trim() === "") return "";
296
+ const raw = typeof value === "string" ? value.trim() : String(value);
297
+ const match = typeof value === "string" ? raw.match(LOOK_BACK_DATE_PATTERN) : null;
298
+ if (!match) throw new Error(`Look-back Date must be a date in YYYY-MM-DD format. Received: ${raw}`);
299
+ const [, yearStr, monthStr, dayStr] = match;
300
+ const year = Number(yearStr);
301
+ const month = Number(monthStr);
302
+ const day = Number(dayStr);
303
+ const parsed = new Date(Date.UTC(year, month - 1, day));
304
+ if (parsed.getUTCFullYear() !== year || parsed.getUTCMonth() !== month - 1 || parsed.getUTCDate() !== day) throw new Error(`Look-back Date must be a date in YYYY-MM-DD format. Received: ${raw}`);
305
+ if (parsed.getTime() > Date.now()) throw new Error(`Look-back Date cannot be a future date. Received: ${raw}`);
306
+ return parsed.toISOString();
307
+ };
308
+ //#endregion
309
+ //#region src/util/misc.ts
310
+ const getBase64FromUrl = (url) => {
311
+ const lastPathSegmentMatch = url.match(/\/([^/]+)$/);
312
+ return lastPathSegmentMatch ? lastPathSegmentMatch[1] : "";
313
+ };
314
+ const generateWebhookName = (flowName, stateKey) => {
315
+ return `${flowName.slice(0, 30)}-${stateKey.slice(-8)}`;
316
+ };
317
+ const resolveSurveyResponseChanges = (data) => {
318
+ const changesObject = data ?? {
319
+ created: [],
320
+ updated: []
321
+ };
322
+ return [...(changesObject.created ?? []).map((record) => ({
323
+ changeType: "created",
324
+ record
325
+ })), ...(changesObject.updated ?? []).map((record) => ({
326
+ changeType: "updated",
327
+ record
328
+ }))];
329
+ };
330
+ //#endregion
331
+ //#region src/util/eventsWebhookCreate.ts
332
+ const eventsWebhookCreate = async (context, { connection, eventType, objectType, objectIds }) => {
333
+ const client = createClient(connection, context.debug.enabled);
334
+ const flowName = context.flow.name;
335
+ const webhookUrl = context.webhookUrls[flowName];
336
+ const stateKey = getBase64FromUrl(webhookUrl);
337
+ const webhookId = context.crossFlowState[stateKey];
338
+ context.logger.info(`Started Events Webhook Create for ${flowName}`);
339
+ if (webhookId) {
340
+ context.logger.info(`Updating existing webhook ${webhookId}`);
341
+ const updateBody = {
342
+ event_type: eventType,
343
+ object_type: objectType,
344
+ ...objectIds && objectIds.length > 0 && { object_ids: objectIds }
345
+ };
346
+ try {
347
+ const { data } = await client.patch(`/webhooks/${webhookId}`, updateBody);
348
+ context.logger.info(`Webhook ${data.id} updated successfully for ${flowName}`);
349
+ } catch (error) {
350
+ context.logger.error(`Error updating webhook ${webhookId} for ${flowName}: ${error.message}`);
351
+ throw error;
352
+ }
353
+ } else {
354
+ const createBody = {
355
+ name: generateWebhookName(flowName, stateKey),
356
+ event_type: eventType,
357
+ subscription_url: webhookUrl,
358
+ object_type: objectType,
359
+ ...objectIds && objectIds.length > 0 && { object_ids: objectIds }
360
+ };
361
+ try {
362
+ const { data } = await client.post("/webhooks", createBody);
363
+ context.crossFlowState[stateKey] = data.id;
364
+ context.logger.info(`Webhook ${data.id} created successfully for ${flowName}`);
365
+ } catch (error) {
366
+ context.logger.error(`Error creating webhook for ${flowName}: ${error.message}`);
367
+ throw error;
368
+ }
369
+ }
370
+ };
371
+ //#endregion
372
+ //#region src/util/eventsWebhookDelete.ts
373
+ const eventsWebhookDelete = async (context, { connection }) => {
374
+ const client = createClient(connection, context.debug.enabled);
375
+ const flowName = context.flow.name;
376
+ const webhookUrl = context.webhookUrls[flowName];
377
+ const stateKey = getBase64FromUrl(webhookUrl);
378
+ const webhookId = context.crossFlowState[stateKey];
379
+ context.logger.info(`Started Events Webhook Delete for ${flowName}`);
380
+ if (webhookId) {
381
+ context.logger.info(`Deleting webhook ${webhookId}`);
382
+ try {
383
+ await client.delete(`/webhooks/${webhookId}`);
384
+ delete context.crossFlowState[stateKey];
385
+ context.logger.info(`Webhook ${webhookId} deleted successfully for ${flowName}`);
386
+ } catch (error) {
387
+ context.logger.error(`Error deleting webhook ${webhookId} for ${flowName}: ${error.message}`);
388
+ throw error;
389
+ }
390
+ } else context.logger.info(`No webhook found to delete for ${flowName}`);
391
+ };
392
+ //#endregion
393
+ //#region src/util/eventsWebhookPerform.ts
394
+ const eventsWebhookPerform = async (context, payload, { connection }) => {
395
+ if (!context.isSimulatedTestExecution) {
396
+ const headers = _prismatic_io_spectral.util.types.lowerCaseHeaders(payload.headers);
397
+ const signature = headers["sm-signature"];
398
+ const receivedApiKey = headers["sm-apikey"];
399
+ if (!signature) throw new Error("Missing Sm-Signature header. This request may not be from SurveyMonkey.");
400
+ const rawBody = _prismatic_io_spectral.util.types.toString(payload.rawBody.data);
401
+ const apiKey = getApiKey(connection);
402
+ const apiSecret = getApiSecret(connection);
403
+ if (receivedApiKey && receivedApiKey !== apiKey) context.logger.warn("Sm-Apikey header does not match configured API key.");
404
+ if (!verifySignature(rawBody, signature, apiKey, apiSecret)) throw new Error("Webhook signature verification failed. The request may have been tampered with.");
405
+ context.logger.debug("Webhook signature verified successfully.");
406
+ }
407
+ return { payload };
408
+ };
409
+ //#endregion
410
+ //#region src/client.ts
411
+ const createClient = (connection, debug) => {
412
+ validateConnection(connection);
413
+ return (0, _prismatic_io_spectral_http.createClient)({
414
+ baseUrl: getBaseUrl(connection),
415
+ headers: {
416
+ Authorization: `Bearer ${getAccessToken(connection)}`,
417
+ "Content-Type": "application/json"
418
+ },
419
+ debug
420
+ });
421
+ };
422
+ //#endregion
423
+ //#region src/inputs/common.ts
424
+ const connectionInput = (0, _prismatic_io_spectral.input)({
425
+ label: "Connection",
426
+ type: "connection",
427
+ required: true,
428
+ comments: "The SurveyMonkey connection to use."
429
+ });
430
+ const fetchAll = (0, _prismatic_io_spectral.input)({
431
+ label: "Fetch All",
432
+ type: "boolean",
433
+ required: false,
434
+ default: "false",
435
+ comments: "When true, automatically fetches all pages of results using pagination. The API returns up to 100 results per page.",
436
+ clean: _prismatic_io_spectral.util.types.toBool
437
+ });
438
+ const page = (0, _prismatic_io_spectral.input)({
439
+ label: "Page",
440
+ type: "string",
441
+ required: false,
442
+ comments: "The page number to retrieve (starts at 1).",
443
+ example: "1",
444
+ placeholder: "Enter page number",
445
+ clean: _prismatic_io_spectral.util.types.toNumber
446
+ });
447
+ const perPage = (0, _prismatic_io_spectral.input)({
448
+ label: "Per Page",
449
+ type: "string",
450
+ required: false,
451
+ comments: "The maximum number of results to return per page. Maximum: 100.",
452
+ example: "50",
453
+ placeholder: "Enter results per page",
454
+ clean: _prismatic_io_spectral.util.types.toNumber
455
+ });
456
+ const pagination = (0, _prismatic_io_spectral.structuredObjectInput)({
457
+ label: "Pagination",
458
+ required: false,
459
+ comments: "Page number and results-per-page page-navigation controls.",
460
+ inputs: {
461
+ page,
462
+ perPage
463
+ }
464
+ });
465
+ const extraBody = (0, _prismatic_io_spectral.input)({
466
+ label: "Extra Body Fields",
467
+ type: "code",
468
+ language: "json",
469
+ comments: "Additional body fields to include in the request as a JSON object.",
470
+ required: false,
471
+ example: JSON.stringify({
472
+ phone_number: "1234567890",
473
+ href: "https://example.com/contact/1234567890"
474
+ }, null, 2),
475
+ clean: _prismatic_io_spectral.util.types.toObject
476
+ });
477
+ const getCurrentUserInputs = { connection: connectionInput };
478
+ const { debugRequest, ...httpRawRequestInputs } = _prismatic_io_spectral_http.inputs;
479
+ const rawRequestInputs = {
480
+ connection: connectionInput,
481
+ ...httpRawRequestInputs,
482
+ url: {
483
+ ...httpRawRequestInputs.url,
484
+ comments: "Input the path only (e.g., /surveys). The base URL is already included based on the configured region (e.g., https://api.surveymonkey.com/v3).",
485
+ example: "/surveys"
486
+ }
487
+ };
488
+ //#endregion
489
+ //#region src/inputs/surveys.ts
490
+ const surveyId = (0, _prismatic_io_spectral.input)({
491
+ label: "Survey ID",
492
+ type: "string",
493
+ required: true,
494
+ comments: "The unique identifier of the survey.",
495
+ example: "1234567890",
496
+ placeholder: "Enter survey ID",
497
+ dataSource: "selectSurvey",
498
+ clean: _prismatic_io_spectral.util.types.toString
499
+ });
500
+ const surveyTitle = (0, _prismatic_io_spectral.input)({
501
+ label: "Survey Title",
502
+ type: "string",
503
+ required: true,
504
+ comments: "The display name shown to respondents when they access the survey.",
505
+ example: "Customer Satisfaction Survey",
506
+ placeholder: "Enter survey title",
507
+ clean: _prismatic_io_spectral.util.types.toString
508
+ });
509
+ const surveyNickname = (0, _prismatic_io_spectral.input)({
510
+ label: "Nickname",
511
+ type: "string",
512
+ required: false,
513
+ comments: "Internal nickname for the survey (not shown to respondents).",
514
+ example: "Q1 2026 CSAT",
515
+ placeholder: "Enter survey nickname",
516
+ clean: toOptionalString
517
+ });
518
+ const fromTemplateId = (0, _prismatic_io_spectral.input)({
519
+ label: "Template ID",
520
+ type: "string",
521
+ required: false,
522
+ comments: "ID of an existing template to copy. Use this OR 'From Survey ID', not both.",
523
+ example: "1234567890",
524
+ placeholder: "Enter template ID",
525
+ clean: toOptionalString
526
+ });
527
+ const fromSurveyId = (0, _prismatic_io_spectral.input)({
528
+ label: "From Survey ID",
529
+ type: "string",
530
+ required: false,
531
+ comments: "ID of an existing survey to copy. Use this OR 'Template ID', not both.",
532
+ example: "1234567890",
533
+ placeholder: "Enter survey ID",
534
+ clean: toOptionalString
535
+ });
536
+ const surveyLanguage = (0, _prismatic_io_spectral.input)({
537
+ label: "Language",
538
+ type: "string",
539
+ required: false,
540
+ default: "en",
541
+ comments: "Language code for the survey (e.g., 'en', 'es', 'fr').",
542
+ example: "en",
543
+ placeholder: "Enter language code",
544
+ clean: toOptionalString
545
+ });
546
+ const listSurveysInputs = {
547
+ connection: connectionInput,
548
+ fetchAll,
549
+ pagination
550
+ };
551
+ const getSurveyInputs = {
552
+ connection: connectionInput,
553
+ surveyId
554
+ };
555
+ const createSurveyInputs = {
556
+ connection: connectionInput,
557
+ title: surveyTitle,
558
+ nickname: surveyNickname,
559
+ fromTemplateId,
560
+ fromSurveyId,
561
+ language: surveyLanguage,
562
+ extraBody
563
+ };
564
+ const deleteSurveyInputs = {
565
+ connection: connectionInput,
566
+ surveyId
567
+ };
568
+ const selectSurveyInputs = { connection: connectionInput };
569
+ //#endregion
570
+ //#region src/inputs/collectors.ts
571
+ const collectorId = (0, _prismatic_io_spectral.input)({
572
+ label: "Collector ID",
573
+ type: "string",
574
+ required: true,
575
+ comments: "The unique identifier of the collector.",
576
+ example: "1234567890",
577
+ placeholder: "Enter collector ID",
578
+ dataSource: "selectCollector",
579
+ clean: _prismatic_io_spectral.util.types.toString
580
+ });
581
+ const collectorName = (0, _prismatic_io_spectral.input)({
582
+ label: "Collector Name",
583
+ type: "string",
584
+ required: false,
585
+ comments: "The name of the collector.",
586
+ example: "Email Invite - January",
587
+ placeholder: "Enter collector name",
588
+ clean: toOptionalString
589
+ });
590
+ const collectorType = (0, _prismatic_io_spectral.input)({
591
+ label: "Collector Type",
592
+ type: "string",
593
+ required: true,
594
+ default: "weblink",
595
+ model: [
596
+ {
597
+ label: "Web Link",
598
+ value: "weblink"
599
+ },
600
+ {
601
+ label: "Email",
602
+ value: "email"
603
+ },
604
+ {
605
+ label: "Social Media",
606
+ value: "social"
607
+ },
608
+ {
609
+ label: "Embedded",
610
+ value: "embedded"
611
+ },
612
+ {
613
+ label: "Popup",
614
+ value: "popup"
615
+ }
616
+ ],
617
+ comments: "Type of collector. Note: Non-weblink collectors may require a paid plan.",
618
+ placeholder: "Select collector type",
619
+ clean: _prismatic_io_spectral.util.types.toString
620
+ });
621
+ const collectorRedirectUrl = (0, _prismatic_io_spectral.input)({
622
+ label: "Redirect URL",
623
+ type: "string",
624
+ required: false,
625
+ comments: "URL to redirect respondents to after completing the survey.",
626
+ example: "https://example.com/thank-you",
627
+ placeholder: "Enter redirect URL",
628
+ clean: toOptionalString
629
+ });
630
+ const collectorThankYouMessage = (0, _prismatic_io_spectral.input)({
631
+ label: "Thank You Message",
632
+ type: "text",
633
+ required: false,
634
+ comments: "Message shown to respondents after completing the survey.",
635
+ example: "Thank you for your feedback!",
636
+ placeholder: "Enter thank you message",
637
+ clean: toOptionalString
638
+ });
639
+ const collectorCloseDate = (0, _prismatic_io_spectral.input)({
640
+ label: "Close Date",
641
+ type: "string",
642
+ required: false,
643
+ comments: "Date/time to close the collector (ISO 8601 format).",
644
+ example: "2026-12-31T23:59:59+00:00",
645
+ placeholder: "Enter close date (ISO 8601 format)",
646
+ clean: toOptionalString
647
+ });
648
+ const allowMultipleResponses = (0, _prismatic_io_spectral.input)({
649
+ label: "Allow Multiple Responses",
650
+ type: "boolean",
651
+ required: false,
652
+ default: "false",
653
+ comments: "When true, respondents can submit multiple responses.",
654
+ clean: _prismatic_io_spectral.util.types.toBool
655
+ });
656
+ const allowMultipleResponsesModel = (0, _prismatic_io_spectral.input)({
657
+ label: "Allow Multiple Responses",
658
+ type: "string",
659
+ required: false,
660
+ model: [{
661
+ label: "Yes",
662
+ value: "true"
663
+ }, {
664
+ label: "No",
665
+ value: "false"
666
+ }],
667
+ comments: "When true, respondents can submit multiple responses.",
668
+ clean: toOptionalString
669
+ });
670
+ const createCollectorSettings = (0, _prismatic_io_spectral.structuredObjectInput)({
671
+ label: "Collector Settings",
672
+ required: false,
673
+ comments: "Thank you message, close date, redirect URL, and multiple-response setting.",
674
+ inputs: {
675
+ thankYouMessage: collectorThankYouMessage,
676
+ closeDate: collectorCloseDate,
677
+ redirectUrl: collectorRedirectUrl,
678
+ allowMultipleResponses
679
+ }
680
+ });
681
+ const updateCollectorSettings = (0, _prismatic_io_spectral.structuredObjectInput)({
682
+ label: "Collector Settings",
683
+ required: false,
684
+ comments: "Thank you message, close date, redirect URL, and multiple-response setting.",
685
+ inputs: {
686
+ thankYouMessage: collectorThankYouMessage,
687
+ closeDate: collectorCloseDate,
688
+ redirectUrl: collectorRedirectUrl,
689
+ allowMultipleResponsesModel
690
+ }
691
+ });
692
+ const listCollectorsInputs = {
693
+ connection: connectionInput,
694
+ surveyId,
695
+ fetchAll,
696
+ pagination
697
+ };
698
+ const getCollectorInputs = {
699
+ connection: connectionInput,
700
+ collectorId
701
+ };
702
+ const createCollectorInputs = {
703
+ connection: connectionInput,
704
+ surveyId,
705
+ type: collectorType,
706
+ name: collectorName,
707
+ collectorSettings: createCollectorSettings,
708
+ extraBody
709
+ };
710
+ const updateCollectorInputs = {
711
+ connection: connectionInput,
712
+ collectorId,
713
+ name: collectorName,
714
+ collectorSettings: updateCollectorSettings,
715
+ extraBody
716
+ };
717
+ const deleteCollectorInputs = {
718
+ connection: connectionInput,
719
+ collectorId
720
+ };
721
+ const getCollectorStatsInputs = {
722
+ connection: connectionInput,
723
+ collectorId
724
+ };
725
+ const selectCollectorInputs = {
726
+ connection: connectionInput,
727
+ surveyId: {
728
+ ...surveyId,
729
+ dataSource: void 0
730
+ }
731
+ };
732
+ //#endregion
733
+ //#region src/inputs/responses.ts
734
+ const responseId = (0, _prismatic_io_spectral.input)({
735
+ label: "Response ID",
736
+ type: "string",
737
+ required: true,
738
+ comments: "The unique identifier of the response.",
739
+ example: "5007154402",
740
+ placeholder: "Enter response ID",
741
+ dataSource: "selectResponse",
742
+ clean: _prismatic_io_spectral.util.types.toString
743
+ });
744
+ const responseStatus = (0, _prismatic_io_spectral.input)({
745
+ label: "Response Status",
746
+ type: "string",
747
+ required: false,
748
+ model: [
749
+ {
750
+ label: "All",
751
+ value: ""
752
+ },
753
+ {
754
+ label: "Completed",
755
+ value: "completed"
756
+ },
757
+ {
758
+ label: "Partial",
759
+ value: "partial"
760
+ },
761
+ {
762
+ label: "Disqualified",
763
+ value: "disqualified"
764
+ },
765
+ {
766
+ label: "Over Quota",
767
+ value: "overquota"
768
+ }
769
+ ],
770
+ comments: "Filter responses by status.",
771
+ placeholder: "Select response status",
772
+ clean: toOptionalString
773
+ });
774
+ const responsePages = (0, _prismatic_io_spectral.input)({
775
+ label: "Response Pages",
776
+ type: "code",
777
+ language: "json",
778
+ required: true,
779
+ comments: "Pages from the survey and their associated responses.",
780
+ example: JSON.stringify([{
781
+ id: "1234",
782
+ questions: [{
783
+ id: "1234",
784
+ variable_id: "",
785
+ answers: [{
786
+ choice_id: "123456",
787
+ row_id: "",
788
+ col_id: "",
789
+ other_id: "",
790
+ text: ""
791
+ }]
792
+ }]
793
+ }], null, 2),
794
+ clean: _prismatic_io_spectral.util.types.toObject
795
+ });
796
+ const responseUpdateStatus = (0, _prismatic_io_spectral.input)({
797
+ label: "Status",
798
+ type: "string",
799
+ required: false,
800
+ model: [
801
+ {
802
+ label: "Completed",
803
+ value: "completed"
804
+ },
805
+ {
806
+ label: "Partial",
807
+ value: "partial"
808
+ },
809
+ {
810
+ label: "Disqualified",
811
+ value: "disqualified"
812
+ },
813
+ {
814
+ label: "Over Quota",
815
+ value: "overquota"
816
+ }
817
+ ],
818
+ comments: "Update the response status.",
819
+ placeholder: "Select status",
820
+ clean: toOptionalString
821
+ });
822
+ const responseCustomValue = (0, _prismatic_io_spectral.input)({
823
+ label: "Custom Value",
824
+ type: "string",
825
+ required: false,
826
+ comments: "The custom metadata value to associate with the response.",
827
+ placeholder: "Enter custom value",
828
+ clean: toOptionalString
829
+ });
830
+ const listResponsesInputs = {
831
+ connection: connectionInput,
832
+ surveyId,
833
+ status: responseStatus,
834
+ fetchAll,
835
+ pagination
836
+ };
837
+ const getResponseInputs = {
838
+ connection: connectionInput,
839
+ surveyId,
840
+ responseId
841
+ };
842
+ const deleteResponseInputs = {
843
+ connection: connectionInput,
844
+ surveyId,
845
+ responseId
846
+ };
847
+ const updateResponseInputs = {
848
+ connection: connectionInput,
849
+ surveyId,
850
+ responseId,
851
+ responsePages,
852
+ status: responseUpdateStatus,
853
+ customValue: responseCustomValue,
854
+ extraBody
855
+ };
856
+ //#endregion
857
+ //#region src/inputs/contacts.ts
858
+ const contactId = (0, _prismatic_io_spectral.input)({
859
+ label: "Contact ID",
860
+ type: "string",
861
+ required: true,
862
+ comments: "The unique identifier of the contact.",
863
+ example: "1234567890",
864
+ placeholder: "Enter contact ID",
865
+ dataSource: "selectContact",
866
+ clean: _prismatic_io_spectral.util.types.toString
867
+ });
868
+ const contactEmail = (0, _prismatic_io_spectral.input)({
869
+ label: "Email",
870
+ type: "string",
871
+ required: true,
872
+ comments: "The contact's email address.",
873
+ example: "john.doe@example.com",
874
+ placeholder: "Enter email address",
875
+ clean: _prismatic_io_spectral.util.types.toString
876
+ });
877
+ const contactFirstName = (0, _prismatic_io_spectral.input)({
878
+ label: "First Name",
879
+ type: "string",
880
+ required: false,
881
+ comments: "The contact's first name.",
882
+ example: "John",
883
+ placeholder: "Enter first name",
884
+ clean: toOptionalString
885
+ });
886
+ const contactLastName = (0, _prismatic_io_spectral.input)({
887
+ label: "Last Name",
888
+ type: "string",
889
+ required: false,
890
+ comments: "The contact's last name.",
891
+ example: "Doe",
892
+ placeholder: "Enter last name",
893
+ clean: toOptionalString
894
+ });
895
+ const contactCustomFields = (0, _prismatic_io_spectral.input)({
896
+ label: "Custom Fields",
897
+ type: "string",
898
+ collection: "keyvaluelist",
899
+ required: false,
900
+ comments: "Custom field values as key-value pairs.",
901
+ placeholder: "Enter custom fields",
902
+ clean: (value) => _prismatic_io_spectral.util.types.keyValPairListToObject(value)
903
+ });
904
+ const updateExistingContacts = (0, _prismatic_io_spectral.input)({
905
+ label: "Update Existing Contacts",
906
+ type: "boolean",
907
+ required: false,
908
+ default: "false",
909
+ comments: "When true, existing contacts will be updated if they exist.",
910
+ clean: _prismatic_io_spectral.util.types.toBool
911
+ });
912
+ const bulkContacts = (0, _prismatic_io_spectral.input)({
913
+ label: "Contacts",
914
+ type: "code",
915
+ language: "json",
916
+ required: true,
917
+ comments: "JSON array of contact objects. Each must have \"email\", optionally \"first_name\", \"last_name\", and \"custom_fields\".",
918
+ example: JSON.stringify([{
919
+ email: "john@example.com",
920
+ first_name: "John",
921
+ last_name: "Doe"
922
+ }, {
923
+ email: "jane@example.com",
924
+ first_name: "Jane"
925
+ }], null, 2),
926
+ clean: _prismatic_io_spectral.util.types.toObject
927
+ });
928
+ const listContactsInputs = {
929
+ connection: connectionInput,
930
+ fetchAll,
931
+ pagination
932
+ };
933
+ const getContactInputs = {
934
+ connection: connectionInput,
935
+ contactId
936
+ };
937
+ const createContactInputs = {
938
+ connection: connectionInput,
939
+ email: contactEmail,
940
+ firstName: contactFirstName,
941
+ lastName: contactLastName,
942
+ customFields: contactCustomFields,
943
+ extraBody
944
+ };
945
+ const updateContactInputs = {
946
+ connection: connectionInput,
947
+ contactId,
948
+ email: {
949
+ ...contactEmail,
950
+ required: false,
951
+ clean: toOptionalString
952
+ },
953
+ firstName: contactFirstName,
954
+ lastName: contactLastName,
955
+ customFields: contactCustomFields,
956
+ extraBody
957
+ };
958
+ const deleteContactInputs = {
959
+ connection: connectionInput,
960
+ contactId
961
+ };
962
+ const createContactsBulkInputs = {
963
+ connection: connectionInput,
964
+ contacts: bulkContacts,
965
+ updateExistingContacts
966
+ };
967
+ //#endregion
968
+ //#region src/inputs/contactLists.ts
969
+ const contactListId = (0, _prismatic_io_spectral.input)({
970
+ label: "Contact List ID",
971
+ type: "string",
972
+ required: true,
973
+ comments: "The unique identifier of the contact list.",
974
+ example: "1234567890",
975
+ placeholder: "Enter contact list ID",
976
+ dataSource: "selectContactList",
977
+ clean: _prismatic_io_spectral.util.types.toString
978
+ });
979
+ const contactListName = (0, _prismatic_io_spectral.input)({
980
+ label: "Contact List Name",
981
+ type: "string",
982
+ required: true,
983
+ comments: "The name of the contact list.",
984
+ example: "Newsletter Subscribers",
985
+ placeholder: "Enter contact list name",
986
+ clean: _prismatic_io_spectral.util.types.toString
987
+ });
988
+ const listContactListsInputs = {
989
+ connection: connectionInput,
990
+ fetchAll,
991
+ pagination
992
+ };
993
+ const getContactListInputs = {
994
+ connection: connectionInput,
995
+ contactListId
996
+ };
997
+ const createContactListInputs = {
998
+ connection: connectionInput,
999
+ name: contactListName
1000
+ };
1001
+ const updateContactListInputs = {
1002
+ connection: connectionInput,
1003
+ contactListId,
1004
+ name: contactListName
1005
+ };
1006
+ const deleteContactListInputs = {
1007
+ connection: connectionInput,
1008
+ contactListId
1009
+ };
1010
+ const selectContactListInputs = { connection: connectionInput };
1011
+ //#endregion
1012
+ //#region src/inputs/webhooks.ts
1013
+ const webhookId = (0, _prismatic_io_spectral.input)({
1014
+ label: "Webhook ID",
1015
+ type: "string",
1016
+ required: true,
1017
+ comments: "The unique identifier of the webhook.",
1018
+ example: "1234567890",
1019
+ placeholder: "Enter webhook ID",
1020
+ clean: _prismatic_io_spectral.util.types.toString
1021
+ });
1022
+ const webhookName = (0, _prismatic_io_spectral.input)({
1023
+ label: "Webhook Name",
1024
+ type: "string",
1025
+ required: true,
1026
+ comments: "The name of the webhook.",
1027
+ example: "Response Completed Hook",
1028
+ placeholder: "Enter webhook name",
1029
+ clean: _prismatic_io_spectral.util.types.toString
1030
+ });
1031
+ const webhookEventType = (0, _prismatic_io_spectral.input)({
1032
+ label: "Event Type",
1033
+ type: "string",
1034
+ required: true,
1035
+ model: WEBHOOK_EVENT_TYPES.map((event) => ({
1036
+ label: event.label,
1037
+ value: event.key
1038
+ })),
1039
+ comments: "The event type to subscribe to.",
1040
+ placeholder: "Select event type",
1041
+ clean: _prismatic_io_spectral.util.types.toString
1042
+ });
1043
+ const webhookObjectType = (0, _prismatic_io_spectral.input)({
1044
+ label: "Object Type",
1045
+ type: "string",
1046
+ required: false,
1047
+ model: [{
1048
+ label: "Survey",
1049
+ value: "survey"
1050
+ }, {
1051
+ label: "Collector",
1052
+ value: "collector"
1053
+ }],
1054
+ comments: "Filter events by object type.",
1055
+ placeholder: "Select object type",
1056
+ clean: toOptionalString
1057
+ });
1058
+ const webhookObjectIds = (0, _prismatic_io_spectral.input)({
1059
+ label: "Object IDs",
1060
+ type: "string",
1061
+ collection: "valuelist",
1062
+ required: false,
1063
+ comments: "List of survey or collector IDs to filter events. Leave empty for all.",
1064
+ placeholder: "Enter object IDs",
1065
+ example: "1234567890",
1066
+ clean: toArrayOfStrings
1067
+ });
1068
+ const webhookSubscriptionUrl = (0, _prismatic_io_spectral.input)({
1069
+ label: "Subscription URL",
1070
+ type: "string",
1071
+ required: true,
1072
+ comments: "URL to receive webhook callbacks. Must be unique and handle HEAD requests.",
1073
+ example: "https://example.com/webhook",
1074
+ placeholder: "Enter webhook URL",
1075
+ clean: _prismatic_io_spectral.util.types.toString
1076
+ });
1077
+ const listWebhooksInputs = {
1078
+ connection: connectionInput,
1079
+ fetchAll,
1080
+ pagination
1081
+ };
1082
+ const getWebhookInputs = {
1083
+ connection: connectionInput,
1084
+ webhookId
1085
+ };
1086
+ const createWebhookInputs = {
1087
+ connection: connectionInput,
1088
+ name: webhookName,
1089
+ subscriptionUrl: webhookSubscriptionUrl,
1090
+ eventType: webhookEventType,
1091
+ objectType: webhookObjectType,
1092
+ objectIds: webhookObjectIds
1093
+ };
1094
+ const updateWebhookInputs = {
1095
+ connection: connectionInput,
1096
+ webhookId,
1097
+ name: {
1098
+ ...webhookName,
1099
+ required: false,
1100
+ clean: toOptionalString
1101
+ },
1102
+ subscriptionUrl: {
1103
+ ...webhookSubscriptionUrl,
1104
+ required: false,
1105
+ clean: toOptionalString
1106
+ },
1107
+ eventType: {
1108
+ ...webhookEventType,
1109
+ required: false,
1110
+ clean: toOptionalString
1111
+ },
1112
+ objectType: webhookObjectType,
1113
+ objectIds: webhookObjectIds
1114
+ };
1115
+ const deleteWebhookInputs = {
1116
+ connection: connectionInput,
1117
+ webhookId
1118
+ };
1119
+ const eventsWebhookInputs = {
1120
+ connection: connectionInput,
1121
+ eventType: webhookEventType,
1122
+ objectType: webhookObjectType,
1123
+ objectIds: webhookObjectIds
1124
+ };
1125
+ const pollChangesInputs = {
1126
+ connection: connectionInput,
1127
+ surveyId,
1128
+ lookBackDate: (0, _prismatic_io_spectral.input)({
1129
+ label: "Look-back Date",
1130
+ placeholder: "Enter look-back date (YYYY-MM-DD)",
1131
+ type: "string",
1132
+ required: false,
1133
+ comments: "The date the initial sync starts from, in YYYY-MM-DD format. Cannot be a future date. Leave empty to start from the first recurrence with no backfill. When set, the initial sync seeds each response modified on or after this date once, ignoring the visibility filters.",
1134
+ example: "2026-01-01",
1135
+ clean: lookBackDateClean
1136
+ }),
1137
+ showNewRecords: (0, _prismatic_io_spectral.input)({
1138
+ label: "Show New Records",
1139
+ type: "boolean",
1140
+ required: false,
1141
+ default: "true",
1142
+ comments: "Include newly created survey responses in the results, emitted on the created branch.",
1143
+ clean: _prismatic_io_spectral.util.types.toBool
1144
+ }),
1145
+ showUpdatedRecords: (0, _prismatic_io_spectral.input)({
1146
+ label: "Show Updated Records",
1147
+ type: "boolean",
1148
+ required: false,
1149
+ default: "true",
1150
+ comments: "Include previously created survey responses that were modified since the last poll, emitted on the updated branch.",
1151
+ clean: _prismatic_io_spectral.util.types.toBool
1152
+ })
1153
+ };
1154
+ //#endregion
1155
+ //#region src/examplePayloads.ts
1156
+ const listSurveysExamplePayload = { data: {
1157
+ data: [{
1158
+ id: "123456789",
1159
+ title: "Customer Satisfaction Survey",
1160
+ nickname: "Q1 CSAT",
1161
+ href: "https://api.surveymonkey.com/v3/surveys/123456789",
1162
+ date_created: "2026-01-15T10:30:00+00:00",
1163
+ date_modified: "2026-01-20T14:45:00+00:00"
1164
+ }, {
1165
+ id: "987654321",
1166
+ title: "Employee Engagement Survey",
1167
+ href: "https://api.surveymonkey.com/v3/surveys/987654321",
1168
+ date_created: "2026-01-10T08:00:00+00:00",
1169
+ date_modified: "2026-01-18T16:30:00+00:00"
1170
+ }],
1171
+ page: 1,
1172
+ per_page: 2,
1173
+ total: 2,
1174
+ links: { self: "https://api.surveymonkey.com/v3/surveys?page=1" }
1175
+ } };
1176
+ const getSurveyExamplePayload = { data: {
1177
+ id: "123456789",
1178
+ title: "Customer Satisfaction Survey",
1179
+ nickname: "Q1 CSAT",
1180
+ language: "en",
1181
+ question_count: 10,
1182
+ page_count: 3,
1183
+ date_created: "2026-01-15T10:30:00+00:00",
1184
+ date_modified: "2026-01-20T14:45:00+00:00",
1185
+ href: "https://api.surveymonkey.com/v3/surveys/123456789"
1186
+ } };
1187
+ const getSurveyDetailsExamplePayload = { data: {
1188
+ id: "123456789",
1189
+ title: "Customer Satisfaction Survey",
1190
+ nickname: "Q1 CSAT",
1191
+ language: "en",
1192
+ question_count: 2,
1193
+ page_count: 1,
1194
+ date_created: "2026-01-15T10:30:00+00:00",
1195
+ date_modified: "2026-01-20T14:45:00+00:00",
1196
+ preview: "https://www.surveymonkey.com/r/Preview/",
1197
+ href: "https://api.surveymonkey.com/v3/surveys/123456789",
1198
+ pages: [{
1199
+ id: "111111",
1200
+ title: "Page 1",
1201
+ description: "Welcome to our survey",
1202
+ position: 1,
1203
+ question_count: 2,
1204
+ href: "https://api.surveymonkey.com/v3/surveys/123456789/pages/111111",
1205
+ questions: [{
1206
+ id: "222222",
1207
+ heading: "How satisfied are you with our service?",
1208
+ position: 1,
1209
+ family: "single_choice",
1210
+ subtype: "vertical",
1211
+ href: "https://api.surveymonkey.com/v3/surveys/123456789/pages/111111/questions/222222",
1212
+ answers: { choices: [
1213
+ {
1214
+ id: "333333",
1215
+ position: 1,
1216
+ text: "Very Satisfied"
1217
+ },
1218
+ {
1219
+ id: "444444",
1220
+ position: 2,
1221
+ text: "Satisfied"
1222
+ },
1223
+ {
1224
+ id: "555555",
1225
+ position: 3,
1226
+ text: "Neutral"
1227
+ },
1228
+ {
1229
+ id: "666666",
1230
+ position: 4,
1231
+ text: "Dissatisfied"
1232
+ },
1233
+ {
1234
+ id: "777777",
1235
+ position: 5,
1236
+ text: "Very Dissatisfied"
1237
+ }
1238
+ ] }
1239
+ }, {
1240
+ id: "888888",
1241
+ heading: "Any additional comments?",
1242
+ position: 2,
1243
+ family: "open_ended",
1244
+ subtype: "essay",
1245
+ href: "https://api.surveymonkey.com/v3/surveys/123456789/pages/111111/questions/888888"
1246
+ }]
1247
+ }]
1248
+ } };
1249
+ const createSurveyExamplePayload = { data: {
1250
+ id: "123456789",
1251
+ title: "Customer Satisfaction Survey",
1252
+ nickname: "Q1 CSAT",
1253
+ language: "en",
1254
+ question_count: 0,
1255
+ page_count: 1,
1256
+ date_created: "2026-01-21T10:30:00+00:00",
1257
+ date_modified: "2026-01-21T10:30:00+00:00",
1258
+ href: "https://api.surveymonkey.com/v3/surveys/123456789"
1259
+ } };
1260
+ const deleteSurveyExamplePayload = { data: { success: true } };
1261
+ const listCollectorsExamplePayload = { data: {
1262
+ data: [{
1263
+ id: "111111111",
1264
+ name: "Web Link",
1265
+ type: "weblink",
1266
+ status: "open",
1267
+ date_created: "2026-01-15T10:30:00+00:00",
1268
+ date_modified: "2026-01-20T14:45:00+00:00",
1269
+ href: "https://api.surveymonkey.com/v3/surveys/123456789/collectors/111111111"
1270
+ }, {
1271
+ id: "222222222",
1272
+ name: "Email Invitation",
1273
+ type: "email",
1274
+ status: "open",
1275
+ date_created: "2026-01-16T09:00:00+00:00",
1276
+ date_modified: "2026-01-18T11:30:00+00:00",
1277
+ href: "https://api.surveymonkey.com/v3/surveys/123456789/collectors/222222222"
1278
+ }],
1279
+ page: 1,
1280
+ per_page: 2,
1281
+ total: 2,
1282
+ links: { self: "https://api.surveymonkey.com/v3/surveys/123456789/collectors?page=1" }
1283
+ } };
1284
+ const getCollectorExamplePayload = { data: {
1285
+ id: "111111111",
1286
+ name: "Web Link",
1287
+ type: "weblink",
1288
+ status: "open",
1289
+ date_created: "2026-01-15T10:30:00+00:00",
1290
+ date_modified: "2026-01-20T14:45:00+00:00",
1291
+ href: "https://api.surveymonkey.com/v3/surveys/123456789/collectors/111111111",
1292
+ url: "https://www.surveymonkey.com/r/EXAMPLE"
1293
+ } };
1294
+ const getCollectorStatsExamplePayload = { data: {
1295
+ id: "111111111",
1296
+ total: 150,
1297
+ started: 200,
1298
+ completed: 120,
1299
+ partial: 20,
1300
+ disqualified: 0,
1301
+ unique_clicks: 250
1302
+ } };
1303
+ const createCollectorExamplePayload = { data: {
1304
+ id: "333333333",
1305
+ name: "New Web Link",
1306
+ type: "weblink",
1307
+ status: "open",
1308
+ date_created: "2026-01-21T10:30:00+00:00",
1309
+ date_modified: "2026-01-21T10:30:00+00:00",
1310
+ href: "https://api.surveymonkey.com/v3/surveys/123456789/collectors/333333333",
1311
+ url: "https://www.surveymonkey.com/r/NEWLINK"
1312
+ } };
1313
+ const updateCollectorExamplePayload = { data: {
1314
+ id: "111111111",
1315
+ name: "Updated Web Link",
1316
+ type: "weblink",
1317
+ status: "closed",
1318
+ date_created: "2026-01-15T10:30:00+00:00",
1319
+ date_modified: "2026-01-21T15:00:00+00:00",
1320
+ href: "https://api.surveymonkey.com/v3/surveys/123456789/collectors/111111111"
1321
+ } };
1322
+ const deleteCollectorExamplePayload = { data: { success: true } };
1323
+ const listResponsesExamplePayload = { data: {
1324
+ data: [{
1325
+ id: "5555555555",
1326
+ survey_id: "123456789",
1327
+ collector_id: "111111111",
1328
+ response_status: "completed",
1329
+ date_created: "2026-01-20T10:15:00+00:00",
1330
+ date_modified: "2026-01-20T10:30:00+00:00",
1331
+ href: "https://api.surveymonkey.com/v3/surveys/123456789/responses/5555555555",
1332
+ analyze_url: "https://www.surveymonkey.com/analyze/response",
1333
+ ip_address: "192.168.1.1",
1334
+ recipient_id: "",
1335
+ total_time: 300
1336
+ }, {
1337
+ id: "6666666666",
1338
+ survey_id: "123456789",
1339
+ collector_id: "111111111",
1340
+ response_status: "partial",
1341
+ date_created: "2026-01-20T11:00:00+00:00",
1342
+ date_modified: "2026-01-20T11:05:00+00:00",
1343
+ href: "https://api.surveymonkey.com/v3/surveys/123456789/responses/6666666666",
1344
+ total_time: 150
1345
+ }],
1346
+ page: 1,
1347
+ per_page: 2,
1348
+ total: 2,
1349
+ links: { self: "https://api.surveymonkey.com/v3/surveys/123456789/responses?page=1" }
1350
+ } };
1351
+ const getResponseExamplePayload = { data: {
1352
+ id: "5555555555",
1353
+ survey_id: "123456789",
1354
+ collector_id: "111111111",
1355
+ response_status: "completed",
1356
+ date_created: "2026-01-20T10:15:00+00:00",
1357
+ date_modified: "2026-01-20T10:30:00+00:00",
1358
+ href: "https://api.surveymonkey.com/v3/surveys/123456789/responses/5555555555",
1359
+ analyze_url: "https://www.surveymonkey.com/analyze/response",
1360
+ ip_address: "192.168.1.1",
1361
+ recipient_id: "",
1362
+ total_time: 300
1363
+ } };
1364
+ const getResponseDetailsExamplePayload = { data: {
1365
+ id: "5555555555",
1366
+ survey_id: "123456789",
1367
+ collector_id: "111111111",
1368
+ response_status: "completed",
1369
+ date_created: "2026-01-20T10:15:00+00:00",
1370
+ date_modified: "2026-01-20T10:30:00+00:00",
1371
+ href: "https://api.surveymonkey.com/v3/surveys/123456789/responses/5555555555",
1372
+ analyze_url: "https://www.surveymonkey.com/analyze/response",
1373
+ ip_address: "192.168.1.1",
1374
+ recipient_id: "",
1375
+ total_time: 300,
1376
+ pages: [{
1377
+ id: "111111",
1378
+ questions: [{
1379
+ id: "222222",
1380
+ answers: [{
1381
+ choice_id: "333333",
1382
+ text: "Very Satisfied"
1383
+ }]
1384
+ }, {
1385
+ id: "888888",
1386
+ answers: [{ text: "Great service! Very happy with the experience." }]
1387
+ }]
1388
+ }]
1389
+ } };
1390
+ const listResponsesBulkExamplePayload = { data: {
1391
+ data: [{
1392
+ id: "5555555555",
1393
+ survey_id: "123456789",
1394
+ collector_id: "111111111",
1395
+ response_status: "completed",
1396
+ date_created: "2026-01-20T10:15:00+00:00",
1397
+ date_modified: "2026-01-20T10:30:00+00:00",
1398
+ href: "https://api.surveymonkey.com/v3/surveys/123456789/responses/5555555555",
1399
+ pages: [{
1400
+ id: "111111",
1401
+ questions: [{
1402
+ id: "222222",
1403
+ answers: [{
1404
+ choice_id: "333333",
1405
+ text: "Very Satisfied"
1406
+ }]
1407
+ }]
1408
+ }]
1409
+ }],
1410
+ page: 1,
1411
+ per_page: 1,
1412
+ total: 1,
1413
+ links: { self: "https://api.surveymonkey.com/v3/surveys/123456789/responses/bulk?page=1" }
1414
+ } };
1415
+ const updateResponseExamplePayload = { data: {
1416
+ id: "5555555555",
1417
+ survey_id: "123456789",
1418
+ collector_id: "111111111",
1419
+ response_status: "completed",
1420
+ date_created: "2026-01-20T10:15:00+00:00",
1421
+ date_modified: "2026-01-21T16:00:00+00:00",
1422
+ href: "https://api.surveymonkey.com/v3/surveys/123456789/responses/5555555555"
1423
+ } };
1424
+ const deleteResponseExamplePayload = { data: { success: true } };
1425
+ const listContactsExamplePayload = { data: {
1426
+ data: [{
1427
+ id: "1111111111",
1428
+ email: "john.doe@example.com",
1429
+ first_name: "John",
1430
+ last_name: "Doe",
1431
+ href: "https://api.surveymonkey.com/v3/contacts/1111111111"
1432
+ }, {
1433
+ id: "2222222222",
1434
+ email: "jane.smith@example.com",
1435
+ first_name: "Jane",
1436
+ last_name: "Smith",
1437
+ href: "https://api.surveymonkey.com/v3/contacts/2222222222"
1438
+ }],
1439
+ page: 1,
1440
+ per_page: 2,
1441
+ total: 2,
1442
+ links: { self: "https://api.surveymonkey.com/v3/contacts?page=1" }
1443
+ } };
1444
+ const getContactExamplePayload = { data: {
1445
+ id: "1111111111",
1446
+ email: "john.doe@example.com",
1447
+ first_name: "John",
1448
+ last_name: "Doe",
1449
+ custom_fields: {
1450
+ 1: "Customer",
1451
+ 2: "Premium"
1452
+ },
1453
+ href: "https://api.surveymonkey.com/v3/contacts/1111111111"
1454
+ } };
1455
+ const createContactExamplePayload = { data: {
1456
+ id: "3333333333",
1457
+ email: "new.contact@example.com",
1458
+ first_name: "New",
1459
+ last_name: "Contact",
1460
+ href: "https://api.surveymonkey.com/v3/contacts/3333333333"
1461
+ } };
1462
+ const createBulkContactsExamplePayload = { data: {
1463
+ succeeded: [{
1464
+ id: "4444444444",
1465
+ email: "bulk1@example.com",
1466
+ first_name: "Bulk",
1467
+ last_name: "User1",
1468
+ href: "https://api.surveymonkey.com/v3/contacts/4444444444"
1469
+ }, {
1470
+ id: "5555555555",
1471
+ email: "bulk2@example.com",
1472
+ first_name: "Bulk",
1473
+ last_name: "User2",
1474
+ href: "https://api.surveymonkey.com/v3/contacts/5555555555"
1475
+ }],
1476
+ failed: [],
1477
+ invalids: []
1478
+ } };
1479
+ const updateContactExamplePayload = { data: {
1480
+ id: "1111111111",
1481
+ email: "john.doe@example.com",
1482
+ first_name: "John",
1483
+ last_name: "Updated",
1484
+ href: "https://api.surveymonkey.com/v3/contacts/1111111111"
1485
+ } };
1486
+ const deleteContactExamplePayload = { data: { success: true } };
1487
+ const listContactListsExamplePayload = { data: {
1488
+ data: [{
1489
+ id: "111111",
1490
+ name: "Customer List",
1491
+ href: "https://api.surveymonkey.com/v3/contact_lists/111111"
1492
+ }, {
1493
+ id: "222222",
1494
+ name: "Employee List",
1495
+ href: "https://api.surveymonkey.com/v3/contact_lists/222222"
1496
+ }],
1497
+ page: 1,
1498
+ per_page: 2,
1499
+ total: 2,
1500
+ links: { self: "https://api.surveymonkey.com/v3/contact_lists?page=1" }
1501
+ } };
1502
+ const getContactListExamplePayload = { data: {
1503
+ id: "111111",
1504
+ name: "Customer List",
1505
+ href: "https://api.surveymonkey.com/v3/contact_lists/111111"
1506
+ } };
1507
+ const createContactListExamplePayload = { data: {
1508
+ id: "333333",
1509
+ name: "New Contact List",
1510
+ href: "https://api.surveymonkey.com/v3/contact_lists/333333"
1511
+ } };
1512
+ const updateContactListExamplePayload = { data: {
1513
+ id: "111111",
1514
+ name: "Updated Customer List",
1515
+ href: "https://api.surveymonkey.com/v3/contact_lists/111111"
1516
+ } };
1517
+ const deleteContactListExamplePayload = { data: { success: true } };
1518
+ const listWebhooksExamplePayload = { data: {
1519
+ data: [{
1520
+ id: "111111",
1521
+ name: "Response Webhook",
1522
+ href: "https://api.surveymonkey.com/v3/webhooks/111111",
1523
+ event_type: "response_completed",
1524
+ object_type: "survey",
1525
+ object_ids: ["123456789"],
1526
+ subscription_url: "https://example.com/webhook"
1527
+ }, {
1528
+ id: "222222",
1529
+ name: "Collector Webhook",
1530
+ href: "https://api.surveymonkey.com/v3/webhooks/222222",
1531
+ event_type: "collector_created",
1532
+ object_type: "survey",
1533
+ object_ids: ["987654321"],
1534
+ subscription_url: "https://example.com/webhook"
1535
+ }],
1536
+ page: 1,
1537
+ per_page: 2,
1538
+ total: 2,
1539
+ links: { self: "https://api.surveymonkey.com/v3/webhooks?page=1" }
1540
+ } };
1541
+ const getWebhookExamplePayload = { data: {
1542
+ id: "111111",
1543
+ name: "Response Webhook",
1544
+ href: "https://api.surveymonkey.com/v3/webhooks/111111",
1545
+ event_type: "response_completed",
1546
+ object_type: "survey",
1547
+ object_ids: ["123456789"],
1548
+ subscription_url: "https://example.com/webhook"
1549
+ } };
1550
+ const createWebhookExamplePayload = { data: {
1551
+ id: "333333",
1552
+ name: "New Webhook",
1553
+ href: "https://api.surveymonkey.com/v3/webhooks/333333",
1554
+ event_type: "response_completed",
1555
+ object_type: "survey",
1556
+ object_ids: ["123456789"],
1557
+ subscription_url: "https://example.com/new-webhook"
1558
+ } };
1559
+ const updateWebhookExamplePayload = { data: {
1560
+ id: "111111",
1561
+ name: "Updated Response Webhook",
1562
+ href: "https://api.surveymonkey.com/v3/webhooks/111111",
1563
+ event_type: "response_completed",
1564
+ object_type: "survey",
1565
+ object_ids: ["123456789", "987654321"],
1566
+ subscription_url: "https://example.com/updated-webhook"
1567
+ } };
1568
+ const deleteWebhookExamplePayload = { data: { success: true } };
1569
+ const getMeExamplePayload = { data: {
1570
+ id: "12345678",
1571
+ username: "SurveyUser123",
1572
+ email: "user@example.com",
1573
+ account_type: "premier",
1574
+ language: "en",
1575
+ date_created: "2020-01-15T08:00:00+00:00",
1576
+ date_last_login: "2026-01-21T09:30:00+00:00",
1577
+ href: "https://api.surveymonkey.com/v3/users/12345678"
1578
+ } };
1579
+ const rawRequestExamplePayload = { data: { message: "Raw request executed successfully" } };
1580
+ const selectSurveyExamplePayload = { result: [
1581
+ {
1582
+ label: "Customer Satisfaction Survey",
1583
+ key: "123456789"
1584
+ },
1585
+ {
1586
+ label: "Employee Feedback Q1 2026",
1587
+ key: "987654321"
1588
+ },
1589
+ {
1590
+ label: "Product Research Survey",
1591
+ key: "456789123"
1592
+ }
1593
+ ] };
1594
+ const selectCollectorExamplePayload = { result: [
1595
+ {
1596
+ label: "Web Link - January (weblink)",
1597
+ key: "111111111"
1598
+ },
1599
+ {
1600
+ label: "Email Campaign (email)",
1601
+ key: "222222222"
1602
+ },
1603
+ {
1604
+ label: "Social Media (social)",
1605
+ key: "333333333"
1606
+ }
1607
+ ] };
1608
+ const selectContactListExamplePayload = { result: [
1609
+ {
1610
+ label: "Customer List",
1611
+ key: "111111"
1612
+ },
1613
+ {
1614
+ label: "Employee List",
1615
+ key: "222222"
1616
+ },
1617
+ {
1618
+ label: "VIP Customers",
1619
+ key: "333333"
1620
+ }
1621
+ ] };
1622
+ const selectWebhookEventTypeExamplePayload = { result: [
1623
+ {
1624
+ label: "Response Completed",
1625
+ key: "response_completed"
1626
+ },
1627
+ {
1628
+ label: "Response Created",
1629
+ key: "response_created"
1630
+ },
1631
+ {
1632
+ label: "Response Updated",
1633
+ key: "response_updated"
1634
+ },
1635
+ {
1636
+ label: "Response Deleted",
1637
+ key: "response_deleted"
1638
+ },
1639
+ {
1640
+ label: "Response Disqualified",
1641
+ key: "response_disqualified"
1642
+ },
1643
+ {
1644
+ label: "Response Over Quota",
1645
+ key: "response_overquota"
1646
+ },
1647
+ {
1648
+ label: "Survey Created",
1649
+ key: "survey_created"
1650
+ },
1651
+ {
1652
+ label: "Survey Updated",
1653
+ key: "survey_updated"
1654
+ },
1655
+ {
1656
+ label: "Survey Deleted",
1657
+ key: "survey_deleted"
1658
+ },
1659
+ {
1660
+ label: "Collector Created",
1661
+ key: "collector_created"
1662
+ },
1663
+ {
1664
+ label: "Collector Updated",
1665
+ key: "collector_updated"
1666
+ },
1667
+ {
1668
+ label: "Collector Deleted",
1669
+ key: "collector_deleted"
1670
+ }
1671
+ ] };
1672
+ const eventsWebhookExamplePayload = { payload: {
1673
+ headers: {
1674
+ "Content-Type": "application/json",
1675
+ "Sm-Apikey": "your-api-key",
1676
+ "Sm-Signature": "base64-encoded-hmac-signature"
1677
+ },
1678
+ body: { data: {
1679
+ name: "My Survey Webhook",
1680
+ filter_type: "survey",
1681
+ filter_id: "123456789",
1682
+ event_type: "response_completed",
1683
+ event_id: "unique-event-id-12345",
1684
+ object_type: "response",
1685
+ object_id: "987654321",
1686
+ event_datetime: "2026-01-21T10:30:00.000000+00:00",
1687
+ resources: {
1688
+ survey_id: "123456789",
1689
+ collector_id: "111222333",
1690
+ respondent_id: "444555666",
1691
+ recipient_id: "777888999"
1692
+ }
1693
+ } },
1694
+ rawBody: { data: Buffer.from(JSON.stringify({
1695
+ name: "My Survey Webhook",
1696
+ filter_type: "survey",
1697
+ filter_id: "123456789",
1698
+ event_type: "response_completed",
1699
+ event_id: "unique-event-id-12345",
1700
+ object_type: "response",
1701
+ object_id: "987654321",
1702
+ event_datetime: "2026-01-21T10:30:00.000000+00:00",
1703
+ resources: {
1704
+ survey_id: "123456789",
1705
+ collector_id: "111222333",
1706
+ respondent_id: "444555666",
1707
+ recipient_id: "777888999"
1708
+ }
1709
+ })) },
1710
+ queryParameters: {},
1711
+ webhookUrls: { Flow: "https://hooks.example.io/trigger/abc123" },
1712
+ webhookApiKeys: { Flow: ["api-key-1"] },
1713
+ customer: {
1714
+ id: "customer-123",
1715
+ externalId: "ext-customer-123",
1716
+ name: "Example Customer"
1717
+ },
1718
+ instance: {
1719
+ id: "instance-456",
1720
+ name: "SurveyMonkey Integration"
1721
+ },
1722
+ integration: {
1723
+ id: "integration-789",
1724
+ name: "SurveyMonkey",
1725
+ versionSequenceId: "1",
1726
+ externalVersion: "1.0.0"
1727
+ },
1728
+ flow: {
1729
+ id: "flow-abc",
1730
+ stableId: "flow-stable-abc",
1731
+ name: "Survey Events Flow"
1732
+ },
1733
+ user: {
1734
+ id: "user-xyz",
1735
+ name: "John Doe",
1736
+ email: "john.doe@example.com",
1737
+ externalId: "ext-user-xyz"
1738
+ },
1739
+ executionId: "execution-12345",
1740
+ startedAt: "2026-01-21T10:30:00.000Z",
1741
+ invokeUrl: "https://hooks.example.io/trigger/abc123",
1742
+ pathFragment: "",
1743
+ globalDebug: false
1744
+ } };
1745
+ const pollChangesTriggerExamplePayload = { payload: {
1746
+ headers: {},
1747
+ queryParameters: {},
1748
+ rawBody: { data: null },
1749
+ body: { data: {
1750
+ created: [{
1751
+ id: "5007154401",
1752
+ survey_id: "1234567890",
1753
+ collector_id: "987654321",
1754
+ response_status: "completed",
1755
+ date_created: "2026-05-26T14:30:00+00:00",
1756
+ date_modified: "2026-05-26T14:30:00+00:00",
1757
+ href: "https://api.surveymonkey.com/v3/surveys/1234567890/responses/5007154401",
1758
+ pages: []
1759
+ }],
1760
+ updated: [{
1761
+ id: "5007150099",
1762
+ survey_id: "1234567890",
1763
+ collector_id: "987654321",
1764
+ response_status: "completed",
1765
+ date_created: "2026-04-12T09:00:00+00:00",
1766
+ date_modified: "2026-05-26T15:45:00+00:00",
1767
+ href: "https://api.surveymonkey.com/v3/surveys/1234567890/responses/5007150099",
1768
+ pages: []
1769
+ }]
1770
+ } },
1771
+ pathFragment: "",
1772
+ webhookUrls: {},
1773
+ webhookApiKeys: {},
1774
+ invokeUrl: "",
1775
+ executionId: "RXhhbXBsZUV4ZWN1dGlvblJlc3VsdElk",
1776
+ customer: {
1777
+ id: "testCustomerId",
1778
+ name: "Test Customer",
1779
+ externalId: "testExternalId"
1780
+ },
1781
+ instance: {
1782
+ id: "testInstanceId",
1783
+ name: "Test Instance"
1784
+ },
1785
+ user: {
1786
+ id: "testUserId",
1787
+ email: "user@example.com",
1788
+ name: "Test User",
1789
+ externalId: "testUserExternalId"
1790
+ },
1791
+ integration: {
1792
+ id: "testIntegrationId",
1793
+ name: "Test Integration",
1794
+ versionSequenceId: "1",
1795
+ externalVersion: ""
1796
+ },
1797
+ flow: {
1798
+ id: "testFlowId",
1799
+ stableId: "testFlowStableId",
1800
+ name: "Test Flow"
1801
+ },
1802
+ startedAt: "2024-01-15T00:00:00.000Z",
1803
+ globalDebug: false
1804
+ } };
1805
+ //#endregion
1806
+ //#region src/actions/surveys/index.ts
1807
+ var surveys_default = {
1808
+ listSurveys: (0, _prismatic_io_spectral.action)({
1809
+ display: {
1810
+ label: "List Surveys",
1811
+ description: "List all surveys accessible to the authenticated user."
1812
+ },
1813
+ inputs: listSurveysInputs,
1814
+ perform: async (context, { connection, fetchAll, pagination = {} }) => {
1815
+ return { data: await paginateResults(createClient(connection, context.debug.enabled), "/surveys", fetchAll, {
1816
+ page: pagination.page,
1817
+ per_page: pagination.perPage
1818
+ }) };
1819
+ },
1820
+ examplePayload: listSurveysExamplePayload
1821
+ }),
1822
+ getSurvey: (0, _prismatic_io_spectral.action)({
1823
+ display: {
1824
+ label: "Get Survey",
1825
+ description: "Retrieve summary information about a survey. Use 'Get Survey Details' for full structure."
1826
+ },
1827
+ inputs: getSurveyInputs,
1828
+ perform: async (context, { connection, surveyId }) => {
1829
+ const { data } = await createClient(connection, context.debug.enabled).get(`/surveys/${surveyId}`);
1830
+ return { data };
1831
+ },
1832
+ examplePayload: getSurveyExamplePayload
1833
+ }),
1834
+ getSurveyDetails: (0, _prismatic_io_spectral.action)({
1835
+ display: {
1836
+ label: "Get Survey Details",
1837
+ description: "Retrieve the complete survey structure including pages and questions."
1838
+ },
1839
+ inputs: getSurveyInputs,
1840
+ perform: async (context, { connection, surveyId }) => {
1841
+ const { data } = await createClient(connection, context.debug.enabled).get(`/surveys/${surveyId}/details`);
1842
+ return { data };
1843
+ },
1844
+ examplePayload: getSurveyDetailsExamplePayload
1845
+ }),
1846
+ createSurvey: (0, _prismatic_io_spectral.action)({
1847
+ display: {
1848
+ label: "Create Survey",
1849
+ description: "Create a new survey. Can be blank, from a template, or copied from an existing survey."
1850
+ },
1851
+ inputs: createSurveyInputs,
1852
+ perform: async (context, { connection, title, nickname, fromTemplateId, fromSurveyId, language, extraBody }) => {
1853
+ const client = createClient(connection, context.debug.enabled);
1854
+ const body = {
1855
+ title,
1856
+ nickname,
1857
+ from_template_id: fromTemplateId,
1858
+ from_survey_id: fromSurveyId,
1859
+ language,
1860
+ ...extraBody
1861
+ };
1862
+ const { data } = await client.post("/surveys", body);
1863
+ return { data };
1864
+ },
1865
+ examplePayload: createSurveyExamplePayload
1866
+ }),
1867
+ deleteSurvey: (0, _prismatic_io_spectral.action)({
1868
+ display: {
1869
+ label: "Delete Survey",
1870
+ description: "Permanently delete a survey and all its data. This cannot be undone."
1871
+ },
1872
+ inputs: deleteSurveyInputs,
1873
+ perform: async (context, { connection, surveyId }) => {
1874
+ await createClient(connection, context.debug.enabled).delete(`/surveys/${surveyId}`);
1875
+ return { data: {
1876
+ success: true,
1877
+ surveyId,
1878
+ message: `Survey ${surveyId} has been deleted.`
1879
+ } };
1880
+ },
1881
+ examplePayload: deleteSurveyExamplePayload
1882
+ })
1883
+ };
1884
+ //#endregion
1885
+ //#region src/actions/collectors/index.ts
1886
+ var collectors_default = {
1887
+ listCollectors: (0, _prismatic_io_spectral.action)({
1888
+ display: {
1889
+ label: "List Collectors",
1890
+ description: "List all collectors for a survey."
1891
+ },
1892
+ inputs: listCollectorsInputs,
1893
+ perform: async (context, { connection, surveyId, fetchAll, pagination = {} }) => {
1894
+ return { data: await paginateResults(createClient(connection, context.debug.enabled), `/surveys/${surveyId}/collectors`, fetchAll, {
1895
+ page: pagination.page,
1896
+ per_page: pagination.perPage
1897
+ }) };
1898
+ },
1899
+ examplePayload: listCollectorsExamplePayload
1900
+ }),
1901
+ getCollector: (0, _prismatic_io_spectral.action)({
1902
+ display: {
1903
+ label: "Get Collector",
1904
+ description: "Retrieve details about a specific collector."
1905
+ },
1906
+ inputs: getCollectorInputs,
1907
+ perform: async (context, { connection, collectorId }) => {
1908
+ const { data } = await createClient(connection, context.debug.enabled).get(`/collectors/${collectorId}`);
1909
+ return { data };
1910
+ },
1911
+ examplePayload: getCollectorExamplePayload
1912
+ }),
1913
+ createCollector: (0, _prismatic_io_spectral.action)({
1914
+ display: {
1915
+ label: "Create Collector",
1916
+ description: "Create a new collector for a survey. Non-weblink collectors require a paid plan."
1917
+ },
1918
+ inputs: createCollectorInputs,
1919
+ perform: async (context, { connection, surveyId, type, name, collectorSettings = {}, extraBody }) => {
1920
+ const client = createClient(connection, context.debug.enabled);
1921
+ const body = {
1922
+ type,
1923
+ name,
1924
+ thank_you_message: collectorSettings.thankYouMessage,
1925
+ close_date: collectorSettings.closeDate,
1926
+ redirect_url: collectorSettings.redirectUrl,
1927
+ allow_multiple_responses: collectorSettings.allowMultipleResponses,
1928
+ ...extraBody
1929
+ };
1930
+ const { data } = await client.post(`/surveys/${surveyId}/collectors`, body);
1931
+ return { data };
1932
+ },
1933
+ examplePayload: createCollectorExamplePayload
1934
+ }),
1935
+ updateCollector: (0, _prismatic_io_spectral.action)({
1936
+ display: {
1937
+ label: "Update Collector",
1938
+ description: "Update an existing collector's settings."
1939
+ },
1940
+ inputs: updateCollectorInputs,
1941
+ perform: async (context, { connection, collectorId, name, collectorSettings = {}, extraBody }) => {
1942
+ const client = createClient(connection, context.debug.enabled);
1943
+ const body = {
1944
+ name,
1945
+ thank_you_message: collectorSettings.thankYouMessage,
1946
+ close_date: collectorSettings.closeDate,
1947
+ redirect_url: collectorSettings.redirectUrl,
1948
+ allow_multiple_responses: collectorSettings.allowMultipleResponsesModel ? _prismatic_io_spectral.util.types.toBool(collectorSettings.allowMultipleResponsesModel) : void 0,
1949
+ ...extraBody
1950
+ };
1951
+ const { data } = await client.patch(`/collectors/${collectorId}`, body);
1952
+ return { data };
1953
+ },
1954
+ examplePayload: updateCollectorExamplePayload
1955
+ }),
1956
+ deleteCollector: (0, _prismatic_io_spectral.action)({
1957
+ display: {
1958
+ label: "Delete Collector",
1959
+ description: "Delete a collector."
1960
+ },
1961
+ inputs: deleteCollectorInputs,
1962
+ perform: async (context, { connection, collectorId }) => {
1963
+ await createClient(connection, context.debug.enabled).delete(`/collectors/${collectorId}`);
1964
+ return { data: {
1965
+ success: true,
1966
+ collectorId,
1967
+ message: `Collector ${collectorId} has been deleted.`
1968
+ } };
1969
+ },
1970
+ examplePayload: deleteCollectorExamplePayload
1971
+ }),
1972
+ getCollectorStats: (0, _prismatic_io_spectral.action)({
1973
+ display: {
1974
+ label: "Get Collector Stats",
1975
+ description: "Get response statistics for a collector."
1976
+ },
1977
+ inputs: getCollectorStatsInputs,
1978
+ perform: async (context, { connection, collectorId }) => {
1979
+ const { data } = await createClient(connection, context.debug.enabled).get(`/collectors/${collectorId}/stats`);
1980
+ return { data };
1981
+ },
1982
+ examplePayload: getCollectorStatsExamplePayload
1983
+ })
1984
+ };
1985
+ //#endregion
1986
+ //#region src/actions/responses/index.ts
1987
+ var responses_default = {
1988
+ listResponses: (0, _prismatic_io_spectral.action)({
1989
+ display: {
1990
+ label: "List Responses",
1991
+ description: "List summary information for all responses to a survey."
1992
+ },
1993
+ inputs: listResponsesInputs,
1994
+ perform: async (context, { connection, surveyId, status, fetchAll, pagination = {} }) => {
1995
+ const client = createClient(connection, context.debug.enabled);
1996
+ const endpoint = `/surveys/${surveyId}/responses`;
1997
+ const params = {};
1998
+ if (status) params.status = status;
1999
+ return { data: await paginateResults(client, endpoint, fetchAll, {
2000
+ ...params,
2001
+ page: pagination.page,
2002
+ per_page: pagination.perPage
2003
+ }) };
2004
+ },
2005
+ examplePayload: listResponsesExamplePayload
2006
+ }),
2007
+ getResponse: (0, _prismatic_io_spectral.action)({
2008
+ display: {
2009
+ label: "Get Response",
2010
+ description: "Get summary information about a specific response. Use 'Get Response Details' for full answers."
2011
+ },
2012
+ inputs: getResponseInputs,
2013
+ perform: async (context, { connection, surveyId, responseId }) => {
2014
+ const { data } = await createClient(connection, context.debug.enabled).get(`/surveys/${surveyId}/responses/${responseId}`);
2015
+ return { data };
2016
+ },
2017
+ examplePayload: getResponseExamplePayload
2018
+ }),
2019
+ getResponseDetails: (0, _prismatic_io_spectral.action)({
2020
+ display: {
2021
+ label: "Get Response Details",
2022
+ description: "Get complete response details including all answers. Requires responses_read_detail scope."
2023
+ },
2024
+ inputs: getResponseInputs,
2025
+ perform: async (context, { connection, surveyId, responseId }) => {
2026
+ const { data } = await createClient(connection, context.debug.enabled).get(`/surveys/${surveyId}/responses/${responseId}/details`);
2027
+ return { data };
2028
+ },
2029
+ examplePayload: getResponseDetailsExamplePayload
2030
+ }),
2031
+ listResponsesBulk: (0, _prismatic_io_spectral.action)({
2032
+ display: {
2033
+ label: "List Responses Bulk",
2034
+ description: "Bulk export responses with full answer details. More efficient for large exports."
2035
+ },
2036
+ inputs: listResponsesInputs,
2037
+ perform: async (context, { connection, surveyId, status, fetchAll, pagination = {} }) => {
2038
+ const client = createClient(connection, context.debug.enabled);
2039
+ const endpoint = `/surveys/${surveyId}/responses/bulk`;
2040
+ const params = {};
2041
+ if (status) params.status = status;
2042
+ return { data: await paginateResults(client, endpoint, fetchAll, {
2043
+ ...params,
2044
+ page: pagination.page,
2045
+ per_page: pagination.perPage
2046
+ }) };
2047
+ },
2048
+ examplePayload: listResponsesBulkExamplePayload
2049
+ }),
2050
+ updateResponse: (0, _prismatic_io_spectral.action)({
2051
+ display: {
2052
+ label: "Update Response",
2053
+ description: "Update response metadata such as status."
2054
+ },
2055
+ inputs: updateResponseInputs,
2056
+ perform: async (context, { connection, surveyId, responseId, responsePages, status, customValue, extraBody }) => {
2057
+ const client = createClient(connection, context.debug.enabled);
2058
+ if (!Array.isArray(responsePages)) throw new Error("Response pages must be a JSON array of response pages.");
2059
+ const body = {
2060
+ pages: responsePages,
2061
+ response_status: status,
2062
+ custom_value: customValue,
2063
+ ...extraBody
2064
+ };
2065
+ const { data } = await client.patch(`/surveys/${surveyId}/responses/${responseId}`, body);
2066
+ return { data };
2067
+ },
2068
+ examplePayload: updateResponseExamplePayload
2069
+ }),
2070
+ deleteResponse: (0, _prismatic_io_spectral.action)({
2071
+ display: {
2072
+ label: "Delete Response",
2073
+ description: "Delete a survey response."
2074
+ },
2075
+ inputs: deleteResponseInputs,
2076
+ perform: async (context, { connection, surveyId, responseId }) => {
2077
+ await createClient(connection, context.debug.enabled).delete(`/surveys/${surveyId}/responses/${responseId}`);
2078
+ return { data: {
2079
+ success: true,
2080
+ surveyId,
2081
+ responseId,
2082
+ message: `Response ${responseId} has been deleted.`
2083
+ } };
2084
+ },
2085
+ examplePayload: deleteResponseExamplePayload
2086
+ })
2087
+ };
2088
+ //#endregion
2089
+ //#region src/actions/contacts/index.ts
2090
+ var contacts_default = {
2091
+ listContacts: (0, _prismatic_io_spectral.action)({
2092
+ display: {
2093
+ label: "List Contacts",
2094
+ description: "List all contacts in your account."
2095
+ },
2096
+ inputs: listContactsInputs,
2097
+ perform: async (context, { connection, fetchAll, pagination = {} }) => {
2098
+ return { data: await paginateResults(createClient(connection, context.debug.enabled), "/contacts", fetchAll, {
2099
+ page: pagination.page,
2100
+ per_page: pagination.perPage
2101
+ }) };
2102
+ },
2103
+ examplePayload: listContactsExamplePayload
2104
+ }),
2105
+ getContact: (0, _prismatic_io_spectral.action)({
2106
+ display: {
2107
+ label: "Get Contact",
2108
+ description: "Retrieve details about a specific contact."
2109
+ },
2110
+ inputs: getContactInputs,
2111
+ perform: async (context, { connection, contactId }) => {
2112
+ const { data } = await createClient(connection, context.debug.enabled).get(`/contacts/${contactId}`);
2113
+ return { data };
2114
+ },
2115
+ examplePayload: getContactExamplePayload
2116
+ }),
2117
+ createContact: (0, _prismatic_io_spectral.action)({
2118
+ display: {
2119
+ label: "Create Contact",
2120
+ description: "Create a new contact."
2121
+ },
2122
+ inputs: createContactInputs,
2123
+ perform: async (context, { connection, email, firstName, lastName, customFields, extraBody }) => {
2124
+ const client = createClient(connection, context.debug.enabled);
2125
+ const body = {
2126
+ email,
2127
+ first_name: firstName,
2128
+ last_name: lastName,
2129
+ custom_fields: customFields || void 0,
2130
+ ...extraBody
2131
+ };
2132
+ const { data } = await client.post("/contacts", body);
2133
+ return { data };
2134
+ },
2135
+ examplePayload: createContactExamplePayload
2136
+ }),
2137
+ createContactsBulk: (0, _prismatic_io_spectral.action)({
2138
+ display: {
2139
+ label: "Create Contacts Bulk",
2140
+ description: "Create multiple contacts at once using a JSON array."
2141
+ },
2142
+ inputs: createContactsBulkInputs,
2143
+ perform: async (context, { connection, contacts, updateExistingContacts }) => {
2144
+ const client = createClient(connection, context.debug.enabled);
2145
+ if (!Array.isArray(contacts)) throw new Error("Contacts must be a JSON array of contact objects.");
2146
+ const { data } = await client.post("/contacts/bulk", {
2147
+ contacts,
2148
+ update_existing: updateExistingContacts
2149
+ });
2150
+ return { data };
2151
+ },
2152
+ examplePayload: createBulkContactsExamplePayload
2153
+ }),
2154
+ updateContact: (0, _prismatic_io_spectral.action)({
2155
+ display: {
2156
+ label: "Update Contact",
2157
+ description: "Update an existing contact's information."
2158
+ },
2159
+ inputs: updateContactInputs,
2160
+ perform: async (context, { connection, contactId, email, firstName, lastName, customFields, extraBody }) => {
2161
+ const client = createClient(connection, context.debug.enabled);
2162
+ const body = {
2163
+ email,
2164
+ first_name: firstName,
2165
+ last_name: lastName,
2166
+ custom_fields: customFields || void 0,
2167
+ ...extraBody
2168
+ };
2169
+ const { data } = await client.patch(`/contacts/${contactId}`, body);
2170
+ return { data };
2171
+ },
2172
+ examplePayload: updateContactExamplePayload
2173
+ }),
2174
+ deleteContact: (0, _prismatic_io_spectral.action)({
2175
+ display: {
2176
+ label: "Delete Contact",
2177
+ description: "Delete a contact."
2178
+ },
2179
+ inputs: deleteContactInputs,
2180
+ perform: async (context, { connection, contactId }) => {
2181
+ await createClient(connection, context.debug.enabled).delete(`/contacts/${contactId}`);
2182
+ return { data: {
2183
+ success: true,
2184
+ contactId,
2185
+ message: `Contact ${contactId} has been deleted.`
2186
+ } };
2187
+ },
2188
+ examplePayload: deleteContactExamplePayload
2189
+ })
2190
+ };
2191
+ //#endregion
2192
+ //#region src/actions/contactLists/index.ts
2193
+ var contactLists_default = {
2194
+ listContactLists: (0, _prismatic_io_spectral.action)({
2195
+ display: {
2196
+ label: "List Contact Lists",
2197
+ description: "List all contact lists in your account."
2198
+ },
2199
+ inputs: listContactListsInputs,
2200
+ perform: async (context, { connection, fetchAll, pagination = {} }) => {
2201
+ return { data: await paginateResults(createClient(connection, context.debug.enabled), "/contact_lists", fetchAll, {
2202
+ page: pagination.page,
2203
+ per_page: pagination.perPage
2204
+ }) };
2205
+ },
2206
+ examplePayload: listContactListsExamplePayload
2207
+ }),
2208
+ getContactList: (0, _prismatic_io_spectral.action)({
2209
+ display: {
2210
+ label: "Get Contact List",
2211
+ description: "Retrieve details about a specific contact list."
2212
+ },
2213
+ inputs: getContactListInputs,
2214
+ perform: async (context, { connection, contactListId }) => {
2215
+ const { data } = await createClient(connection, context.debug.enabled).get(`/contact_lists/${contactListId}`);
2216
+ return { data };
2217
+ },
2218
+ examplePayload: getContactListExamplePayload
2219
+ }),
2220
+ createContactList: (0, _prismatic_io_spectral.action)({
2221
+ display: {
2222
+ label: "Create Contact List",
2223
+ description: "Create a new contact list."
2224
+ },
2225
+ inputs: createContactListInputs,
2226
+ perform: async (context, { connection, name }) => {
2227
+ const client = createClient(connection, context.debug.enabled);
2228
+ const body = { name };
2229
+ const { data } = await client.post("/contact_lists", body);
2230
+ return { data };
2231
+ },
2232
+ examplePayload: createContactListExamplePayload
2233
+ }),
2234
+ updateContactList: (0, _prismatic_io_spectral.action)({
2235
+ display: {
2236
+ label: "Update Contact List",
2237
+ description: "Update a contact list's name."
2238
+ },
2239
+ inputs: updateContactListInputs,
2240
+ perform: async (context, { connection, contactListId, name }) => {
2241
+ const { data } = await createClient(connection, context.debug.enabled).patch(`/contact_lists/${contactListId}`, { name });
2242
+ return { data };
2243
+ },
2244
+ examplePayload: updateContactListExamplePayload
2245
+ }),
2246
+ deleteContactList: (0, _prismatic_io_spectral.action)({
2247
+ display: {
2248
+ label: "Delete Contact List",
2249
+ description: "Delete a contact list."
2250
+ },
2251
+ inputs: deleteContactListInputs,
2252
+ perform: async (context, { connection, contactListId }) => {
2253
+ await createClient(connection, context.debug.enabled).delete(`/contact_lists/${contactListId}`);
2254
+ return { data: {
2255
+ success: true,
2256
+ contactListId,
2257
+ message: `Contact list ${contactListId} has been deleted.`
2258
+ } };
2259
+ },
2260
+ examplePayload: deleteContactListExamplePayload
2261
+ })
2262
+ };
2263
+ //#endregion
2264
+ //#region src/actions/webhooks/index.ts
2265
+ var webhooks_default = {
2266
+ listWebhooks: (0, _prismatic_io_spectral.action)({
2267
+ display: {
2268
+ label: "List Webhooks",
2269
+ description: "List all webhooks in your account."
2270
+ },
2271
+ inputs: listWebhooksInputs,
2272
+ perform: async (context, { connection, fetchAll, pagination = {} }) => {
2273
+ return { data: await paginateResults(createClient(connection, context.debug.enabled), "/webhooks", fetchAll, {
2274
+ page: pagination.page,
2275
+ per_page: pagination.perPage
2276
+ }) };
2277
+ },
2278
+ examplePayload: listWebhooksExamplePayload
2279
+ }),
2280
+ getWebhook: (0, _prismatic_io_spectral.action)({
2281
+ display: {
2282
+ label: "Get Webhook",
2283
+ description: "Retrieve details about a specific webhook."
2284
+ },
2285
+ inputs: getWebhookInputs,
2286
+ perform: async (context, { connection, webhookId }) => {
2287
+ const { data } = await createClient(connection, context.debug.enabled).get(`/webhooks/${webhookId}`);
2288
+ return { data };
2289
+ },
2290
+ examplePayload: getWebhookExamplePayload
2291
+ }),
2292
+ createWebhook: (0, _prismatic_io_spectral.action)({
2293
+ display: {
2294
+ label: "Create Webhook",
2295
+ description: "Create a new webhook subscription. The URL must be unique and handle HEAD requests."
2296
+ },
2297
+ inputs: createWebhookInputs,
2298
+ perform: async (context, { connection, name, eventType, objectType, objectIds, subscriptionUrl }) => {
2299
+ const client = createClient(connection, context.debug.enabled);
2300
+ const body = {
2301
+ name,
2302
+ event_type: eventType,
2303
+ subscription_url: subscriptionUrl,
2304
+ object_type: objectType,
2305
+ ...objectIds && objectIds.length > 0 && { object_ids: objectIds }
2306
+ };
2307
+ const { data } = await client.post("/webhooks", body);
2308
+ return { data };
2309
+ },
2310
+ examplePayload: createWebhookExamplePayload
2311
+ }),
2312
+ updateWebhook: (0, _prismatic_io_spectral.action)({
2313
+ display: {
2314
+ label: "Update Webhook",
2315
+ description: "Update an existing webhook's settings."
2316
+ },
2317
+ inputs: updateWebhookInputs,
2318
+ perform: async (context, { connection, webhookId, name, eventType, objectType, objectIds, subscriptionUrl }) => {
2319
+ const client = createClient(connection, context.debug.enabled);
2320
+ const body = {
2321
+ name,
2322
+ event_type: eventType,
2323
+ object_type: objectType,
2324
+ ...objectIds && objectIds.length > 0 && { object_ids: objectIds },
2325
+ subscription_url: subscriptionUrl
2326
+ };
2327
+ const { data } = await client.patch(`/webhooks/${webhookId}`, body);
2328
+ return { data };
2329
+ },
2330
+ examplePayload: updateWebhookExamplePayload
2331
+ }),
2332
+ deleteWebhook: (0, _prismatic_io_spectral.action)({
2333
+ display: {
2334
+ label: "Delete Webhook",
2335
+ description: "Delete a webhook subscription."
2336
+ },
2337
+ inputs: deleteWebhookInputs,
2338
+ perform: async (context, { connection, webhookId }) => {
2339
+ await createClient(connection, context.debug.enabled).delete(`/webhooks/${webhookId}`);
2340
+ return { data: {
2341
+ success: true,
2342
+ webhookId,
2343
+ message: `Webhook ${webhookId} has been deleted.`
2344
+ } };
2345
+ },
2346
+ examplePayload: deleteWebhookExamplePayload
2347
+ })
2348
+ };
2349
+ //#endregion
2350
+ //#region src/actions/users/index.ts
2351
+ var users_default = { getCurrentUser: (0, _prismatic_io_spectral.action)({
2352
+ display: {
2353
+ label: "Get Current User",
2354
+ description: "Retrieve information about the currently authenticated user."
2355
+ },
2356
+ inputs: getCurrentUserInputs,
2357
+ perform: async (context, { connection }) => {
2358
+ const { data } = await createClient(connection, context.debug.enabled).get("/users/me");
2359
+ return { data };
2360
+ },
2361
+ examplePayload: getMeExamplePayload
2362
+ }) };
2363
+ //#endregion
2364
+ //#region src/actions/misc/index.ts
2365
+ var misc_default = { rawRequest: (0, _prismatic_io_spectral.action)({
2366
+ display: {
2367
+ label: "Raw Request",
2368
+ description: "Send raw HTTP request to SurveyMonkey API."
2369
+ },
2370
+ inputs: rawRequestInputs,
2371
+ perform: async (context, { connection, ...restInputs }) => {
2372
+ validateConnection(connection);
2373
+ const baseUrl = getBaseUrl(connection);
2374
+ const headers = {
2375
+ Authorization: `Bearer ${getAccessToken(connection)}`,
2376
+ "Content-Type": "application/json"
2377
+ };
2378
+ const { data } = await (0, _prismatic_io_spectral_http.sendRawRequest)(baseUrl, {
2379
+ ...restInputs,
2380
+ debugRequest: context.debug.enabled
2381
+ }, headers);
2382
+ return { data };
2383
+ },
2384
+ examplePayload: rawRequestExamplePayload
2385
+ }) };
2386
+ //#endregion
2387
+ //#region src/actions/index.ts
2388
+ var actions_default = {
2389
+ ...surveys_default,
2390
+ ...collectors_default,
2391
+ ...responses_default,
2392
+ ...contacts_default,
2393
+ ...contactLists_default,
2394
+ ...webhooks_default,
2395
+ ...users_default,
2396
+ ...misc_default
2397
+ };
2398
+ //#endregion
2399
+ //#region src/dataSources/index.ts
2400
+ var dataSources_default = {
2401
+ selectSurvey: (0, _prismatic_io_spectral.dataSource)({
2402
+ display: {
2403
+ label: "Select Survey",
2404
+ description: "A picklist of your SurveyMonkey surveys."
2405
+ },
2406
+ inputs: selectSurveyInputs,
2407
+ perform: async (_context, { connection }) => {
2408
+ return { result: (await paginateResults(createClient(connection, false), "/surveys", true)).data.map((survey) => ({
2409
+ label: survey.title,
2410
+ key: survey.id
2411
+ })) };
2412
+ },
2413
+ examplePayload: selectSurveyExamplePayload,
2414
+ dataSourceType: "picklist"
2415
+ }),
2416
+ selectCollector: (0, _prismatic_io_spectral.dataSource)({
2417
+ display: {
2418
+ label: "Select Collector",
2419
+ description: "A picklist of collectors for the selected survey."
2420
+ },
2421
+ inputs: selectCollectorInputs,
2422
+ perform: async (_context, { connection, surveyId }) => {
2423
+ return { result: (await paginateResults(createClient(connection, false), `/surveys/${surveyId}/collectors`, true)).data.map((collector) => ({
2424
+ label: `${collector.name} (${collector.type})`,
2425
+ key: collector.id
2426
+ })) };
2427
+ },
2428
+ examplePayload: selectCollectorExamplePayload,
2429
+ dataSourceType: "picklist"
2430
+ }),
2431
+ selectContact: (0, _prismatic_io_spectral.dataSource)({
2432
+ display: {
2433
+ label: "Select Contact",
2434
+ description: "A picklist of contacts in your SurveyMonkey account."
2435
+ },
2436
+ inputs: { connection: connectionInput },
2437
+ perform: async (_context, { connection }) => {
2438
+ return { result: (await paginateResults(createClient(connection, false), "/contacts", true)).data.map((contact) => ({
2439
+ label: [
2440
+ contact.first_name,
2441
+ contact.last_name,
2442
+ `<${contact.email}>`
2443
+ ].filter(Boolean).join(" "),
2444
+ key: contact.id.toString()
2445
+ })).sort((a, b) => (a.label ?? "") < (b.label ?? "") ? -1 : 1) };
2446
+ },
2447
+ dataSourceType: "picklist",
2448
+ examplePayload: { result: [{
2449
+ label: "Jane Smith <jane@example.com>",
2450
+ key: "1234567890"
2451
+ }, {
2452
+ label: "John Doe <john@example.com>",
2453
+ key: "9876543210"
2454
+ }] }
2455
+ }),
2456
+ selectContactList: (0, _prismatic_io_spectral.dataSource)({
2457
+ display: {
2458
+ label: "Select Contact List",
2459
+ description: "A picklist of your SurveyMonkey contact lists."
2460
+ },
2461
+ inputs: selectContactListInputs,
2462
+ perform: async (_context, { connection }) => {
2463
+ return { result: (await paginateResults(createClient(connection, false), "/contact_lists", true)).data.map((list) => ({
2464
+ label: list.name,
2465
+ key: list.id
2466
+ })) };
2467
+ },
2468
+ examplePayload: selectContactListExamplePayload,
2469
+ dataSourceType: "picklist"
2470
+ }),
2471
+ selectResponse: (0, _prismatic_io_spectral.dataSource)({
2472
+ display: {
2473
+ label: "Select Response",
2474
+ description: "A picklist of responses for the selected SurveyMonkey survey."
2475
+ },
2476
+ inputs: {
2477
+ connection: connectionInput,
2478
+ surveyId: {
2479
+ ...surveyId,
2480
+ dataSource: void 0
2481
+ }
2482
+ },
2483
+ perform: async (_context, { connection, surveyId }) => {
2484
+ return { result: (await paginateResults(createClient(connection, false), `/surveys/${surveyId}/responses`, true)).data.map((item) => ({
2485
+ label: `${item.id} (${item.response_status}${item.date_created ? ` - ${item.date_created}` : ""})`,
2486
+ key: item.id.toString()
2487
+ })).sort((a, b) => (a.label ?? "") < (b.label ?? "") ? -1 : 1) };
2488
+ },
2489
+ dataSourceType: "picklist",
2490
+ examplePayload: { result: [{
2491
+ label: "5007154402 (completed - 2026-01-15T10:30:00+00:00)",
2492
+ key: "5007154402"
2493
+ }, {
2494
+ label: "5007154403 (partial - 2026-01-16T14:20:00+00:00)",
2495
+ key: "5007154403"
2496
+ }] }
2497
+ }),
2498
+ selectWebhookEventType: (0, _prismatic_io_spectral.dataSource)({
2499
+ display: {
2500
+ label: "Select Webhook Event Type",
2501
+ description: "A picklist of available SurveyMonkey webhook event types."
2502
+ },
2503
+ inputs: {},
2504
+ perform: async () => {
2505
+ return { result: WEBHOOK_EVENT_TYPES };
2506
+ },
2507
+ examplePayload: selectWebhookEventTypeExamplePayload,
2508
+ dataSourceType: "picklist"
2509
+ })
2510
+ };
2511
+ //#endregion
2512
+ //#region src/triggers/index.ts
2513
+ var triggers_default = {
2514
+ eventsWebhook: (0, _prismatic_io_spectral.trigger)({
2515
+ display: {
2516
+ label: "Webhook Events",
2517
+ description: "Receive real-time notifications for SurveyMonkey events. Automatically creates and manages a webhook subscription when the instance is deployed, and removes the subscription when the instance is deleted."
2518
+ },
2519
+ allowsBranching: false,
2520
+ inputs: eventsWebhookInputs,
2521
+ synchronousResponseSupport: "invalid",
2522
+ scheduleSupport: "invalid",
2523
+ perform: eventsWebhookPerform,
2524
+ webhookLifecycleHandlers: {
2525
+ create: eventsWebhookCreate,
2526
+ delete: eventsWebhookDelete
2527
+ },
2528
+ examplePayload: eventsWebhookExamplePayload
2529
+ }),
2530
+ pollChangesTrigger: (0, _prismatic_io_spectral.pollingTrigger)({
2531
+ display: {
2532
+ label: "New and Updated Records",
2533
+ description: "Retrieves existing and ongoing survey responses from SurveyMonkey. Load history once, check for changes on a schedule, or both. New responses are emitted on the created branch and previously created responses that changed are emitted on the updated branch. Requires the responses_read_detail scope, available on paid SurveyMonkey plans."
2534
+ },
2535
+ examplePayload: pollChangesTriggerExamplePayload,
2536
+ inputs: pollChangesInputs,
2537
+ triggerResolverSupport: "valid",
2538
+ batchConfig: { batchSize: 50 },
2539
+ triggerResolver: { resolveItems: (_context, { payload }) => resolveSurveyResponseChanges(payload.body.data) },
2540
+ perform: async (context, payload, params) => {
2541
+ const now = (/* @__PURE__ */ new Date()).toISOString();
2542
+ const pollState = context.polling.getState();
2543
+ const isBackfill = !pollState?.lastPolledAt && Boolean(params.lookBackDate);
2544
+ const lastPolledAt = pollState?.lastPolledAt ?? (params.lookBackDate || now);
2545
+ const records = (await paginateResults(createClient(params.connection, context.debug.enabled), `/surveys/${params.surveyId}/responses/bulk`, true, {
2546
+ start_modified_at: toSurveyMonkeyDate(lastPolledAt),
2547
+ sort_by: "date_modified",
2548
+ sort_order: "ASC"
2549
+ })).data ?? [];
2550
+ const lastPolledAtDate = new Date(lastPolledAt);
2551
+ const created = [];
2552
+ const updated = [];
2553
+ for (const record of records) {
2554
+ const createdValue = record.date_created;
2555
+ const createdAtDate = typeof createdValue === "string" ? new Date(createdValue) : null;
2556
+ const isNew = createdAtDate !== null && (isBackfill ? createdAtDate >= lastPolledAtDate : createdAtDate > lastPolledAtDate);
2557
+ if (isNew && (isBackfill || params.showNewRecords !== false)) created.push(record);
2558
+ else if (!isNew && (isBackfill || params.showUpdatedRecords !== false)) updated.push(record);
2559
+ }
2560
+ context.polling.setState({ lastPolledAt: now });
2561
+ if (context.debug.enabled) context.logger.debug(`Polled SurveyMonkey survey ${params.surveyId}: ${records.length} fetched, ${created.length} created, ${updated.length} updated`);
2562
+ const totalMatched = created.length + updated.length;
2563
+ return {
2564
+ payload: {
2565
+ ...payload,
2566
+ body: { data: {
2567
+ created,
2568
+ updated
2569
+ } }
2570
+ },
2571
+ polledNoChanges: totalMatched === 0
2572
+ };
2573
+ }
2574
+ })
2575
+ };
2576
+ //#endregion
2577
+ //#region src/index.ts
2578
+ var src_default = (0, _prismatic_io_spectral.component)({
2579
+ key: "surveymonkey",
2580
+ public: true,
2581
+ documentationUrl: "https://prismatic.io/docs/components/surveymonkey/",
2582
+ display: {
2583
+ label: "SurveyMonkey",
2584
+ description: "Manage surveys, collectors, responses, contacts, and webhooks in SurveyMonkey.",
2585
+ category: "Application Connectors",
2586
+ iconPath: "icon.png"
2587
+ },
2588
+ connections: connections_default,
2589
+ actions: actions_default,
2590
+ dataSources: dataSources_default,
2591
+ triggers: triggers_default,
2592
+ hooks: { error: _prismatic_io_spectral_http.handleErrors }
2593
+ });
2594
+ //#endregion
2595
+ //#region npm-dist/.entry.ts
2596
+ var _entry_default = (0, _prismatic_io_spectral.callableComponent)(src_default);
2597
+ //#endregion
2598
+ module.exports = _entry_default;