n8n-nodes-preroll 0.1.0

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.
Files changed (30) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +96 -0
  3. package/dist/credentials/PreRollApi.credentials.d.ts +9 -0
  4. package/dist/credentials/PreRollApi.credentials.js +43 -0
  5. package/dist/nodes/PreRoll/PreRoll.node.d.ts +5 -0
  6. package/dist/nodes/PreRoll/PreRoll.node.js +340 -0
  7. package/dist/nodes/PreRoll/PreRollTrigger.node.d.ts +12 -0
  8. package/dist/nodes/PreRoll/PreRollTrigger.node.js +159 -0
  9. package/dist/nodes/PreRoll/preroll.svg +7 -0
  10. package/dist/nodes/PreRoll/resources/ActivityDescription.d.ts +3 -0
  11. package/dist/nodes/PreRoll/resources/ActivityDescription.js +36 -0
  12. package/dist/nodes/PreRoll/resources/AiDescription.d.ts +3 -0
  13. package/dist/nodes/PreRoll/resources/AiDescription.js +97 -0
  14. package/dist/nodes/PreRoll/resources/ClientDescription.d.ts +3 -0
  15. package/dist/nodes/PreRoll/resources/ClientDescription.js +72 -0
  16. package/dist/nodes/PreRoll/resources/DashboardDescription.d.ts +3 -0
  17. package/dist/nodes/PreRoll/resources/DashboardDescription.js +17 -0
  18. package/dist/nodes/PreRoll/resources/DeliverableDescription.d.ts +3 -0
  19. package/dist/nodes/PreRoll/resources/DeliverableDescription.js +123 -0
  20. package/dist/nodes/PreRoll/resources/EpisodeDescription.d.ts +3 -0
  21. package/dist/nodes/PreRoll/resources/EpisodeDescription.js +123 -0
  22. package/dist/nodes/PreRoll/resources/MeetingNoteDescription.d.ts +3 -0
  23. package/dist/nodes/PreRoll/resources/MeetingNoteDescription.js +50 -0
  24. package/dist/nodes/PreRoll/resources/PipelineStageDescription.d.ts +3 -0
  25. package/dist/nodes/PreRoll/resources/PipelineStageDescription.js +27 -0
  26. package/dist/nodes/PreRoll/resources/ShowDescription.d.ts +3 -0
  27. package/dist/nodes/PreRoll/resources/ShowDescription.js +134 -0
  28. package/dist/nodes/PreRoll/resources/TagDescription.d.ts +3 -0
  29. package/dist/nodes/PreRoll/resources/TagDescription.js +59 -0
  30. package/package.json +50 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Trevor O'Hare
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # n8n-nodes-preroll
2
+
3
+ n8n community node for [PreRoll](https://preroll.io) — podcast production management.
4
+
5
+ Interact with your PreRoll instance from n8n workflows: manage clients, shows, episodes, deliverables, tags, and AI features. Includes a trigger node for real-time webhook events.
6
+
7
+ [n8n](https://n8n.io/) is a [fair-code licensed](https://docs.n8n.io/reference/license/) workflow automation platform.
8
+
9
+ ## Installation
10
+
11
+ Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes/installation/) in the n8n community nodes documentation.
12
+
13
+ **npm package name:** `n8n-nodes-preroll`
14
+
15
+ ## Credentials
16
+
17
+ You need a PreRoll API key to authenticate:
18
+
19
+ 1. Log in to your PreRoll instance
20
+ 2. Go to **Settings → API Keys**
21
+ 3. Click **Create API Key** and copy the key (starts with `pr_`)
22
+ 4. In n8n, create a new **PreRoll API** credential with your API key and base URL
23
+
24
+ > API keys require a Pro or Studio plan.
25
+
26
+ ## Nodes
27
+
28
+ ### PreRoll
29
+
30
+ The main node supports these resources and operations:
31
+
32
+ | Resource | Operations |
33
+ |----------|-----------|
34
+ | **Client** | Get, Get Many, Create, Update, Delete |
35
+ | **Show** | Get, Get Many, Create, Update, Delete |
36
+ | **Episode** | Get, Get Many, Create, Update, Delete |
37
+ | **Deliverable** | Get, Get Many, Create, Update |
38
+ | **Tag** | Get Many, Create, Update, Delete |
39
+ | **Meeting Note** | Get Many, Create |
40
+ | **Pipeline Stage** | Get Many |
41
+ | **Activity** | Get Many |
42
+ | **AI** | Get Credits, Get Transcription, Transcribe Episode, Generate Content, Run Pipeline |
43
+ | **Dashboard** | Get Overview |
44
+
45
+ ### PreRoll Trigger
46
+
47
+ Webhook-based trigger that starts workflows when events occur in PreRoll:
48
+
49
+ - `episode.status_changed` — Episode status updated
50
+ - `episode.stage_changed` — Episode moved to a different pipeline stage
51
+ - `episode.published` — Episode published
52
+ - `episode.scheduled` — Episode scheduled for publishing
53
+ - `deliverable.submitted` — New deliverable submitted for review
54
+ - `deliverable.approved` — Deliverable approved by client
55
+ - `deliverable.revision_requested` — Client requested revisions on a deliverable
56
+ - `deliverable.resubmitted` — Deliverable resubmitted after revision
57
+
58
+ The trigger node automatically registers and deregisters webhook endpoints in PreRoll when the workflow is activated/deactivated.
59
+
60
+ ## Example Workflows
61
+
62
+ ### Notify Slack when an episode is published
63
+
64
+ 1. Add a **PreRoll Trigger** node with event `episode.published`
65
+ 2. Connect to a **Slack** node to post a message
66
+
67
+ ### Auto-transcribe new episodes
68
+
69
+ 1. Add a **PreRoll Trigger** node with event `episode.stage_changed`
70
+ 2. Add an **IF** node to check if the new stage is "Editing"
71
+ 3. Connect to a **PreRoll** node → AI → Transcribe Episode
72
+
73
+ ### Weekly episode report
74
+
75
+ 1. Add a **Schedule Trigger** (every Monday)
76
+ 2. Connect to a **PreRoll** node → Dashboard → Get Overview
77
+ 3. Connect to an **Email** node to send the summary
78
+
79
+ ## Development
80
+
81
+ ```bash
82
+ # Install dependencies
83
+ npm install
84
+
85
+ # Build
86
+ npm run build
87
+
88
+ # Link for local testing
89
+ npm link
90
+ cd ~/.n8n/custom
91
+ npm link n8n-nodes-preroll
92
+ ```
93
+
94
+ ## License
95
+
96
+ MIT
@@ -0,0 +1,9 @@
1
+ import { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
2
+ export declare class PreRollApi implements ICredentialType {
3
+ name: string;
4
+ displayName: string;
5
+ documentationUrl: string;
6
+ properties: INodeProperties[];
7
+ authenticate: IAuthenticateGeneric;
8
+ test: ICredentialTestRequest;
9
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PreRollApi = void 0;
4
+ class PreRollApi {
5
+ constructor() {
6
+ this.name = 'preRollApi';
7
+ this.displayName = 'PreRoll API';
8
+ this.documentationUrl = 'https://preroll.io/docs/api';
9
+ this.properties = [
10
+ {
11
+ displayName: 'API Key',
12
+ name: 'apiKey',
13
+ type: 'string',
14
+ typeOptions: { password: true },
15
+ default: '',
16
+ placeholder: 'pr_...',
17
+ description: 'API key from PreRoll Settings → API Keys',
18
+ },
19
+ {
20
+ displayName: 'Base URL',
21
+ name: 'baseUrl',
22
+ type: 'string',
23
+ default: 'https://api.preroll.io',
24
+ description: 'Base URL of your PreRoll instance',
25
+ },
26
+ ];
27
+ this.authenticate = {
28
+ type: 'generic',
29
+ properties: {
30
+ headers: {
31
+ Authorization: '=Bearer {{$credentials.apiKey}}',
32
+ },
33
+ },
34
+ };
35
+ this.test = {
36
+ request: {
37
+ baseURL: '={{$credentials.baseUrl}}',
38
+ url: '/api/v1/dashboard',
39
+ },
40
+ };
41
+ }
42
+ }
43
+ exports.PreRollApi = PreRollApi;
@@ -0,0 +1,5 @@
1
+ import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
+ export declare class PreRoll implements INodeType {
3
+ description: INodeTypeDescription;
4
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
5
+ }
@@ -0,0 +1,340 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PreRoll = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ const ClientDescription_1 = require("./resources/ClientDescription");
6
+ const ShowDescription_1 = require("./resources/ShowDescription");
7
+ const EpisodeDescription_1 = require("./resources/EpisodeDescription");
8
+ const DeliverableDescription_1 = require("./resources/DeliverableDescription");
9
+ const TagDescription_1 = require("./resources/TagDescription");
10
+ const MeetingNoteDescription_1 = require("./resources/MeetingNoteDescription");
11
+ const PipelineStageDescription_1 = require("./resources/PipelineStageDescription");
12
+ const ActivityDescription_1 = require("./resources/ActivityDescription");
13
+ const AiDescription_1 = require("./resources/AiDescription");
14
+ const DashboardDescription_1 = require("./resources/DashboardDescription");
15
+ class PreRoll {
16
+ constructor() {
17
+ this.description = {
18
+ displayName: 'PreRoll',
19
+ name: 'preRoll',
20
+ icon: 'file:preroll.svg',
21
+ group: ['transform'],
22
+ version: 1,
23
+ subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
24
+ description: 'Interact with PreRoll — podcast production management',
25
+ defaults: {
26
+ name: 'PreRoll',
27
+ },
28
+ inputs: ['main'],
29
+ outputs: ['main'],
30
+ credentials: [
31
+ {
32
+ name: 'preRollApi',
33
+ required: true,
34
+ },
35
+ ],
36
+ properties: [
37
+ {
38
+ displayName: 'Resource',
39
+ name: 'resource',
40
+ type: 'options',
41
+ noDataExpression: true,
42
+ options: [
43
+ { name: 'Activity', value: 'activity' },
44
+ { name: 'AI', value: 'ai' },
45
+ { name: 'Client', value: 'client' },
46
+ { name: 'Dashboard', value: 'dashboard' },
47
+ { name: 'Deliverable', value: 'deliverable' },
48
+ { name: 'Episode', value: 'episode' },
49
+ { name: 'Meeting Note', value: 'meetingNote' },
50
+ { name: 'Pipeline Stage', value: 'pipelineStage' },
51
+ { name: 'Show', value: 'show' },
52
+ { name: 'Tag', value: 'tag' },
53
+ ],
54
+ default: 'episode',
55
+ },
56
+ ...ClientDescription_1.clientOperations,
57
+ ...ClientDescription_1.clientFields,
58
+ ...ShowDescription_1.showOperations,
59
+ ...ShowDescription_1.showFields,
60
+ ...EpisodeDescription_1.episodeOperations,
61
+ ...EpisodeDescription_1.episodeFields,
62
+ ...DeliverableDescription_1.deliverableOperations,
63
+ ...DeliverableDescription_1.deliverableFields,
64
+ ...TagDescription_1.tagOperations,
65
+ ...TagDescription_1.tagFields,
66
+ ...MeetingNoteDescription_1.meetingNoteOperations,
67
+ ...MeetingNoteDescription_1.meetingNoteFields,
68
+ ...PipelineStageDescription_1.pipelineStageOperations,
69
+ ...PipelineStageDescription_1.pipelineStageFields,
70
+ ...ActivityDescription_1.activityOperations,
71
+ ...ActivityDescription_1.activityFields,
72
+ ...AiDescription_1.aiOperations,
73
+ ...AiDescription_1.aiFields,
74
+ ...DashboardDescription_1.dashboardOperations,
75
+ ...DashboardDescription_1.dashboardFields,
76
+ ],
77
+ };
78
+ }
79
+ async execute() {
80
+ const items = this.getInputData();
81
+ const returnData = [];
82
+ const resource = this.getNodeParameter('resource', 0);
83
+ const operation = this.getNodeParameter('operation', 0);
84
+ const credentials = await this.getCredentials('preRollApi');
85
+ const baseUrl = credentials.baseUrl.replace(/\/$/, '');
86
+ for (let i = 0; i < items.length; i++) {
87
+ try {
88
+ let responseData;
89
+ // ────────── Client ──────────
90
+ if (resource === 'client') {
91
+ if (operation === 'getAll') {
92
+ responseData = await apiRequest.call(this, 'GET', baseUrl, '/clients');
93
+ }
94
+ else if (operation === 'get') {
95
+ const id = this.getNodeParameter('clientId', i);
96
+ responseData = await apiRequest.call(this, 'GET', baseUrl, `/clients/${id}`);
97
+ }
98
+ else if (operation === 'create') {
99
+ const name = this.getNodeParameter('name', i);
100
+ const additional = this.getNodeParameter('additionalFields', i);
101
+ responseData = await apiRequest.call(this, 'POST', baseUrl, '/clients', { name, ...additional });
102
+ }
103
+ else if (operation === 'update') {
104
+ const id = this.getNodeParameter('clientId', i);
105
+ const fields = this.getNodeParameter('updateFields', i);
106
+ responseData = await apiRequest.call(this, 'PATCH', baseUrl, `/clients/${id}`, fields);
107
+ }
108
+ else if (operation === 'delete') {
109
+ const id = this.getNodeParameter('clientId', i);
110
+ await apiRequest.call(this, 'DELETE', baseUrl, `/clients/${id}`);
111
+ responseData = { success: true };
112
+ }
113
+ else {
114
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown operation: ${operation}`);
115
+ }
116
+ // ────────── Show ──────────
117
+ }
118
+ else if (resource === 'show') {
119
+ if (operation === 'getAll') {
120
+ const clientId = this.getNodeParameter('clientId', i);
121
+ const qs = clientId ? `?client_id=${clientId}` : '';
122
+ responseData = await apiRequest.call(this, 'GET', baseUrl, `/shows${qs}`);
123
+ }
124
+ else if (operation === 'get') {
125
+ const id = this.getNodeParameter('showId', i);
126
+ responseData = await apiRequest.call(this, 'GET', baseUrl, `/shows/${id}`);
127
+ }
128
+ else if (operation === 'create') {
129
+ const clientId = this.getNodeParameter('clientId', i);
130
+ const name = this.getNodeParameter('name', i);
131
+ const additional = this.getNodeParameter('additionalFields', i);
132
+ responseData = await apiRequest.call(this, 'POST', baseUrl, '/shows', { client_id: clientId, name, ...additional });
133
+ }
134
+ else if (operation === 'update') {
135
+ const id = this.getNodeParameter('showId', i);
136
+ const fields = this.getNodeParameter('updateFields', i);
137
+ responseData = await apiRequest.call(this, 'PATCH', baseUrl, `/shows/${id}`, fields);
138
+ }
139
+ else if (operation === 'delete') {
140
+ const id = this.getNodeParameter('showId', i);
141
+ await apiRequest.call(this, 'DELETE', baseUrl, `/shows/${id}`);
142
+ responseData = { success: true };
143
+ }
144
+ else {
145
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown operation: ${operation}`);
146
+ }
147
+ // ────────── Episode ──────────
148
+ }
149
+ else if (resource === 'episode') {
150
+ if (operation === 'getAll') {
151
+ const filters = this.getNodeParameter('filters', i);
152
+ const params = new URLSearchParams();
153
+ for (const [key, val] of Object.entries(filters)) {
154
+ if (val !== '' && val !== undefined && val !== false)
155
+ params.set(key, String(val));
156
+ }
157
+ const qs = params.toString() ? `?${params}` : '';
158
+ responseData = await apiRequest.call(this, 'GET', baseUrl, `/episodes${qs}`);
159
+ }
160
+ else if (operation === 'get') {
161
+ const showId = this.getNodeParameter('showId', i);
162
+ const episodeId = this.getNodeParameter('episodeId', i);
163
+ responseData = await apiRequest.call(this, 'GET', baseUrl, `/shows/${showId}/episodes/${episodeId}`);
164
+ }
165
+ else if (operation === 'create') {
166
+ const showId = this.getNodeParameter('showId', i);
167
+ const title = this.getNodeParameter('title', i);
168
+ const additional = this.getNodeParameter('additionalFields', i);
169
+ responseData = await apiRequest.call(this, 'POST', baseUrl, `/shows/${showId}/episodes`, { title, ...additional });
170
+ }
171
+ else if (operation === 'update') {
172
+ const showId = this.getNodeParameter('showId', i);
173
+ const episodeId = this.getNodeParameter('episodeId', i);
174
+ const fields = this.getNodeParameter('updateFields', i);
175
+ responseData = await apiRequest.call(this, 'PATCH', baseUrl, `/shows/${showId}/episodes/${episodeId}`, fields);
176
+ }
177
+ else if (operation === 'delete') {
178
+ const showId = this.getNodeParameter('showId', i);
179
+ const episodeId = this.getNodeParameter('episodeId', i);
180
+ await apiRequest.call(this, 'DELETE', baseUrl, `/shows/${showId}/episodes/${episodeId}`);
181
+ responseData = { success: true };
182
+ }
183
+ else {
184
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown operation: ${operation}`);
185
+ }
186
+ // ────────── Deliverable ──────────
187
+ }
188
+ else if (resource === 'deliverable') {
189
+ if (operation === 'getAll') {
190
+ const filters = this.getNodeParameter('filters', i);
191
+ const params = new URLSearchParams();
192
+ for (const [key, val] of Object.entries(filters)) {
193
+ if (val !== '' && val !== undefined)
194
+ params.set(key, String(val));
195
+ }
196
+ const qs = params.toString() ? `?${params}` : '';
197
+ responseData = await apiRequest.call(this, 'GET', baseUrl, `/deliverables${qs}`);
198
+ }
199
+ else if (operation === 'get') {
200
+ const id = this.getNodeParameter('deliverableId', i);
201
+ responseData = await apiRequest.call(this, 'GET', baseUrl, `/deliverables/${id}`);
202
+ }
203
+ else if (operation === 'create') {
204
+ const showId = this.getNodeParameter('showId', i);
205
+ const title = this.getNodeParameter('title', i);
206
+ const additional = this.getNodeParameter('additionalFields', i);
207
+ responseData = await apiRequest.call(this, 'POST', baseUrl, '/deliverables', { show_id: showId, title, ...additional });
208
+ }
209
+ else if (operation === 'update') {
210
+ const id = this.getNodeParameter('deliverableId', i);
211
+ const fields = this.getNodeParameter('updateFields', i);
212
+ responseData = await apiRequest.call(this, 'PATCH', baseUrl, `/deliverables/${id}`, fields);
213
+ }
214
+ else {
215
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown operation: ${operation}`);
216
+ }
217
+ // ────────── Tag ──────────
218
+ }
219
+ else if (resource === 'tag') {
220
+ if (operation === 'getAll') {
221
+ responseData = await apiRequest.call(this, 'GET', baseUrl, '/tags');
222
+ }
223
+ else if (operation === 'create') {
224
+ const name = this.getNodeParameter('name', i);
225
+ const color = this.getNodeParameter('color', i);
226
+ responseData = await apiRequest.call(this, 'POST', baseUrl, '/tags', { name, color });
227
+ }
228
+ else if (operation === 'update') {
229
+ const id = this.getNodeParameter('tagId', i);
230
+ const fields = this.getNodeParameter('updateFields', i);
231
+ responseData = await apiRequest.call(this, 'PATCH', baseUrl, `/tags/${id}`, fields);
232
+ }
233
+ else if (operation === 'delete') {
234
+ const id = this.getNodeParameter('tagId', i);
235
+ await apiRequest.call(this, 'DELETE', baseUrl, `/tags/${id}`);
236
+ responseData = { success: true };
237
+ }
238
+ else {
239
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown operation: ${operation}`);
240
+ }
241
+ // ────────── Meeting Note ──────────
242
+ }
243
+ else if (resource === 'meetingNote') {
244
+ const clientId = this.getNodeParameter('clientId', i);
245
+ if (operation === 'getAll') {
246
+ responseData = await apiRequest.call(this, 'GET', baseUrl, `/clients/${clientId}/notes`);
247
+ }
248
+ else if (operation === 'create') {
249
+ const content = this.getNodeParameter('content', i);
250
+ const additional = this.getNodeParameter('additionalFields', i);
251
+ responseData = await apiRequest.call(this, 'POST', baseUrl, `/clients/${clientId}/notes`, { content, ...additional });
252
+ }
253
+ else {
254
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown operation: ${operation}`);
255
+ }
256
+ // ────────── Pipeline Stage ──────────
257
+ }
258
+ else if (resource === 'pipelineStage') {
259
+ const showId = this.getNodeParameter('showId', i);
260
+ responseData = await apiRequest.call(this, 'GET', baseUrl, `/shows/${showId}/stages`);
261
+ // ────────── Activity ──────────
262
+ }
263
+ else if (resource === 'activity') {
264
+ const showId = this.getNodeParameter('showId', i);
265
+ const limit = this.getNodeParameter('limit', i);
266
+ responseData = await apiRequest.call(this, 'GET', baseUrl, `/activity?show_id=${showId}&limit=${limit}`);
267
+ // ────────── AI ──────────
268
+ }
269
+ else if (resource === 'ai') {
270
+ if (operation === 'getCredits') {
271
+ responseData = await apiRequest.call(this, 'GET', baseUrl, '/ai/credits');
272
+ }
273
+ else if (operation === 'getTranscription') {
274
+ const episodeId = this.getNodeParameter('episodeId', i);
275
+ responseData = await apiRequest.call(this, 'GET', baseUrl, `/episodes/${episodeId}/transcription`);
276
+ }
277
+ else if (operation === 'transcribe') {
278
+ const episodeId = this.getNodeParameter('episodeId', i);
279
+ const audioUrl = this.getNodeParameter('audioUrl', i);
280
+ responseData = await apiRequest.call(this, 'POST', baseUrl, `/episodes/${episodeId}/transcribe`, {
281
+ source_type: 'url',
282
+ audio_url: audioUrl,
283
+ });
284
+ }
285
+ else if (operation === 'generate') {
286
+ const episodeId = this.getNodeParameter('episodeId', i);
287
+ const generationType = this.getNodeParameter('generationType', i);
288
+ const options = this.getNodeParameter('generateOptions', i);
289
+ responseData = await apiRequest.call(this, 'POST', baseUrl, `/episodes/${episodeId}/generate`, {
290
+ type: generationType,
291
+ ...options,
292
+ });
293
+ }
294
+ else if (operation === 'runPipeline') {
295
+ const showId = this.getNodeParameter('showId', i);
296
+ const episodeId = this.getNodeParameter('episodeId', i);
297
+ responseData = await apiRequest.call(this, 'POST', baseUrl, `/shows/${showId}/episodes/${episodeId}/pipeline`, {});
298
+ }
299
+ else {
300
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown operation: ${operation}`);
301
+ }
302
+ // ────────── Dashboard ──────────
303
+ }
304
+ else if (resource === 'dashboard') {
305
+ responseData = await apiRequest.call(this, 'GET', baseUrl, '/dashboard');
306
+ }
307
+ else {
308
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown resource: ${resource}`);
309
+ }
310
+ const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
311
+ returnData.push(...executionData);
312
+ }
313
+ catch (error) {
314
+ if (this.continueOnFail()) {
315
+ const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
316
+ returnData.push(...executionData);
317
+ continue;
318
+ }
319
+ throw error;
320
+ }
321
+ }
322
+ return [returnData];
323
+ }
324
+ }
325
+ exports.PreRoll = PreRoll;
326
+ async function apiRequest(method, baseUrl, path, body) {
327
+ const options = {
328
+ method: method,
329
+ url: `${baseUrl}/api/v1${path}`,
330
+ json: true,
331
+ };
332
+ if (body && Object.keys(body).length > 0) {
333
+ options.body = body;
334
+ }
335
+ const response = await this.helpers.httpRequestWithAuthentication.call(this, 'preRollApi', options);
336
+ if (method === 'DELETE') {
337
+ return { success: true };
338
+ }
339
+ return (response.data ?? response);
340
+ }
@@ -0,0 +1,12 @@
1
+ import { IHookFunctions, INodeType, INodeTypeDescription, IWebhookFunctions, IWebhookResponseData } from 'n8n-workflow';
2
+ export declare class PreRollTrigger implements INodeType {
3
+ description: INodeTypeDescription;
4
+ webhookMethods: {
5
+ default: {
6
+ checkExists(this: IHookFunctions): Promise<boolean>;
7
+ create(this: IHookFunctions): Promise<boolean>;
8
+ delete(this: IHookFunctions): Promise<boolean>;
9
+ };
10
+ };
11
+ webhook(this: IWebhookFunctions): Promise<IWebhookResponseData>;
12
+ }