@frogbotai/piece-linear 0.29.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/createComment.js +23 -7
- package/dist/actions/createComment.js.map +1 -1
- package/dist/actions/createIssue.js +12 -6
- package/dist/actions/createIssue.js.map +1 -1
- package/dist/actions/createProject.js +20 -7
- package/dist/actions/createProject.js.map +1 -1
- package/dist/actions/options.js +35 -18
- package/dist/actions/options.js.map +1 -1
- package/dist/actions/rawGraphqlQuery.js +4 -3
- package/dist/actions/rawGraphqlQuery.js.map +1 -1
- package/dist/actions/updateIssue.js +12 -6
- package/dist/actions/updateIssue.js.map +1 -1
- package/dist/actions/updateProject.js +21 -7
- package/dist/actions/updateProject.js.map +1 -1
- package/dist/adapter.js +6 -3
- package/dist/adapter.js.map +1 -1
- package/dist/client.js +6 -3
- package/dist/client.js.map +1 -1
- package/dist/config.js +29 -17
- package/dist/config.js.map +1 -1
- package/dist/define.js +1 -0
- package/dist/define.js.map +1 -1
- package/dist/index.js +55 -23
- package/dist/index.js.map +1 -1
- package/dist/questions/elicitation.js +45 -34
- package/dist/questions/elicitation.js.map +1 -1
- package/dist/questions/index.js +2 -1
- package/dist/questions/index.js.map +1 -1
- package/dist/questions/linearThread.js +8 -6
- package/dist/questions/linearThread.js.map +1 -1
- package/dist/questions/notify.js +23 -10
- package/dist/questions/notify.js.map +1 -1
- package/dist/questions/parse.js +118 -61
- package/dist/questions/parse.js.map +1 -1
- package/dist/questions/render.js +23 -5
- package/dist/questions/render.js.map +1 -1
- package/dist/questions/settled.js +4 -4
- package/dist/questions/settled.js.map +1 -1
- package/dist/questions/supports.js +2 -1
- package/dist/questions/supports.js.map +1 -1
- package/dist/triggers/commentCreated.js +3 -6
- package/dist/triggers/commentCreated.js.map +1 -1
- package/dist/triggers/issueCreated.js +4 -1
- package/dist/triggers/issueCreated.js.map +1 -1
- package/dist/triggers/issueRemoved.js +4 -1
- package/dist/triggers/issueRemoved.js.map +1 -1
- package/dist/triggers/issueUpdated.js +4 -1
- package/dist/triggers/issueUpdated.js.map +1 -1
- package/dist/triggers/projectCreated.js +2 -1
- package/dist/triggers/projectCreated.js.map +1 -1
- package/dist/triggers/projectRemoved.js +2 -1
- package/dist/triggers/projectRemoved.js.map +1 -1
- package/dist/triggers/projectUpdated.js +3 -4
- package/dist/triggers/projectUpdated.js.map +1 -1
- package/dist/triggers/webhook.js +24 -24
- package/dist/triggers/webhook.js.map +1 -1
- package/dist/webhook.js +11 -17
- package/dist/webhook.js.map +1 -1
- package/package.json +4 -4
package/dist/questions/parse.js
CHANGED
|
@@ -4,106 +4,163 @@ const NUMBER_LIST = /^\d+(?:[\s,]+\d+)+$/;
|
|
|
4
4
|
const OPTION_NUMBER = /^(\d+)[.)]?$/;
|
|
5
5
|
const LIST_MARKER = /^(?:[-*+]|\d+[.)])\s+/;
|
|
6
6
|
const MARKDOWN_ESCAPE = /\\([!-/:-@[-`{-~])/g;
|
|
7
|
-
export const parseLinearQuestion = ({ call, interaction, question, settled
|
|
8
|
-
if (interaction.type !== 'message')
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
export const parseLinearQuestion = ({ call, interaction, question, settled })=>{
|
|
8
|
+
if (interaction.type !== 'message') return {
|
|
9
|
+
kind: 'ignore'
|
|
10
|
+
};
|
|
11
|
+
if (stopRequested(interaction)) return {
|
|
12
|
+
kind: 'dismiss'
|
|
13
|
+
};
|
|
12
14
|
const { metadata, text } = interaction.message;
|
|
13
|
-
const result = parseReply({
|
|
15
|
+
const result = parseReply({
|
|
16
|
+
input: call.input,
|
|
17
|
+
text
|
|
18
|
+
});
|
|
14
19
|
const early = new Date(metadata.dateSent).getTime() < new Date(question.messages.at(-1).postedAt).getTime();
|
|
15
20
|
if (settled || early) {
|
|
16
|
-
return result.kind === 'answer' && result.explicit ? {
|
|
21
|
+
return result.kind === 'answer' && result.explicit ? {
|
|
22
|
+
kind: 'stale'
|
|
23
|
+
} : {
|
|
24
|
+
kind: 'ignore'
|
|
25
|
+
};
|
|
17
26
|
}
|
|
18
|
-
return result.kind === 'answer' ? {
|
|
27
|
+
return result.kind === 'answer' ? {
|
|
28
|
+
kind: 'answer',
|
|
29
|
+
output: result.output
|
|
30
|
+
} : result;
|
|
19
31
|
};
|
|
20
32
|
function parseReply({ input, text }) {
|
|
21
33
|
const { questions } = input;
|
|
22
34
|
const numbered = !isSelectQuestion(input);
|
|
23
|
-
const lines = questions.length === 1
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
.split(/\r?\n/)
|
|
27
|
-
.map((line) => line.trim())
|
|
28
|
-
.filter(Boolean);
|
|
35
|
+
const lines = questions.length === 1 ? [
|
|
36
|
+
text.trim()
|
|
37
|
+
] : text.split(/\r?\n/).map((line)=>line.trim()).filter(Boolean);
|
|
29
38
|
if (lines.length !== questions.length) {
|
|
30
39
|
return {
|
|
31
40
|
kind: 'rejected',
|
|
32
|
-
reason: `Answer each of the ${questions.length} questions on its own line, in the order shown
|
|
41
|
+
reason: `Answer each of the ${questions.length} questions on its own line, in the order shown.`
|
|
33
42
|
};
|
|
34
43
|
}
|
|
35
|
-
const results = questions.map((item, index)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
const results = questions.map((item, index)=>parseLine({
|
|
45
|
+
item,
|
|
46
|
+
line: lines[index],
|
|
47
|
+
numbered,
|
|
48
|
+
unmarkCustom: questions.length > 1
|
|
49
|
+
}));
|
|
50
|
+
const failure = results.find((result)=>'reason' in result);
|
|
51
|
+
if (failure) return {
|
|
52
|
+
kind: 'rejected',
|
|
53
|
+
reason: failure.reason
|
|
54
|
+
};
|
|
55
|
+
const answers = results.map((result)=>result.answer);
|
|
40
56
|
return {
|
|
41
57
|
kind: 'answer',
|
|
42
|
-
output: {
|
|
43
|
-
|
|
58
|
+
output: {
|
|
59
|
+
answers
|
|
60
|
+
},
|
|
61
|
+
explicit: answers.every(({ custom })=>custom === undefined)
|
|
44
62
|
};
|
|
45
63
|
}
|
|
46
|
-
function parseLine({ item, line, numbered, unmarkCustom
|
|
64
|
+
function parseLine({ item, line, numbered, unmarkCustom }) {
|
|
47
65
|
const unmarked = line.replace(LIST_MARKER, '');
|
|
48
|
-
const selected = line
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
66
|
+
const selected = line ? selectOptions({
|
|
67
|
+
item,
|
|
68
|
+
line,
|
|
69
|
+
numbered
|
|
70
|
+
}) ?? (unmarked !== line ? selectOptions({
|
|
71
|
+
item,
|
|
72
|
+
line: unmarked,
|
|
73
|
+
numbered
|
|
74
|
+
}) : undefined) : undefined;
|
|
75
|
+
if (selected) return {
|
|
76
|
+
answer: {
|
|
77
|
+
header: item.header,
|
|
78
|
+
selected
|
|
79
|
+
}
|
|
80
|
+
};
|
|
54
81
|
const custom = unmarkCustom ? unmarked : line;
|
|
55
|
-
if (custom && item.custom)
|
|
56
|
-
|
|
57
|
-
|
|
82
|
+
if (custom && item.custom) return {
|
|
83
|
+
answer: {
|
|
84
|
+
header: item.header,
|
|
85
|
+
selected: [],
|
|
86
|
+
custom
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
return {
|
|
90
|
+
reason: replyHint({
|
|
91
|
+
item,
|
|
92
|
+
numbered
|
|
93
|
+
})
|
|
94
|
+
};
|
|
58
95
|
}
|
|
59
|
-
function selectOptions({ item, line, numbered
|
|
60
|
-
const whole = optionIndex({
|
|
61
|
-
|
|
62
|
-
|
|
96
|
+
function selectOptions({ item, line, numbered }) {
|
|
97
|
+
const whole = optionIndex({
|
|
98
|
+
item,
|
|
99
|
+
numbered,
|
|
100
|
+
token: line
|
|
101
|
+
});
|
|
102
|
+
if (whole !== undefined) return [
|
|
103
|
+
item.options[whole].label
|
|
104
|
+
];
|
|
63
105
|
const segments = numbered && NUMBER_LIST.test(line) ? line.split(/[\s,]+/) : line.split(',');
|
|
64
|
-
const indexes = matchSegments({
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
106
|
+
const indexes = matchSegments({
|
|
107
|
+
item,
|
|
108
|
+
numbered,
|
|
109
|
+
segments
|
|
110
|
+
});
|
|
111
|
+
if (!indexes?.length) return undefined;
|
|
112
|
+
const unique = [
|
|
113
|
+
...new Set(indexes)
|
|
114
|
+
].sort((a, b)=>a - b);
|
|
115
|
+
if (!item.multiple && unique.length !== 1) return undefined;
|
|
116
|
+
return unique.map((index)=>item.options[index].label);
|
|
71
117
|
}
|
|
72
|
-
function matchSegments({ item, numbered, segments
|
|
73
|
-
const limit = 2 * Math.max(10, ...item.options.map(({ label })
|
|
118
|
+
function matchSegments({ item, numbered, segments }) {
|
|
119
|
+
const limit = 2 * Math.max(10, ...item.options.map(({ label })=>label.length));
|
|
74
120
|
const matches = [];
|
|
75
121
|
matches[segments.length] = [];
|
|
76
|
-
for
|
|
122
|
+
for(let start = segments.length - 1; start >= 0; start--){
|
|
77
123
|
if (!segments[start].trim()) {
|
|
78
124
|
matches[start] = matches[start + 1];
|
|
79
125
|
continue;
|
|
80
126
|
}
|
|
81
|
-
for
|
|
127
|
+
for(let end = start + 1; end <= segments.length; end++){
|
|
82
128
|
const token = segments.slice(start, end).join(',').trim();
|
|
83
|
-
if (token.length > limit)
|
|
84
|
-
break;
|
|
129
|
+
if (token.length > limit) break;
|
|
85
130
|
const rest = matches[end];
|
|
86
|
-
const index = rest ? optionIndex({
|
|
87
|
-
|
|
88
|
-
|
|
131
|
+
const index = rest ? optionIndex({
|
|
132
|
+
item,
|
|
133
|
+
numbered,
|
|
134
|
+
token
|
|
135
|
+
}) : undefined;
|
|
136
|
+
if (index !== undefined) matches[start] = [
|
|
137
|
+
index,
|
|
138
|
+
...rest
|
|
139
|
+
];
|
|
89
140
|
}
|
|
90
141
|
}
|
|
91
142
|
return matches[0];
|
|
92
143
|
}
|
|
93
|
-
function optionIndex({ item, numbered, token
|
|
144
|
+
function optionIndex({ item, numbered, token }) {
|
|
94
145
|
const unescaped = token.replace(MARKDOWN_ESCAPE, '$1');
|
|
95
|
-
const label = labelIndex({
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
146
|
+
const label = labelIndex({
|
|
147
|
+
item,
|
|
148
|
+
text: token
|
|
149
|
+
}) ?? (unescaped !== token ? labelIndex({
|
|
150
|
+
item,
|
|
151
|
+
text: unescaped
|
|
152
|
+
}) : undefined);
|
|
153
|
+
if (label !== undefined || !numbered) return label;
|
|
99
154
|
const number = Number(OPTION_NUMBER.exec(token)?.[1] ?? 0);
|
|
100
155
|
return number >= 1 && number <= item.options.length ? number - 1 : undefined;
|
|
101
156
|
}
|
|
102
157
|
function labelIndex({ item, text }) {
|
|
103
|
-
const exact = item.options.findIndex(({ label })
|
|
104
|
-
if (exact !== -1)
|
|
105
|
-
|
|
106
|
-
|
|
158
|
+
const exact = item.options.findIndex(({ label })=>label === text);
|
|
159
|
+
if (exact !== -1) return exact;
|
|
160
|
+
const folded = item.options.flatMap(({ label }, index)=>label.toLowerCase() === text.toLowerCase() ? [
|
|
161
|
+
index
|
|
162
|
+
] : []);
|
|
107
163
|
return folded.length === 1 ? folded[0] : undefined;
|
|
108
164
|
}
|
|
165
|
+
|
|
109
166
|
//# sourceMappingURL=parse.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/questions/parse.ts"],"names":["isSelectQuestion","replyHint","stopRequested","NUMBER_LIST","OPTION_NUMBER","LIST_MARKER","MARKDOWN_ESCAPE","parseLinearQuestion","call","interaction","question","settled","type","kind","metadata","text","message","result","parseReply","input","early","Date","dateSent","getTime","messages","at","postedAt","explicit","output","questions","numbered","lines","length","trim","split","map","line","filter","Boolean","reason","results","item","index","parseLine","unmarkCustom","failure","find","answers","answer","every","custom","undefined","unmarked","replace","selected","selectOptions","header","whole","optionIndex","token","options","label","segments","test","indexes","matchSegments","unique","Set","sort","a","b","multiple","limit","Math","max","matches","start","end","slice","join","rest","unescaped","labelIndex","number","Number","exec","exact","findIndex","folded","flatMap","toLowerCase"],"mappings":"AAEA,SAASA,gBAAgB,EAAEC,SAAS,QAAQ,mBAAmB;AAC/D,SAASC,aAAa,QAAQ,oBAAoB;AAWlD,MAAMC,cAAc;AACpB,MAAMC,gBAAgB;AACtB,MAAMC,cAAc;AACpB,MAAMC,kBAAkB;AAExB,OAAO,MAAMC,sBAAsD,CAAC,EAClEC,IAAI,EACJC,WAAW,EACXC,QAAQ,EACRC,OAAO,EACR;IACC,IAAIF,YAAYG,IAAI,KAAK,WAAW,OAAO;QAAEC,MAAM;IAAS;IAE5D,IAAIX,cAAcO,cAAc,OAAO;QAAEI,MAAM;IAAU;IAEzD,MAAM,EAAEC,QAAQ,EAAEC,IAAI,EAAE,GAAGN,YAAYO,OAAO;IAC9C,MAAMC,SAASC,WAAW;QAAEC,OAAOX,KAAKW,KAAK;QAAEJ;IAAK;IAEpD,MAAMK,QACJ,IAAIC,KAAKP,SAASQ,QAAQ,EAAEC,OAAO,KAAK,IAAIF,KAAKX,SAASc,QAAQ,CAACC,EAAE,CAAC,CAAC,GAAIC,QAAQ,EAAEH,OAAO;IAE9F,IAAIZ,WAAWS,OAAO;QACpB,OAAOH,OAAOJ,IAAI,KAAK,YAAYI,OAAOU,QAAQ,GAAG;YAAEd,MAAM;QAAQ,IAAI;YAAEA,MAAM;QAAS;IAC5F;IAEA,OAAOI,OAAOJ,IAAI,KAAK,WAAW;QAAEA,MAAM;QAAUe,QAAQX,OAAOW,MAAM;IAAC,IAAIX;AAChF,EAAE;AAEF,SAASC,WAAW,EAAEC,KAAK,EAAEJ,IAAI,EAA0C;IACzE,MAAM,EAAEc,SAAS,EAAE,GAAGV;IACtB,MAAMW,WAAW,CAAC9B,iBAAiBmB;IAEnC,MAAMY,QACJF,UAAUG,MAAM,KAAK,IACjB;QAACjB,KAAKkB,IAAI;KAAG,GACblB,KACGmB,KAAK,CAAC,SACNC,GAAG,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AAO,CAAC,CAAC,EAAE5B,KAAK,EAAE,EAAEnB,QAC9CmB,MAAM6B,WAAW,OAAO3E,KAAK2E,WAAW,KAAK;YAAChD;SAAM,GAAG,EAAE;IAG3D,OAAO8C,OAAOxD,MAAM,KAAK,IAAIwD,MAAM,CAAC,EAAE,GAAGrC;AAC3C","file":"parse.js"}
|
package/dist/questions/render.js
CHANGED
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
import { elicitation } from './elicitation.js';
|
|
2
2
|
import { postActivity } from './linearThread.js';
|
|
3
|
-
export const renderLinearQuestion = async ({ calls, client, thread
|
|
3
|
+
export const renderLinearQuestion = async ({ calls, client, thread })=>{
|
|
4
4
|
const [call] = calls;
|
|
5
|
-
if (!call)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
if (!call) return [];
|
|
6
|
+
const id = await postActivity({
|
|
7
|
+
activity: elicitation({
|
|
8
|
+
call
|
|
9
|
+
}),
|
|
10
|
+
client,
|
|
11
|
+
threadId: thread.id
|
|
12
|
+
});
|
|
13
|
+
return [
|
|
14
|
+
{
|
|
15
|
+
calls: [
|
|
16
|
+
call.toolCallId
|
|
17
|
+
],
|
|
18
|
+
messages: [
|
|
19
|
+
{
|
|
20
|
+
id,
|
|
21
|
+
postedAt: ''
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
];
|
|
9
26
|
};
|
|
27
|
+
|
|
10
28
|
//# sourceMappingURL=render.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/questions/render.ts"],"names":["elicitation","postActivity","renderLinearQuestion","calls","client","thread","call","id","activity","threadId","toolCallId","messages","postedAt"],"mappings":"AAGA,SAASA,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,YAAY,QAAQ,oBAAoB;AAEjD,OAAO,MAAMC,uBAAgE,OAAO,EAClFC,KAAK,EACLC,MAAM,EACNC,MAAM,EACP;IACC,MAAM,CAACC,KAAK,GAAGH;IAEf,IAAI,CAACG,MAAM,OAAO,EAAE;IAEpB,MAAMC,KAAK,MAAMN,aAAa;QAAEO,UAAUR,YAAY;YAAEM;QAAK;QAAIF;QAAQK,UAAUJ,OAAOE,EAAE;IAAC;IAE7F,OAAO;QAAC;YAAEJ,OAAO;gBAACG,KAAKI,UAAU;aAAC;YAAEC,UAAU;gBAAC;oBAAEJ;oBAAIK,UAAU;gBAAG;aAAE;QAAC;KAAE;AACzE,EAAE","file":"render.js"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { escapeMarkdown, response } from './elicitation.js';
|
|
2
2
|
import { postActivity } from './linearThread.js';
|
|
3
|
-
export const settleLinearQuestion = async ({ actor, client, outcome, thread
|
|
4
|
-
if ('output' in outcome || !actor)
|
|
5
|
-
return;
|
|
3
|
+
export const settleLinearQuestion = async ({ actor, client, outcome, thread })=>{
|
|
4
|
+
if ('output' in outcome || !actor) return;
|
|
6
5
|
const name = actor.channel?.name ?? actor.channel?.username;
|
|
7
6
|
await postActivity({
|
|
8
7
|
activity: response(name ? `Stopped. ${escapeMarkdown(name)} dismissed the question.` : 'Stopped.'),
|
|
9
8
|
client,
|
|
10
|
-
threadId: thread.id
|
|
9
|
+
threadId: thread.id
|
|
11
10
|
});
|
|
12
11
|
};
|
|
12
|
+
|
|
13
13
|
//# sourceMappingURL=settled.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/questions/settled.ts"],"names":["escapeMarkdown","response","postActivity","settleLinearQuestion","actor","client","outcome","thread","name","channel","username","activity","threadId","id"],"mappings":"AAGA,SAASA,cAAc,EAAEC,QAAQ,QAAQ,mBAAmB;AAC5D,SAASC,YAAY,QAAQ,oBAAoB;AAEjD,OAAO,MAAMC,uBAAiE,OAAO,EACnFC,KAAK,EACLC,MAAM,EACNC,OAAO,EACPC,MAAM,EACP;IACC,IAAI,YAAYD,WAAW,CAACF,OAAO;IAEnC,MAAMI,OAAOJ,MAAMK,OAAO,EAAED,QAAQJ,MAAMK,OAAO,EAAEC;IAEnD,MAAMR,aAAa;QACjBS,UAAUV,SACRO,OAAO,CAAC,SAAS,EAAER,eAAeQ,MAAM,wBAAwB,CAAC,GAAG;QAEtEH;QACAO,UAAUL,OAAOM,EAAE;IACrB;AACF,EAAE","file":"settled.js"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { agentSessionId } from './linearThread.js';
|
|
2
|
-
export const supportsLinearQuestion = ({ thread
|
|
2
|
+
export const supportsLinearQuestion = ({ thread })=>agentSessionId(thread.id) !== undefined;
|
|
3
|
+
|
|
3
4
|
//# sourceMappingURL=supports.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/questions/supports.ts"],"names":["agentSessionId","supportsLinearQuestion","thread","id","undefined"],"mappings":"AAEA,SAASA,cAAc,QAAQ,oBAAoB;AAEnD,OAAO,MAAMC,yBAAyE,CAAC,EACrFC,MAAM,EACP,GAAKF,eAAeE,OAAOC,EAAE,MAAMC,UAAU","file":"supports.js"}
|
|
@@ -6,12 +6,9 @@ export const commentCreated = webhookTrigger({
|
|
|
6
6
|
resourceType: 'Comment',
|
|
7
7
|
input: z.object({
|
|
8
8
|
teamIds: z.array(z.string()).optional(),
|
|
9
|
-
authorIds: z.array(z.string()).optional()
|
|
9
|
+
authorIds: z.array(z.string()).optional()
|
|
10
10
|
}),
|
|
11
|
-
matches: (delivery, input)
|
|
12
|
-
(delivery.data?.issue?.team?.id !== undefined &&
|
|
13
|
-
input.teamIds.includes(delivery.data.issue.team.id))) &&
|
|
14
|
-
(!input.authorIds?.length ||
|
|
15
|
-
(delivery.data?.userId !== undefined && input.authorIds.includes(delivery.data.userId))),
|
|
11
|
+
matches: (delivery, input)=>(!input.teamIds?.length || delivery.data?.issue?.team?.id !== undefined && input.teamIds.includes(delivery.data.issue.team.id)) && (!input.authorIds?.length || delivery.data?.userId !== undefined && input.authorIds.includes(delivery.data.userId))
|
|
16
12
|
});
|
|
13
|
+
|
|
17
14
|
//# sourceMappingURL=commentCreated.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/triggers/commentCreated.ts"],"names":["z","webhookTrigger","commentCreated","slug","action","resourceType","input","object","teamIds","array","string","optional","authorIds","matches","delivery","length","data","issue","team","id","undefined","includes","userId"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAM;AAExB,SAASC,cAAc,QAAQ,eAAe;AAE9C,OAAO,MAAMC,iBAAiBD,eAAe;IAC3CE,MAAM;IACNC,QAAQ;IACRC,cAAc;IACdC,OAAON,EAAEO,MAAM,CAAC;QACdC,SAASR,EAAES,KAAK,CAACT,EAAEU,MAAM,IAAIC,QAAQ;QACrCC,WAAWZ,EAAES,KAAK,CAACT,EAAEU,MAAM,IAAIC,QAAQ;IACzC;IACAE,SAAS,CAACC,UAAUR,QAClB,AAAC,CAAA,CAACA,MAAME,OAAO,EAAEO,UACdD,SAASE,IAAI,EAAEC,OAAOC,MAAMC,OAAOC,aAClCd,MAAME,OAAO,CAACa,QAAQ,CAACP,SAASE,IAAI,CAACC,KAAK,CAACC,IAAI,CAACC,EAAE,CAAC,KACtD,CAAA,CAACb,MAAMM,SAAS,EAAEG,UAChBD,SAASE,IAAI,EAAEM,WAAWF,aAAad,MAAMM,SAAS,CAACS,QAAQ,CAACP,SAASE,IAAI,CAACM,MAAM,CAAC;AAC5F,GAAG","file":"commentCreated.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/triggers/issueCreated.ts"],"names":["z","teamId","webhookTrigger","issueCreated","slug","action","resourceType","input","object"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAM;AAExB,SAASC,MAAM,QAAQ,eAAe;AACtC,SAASC,cAAc,QAAQ,eAAe;AAE9C,OAAO,MAAMC,eAAeD,eAAe;IACzCE,MAAM;IACNC,QAAQ;IACRC,cAAc;IACdC,OAAOP,EAAEQ,MAAM,CAAC;QAAEP;IAAO;AAC3B,GAAG","file":"issueCreated.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/triggers/issueRemoved.ts"],"names":["z","teamId","webhookTrigger","issueRemoved","slug","action","resourceType","input","object"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAM;AAExB,SAASC,MAAM,QAAQ,eAAe;AACtC,SAASC,cAAc,QAAQ,eAAe;AAE9C,OAAO,MAAMC,eAAeD,eAAe;IACzCE,MAAM;IACNC,QAAQ;IACRC,cAAc;IACdC,OAAOP,EAAEQ,MAAM,CAAC;QAAEP;IAAO;AAC3B,GAAG","file":"issueRemoved.js"}
|
|
@@ -5,6 +5,9 @@ export const issueUpdated = webhookTrigger({
|
|
|
5
5
|
slug: 'issueUpdated',
|
|
6
6
|
action: 'update',
|
|
7
7
|
resourceType: 'Issue',
|
|
8
|
-
input: z.object({
|
|
8
|
+
input: z.object({
|
|
9
|
+
teamId: teamId.optional()
|
|
10
|
+
})
|
|
9
11
|
});
|
|
12
|
+
|
|
10
13
|
//# sourceMappingURL=issueUpdated.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/triggers/issueUpdated.ts"],"names":["z","teamId","webhookTrigger","issueUpdated","slug","action","resourceType","input","object","optional"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAM;AAExB,SAASC,MAAM,QAAQ,eAAe;AACtC,SAASC,cAAc,QAAQ,eAAe;AAE9C,OAAO,MAAMC,eAAeD,eAAe;IACzCE,MAAM;IACNC,QAAQ;IACRC,cAAc;IACdC,OAAOP,EAAEQ,MAAM,CAAC;QAAEP,QAAQA,OAAOQ,QAAQ;IAAG;AAC9C,GAAG","file":"issueUpdated.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/triggers/projectCreated.ts"],"names":["z","webhookTrigger","projectCreated","slug","action","resourceType","input","object"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAM;AAExB,SAASC,cAAc,QAAQ,eAAe;AAE9C,OAAO,MAAMC,iBAAiBD,eAAe;IAC3CE,MAAM;IACNC,QAAQ;IACRC,cAAc;IACdC,OAAON,EAAEO,MAAM,CAAC,CAAC;AACnB,GAAG","file":"projectCreated.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/triggers/projectRemoved.ts"],"names":["z","webhookTrigger","projectRemoved","slug","action","resourceType","input","object"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAM;AAExB,SAASC,cAAc,QAAQ,eAAe;AAE9C,OAAO,MAAMC,iBAAiBD,eAAe;IAC3CE,MAAM;IACNC,QAAQ;IACRC,cAAc;IACdC,OAAON,EAAEO,MAAM,CAAC,CAAC;AACnB,GAAG","file":"projectRemoved.js"}
|
|
@@ -6,10 +6,9 @@ export const projectUpdated = webhookTrigger({
|
|
|
6
6
|
resourceType: 'Project',
|
|
7
7
|
input: z.object({
|
|
8
8
|
teamIds: z.array(z.string()).optional(),
|
|
9
|
-
projectStatus: z.string().optional()
|
|
9
|
+
projectStatus: z.string().optional()
|
|
10
10
|
}),
|
|
11
|
-
matches: (delivery, input)
|
|
12
|
-
(!input.teamIds?.length || input.teamIds.some((id) => delivery.data?.teamIds?.includes(id))) &&
|
|
13
|
-
(!input.projectStatus || input.projectStatus === delivery.data?.status?.name),
|
|
11
|
+
matches: (delivery, input)=>Boolean(delivery.updatedFrom?.statusId) && (!input.teamIds?.length || input.teamIds.some((id)=>delivery.data?.teamIds?.includes(id))) && (!input.projectStatus || input.projectStatus === delivery.data?.status?.name)
|
|
14
12
|
});
|
|
13
|
+
|
|
15
14
|
//# sourceMappingURL=projectUpdated.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/triggers/projectUpdated.ts"],"names":["z","webhookTrigger","projectUpdated","slug","action","resourceType","input","object","teamIds","array","string","optional","projectStatus","matches","delivery","Boolean","updatedFrom","statusId","length","some","id","data","includes","status","name"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAM;AAExB,SAASC,cAAc,QAAQ,eAAe;AAE9C,OAAO,MAAMC,iBAAiBD,eAAe;IAC3CE,MAAM;IACNC,QAAQ;IACRC,cAAc;IACdC,OAAON,EAAEO,MAAM,CAAC;QACdC,SAASR,EAAES,KAAK,CAACT,EAAEU,MAAM,IAAIC,QAAQ;QACrCC,eAAeZ,EAAEU,MAAM,GAAGC,QAAQ;IACpC;IACAE,SAAS,CAACC,UAAUR,QAClBS,QAAQD,SAASE,WAAW,EAAEC,aAC7B,CAAA,CAACX,MAAME,OAAO,EAAEU,UAAUZ,MAAME,OAAO,CAACW,IAAI,CAAC,CAACC,KAAON,SAASO,IAAI,EAAEb,SAASc,SAASF,IAAG,KACzF,CAAA,CAACd,MAAMM,aAAa,IAAIN,MAAMM,aAAa,KAAKE,SAASO,IAAI,EAAEE,QAAQC,IAAG;AAC/E,GAAG","file":"projectUpdated.js"}
|
package/dist/triggers/webhook.js
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import { defineWebhookTrigger } from '../define.js';
|
|
3
|
-
export function webhookTrigger({ slug, action, resourceType, input, matches
|
|
3
|
+
export function webhookTrigger({ slug, action, resourceType, input, matches }) {
|
|
4
4
|
return defineWebhookTrigger({
|
|
5
5
|
slug,
|
|
6
6
|
description: `Trigger when a Linear ${resourceType.toLowerCase()} is ${action}d.`,
|
|
7
7
|
type: 'webhook',
|
|
8
8
|
input,
|
|
9
|
-
async onEnable({ client, input, webhookUrl, options }) {
|
|
9
|
+
async onEnable ({ client, input, webhookUrl, options }) {
|
|
10
10
|
if (!options.webhookSecret) {
|
|
11
11
|
throw new Error(`Linear ${slug} webhook requires createLinear({ webhookSecret }).`);
|
|
12
12
|
}
|
|
13
|
-
const team = typeof input === 'object' &&
|
|
14
|
-
input !== null &&
|
|
15
|
-
'teamId' in input &&
|
|
16
|
-
typeof input.teamId === 'string'
|
|
17
|
-
? input.teamId
|
|
18
|
-
: undefined;
|
|
13
|
+
const team = typeof input === 'object' && input !== null && 'teamId' in input && typeof input.teamId === 'string' ? input.teamId : undefined;
|
|
19
14
|
const response = await client.createWebhook({
|
|
20
15
|
label: `FrogBot ${slug}`,
|
|
21
16
|
url: webhookUrl,
|
|
22
17
|
secret: options.webhookSecret,
|
|
23
|
-
resourceTypes: [
|
|
24
|
-
|
|
18
|
+
resourceTypes: [
|
|
19
|
+
resourceType
|
|
20
|
+
],
|
|
21
|
+
...team ? {
|
|
22
|
+
teamId: team
|
|
23
|
+
} : {
|
|
24
|
+
allPublicTeams: true
|
|
25
|
+
}
|
|
25
26
|
});
|
|
26
27
|
const webhook = response.success ? await response.webhook : undefined;
|
|
27
28
|
if (!webhook) {
|
|
28
29
|
throw new Error(`Linear failed to create the ${slug} webhook.`);
|
|
29
30
|
}
|
|
30
|
-
return {
|
|
31
|
+
return {
|
|
32
|
+
webhookId: webhook.id
|
|
33
|
+
};
|
|
31
34
|
},
|
|
32
|
-
async onDisable({ client, state }) {
|
|
35
|
+
async onDisable ({ client, state }) {
|
|
33
36
|
const response = await client.deleteWebhook(state.webhookId);
|
|
34
37
|
if (!response.success) {
|
|
35
38
|
throw new Error(`Linear failed to delete the ${slug} webhook '${state.webhookId}'.`);
|
|
36
39
|
}
|
|
37
40
|
},
|
|
38
|
-
async run({ input, req }) {
|
|
41
|
+
async run ({ input, req }) {
|
|
39
42
|
const delivery = req.data;
|
|
40
|
-
return delivery?.type === resourceType &&
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
},
|
|
48
|
-
]
|
|
49
|
-
: [];
|
|
50
|
-
},
|
|
43
|
+
return delivery?.type === resourceType && delivery.action === action && (!matches || matches(delivery, input)) ? [
|
|
44
|
+
{
|
|
45
|
+
dedupeKey: createHash('sha256').update(JSON.stringify(delivery)).digest('hex'),
|
|
46
|
+
data: delivery
|
|
47
|
+
}
|
|
48
|
+
] : [];
|
|
49
|
+
}
|
|
51
50
|
});
|
|
52
51
|
}
|
|
52
|
+
|
|
53
53
|
//# sourceMappingURL=webhook.js.map
|