11import { TogglGateway , TogglService } from "./toggl.js" ;
2+ import { extractTrackingData } from "./extract.js" ;
23
34const withErrorMessage = async function ( t , fnc ) {
45 try {
@@ -9,33 +10,6 @@ const withErrorMessage = async function (t, fnc) {
910 }
1011} ;
1112
12- const stripStoryPointsAndTaskToken = function ( name ) {
13- return name
14- . replace ( / ^ ( \s * \( \d + \) ) ? \s * / , "" ) // story points, e.g. (3)
15- . replace ( / \s * # \w + \s * $ / , "" ) ; // task token, e.g. #orga_5417
16- } ;
17-
18- const extractTrackingData = async function ( t ) {
19- const card = await t . card ( "name" , "labels" , "idShort" , "shortLink" ) ;
20-
21- const projectLabels = card . labels
22- . map ( ( label ) => label . name . match ( / (?< = # ) [ a - z 0 - 9 ] + $ / ) ?. [ 0 ] )
23- . filter ( ( prefix ) => prefix !== undefined ) ;
24- if ( projectLabels . length === 0 ) {
25- throw new Error ( "Card has no valid project labels." ) ;
26- }
27- if ( projectLabels . length > 1 ) {
28- throw new Error ( "Card has multiple project labels." ) ;
29- }
30- const project = projectLabels [ 0 ] ;
31-
32- return {
33- project,
34- task : `${ project } _${ card . idShort } _${ card . shortLink } ` ,
35- description : stripStoryPointsAndTaskToken ( card . name ) ,
36- } ;
37- } ;
38-
3913const setTrackingData = async function ( t , tracking ) {
4014 await t . set ( "card" , "shared" , "tracking" , tracking ) ;
4115} ;
0 commit comments