@frogbotai/piece-pagerduty 0.28.0 → 0.30.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.
- package/dist/actions.js +123 -59
- package/dist/actions.js.map +1 -1
- package/dist/client.js +14 -8
- package/dist/client.js.map +1 -1
- package/dist/config.js +9 -6
- package/dist/config.js.map +1 -1
- package/dist/define.js +1 -0
- package/dist/define.js.map +1 -1
- package/dist/index.js +12 -7
- package/dist/index.js.map +1 -1
- package/dist/triggers.js +23 -19
- package/dist/triggers.js.map +1 -1
- package/dist/webhook.js +8 -11
- package/dist/webhook.js.map +1 -1
- package/package.json +4 -4
package/dist/actions.js
CHANGED
|
@@ -1,25 +1,42 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { defineAction } from './define.js';
|
|
3
|
-
const incident = z.object({
|
|
3
|
+
const incident = z.object({
|
|
4
|
+
id: z.string(),
|
|
5
|
+
status: z.string().optional()
|
|
6
|
+
}).passthrough();
|
|
4
7
|
const incidentOutput = incident;
|
|
5
|
-
const incidentResponse = z.object({
|
|
8
|
+
const incidentResponse = z.object({
|
|
9
|
+
incident: incidentOutput
|
|
10
|
+
});
|
|
6
11
|
const servicesResponse = z.object({
|
|
7
|
-
services: z.array(z.object({
|
|
8
|
-
|
|
12
|
+
services: z.array(z.object({
|
|
13
|
+
id: z.string(),
|
|
14
|
+
name: z.string()
|
|
15
|
+
})),
|
|
16
|
+
more: z.boolean()
|
|
17
|
+
});
|
|
18
|
+
const fromEmail = z.email().meta({
|
|
19
|
+
label: 'From email'
|
|
20
|
+
});
|
|
21
|
+
const incidentId = z.string().min(1).meta({
|
|
22
|
+
label: 'Incident ID'
|
|
9
23
|
});
|
|
10
|
-
const fromEmail = z.email().meta({ label: 'From email' });
|
|
11
|
-
const incidentId = z.string().min(1).meta({ label: 'Incident ID' });
|
|
12
24
|
const createIncidentInput = z.object({
|
|
13
25
|
fromEmail,
|
|
14
|
-
serviceId: z.string().min(1).meta({
|
|
26
|
+
serviceId: z.string().min(1).meta({
|
|
27
|
+
label: 'Service'
|
|
28
|
+
}),
|
|
15
29
|
title: z.string().min(1),
|
|
16
|
-
urgency: z.enum([
|
|
30
|
+
urgency: z.enum([
|
|
31
|
+
'high',
|
|
32
|
+
'low'
|
|
33
|
+
]).default('high'),
|
|
17
34
|
details: z.string().optional(),
|
|
18
35
|
incidentKey: z.string().optional(),
|
|
19
36
|
assigneeIds: z.array(z.string()).optional(),
|
|
20
37
|
priorityId: z.string().optional(),
|
|
21
38
|
conferenceNumber: z.string().optional(),
|
|
22
|
-
conferenceUrl: z.url().optional()
|
|
39
|
+
conferenceUrl: z.url().optional()
|
|
23
40
|
});
|
|
24
41
|
export const createIncident = defineAction({
|
|
25
42
|
slug: 'createIncident',
|
|
@@ -28,99 +45,129 @@ export const createIncident = defineAction({
|
|
|
28
45
|
output: incidentOutput,
|
|
29
46
|
idempotent: false,
|
|
30
47
|
options: {
|
|
31
|
-
serviceId: async ({ client })
|
|
48
|
+
serviceId: async ({ client })=>{
|
|
32
49
|
const services = [];
|
|
33
50
|
let offset = 0;
|
|
34
51
|
let more = true;
|
|
35
|
-
while
|
|
52
|
+
while(more){
|
|
36
53
|
const response = servicesResponse.parse(await client.request({
|
|
37
54
|
method: 'GET',
|
|
38
55
|
path: '/services',
|
|
39
|
-
query: {
|
|
56
|
+
query: {
|
|
57
|
+
limit: '100',
|
|
58
|
+
offset: String(offset)
|
|
59
|
+
}
|
|
40
60
|
}));
|
|
41
61
|
services.push(...response.services);
|
|
42
62
|
more = response.more;
|
|
43
63
|
offset += 100;
|
|
44
64
|
}
|
|
45
|
-
return services.map(({ id, name })
|
|
46
|
-
|
|
65
|
+
return services.map(({ id, name })=>({
|
|
66
|
+
label: name,
|
|
67
|
+
value: id
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
47
70
|
},
|
|
48
|
-
async run({ input, client }) {
|
|
71
|
+
async run ({ input, client }) {
|
|
49
72
|
const payload = {
|
|
50
73
|
type: 'incident',
|
|
51
74
|
title: input.title,
|
|
52
|
-
service: {
|
|
53
|
-
|
|
75
|
+
service: {
|
|
76
|
+
id: input.serviceId,
|
|
77
|
+
type: 'service_reference'
|
|
78
|
+
},
|
|
79
|
+
urgency: input.urgency
|
|
80
|
+
};
|
|
81
|
+
if (input.details) payload.body = {
|
|
82
|
+
type: 'incident_body',
|
|
83
|
+
details: input.details
|
|
54
84
|
};
|
|
55
|
-
if (input.
|
|
56
|
-
payload.body = { type: 'incident_body', details: input.details };
|
|
57
|
-
if (input.incidentKey)
|
|
58
|
-
payload.incident_key = input.incidentKey;
|
|
85
|
+
if (input.incidentKey) payload.incident_key = input.incidentKey;
|
|
59
86
|
if (input.assigneeIds?.length) {
|
|
60
|
-
payload.assignments = input.assigneeIds.map((id)
|
|
61
|
-
|
|
62
|
-
|
|
87
|
+
payload.assignments = input.assigneeIds.map((id)=>({
|
|
88
|
+
assignee: {
|
|
89
|
+
id,
|
|
90
|
+
type: 'user_reference'
|
|
91
|
+
}
|
|
92
|
+
}));
|
|
63
93
|
}
|
|
64
|
-
if (input.priorityId)
|
|
65
|
-
|
|
94
|
+
if (input.priorityId) payload.priority = {
|
|
95
|
+
id: input.priorityId,
|
|
96
|
+
type: 'priority_reference'
|
|
97
|
+
};
|
|
66
98
|
if (input.conferenceNumber || input.conferenceUrl) {
|
|
67
99
|
payload.conference_bridge = {
|
|
68
|
-
...
|
|
69
|
-
|
|
100
|
+
...input.conferenceNumber ? {
|
|
101
|
+
conference_number: input.conferenceNumber
|
|
102
|
+
} : {},
|
|
103
|
+
...input.conferenceUrl ? {
|
|
104
|
+
conference_url: input.conferenceUrl
|
|
105
|
+
} : {}
|
|
70
106
|
};
|
|
71
107
|
}
|
|
72
108
|
const response = incidentResponse.parse(await client.request({
|
|
73
109
|
method: 'POST',
|
|
74
110
|
path: '/incidents',
|
|
75
111
|
fromEmail: input.fromEmail,
|
|
76
|
-
body: {
|
|
112
|
+
body: {
|
|
113
|
+
incident: payload
|
|
114
|
+
}
|
|
77
115
|
}));
|
|
78
116
|
return response.incident;
|
|
79
|
-
}
|
|
117
|
+
}
|
|
80
118
|
});
|
|
81
119
|
const listIncidentsInput = z.object({
|
|
82
|
-
statuses: z.array(z.enum([
|
|
83
|
-
|
|
120
|
+
statuses: z.array(z.enum([
|
|
121
|
+
'triggered',
|
|
122
|
+
'acknowledged',
|
|
123
|
+
'resolved'
|
|
124
|
+
])).optional(),
|
|
125
|
+
urgency: z.enum([
|
|
126
|
+
'high',
|
|
127
|
+
'low'
|
|
128
|
+
]).optional(),
|
|
84
129
|
since: z.string().optional(),
|
|
85
130
|
until: z.string().optional(),
|
|
86
131
|
limit: z.number().int().default(25),
|
|
87
|
-
offset: z.number().int().default(0)
|
|
132
|
+
offset: z.number().int().default(0)
|
|
88
133
|
});
|
|
89
|
-
const listIncidentsOutput = z
|
|
90
|
-
.object({
|
|
134
|
+
const listIncidentsOutput = z.object({
|
|
91
135
|
incidents: z.array(incident),
|
|
92
136
|
limit: z.number().optional(),
|
|
93
137
|
offset: z.number().optional(),
|
|
94
|
-
more: z.boolean().optional()
|
|
95
|
-
})
|
|
96
|
-
.passthrough();
|
|
138
|
+
more: z.boolean().optional()
|
|
139
|
+
}).passthrough();
|
|
97
140
|
export const listIncidents = defineAction({
|
|
98
141
|
slug: 'listIncidents',
|
|
99
142
|
description: 'List PagerDuty incidents with optional filters and pagination.',
|
|
100
143
|
input: listIncidentsInput,
|
|
101
144
|
output: listIncidentsOutput,
|
|
102
145
|
idempotent: true,
|
|
103
|
-
async run({ input, client }) {
|
|
146
|
+
async run ({ input, client }) {
|
|
104
147
|
const response = await client.request({
|
|
105
148
|
method: 'GET',
|
|
106
149
|
path: '/incidents',
|
|
107
150
|
query: {
|
|
108
151
|
'statuses[]': input.statuses,
|
|
109
|
-
'urgencies[]': input.urgency ? [
|
|
152
|
+
'urgencies[]': input.urgency ? [
|
|
153
|
+
input.urgency
|
|
154
|
+
] : undefined,
|
|
110
155
|
since: input.since,
|
|
111
156
|
until: input.until,
|
|
112
157
|
limit: String(Math.max(1, Math.min(100, input.limit))),
|
|
113
|
-
offset: String(Math.max(0, input.offset))
|
|
114
|
-
}
|
|
158
|
+
offset: String(Math.max(0, input.offset))
|
|
159
|
+
}
|
|
115
160
|
});
|
|
116
161
|
return listIncidentsOutput.parse(response);
|
|
117
|
-
}
|
|
162
|
+
}
|
|
118
163
|
});
|
|
119
164
|
function updateIncident(slug, status) {
|
|
120
165
|
const input = z.object({
|
|
121
166
|
incidentId,
|
|
122
167
|
fromEmail,
|
|
123
|
-
...
|
|
168
|
+
...status === 'resolved' ? {
|
|
169
|
+
resolution: z.string().optional()
|
|
170
|
+
} : {}
|
|
124
171
|
});
|
|
125
172
|
return defineAction({
|
|
126
173
|
slug,
|
|
@@ -128,7 +175,7 @@ function updateIncident(slug, status) {
|
|
|
128
175
|
input,
|
|
129
176
|
output: incidentOutput,
|
|
130
177
|
idempotent: true,
|
|
131
|
-
async run({ input: values, client }) {
|
|
178
|
+
async run ({ input: values, client }) {
|
|
132
179
|
const resolution = 'resolution' in values ? values.resolution : undefined;
|
|
133
180
|
const response = incidentResponse.parse(await client.request({
|
|
134
181
|
method: 'PUT',
|
|
@@ -138,36 +185,52 @@ function updateIncident(slug, status) {
|
|
|
138
185
|
incident: {
|
|
139
186
|
type: 'incident',
|
|
140
187
|
status,
|
|
141
|
-
...
|
|
142
|
-
|
|
143
|
-
|
|
188
|
+
...resolution ? {
|
|
189
|
+
body: {
|
|
190
|
+
type: 'incident_body',
|
|
191
|
+
details: resolution
|
|
192
|
+
}
|
|
193
|
+
} : {}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
144
196
|
}));
|
|
145
197
|
return response.incident;
|
|
146
|
-
}
|
|
198
|
+
}
|
|
147
199
|
});
|
|
148
200
|
}
|
|
149
|
-
const getIncidentInput = z.object({
|
|
201
|
+
const getIncidentInput = z.object({
|
|
202
|
+
incidentId
|
|
203
|
+
});
|
|
150
204
|
export const getIncident = defineAction({
|
|
151
205
|
slug: 'getIncident',
|
|
152
206
|
description: 'Get a PagerDuty incident by ID.',
|
|
153
207
|
input: getIncidentInput,
|
|
154
208
|
output: incidentOutput,
|
|
155
209
|
idempotent: true,
|
|
156
|
-
async run({ input, client }) {
|
|
210
|
+
async run ({ input, client }) {
|
|
157
211
|
const response = incidentResponse.parse(await client.request({
|
|
158
212
|
method: 'GET',
|
|
159
|
-
path: `/incidents/${encodeURIComponent(input.incidentId)}
|
|
213
|
+
path: `/incidents/${encodeURIComponent(input.incidentId)}`
|
|
160
214
|
}));
|
|
161
215
|
return response.incident;
|
|
162
|
-
}
|
|
216
|
+
}
|
|
163
217
|
});
|
|
164
218
|
export const acknowledgeIncident = updateIncident('acknowledgeIncident', 'acknowledged');
|
|
165
219
|
export const resolveIncident = updateIncident('resolveIncident', 'resolved');
|
|
166
220
|
const customApiCallInput = z.object({
|
|
167
|
-
method: z.enum([
|
|
221
|
+
method: z.enum([
|
|
222
|
+
'GET',
|
|
223
|
+
'POST',
|
|
224
|
+
'PATCH',
|
|
225
|
+
'PUT',
|
|
226
|
+
'DELETE'
|
|
227
|
+
]),
|
|
168
228
|
path: z.string().startsWith('/'),
|
|
169
|
-
queryParams: z.record(z.string(), z.union([
|
|
170
|
-
|
|
229
|
+
queryParams: z.record(z.string(), z.union([
|
|
230
|
+
z.string(),
|
|
231
|
+
z.array(z.string())
|
|
232
|
+
])).default({}),
|
|
233
|
+
body: z.json().optional()
|
|
171
234
|
});
|
|
172
235
|
const customApiCallOutput = z.json();
|
|
173
236
|
export const customApiCall = defineAction({
|
|
@@ -175,14 +238,15 @@ export const customApiCall = defineAction({
|
|
|
175
238
|
description: 'Make a custom PagerDuty REST API v2 call.',
|
|
176
239
|
input: customApiCallInput,
|
|
177
240
|
output: customApiCallOutput,
|
|
178
|
-
async run({ input, client }) {
|
|
241
|
+
async run ({ input, client }) {
|
|
179
242
|
const response = await client.request({
|
|
180
243
|
method: input.method,
|
|
181
244
|
path: input.path,
|
|
182
245
|
query: input.queryParams,
|
|
183
|
-
body: input.body
|
|
246
|
+
body: input.body
|
|
184
247
|
});
|
|
185
248
|
return customApiCallOutput.parse(response);
|
|
186
|
-
}
|
|
249
|
+
}
|
|
187
250
|
});
|
|
251
|
+
|
|
188
252
|
//# sourceMappingURL=actions.js.map
|
package/dist/actions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/actions.ts"],"names":["z","defineAction","incident","object","id","string","status","optional","passthrough","incidentOutput","incidentResponse","servicesResponse","services","array","name","more","boolean","fromEmail","email","meta","label","incidentId","min","createIncidentInput","serviceId","title","urgency","enum","default","details","incidentKey","assigneeIds","priorityId","conferenceNumber","conferenceUrl","url","createIncident","slug","description","input","output","idempotent","options","client","offset","response","parse","request","method","path","query","limit","String","push","map","value","run","payload","type","service","body","incident_key","length","assignments","assignee","priority","conference_bridge","conference_number","conference_url","listIncidentsInput","statuses","since","until","number","int","listIncidentsOutput","incidents","listIncidents","undefined","Math","max","updateIncident","resolution","values","encodeURIComponent","getIncidentInput","getIncident","acknowledgeIncident","resolveIncident","customApiCallInput","startsWith","queryParams","record","union","json","customApiCallOutput","customApiCall"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAM;AAExB,SAASC,YAAY,QAAQ,cAAc;AAE3C,MAAMC,WAAWF,EAAEG,MAAM,CAAC;IAAEC,IAAIJ,EAAEK,MAAM;IAAIC,QAAQN,EAAEK,MAAM,GAAGE,QAAQ;AAAG,GAAGC,WAAW;AACxF,MAAMC,iBAAiBP;AACvB,MAAMQ,mBAAmBV,EAAEG,MAAM,CAAC;IAAED,UAAUO;AAAe;AAC7D,MAAME,mBAAmBX,EAAEG,MAAM,CAAC;IAChCS,UAAUZ,EAAEa,KAAK,CAACb,EAAEG,MAAM,CAAC;QAAEC,IAAIJ,EAAEK,MAAM;QAAIS,MAAMd,EAAEK,MAAM;IAAG;IAC9DU,MAAMf,EAAEgB,OAA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
2
2
|
const baseUrl = 'https://api.pagerduty.com';
|
|
3
3
|
export function createPagerdutyClient({ auth }) {
|
|
4
4
|
const { apiKey } = pagerdutyAuth.parse(auth);
|
|
5
|
-
async function request({ method, path, query, body, fromEmail
|
|
5
|
+
async function request({ method, path, query, body, fromEmail }) {
|
|
6
6
|
const url = new URL(path, baseUrl);
|
|
7
7
|
if (url.origin !== baseUrl || !path.startsWith('/') || path.startsWith('//')) {
|
|
8
8
|
throw new Error('Path must target the PagerDuty API.');
|
|
9
9
|
}
|
|
10
|
-
Object.entries(query ?? {}).forEach(([key, value])
|
|
11
|
-
if (value === undefined || value === '')
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
Object.entries(query ?? {}).forEach(([key, value])=>{
|
|
11
|
+
if (value === undefined || value === '') return;
|
|
12
|
+
for (const item of Array.isArray(value) ? value : [
|
|
13
|
+
value
|
|
14
|
+
]){
|
|
14
15
|
url.searchParams.append(key, item);
|
|
15
16
|
}
|
|
16
17
|
});
|
|
@@ -20,9 +21,11 @@ export function createPagerdutyClient({ auth }) {
|
|
|
20
21
|
Authorization: `Token token=${apiKey}`,
|
|
21
22
|
Accept: 'application/vnd.pagerduty+json;version=2',
|
|
22
23
|
'Content-Type': 'application/json',
|
|
23
|
-
...
|
|
24
|
+
...fromEmail ? {
|
|
25
|
+
From: fromEmail
|
|
26
|
+
} : {}
|
|
24
27
|
},
|
|
25
|
-
body: body === undefined ? undefined : JSON.stringify(body)
|
|
28
|
+
body: body === undefined ? undefined : JSON.stringify(body)
|
|
26
29
|
});
|
|
27
30
|
const text = await response.text();
|
|
28
31
|
const data = text ? JSON.parse(text) : undefined;
|
|
@@ -31,6 +34,9 @@ export function createPagerdutyClient({ auth }) {
|
|
|
31
34
|
}
|
|
32
35
|
return data;
|
|
33
36
|
}
|
|
34
|
-
return {
|
|
37
|
+
return {
|
|
38
|
+
request
|
|
39
|
+
};
|
|
35
40
|
}
|
|
41
|
+
|
|
36
42
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/client.ts"],"names":["pagerdutyAuth","baseUrl","createPagerdutyClient","auth","apiKey","parse","request","method","path","query","body","fromEmail","url","URL","origin","startsWith","Error","Object","entries","forEach","key","value","undefined","item","Array","isArray","searchParams","append","response","fetch","headers","Authorization","Accept","From","JSON","stringify","text","data","ok","status","statusText"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAc;AAE5C,MAAMC,UAAU;AAMhB,OAAO,SAASC,sBAAsB,EAAEC,IAAI,EAAqB;IAC/D,MAAM,EAAEC,MAAM,EAAE,GAAGJ,cAAcK,KAAK,CAACF;IAEvC,eAAeG,QAAQ,EACrBC,MAAM,EACNC,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,SAAS,EAOV;QACC,MAAMC,MAAM,IAAIC,IAAIL,MAAMP;QAE1B,IAAIW,IAAIE,MAAM,KAAKb,WAAW,CAACO,KAAKO,UAAU,CAAC,QAAQP,KAAKO,UAAU,CAAC,OAAO;YAC5E,MAAM,IAAIC,MAAM;QAClB;QAEAC,OAAOC,OAAO,CAACT,SAAS,CAAC,GAAGU,OAAO,CAAC,CAAC,CAACC,KAAKC,MAAM;YAC/C,IAAIA,UAAUC,aAAaD,UAAU,IAAI;YAEzC,KAAK,MAAME,QAAQC,MAAMC,OAAO,CAACJ,SAASA,QAAQ;gBAACA;aAAM,CAAE;gBACzDT,IAAIc,YAAY,CAACC,MAAM,CAACP,KAAKG;YAC/B;QACF;QAEA,MAAMK,WAAW,MAAMC,MAAMjB,KAAK;YAChCL;YACAuB,SAAS;gBACPC,eAAe,CAAC,YAAY,EAAE3B,QAAQ;gBACtC4B,QAAQ;gBACR,gBAAgB;gBAChB,GAAIrB,YAAY;oBAAEsB,MAAMtB;gBAAU,IAAI,CAAC,CAAC;YAC1C;YACAD,MAAMA,SAASY,YAAYA,YAAYY,KAAKC,SAAS,CAACzB;QACxD;QACA,MAAM0B,OAAO,MAAMR,SAASQ,IAAI;QAChC,MAAMC,OAAOD,OAAQF,KAAK7B,KAAK,CAAC+B,QAAoBd;QAEpD,IAAI,CAACM,SAASU,EAAE,EAAE;YAChB,MAAM,IAAItB,MACR,CAAC,8BAA8B,EAAEY,SAASW,MAAM,CAAC,EAAE,EAAEH,QAAQR,SAASY,UAAU,EAAE;QAEtF;QAEA,OAAOH;IACT;IAEA,OAAO;QAAE/B;IAAQ;AACnB","file":"client.js"}
|
package/dist/config.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export const pagerdutyAuth = z.object({
|
|
3
|
-
apiKey: z.string().min(1).meta({
|
|
3
|
+
apiKey: z.string().min(1).meta({
|
|
4
|
+
label: 'API key',
|
|
5
|
+
secret: true
|
|
6
|
+
})
|
|
4
7
|
});
|
|
5
8
|
export const pagerdutyOptions = z.object({
|
|
6
|
-
signingSecret: z
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
.optional(),
|
|
9
|
+
signingSecret: z.string().min(1).meta({
|
|
10
|
+
label: 'Webhook signing secret',
|
|
11
|
+
secret: true
|
|
12
|
+
}).optional()
|
|
11
13
|
});
|
|
14
|
+
|
|
12
15
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/config.ts"],"names":["z","pagerdutyAuth","object","apiKey","string","min","meta","label","secret","pagerdutyOptions","signingSecret","optional"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAM;AAExB,OAAO,MAAMC,gBAAgBD,EAAEE,MAAM,CAAC;IACpCC,QAAQH,EAAEI,MAAM,GAAGC,GAAG,CAAC,GAAGC,IAAI,CAAC;QAAEC,OAAO;QAAWC,QAAQ;IAAK;AAClE,GAAG;AAEH,OAAO,MAAMC,mBAAmBT,EAAEE,MAAM,CAAC;IACvCQ,eAAeV,EACZI,MAAM,GACNC,GAAG,CAAC,GACJC,IAAI,CAAC;QAAEC,OAAO;QAA0BC,QAAQ;IAAK,GACrDG,QAAQ;AACb,GAAG","file":"config.js"}
|
package/dist/define.js
CHANGED
package/dist/define.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/define.ts"],"names":["createPieceHelpers","defineAction","defineWebhookTrigger"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,iBAAiB;AAKpD,OAAO,MAAM,EAAEC,YAAY,EAAEC,oBAAoB,EAAE,GAAGF,qBAGlD","file":"define.js"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { definePiece } from 'frogbot/pieces';
|
|
2
|
-
import { acknowledgeIncident, createIncident, customApiCall, getIncident, listIncidents, resolveIncident
|
|
2
|
+
import { acknowledgeIncident, createIncident, customApiCall, getIncident, listIncidents, resolveIncident } from './actions.js';
|
|
3
3
|
import { createPagerdutyClient } from './client.js';
|
|
4
4
|
import { pagerdutyAuth, pagerdutyOptions } from './config.js';
|
|
5
5
|
import { incidentAcknowledged, incidentResolved, newIncident } from './triggers.js';
|
|
@@ -10,12 +10,12 @@ export const pagerdutyActions = [
|
|
|
10
10
|
'getIncident',
|
|
11
11
|
'acknowledgeIncident',
|
|
12
12
|
'resolveIncident',
|
|
13
|
-
'customApiCall'
|
|
13
|
+
'customApiCall'
|
|
14
14
|
];
|
|
15
15
|
export const pagerdutyTriggers = [
|
|
16
16
|
'newIncident',
|
|
17
17
|
'incidentResolved',
|
|
18
|
-
'incidentAcknowledged'
|
|
18
|
+
'incidentAcknowledged'
|
|
19
19
|
];
|
|
20
20
|
export const pagerdutyScopes = [];
|
|
21
21
|
export const createPagerduty = definePiece({
|
|
@@ -23,7 +23,7 @@ export const createPagerduty = definePiece({
|
|
|
23
23
|
label: 'PagerDuty',
|
|
24
24
|
admin: {
|
|
25
25
|
description: 'Manage PagerDuty incidents and receive incident events',
|
|
26
|
-
group: 'Developer Tools'
|
|
26
|
+
group: 'Developer Tools'
|
|
27
27
|
},
|
|
28
28
|
auth: pagerdutyAuth,
|
|
29
29
|
options: pagerdutyOptions,
|
|
@@ -34,9 +34,14 @@ export const createPagerduty = definePiece({
|
|
|
34
34
|
getIncident,
|
|
35
35
|
acknowledgeIncident,
|
|
36
36
|
resolveIncident,
|
|
37
|
-
customApiCall
|
|
37
|
+
customApiCall
|
|
38
38
|
],
|
|
39
|
-
triggers: [
|
|
40
|
-
|
|
39
|
+
triggers: [
|
|
40
|
+
newIncident,
|
|
41
|
+
incidentResolved,
|
|
42
|
+
incidentAcknowledged
|
|
43
|
+
],
|
|
44
|
+
webhook: pagerdutyWebhook
|
|
41
45
|
});
|
|
46
|
+
|
|
42
47
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["definePiece","acknowledgeIncident","createIncident","customApiCall","getIncident","listIncidents","resolveIncident","createPagerdutyClient","pagerdutyAuth","pagerdutyOptions","incidentAcknowledged","incidentResolved","newIncident","pagerdutyWebhook","pagerdutyActions","pagerdutyTriggers","pagerdutyScopes","createPagerduty","slug","label","admin","description","group","auth","options","client","actions","triggers","webhook"],"mappings":"AAAA,SAASA,WAAW,QAAQ,iBAAiB;AAE7C,SACEC,mBAAmB,EACnBC,cAAc,EACdC,aAAa,EACbC,WAAW,EACXC,aAAa,EACbC,eAAe,QACV,eAAe;AACtB,SAASC,qBAAqB,QAAQ,cAAc;AACpD,SAASC,aAAa,EAAEC,gBAAgB,QAAQ,cAAc;AAC9D,SAASC,oBAAoB,EAAEC,gBAAgB,EAAEC,WAAW,QAAQ,gBAAgB;AACpF,SAASC,gBAAgB,QAAQ,eAAe;AAEhD,OAAO,MAAMC,mBAAmB;IAC9B;IACA;IACA;IACA;IACA;IACA;CACD,CAAU;AACX,OAAO,MAAMC,oBAAoB;IAC/B;IACA;IACA;CACD,CAAU;AACX,OAAO,MAAMC,kBAAkB,EAAE,CAAU;AAE3C,OAAO,MAAMC,kBAAkBjB,YAAY;IACzCkB,MAAM;IACNC,OAAO;IACPC,OAAO;QACLC,aAAa;QACbC,OAAO;IACT;IACAC,MAAMf;IACNgB,SAASf;IACTgB,QAAQlB;IACRmB,SAAS;QACPxB;QACAG;QACAD;QACAH;QACAK;QACAH;KACD;IACDwB,UAAU;QAACf;QAAaD;QAAkBD;KAAqB;IAC/DkB,SAASf;AACX,GAAG","file":"index.js"}
|
package/dist/triggers.js
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { defineWebhookTrigger } from './define.js';
|
|
3
3
|
const input = z.object({});
|
|
4
|
-
const output = z
|
|
5
|
-
.object({
|
|
6
|
-
event: z
|
|
7
|
-
.object({
|
|
4
|
+
const output = z.object({
|
|
5
|
+
event: z.object({
|
|
8
6
|
id: z.string(),
|
|
9
|
-
event_type: z.string()
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
})
|
|
13
|
-
.passthrough();
|
|
14
|
-
function manualTrigger({ slug, label, description, eventType, }) {
|
|
7
|
+
event_type: z.string()
|
|
8
|
+
}).passthrough()
|
|
9
|
+
}).passthrough();
|
|
10
|
+
function manualTrigger({ slug, label, description, eventType }) {
|
|
15
11
|
return defineWebhookTrigger({
|
|
16
12
|
slug,
|
|
17
13
|
label,
|
|
@@ -19,35 +15,43 @@ function manualTrigger({ slug, label, description, eventType, }) {
|
|
|
19
15
|
type: 'webhook',
|
|
20
16
|
input,
|
|
21
17
|
output,
|
|
22
|
-
async onEnable({ webhookUrl }) {
|
|
23
|
-
return {
|
|
18
|
+
async onEnable ({ webhookUrl }) {
|
|
19
|
+
return {
|
|
20
|
+
webhookUrl
|
|
21
|
+
};
|
|
24
22
|
},
|
|
25
|
-
async onDisable() {
|
|
26
|
-
async run({ req, state }) {
|
|
23
|
+
async onDisable () {},
|
|
24
|
+
async run ({ req, state }) {
|
|
27
25
|
const delivery = output.safeParse(req.data);
|
|
28
26
|
if (!state.webhookUrl || !delivery.success || delivery.data.event.event_type !== eventType) {
|
|
29
27
|
return [];
|
|
30
28
|
}
|
|
31
|
-
return [
|
|
32
|
-
|
|
29
|
+
return [
|
|
30
|
+
{
|
|
31
|
+
data: delivery.data,
|
|
32
|
+
dedupeKey: delivery.data.event.id
|
|
33
|
+
}
|
|
34
|
+
];
|
|
35
|
+
}
|
|
33
36
|
});
|
|
34
37
|
}
|
|
35
38
|
export const newIncident = manualTrigger({
|
|
36
39
|
slug: 'newIncident',
|
|
37
40
|
label: 'New Incident',
|
|
38
41
|
description: 'Triggers when a new incident is created.',
|
|
39
|
-
eventType: 'incident.triggered'
|
|
42
|
+
eventType: 'incident.triggered'
|
|
40
43
|
});
|
|
41
44
|
export const incidentResolved = manualTrigger({
|
|
42
45
|
slug: 'incidentResolved',
|
|
43
46
|
label: 'Incident Resolved',
|
|
44
47
|
description: 'Triggers when an incident is resolved.',
|
|
45
|
-
eventType: 'incident.resolved'
|
|
48
|
+
eventType: 'incident.resolved'
|
|
46
49
|
});
|
|
47
50
|
export const incidentAcknowledged = manualTrigger({
|
|
48
51
|
slug: 'incidentAcknowledged',
|
|
49
52
|
label: 'Incident Acknowledged',
|
|
50
53
|
description: 'Triggers when an incident is acknowledged.',
|
|
51
|
-
eventType: 'incident.acknowledged'
|
|
54
|
+
eventType: 'incident.acknowledged'
|
|
52
55
|
});
|
|
56
|
+
|
|
53
57
|
//# sourceMappingURL=triggers.js.map
|
package/dist/triggers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/triggers.ts"],"names":["z","defineWebhookTrigger","input","object","output","event","id","string","event_type","passthrough","manualTrigger","slug","label","description","eventType","type","onEnable","webhookUrl","onDisable","run","req","state","delivery","safeParse","data","success","dedupeKey","newIncident","incidentResolved","incidentAcknowledged"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAM;AAExB,SAASC,oBAAoB,QAAQ,cAAc;AAEnD,MAAMC,QAAQF,EAAEG,MAAM,CAAC,CAAC;AACxB,MAAMC,SAASJ,EACZG,MAAM,CAAC;IACNE,OAAOL,EACJG,MAAM,CAAC;QACNG,IAAIN,EAAEO,MAAM;QACZC,YAAYR,EAAEO,MAAM;IACtB,GACCE,WAAW;AAChB,GACCA,WAAW;AAEd,SAASC,cAA0C,EACjDC,IAAI,EACJC,KAAK,EACLC,WAAW,EACXC,SAAS,EAMV;IACC,OAAOb,qBAAqB;QAC1BU;QACAC;QACAC;QACAE,MAAM;QACNb;QACAE;QACA,MAAMY,UAAS,EAAEC,UAAU,EAAE;YAC3B,OAAO;gBAAEA;YAAW;QACtB;QACA,MAAMC,cAAa;QACnB,MAAMC,KAAI,EAAEC,GAAG,EAAEC,KAAK,EAAE;YACtB,MAAMC,WAAWlB,OAAOmB,SAAS,CAACH,IAAII,IAAI;YAE1C,IAAI,CAACH,MAAMJ,UAAU,IAAI,CAACK,SAASG,OAAO,IAAIH,SAASE,IAAI,CAACnB,KAAK,CAACG,UAAU,KAAKM,WAAW;gBAC1F,OAAO,EAAE;YACX;YAEA,OAAO;gBAAC;oBAAEU,MAAMF,SAASE,IAAI;oBAAEE,WAAWJ,SAASE,IAAI,CAACnB,KAAK,CAACC,EAAE;gBAAC;aAAE;QACrE;IACF;AACF;AAEA,OAAO,MAAMqB,cAAcjB,cAAc;IACvCC,MAAM;IACNC,OAAO;IACPC,aAAa;IACbC,WAAW;AACb,GAAG;AAEH,OAAO,MAAMc,mBAAmBlB,cAAc;IAC5CC,MAAM;IACNC,OAAO;IACPC,aAAa;IACbC,WAAW;AACb,GAAG;AAEH,OAAO,MAAMe,uBAAuBnB,cAAc;IAChDC,MAAM;IACNC,OAAO;IACPC,aAAa;IACbC,WAAW;AACb,GAAG","file":"triggers.js"}
|
package/dist/webhook.js
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
import { createHmac, timingSafeEqual } from 'node:crypto';
|
|
2
2
|
export const pagerdutyWebhook = {
|
|
3
|
-
async verify({ req, options }) {
|
|
3
|
+
async verify ({ req, options }) {
|
|
4
4
|
const header = req.headers.get('x-pagerduty-signature');
|
|
5
|
-
if (!options.signingSecret || !header || !req.arrayBuffer)
|
|
6
|
-
return false;
|
|
5
|
+
if (!options.signingSecret || !header || !req.arrayBuffer) return false;
|
|
7
6
|
try {
|
|
8
7
|
const body = Buffer.from(await req.arrayBuffer());
|
|
9
|
-
if (body.length === 0)
|
|
10
|
-
return false;
|
|
8
|
+
if (body.length === 0) return false;
|
|
11
9
|
const expected = createHmac('sha256', options.signingSecret).update(body).digest();
|
|
12
|
-
return header.split(',').some((value)
|
|
10
|
+
return header.split(',').some((value)=>{
|
|
13
11
|
const signature = value.trim();
|
|
14
|
-
if (!signature.startsWith('v1='))
|
|
15
|
-
return false;
|
|
12
|
+
if (!signature.startsWith('v1=')) return false;
|
|
16
13
|
const actual = Buffer.from(signature.slice(3), 'hex');
|
|
17
14
|
return actual.length === expected.length && timingSafeEqual(actual, expected);
|
|
18
15
|
});
|
|
19
|
-
}
|
|
20
|
-
catch {
|
|
16
|
+
} catch {
|
|
21
17
|
return false;
|
|
22
18
|
}
|
|
23
|
-
}
|
|
19
|
+
}
|
|
24
20
|
};
|
|
21
|
+
|
|
25
22
|
//# sourceMappingURL=webhook.js.map
|
package/dist/webhook.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/webhook.ts"],"names":["createHmac","timingSafeEqual","pagerdutyWebhook","verify","req","options","header","headers","get","signingSecret","arrayBuffer","body","Buffer","from","length","expected","update","digest","split","some","value","signature","trim","startsWith","actual","slice"],"mappings":"AAAA,SAASA,UAAU,EAAEC,eAAe,QAAQ,cAAc;AAM1D,OAAO,MAAMC,mBAAmD;IAC9D,MAAMC,QAAO,EAAEC,GAAG,EAAEC,OAAO,EAAE;QAC3B,MAAMC,SAASF,IAAIG,OAAO,CAACC,GAAG,CAAC;QAE/B,IAAI,CAACH,QAAQI,aAAa,IAAI,CAACH,UAAU,CAACF,IAAIM,WAAW,EAAE,OAAO;QAElE,IAAI;YACF,MAAMC,OAAOC,OAAOC,IAAI,CAAC,MAAMT,IAAIM,WAAW;YAE9C,IAAIC,KAAKG,MAAM,KAAK,GAAG,OAAO;YAE9B,MAAMC,WAAWf,WAAW,UAAUK,QAAQI,aAAa,EAAEO,MAAM,CAACL,MAAMM,MAAM;YAEhF,OAAOX,OAAOY,KAAK,CAAC,KAAKC,IAAI,CAAC,CAACC;gBAC7B,MAAMC,YAAYD,MAAME,IAAI;gBAE5B,IAAI,CAACD,UAAUE,UAAU,CAAC,QAAQ,OAAO;gBAEzC,MAAMC,SAASZ,OAAOC,IAAI,CAACQ,UAAUI,KAAK,CAAC,IAAI;gBAE/C,OAAOD,OAAOV,MAAM,KAAKC,SAASD,MAAM,IAAIb,gBAAgBuB,QAAQT;YACtE;QACF,EAAE,OAAM;YACN,OAAO;QACT;IACF;AACF,EAAE","file":"webhook.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frogbotai/piece-pagerduty",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.0",
|
|
4
4
|
"description": "pagerduty tools for FrogBot.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Colby Gilbert",
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"zod": "^4.3.6"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"frogbot": "0.
|
|
25
|
+
"frogbot": "0.30.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"typescript": "5.6.2",
|
|
29
|
-
"frogbot": "0.
|
|
29
|
+
"frogbot": "0.30.0"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
|
-
"build": "
|
|
35
|
+
"build": "node ../../../scripts/build-package.mjs",
|
|
36
36
|
"clean": "rm -rf dist",
|
|
37
37
|
"typecheck": "tsc --noEmit"
|
|
38
38
|
}
|