The general principle is a state/city gets to tax any income earned within its borders, whether you live there or not. So your nonresident NY/NYC return gets to tax all of your freelance income earned there.
The state you live in gets to tax all of your worldwide income no matter where it comes from. So NJ gets to tax all income you earn. With that in mind you should better be able to allocate your income to NY/NYC.
Your resident TT/NJ return will prepare a credit for some or all of the NY tax on the income that both states are taxing (freelance). For that reason, prepare the nonresident NY/NYC returns first. Then TT/NJ can get the info it needs from those completed returns to prepare that credit for you. This prevents double taxation.