nolzu 0.0.1 → 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.
- package/LICENSE +105 -0
- package/README.md +24 -7
- package/build/client/_app/immutable/assets/0.SPD4wYkc.css +1 -0
- package/build/client/_app/immutable/assets/1.BRilEoOO.css +1 -0
- package/build/client/_app/immutable/assets/10.DwLiBGDj.css +1 -0
- package/build/client/_app/immutable/assets/11.D_TtWT3D.css +1 -0
- package/build/client/_app/immutable/assets/12.CSVGmtUY.css +1 -0
- package/build/client/_app/immutable/assets/13.qTa7IHbg.css +1 -0
- package/build/client/_app/immutable/assets/19.CbCFXKb8.css +1 -0
- package/build/client/_app/immutable/assets/2.CfHhgI77.css +1 -0
- package/build/client/_app/immutable/assets/20.C5CSZhyT.css +1 -0
- package/build/client/_app/immutable/assets/21.BBpYkZcc.css +1 -0
- package/build/client/_app/immutable/assets/22.C9RgY9kl.css +1 -0
- package/build/client/_app/immutable/assets/23.B6Dp9RJO.css +1 -0
- package/build/client/_app/immutable/assets/24.C7g2abUW.css +1 -0
- package/build/client/_app/immutable/assets/26.DTMI6ROV.css +1 -0
- package/build/client/_app/immutable/assets/27.AxXMpDkB.css +1 -0
- package/build/client/_app/immutable/assets/28.939ac-98.css +1 -0
- package/build/client/_app/immutable/assets/3.3lqex1t-.css +1 -0
- package/build/client/_app/immutable/assets/4.C52MzO_d.css +1 -0
- package/build/client/_app/immutable/assets/5.CsfJAwvS.css +1 -0
- package/build/client/_app/immutable/assets/8.ByspUp-s.css +1 -0
- package/build/client/_app/immutable/assets/9.BCSFZmce.css +1 -0
- package/build/client/_app/immutable/assets/Banner.DDqfpWLD.css +1 -0
- package/build/client/_app/immutable/assets/BoardOff.mpX08-Be.css +1 -0
- package/build/client/_app/immutable/assets/Button.BlwsEgUc.css +1 -0
- package/build/client/_app/immutable/assets/Chip.qAAa6_e5.css +1 -0
- package/build/client/_app/immutable/assets/Dialog.D5Ln60a8.css +1 -0
- package/build/client/_app/immutable/assets/FeaturePanels.DZ_Mth5M.css +1 -0
- package/build/client/_app/immutable/assets/FolderBrowser.DBmRWDCH.css +1 -0
- package/build/client/_app/immutable/assets/Geist-Variable.Bj2R_7yk.woff2 +0 -0
- package/build/client/_app/immutable/assets/GeistMono-Variable.Dispecij.woff2 +0 -0
- package/build/client/_app/immutable/assets/HelpTip.DF6T9nns.css +1 -0
- package/build/client/_app/immutable/assets/InfoBox.CpavOykF.css +1 -0
- package/build/client/_app/immutable/assets/KeyCaps.D2t-lY-8.css +1 -0
- package/build/client/_app/immutable/assets/LogLine.Bu4feLn5.css +1 -0
- package/build/client/_app/immutable/assets/Markdown.DI6AtWAc.css +1 -0
- package/build/client/_app/immutable/assets/ModelPicker.DQzj7Nj8.css +1 -0
- package/build/client/_app/immutable/assets/OptionButtons.BYiyOXOE.css +1 -0
- package/build/client/_app/immutable/assets/PeekPanel.DzMdHoqg.css +1 -0
- package/build/client/_app/immutable/assets/ScoutPage.CVIiLy5c.css +1 -0
- package/build/client/_app/immutable/assets/SetupSteps.B6pZP1Bk.css +1 -0
- package/build/client/_app/immutable/assets/Skeleton.BC-1_U5d.css +1 -0
- package/build/client/_app/immutable/assets/SlotsMeter.Dq7GGYlD.css +1 -0
- package/build/client/_app/immutable/assets/StartConfirm.DxNN2AOb.css +1 -0
- package/build/client/_app/immutable/assets/StatePill.CGWFVUUg.css +1 -0
- package/build/client/_app/immutable/assets/Streamed.DpZ6wgO2.css +1 -0
- package/build/client/_app/immutable/assets/card-pulls.C5uGMuAh.css +1 -0
- package/build/client/_app/immutable/assets/next-step.CKg1w06J.css +1 -0
- package/build/client/_app/immutable/chunks/-B5EclhK.js +1 -0
- package/build/client/_app/immutable/chunks/-Q3zApAy.js +1 -0
- package/build/client/_app/immutable/chunks/6-hwN_Ik.js +3 -0
- package/build/client/_app/immutable/chunks/B16UF4PA.js +11 -0
- package/build/client/_app/immutable/chunks/B1V3h1VF.js +1 -0
- package/build/client/_app/immutable/chunks/B2d2Mkuz.js +68 -0
- package/build/client/_app/immutable/chunks/B2yzhiEa.js +1 -0
- package/build/client/_app/immutable/chunks/B5zDDQUU.js +2 -0
- package/build/client/_app/immutable/chunks/B8DHSiWf.js +1 -0
- package/build/client/_app/immutable/chunks/B8z33EzI.js +1 -0
- package/build/client/_app/immutable/chunks/BCRkrH6c.js +1 -0
- package/build/client/_app/immutable/chunks/BCScjOxu.js +1 -0
- package/build/client/_app/immutable/chunks/BMUQtCEC.js +1 -0
- package/build/client/_app/immutable/chunks/BNnfkvZM.js +1 -0
- package/build/client/_app/immutable/chunks/BelWyZaW.js +1 -0
- package/build/client/_app/immutable/chunks/BhZpqODT.js +1 -0
- package/build/client/_app/immutable/chunks/Bjy-W4x2.js +81 -0
- package/build/client/_app/immutable/chunks/BmafI-Bs.js +1 -0
- package/build/client/_app/immutable/chunks/BvRk9kiK.js +0 -0
- package/build/client/_app/immutable/chunks/C4i6bdQg.js +1 -0
- package/build/client/_app/immutable/chunks/C8u5TyIB.js +1 -0
- package/build/client/_app/immutable/chunks/CFs2xhoy.js +1 -0
- package/build/client/_app/immutable/chunks/CIm2DioU.js +1 -0
- package/build/client/_app/immutable/chunks/CONqGBXC.js +1 -0
- package/build/client/_app/immutable/chunks/CSOz40qO.js +1 -0
- package/build/client/_app/immutable/chunks/CXxuD1ef.js +3 -0
- package/build/client/_app/immutable/chunks/CarrGsZA.js +2 -0
- package/build/client/_app/immutable/chunks/CdrmTD44.js +1 -0
- package/build/client/_app/immutable/chunks/CfJRH9gh.js +2 -0
- package/build/client/_app/immutable/chunks/Ci7C9Cki.js +1 -0
- package/build/client/_app/immutable/chunks/CkOTL1vK.js +1 -0
- package/build/client/_app/immutable/chunks/CngTtGc_.js +1 -0
- package/build/client/_app/immutable/chunks/Cp3A1zR8.js +1 -0
- package/build/client/_app/immutable/chunks/CwtMnwNL.js +3 -0
- package/build/client/_app/immutable/chunks/Cy7f_oXg.js +1 -0
- package/build/client/_app/immutable/chunks/D-wwLm5t.js +1 -0
- package/build/client/_app/immutable/chunks/D2imbgaf.js +1 -0
- package/build/client/_app/immutable/chunks/D32mip60.js +1 -0
- package/build/client/_app/immutable/chunks/D46Vk19W.js +1 -0
- package/build/client/_app/immutable/chunks/DCUUgo-6.js +1 -0
- package/build/client/_app/immutable/chunks/DFjnjJjy.js +1 -0
- package/build/client/_app/immutable/chunks/DHMbSbMg.js +1 -0
- package/build/client/_app/immutable/chunks/DJOFx2wx.js +1 -0
- package/build/client/_app/immutable/chunks/DV4tvxHp.js +3 -0
- package/build/client/_app/immutable/chunks/DXk_5YEw.js +1 -0
- package/build/client/_app/immutable/chunks/DjgnRLJt.js +1 -0
- package/build/client/_app/immutable/chunks/DlWlQ_vP.js +1 -0
- package/build/client/_app/immutable/chunks/DpIAei2y.js +2 -0
- package/build/client/_app/immutable/chunks/Dt-HX3Vu.js +1 -0
- package/build/client/_app/immutable/chunks/DuSthUWX.js +1 -0
- package/build/client/_app/immutable/chunks/Ecfl8TOn.js +2 -0
- package/build/client/_app/immutable/chunks/ITHE99Aa.js +1 -0
- package/build/client/_app/immutable/chunks/Khdge0KS.js +1 -0
- package/build/client/_app/immutable/chunks/LMEKNlm0.js +1 -0
- package/build/client/_app/immutable/chunks/OnIeaiuO.js +1 -0
- package/build/client/_app/immutable/chunks/VFQLu55q.js +1 -0
- package/build/client/_app/immutable/chunks/ZsUxKnQw.js +1 -0
- package/build/client/_app/immutable/chunks/aWP8DVhV.js +1 -0
- package/build/client/_app/immutable/chunks/bB04Xp1f.js +1 -0
- package/build/client/_app/immutable/chunks/eylBqhv8.js +3 -0
- package/build/client/_app/immutable/chunks/hx0ssLL_.js +2 -0
- package/build/client/_app/immutable/chunks/mumDj17t.js +1 -0
- package/build/client/_app/immutable/chunks/pZYp3_TE.js +1 -0
- package/build/client/_app/immutable/chunks/tImwjqWn.js +1 -0
- package/build/client/_app/immutable/chunks/uBIymjUX.js +1 -0
- package/build/client/_app/immutable/chunks/xihTtKlq.js +1 -0
- package/build/client/_app/immutable/entry/app.DVZ1wE36.js +2 -0
- package/build/client/_app/immutable/entry/start.DluCc61B.js +1 -0
- package/build/client/_app/immutable/nodes/0.CwNFevXf.js +1 -0
- package/build/client/_app/immutable/nodes/1.BR6FYiC-.js +1 -0
- package/build/client/_app/immutable/nodes/10.wNwBFtom.js +2 -0
- package/build/client/_app/immutable/nodes/11.DpoIbMNF.js +2 -0
- package/build/client/_app/immutable/nodes/12.CWdUJ8l3.js +2 -0
- package/build/client/_app/immutable/nodes/13.CZ2uTvNS.js +1 -0
- package/build/client/_app/immutable/nodes/14.CzgyXuvL.js +1 -0
- package/build/client/_app/immutable/nodes/15.CzgyXuvL.js +1 -0
- package/build/client/_app/immutable/nodes/16.odL9eB2N.js +1 -0
- package/build/client/_app/immutable/nodes/17.B-RnUeVU.js +1 -0
- package/build/client/_app/immutable/nodes/18.BLYKxyq2.js +1 -0
- package/build/client/_app/immutable/nodes/19.CgyFfPqF.js +3 -0
- package/build/client/_app/immutable/nodes/2.CCWT41Qr.js +1 -0
- package/build/client/_app/immutable/nodes/20.BBk5-krg.js +1 -0
- package/build/client/_app/immutable/nodes/21.CJoU3s1A.js +2 -0
- package/build/client/_app/immutable/nodes/22.CoRvPh8m.js +1 -0
- package/build/client/_app/immutable/nodes/23.zXO3NjnM.js +3 -0
- package/build/client/_app/immutable/nodes/24.CmO27TED.js +1 -0
- package/build/client/_app/immutable/nodes/26.TVKNr_xX.js +18 -0
- package/build/client/_app/immutable/nodes/27.RojtGU_o.js +1 -0
- package/build/client/_app/immutable/nodes/28.CVTdeeSI.js +2 -0
- package/build/client/_app/immutable/nodes/3.Cgib7Vi6.js +1 -0
- package/build/client/_app/immutable/nodes/4.CnMwOCec.js +1 -0
- package/build/client/_app/immutable/nodes/5.-NqYtQj_.js +1 -0
- package/build/client/_app/immutable/nodes/6.D5xk-UBM.js +1 -0
- package/build/client/_app/immutable/nodes/7.IL4b-DII.js +1 -0
- package/build/client/_app/immutable/nodes/8.DJrguHjO.js +11 -0
- package/build/client/_app/immutable/nodes/9.DTUSzWiK.js +1 -0
- package/build/client/_app/version.json +1 -0
- package/build/client/favicon.svg +7 -0
- package/build/env.js +70 -0
- package/build/handler.js +26 -0
- package/build/index.js +149 -0
- package/build/server/chunks/chunks/Banner.js-D4mtxUfF.js +17 -0
- package/build/server/chunks/chunks/BoardOff.js-Dg5-LoR3.js +1627 -0
- package/build/server/chunks/chunks/Button.js-Buh9rnpu.js +43 -0
- package/build/server/chunks/chunks/Chip.js-xZ7vFkHx.js +12 -0
- package/build/server/chunks/chunks/Dialog.js-CGpwdpM-.js +60 -0
- package/build/server/chunks/chunks/FeaturePanels.js-B2sKozgF.js +84 -0
- package/build/server/chunks/chunks/FolderBrowser.js-DUHFhDaX.js +28 -0
- package/build/server/chunks/chunks/HelpTip.js-CzemvmjC.js +19 -0
- package/build/server/chunks/chunks/InfoBox.js-BJiVzZgw.js +10 -0
- package/build/server/chunks/chunks/KeyCaps.js-BMI2Hrh2.js +37 -0
- package/build/server/chunks/chunks/LogLine.js-2b7uX__H.js +35 -0
- package/build/server/chunks/chunks/Markdown.js-Clud88KU.js +4233 -0
- package/build/server/chunks/chunks/ModelPicker.js-FuBgyKIA.js +141 -0
- package/build/server/chunks/chunks/OptionButtons.js-LQKrAwUX.js +28 -0
- package/build/server/chunks/chunks/PeekPanel.js-aZ-r_v3N.js +375 -0
- package/build/server/chunks/chunks/ScoutPage.js-2DcNia96.js +733 -0
- package/build/server/chunks/chunks/SetupSteps.js-D7TAF7xa.js +66 -0
- package/build/server/chunks/chunks/Skeleton.js-diCP2sd5.js +30 -0
- package/build/server/chunks/chunks/SlotsMeter.js-BV_sAGf5.js +18 -0
- package/build/server/chunks/chunks/StartConfirm.js-CzEdFtbO.js +124 -0
- package/build/server/chunks/chunks/StatePill.js-CM7-HXNM.js +27 -0
- package/build/server/chunks/chunks/Streamed.js-_NgwNMMs.js +43 -0
- package/build/server/chunks/chunks/_page.server.js-BaGoctEY.js +1419 -0
- package/build/server/chunks/chunks/activity.js-CSoPUQLq.js +84 -0
- package/build/server/chunks/chunks/add-repo.js-DtHEobfm.js +305 -0
- package/build/server/chunks/chunks/app-header.js-CCflgeEQ.js +13 -0
- package/build/server/chunks/chunks/app.js-CuPn8jtk.js +12 -0
- package/build/server/chunks/chunks/bin.js-Cyb2cYLc.js +58 -0
- package/build/server/chunks/chunks/board-keys.js-CW3qw-MC.js +32 -0
- package/build/server/chunks/chunks/board-page.js-D0tdsE9J.js +860 -0
- package/build/server/chunks/chunks/board.js-BxL3CjB1.js +203 -0
- package/build/server/chunks/chunks/browser-test.js-DJEpOoVz.js +170 -0
- package/build/server/chunks/chunks/card-pulls.js-d_uGmBB3.js +229 -0
- package/build/server/chunks/chunks/card-repos.js-QaMCxiyV.js +59 -0
- package/build/server/chunks/chunks/chain-store.js-D42m8DUo.js +91 -0
- package/build/server/chunks/chunks/chain.js-CJFRywIC.js +52 -0
- package/build/server/chunks/chunks/changes.js-D8ITRMgU.js +513 -0
- package/build/server/chunks/chunks/checkout.js-Ys5L_gA4.js +319 -0
- package/build/server/chunks/chunks/client.js-B7jIMDuS.js +68 -0
- package/build/server/chunks/chunks/clipboard.js-qXskOBim.js +12 -0
- package/build/server/chunks/chunks/cloud-status.js-hy-9zUVX.js +95 -0
- package/build/server/chunks/chunks/coach.js-BhNB14rV.js +296 -0
- package/build/server/chunks/chunks/comments.js-1nWJQptB.js +311 -0
- package/build/server/chunks/chunks/commit-message.js-CMcNZUZw.js +8 -0
- package/build/server/chunks/chunks/create-card.js-DKtprMG6.js +498 -0
- package/build/server/chunks/chunks/db.js-pqoVpAzG.js +80 -0
- package/build/server/chunks/chunks/diff-comments.js-BSCuay_U.js +95 -0
- package/build/server/chunks/chunks/discussion.js-rJ5OMfvX.js +355 -0
- package/build/server/chunks/chunks/display.js-Bf-vGQ7Q.js +61 -0
- package/build/server/chunks/chunks/elapsed.js-DikkNhaD.js +27 -0
- package/build/server/chunks/chunks/engine.js-DS5zUwsE.js +115 -0
- package/build/server/chunks/chunks/env.js-l0sNRNKZ.js +2 -0
- package/build/server/chunks/chunks/estimate.js-BHTYVTaQ.js +2484 -0
- package/build/server/chunks/chunks/evidence-timeline.js-Dk0dTZIy.js +253 -0
- package/build/server/chunks/chunks/evidence.js-CT3tWdbB.js +257 -0
- package/build/server/chunks/chunks/exports.js-Hn-WQRMB.js +150 -0
- package/build/server/chunks/chunks/features.svelte.js-DNsFmFZb.js +10 -0
- package/build/server/chunks/chunks/files.js-V46lE0-6.js +46 -0
- package/build/server/chunks/chunks/filter.js-CsmCtJMd.js +11 -0
- package/build/server/chunks/chunks/forms.js-03E8qnFz.js +35 -0
- package/build/server/chunks/chunks/gate.js-Cbqo8Yy0.js +82 -0
- package/build/server/chunks/chunks/getting-started.js-DKbHofN5.js +55 -0
- package/build/server/chunks/chunks/git.js-l43vBHqs.js +16 -0
- package/build/server/chunks/chunks/home-path.js-BXgrl3TP.js +11 -0
- package/build/server/chunks/chunks/hub-link.js-B5kjLyyd.js +1532 -0
- package/build/server/chunks/chunks/internal.js-DaSBO6jY.js +1239 -0
- package/build/server/chunks/chunks/internal2.js-D6AKyUgY.js +27 -0
- package/build/server/chunks/chunks/knowledge-page.js-D2ALB3v9.js +292 -0
- package/build/server/chunks/chunks/knowledge-revert.js-2eyN9Lcb.js +109 -0
- package/build/server/chunks/chunks/knowledge.js--eAgdzNx.js +394 -0
- package/build/server/chunks/chunks/last-board.js-BemeiK3t.js +23 -0
- package/build/server/chunks/chunks/log.js-R2zUph6T.js +228 -0
- package/build/server/chunks/chunks/loop.js-D3guWKLp.js +4038 -0
- package/build/server/chunks/chunks/loop2.js-B_Qd2m4y.js +67 -0
- package/build/server/chunks/chunks/navigation.js-DQJMz-SM.js +2 -0
- package/build/server/chunks/chunks/new-project.js-DNcr9JpB.js +305 -0
- package/build/server/chunks/chunks/next-step.js-B8Kl0Iv9.js +522 -0
- package/build/server/chunks/chunks/node.js-Bz2jT5wt.js +3381 -0
- package/build/server/chunks/chunks/now-live.svelte.js-hIaDgjJ3.js +13 -0
- package/build/server/chunks/chunks/now-snapshot.js-zGKLIzox.js +207 -0
- package/build/server/chunks/chunks/now.js-Dfm-o0Ha.js +765 -0
- package/build/server/chunks/chunks/onboard.js-LBqPOxyU.js +1525 -0
- package/build/server/chunks/chunks/ordinal.js-Bm_9QEBD.js +12 -0
- package/build/server/chunks/chunks/overview.js-C32iHkXD.js +1108 -0
- package/build/server/chunks/chunks/page-keys.svelte.js-D8vXA_8Z.js +14 -0
- package/build/server/chunks/chunks/patch.js-Bl7vwsUj.js +62 -0
- package/build/server/chunks/chunks/paths.js-DVRjNYFW.js +19 -0
- package/build/server/chunks/chunks/peek.js-D9sSjT9t.js +95 -0
- package/build/server/chunks/chunks/plan.js-DFq5ntMM.js +143 -0
- package/build/server/chunks/chunks/project-files-notice.js-CcqcBgUP.js +19 -0
- package/build/server/chunks/chunks/project-files.js-DTC4jUxy.js +52 -0
- package/build/server/chunks/chunks/project-folder.js-CoKgPiM0.js +22 -0
- package/build/server/chunks/chunks/projects.js-bw2V11od.js +989 -0
- package/build/server/chunks/chunks/prs.js-CLfImauu.js +118 -0
- package/build/server/chunks/chunks/publish.js-D2vWpIJU.js +195 -0
- package/build/server/chunks/chunks/pull-list.js-BCIBJdyz.js +691 -0
- package/build/server/chunks/chunks/qa-ask.svelte.js-8Hf1JWW2.js +47 -0
- package/build/server/chunks/chunks/qa-setup.js-DFOEcNxH.js +1241 -0
- package/build/server/chunks/chunks/quiet.js-1GKY40Ay.js +104 -0
- package/build/server/chunks/chunks/rail.js-BePBwOqZ.js +135 -0
- package/build/server/chunks/chunks/review.js-MPqnq9Gy.js +98 -0
- package/build/server/chunks/chunks/routing.js-B8s1QwSP.js +265 -0
- package/build/server/chunks/chunks/run-log.js-CnN2jOcg.js +94 -0
- package/build/server/chunks/chunks/run.js-COSejjLl.js +34 -0
- package/build/server/chunks/chunks/scout-findings.js-CqJti10a.js +940 -0
- package/build/server/chunks/chunks/scout.js-Bm7wQLX2.js +62 -0
- package/build/server/chunks/chunks/sentinels.js-BXvpnzr3.js +13 -0
- package/build/server/chunks/chunks/server.js-BR0D07DR.js +3803 -0
- package/build/server/chunks/chunks/settings-sections.js-V70W7BkZ.js +103 -0
- package/build/server/chunks/chunks/shared.js-BgfCUZUJ.js +776 -0
- package/build/server/chunks/chunks/sign-in.js-O-pBhi19.js +14 -0
- package/build/server/chunks/chunks/snapshot.js-BekzL_He.js +38 -0
- package/build/server/chunks/chunks/spend.js-BabnR69T.js +63 -0
- package/build/server/chunks/chunks/src.js-Cm8RAH_q.js +609 -0
- package/build/server/chunks/chunks/src2.js-CV8tsClO.js +1186 -0
- package/build/server/chunks/chunks/src3.js-h9tTEbVb.js +11222 -0
- package/build/server/chunks/chunks/stack.js-CMWXhMZS.js +13 -0
- package/build/server/chunks/chunks/standup.js-D-qBnMx4.js +103 -0
- package/build/server/chunks/chunks/state.js-BTDrgu7s.js +71 -0
- package/build/server/chunks/chunks/stream.js-D6r6iqjD.js +66 -0
- package/build/server/chunks/chunks/terms.js-DPZztSEn.js +88 -0
- package/build/server/chunks/chunks/ticket-system.js-Dj9R3XJw.js +147 -0
- package/build/server/chunks/chunks/ticket.js-6sj-2ZEM.js +110 -0
- package/build/server/chunks/chunks/timesheet.js-DfhIokoE.js +212 -0
- package/build/server/chunks/chunks/timesheet2.js-Cu95ddl3.js +84 -0
- package/build/server/chunks/chunks/to-workspace.js-DiOJP59J.js +308 -0
- package/build/server/chunks/chunks/toast-stack.svelte.js-CXIg3_KT.js +10 -0
- package/build/server/chunks/chunks/uneval.js-VnZcgzZr.js +488 -0
- package/build/server/chunks/chunks/utils.js-DQTBh7_6.js +1006 -0
- package/build/server/chunks/chunks/when-said.js-0F9asAma.js +35 -0
- package/build/server/chunks/chunks/workspace.js-BBdJRon9.js +212 -0
- package/build/server/chunks/entries/endpoints/api/board/_server.ts.js-BlYC_lpV.js +69 -0
- package/build/server/chunks/entries/endpoints/api/board/minimize/_server.ts.js-Wddt9YPR.js +68 -0
- package/build/server/chunks/entries/endpoints/api/board/move/_server.ts.js-BwZpCKx0.js +68 -0
- package/build/server/chunks/entries/endpoints/api/board/promote/_server.ts.js-Cw6kvkMq.js +68 -0
- package/build/server/chunks/entries/endpoints/api/board/pulls/_server.ts.js-DFhpbiMo.js +71 -0
- package/build/server/chunks/entries/endpoints/api/board/stop/_server.ts.js-D5eylDMw.js +68 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/answer/_server.ts.js-CG8xh52y.js +68 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/branch/_server.ts.js-a5_P9voA.js +40 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/chain/_server.ts.js-tJvQy6RK.js +70 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/checkouts/_server.ts.js-B2_gx6vF.js +41 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/choice/_server.ts.js-pmAdIQkK.js +34 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/comments/_id_/_server.ts.js-C5NxGWw3.js +68 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/comments/_server.ts.js-0rw7UNv8.js +64 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/commit/_server.ts.js-_yXWCOlQ.js +68 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/commit-diff/_server.ts.js-CRPV3z-g.js +61 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/commit-message/_server.ts.js-CO9mD3u6.js +82 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/context/_server.ts.js-7kzrigFz.js +42 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/delete/_server.ts.js-DH0nO9wG.js +516 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/file/_server.ts.js-D80SvJDi.js +35 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/files/_...path_/_server.ts.js-GxFjb2H0.js +34 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/fix/_server.ts.js-B-HAB050.js +68 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/knowledge/_server.ts.js-D4fN-j7X.js +81 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/link/_other_/_server.ts.js-C00pQDCu.js +42 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/log/_server.ts.js-BXW_tG-I.js +32 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/log/raw/_server.ts.js-pT8StZGR.js +32 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/message/_server.ts.js-ZMno2Hu6.js +68 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/models/_server.ts.js-DEZVpqO3.js +73 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/patch/_server.ts.js-BxfLi-Zs.js +61 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/peek/_server.ts.js-CsTKWIP_.js +169 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/pr/_server.ts.js-CsOeAXkf.js +53 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/pr/comments/_server.ts.js-DZ2XHOhF.js +71 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/pr/discuss/_server.ts.js-CO8eM0e8.js +72 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/pr/discussions/_server.ts.js-Lp7l0Yqv.js +71 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/pr/fix/_server.ts.js-CeIhjpQ4.js +68 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/pr/fix-all/_server.ts.js-D-DKoCpQ.js +68 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/pr/links/_server.ts.js-B_q3jUP3.js +72 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/pr/qa/_server.ts.js-BulVcJY9.js +68 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/pr/seen/_server.ts.js-Z06A6MS1.js +71 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/pr/triage/_server.ts.js-qADU4URF.js +68 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/pull/_server.ts.js-CHnTH9WK.js +58 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/push/_server.ts.js-BPdPwPo2.js +83 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/repos/_server.ts.js-Bjqa3Uoo.js +73 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/research/_server.ts.js-DzQjoHOZ.js +138 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/retry/_server.ts.js-CAodrXqd.js +68 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/send-back/_server.ts.js-CmJSnvTx.js +68 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/stack/_server.ts.js-DjI8S94J.js +82 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/tasks/_server.ts.js-BzX_nNJk.js +71 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/thread/_server.ts.js-Dn36Guxk.js +33 -0
- package/build/server/chunks/entries/endpoints/api/cards/_server.ts.js-DPMOBsvp.js +77 -0
- package/build/server/chunks/entries/endpoints/api/cards/context/_server.ts.js-D6y-g2O-.js +52 -0
- package/build/server/chunks/entries/endpoints/api/cards/next/_server.ts.js-C2se67rf.js +55 -0
- package/build/server/chunks/entries/endpoints/api/chain/_server.ts.js-DKO5Q8GV.js +70 -0
- package/build/server/chunks/entries/endpoints/api/clones/_server.ts.js-Bgcc_Beg.js +56 -0
- package/build/server/chunks/entries/endpoints/api/current-project/_server.ts.js-DZCtSlXs.js +81 -0
- package/build/server/chunks/entries/endpoints/api/evidence/timesheet/_server.ts.js-xJwzSrcl.js +32 -0
- package/build/server/chunks/entries/endpoints/api/folders/_server.ts.js-BdcE7k8S.js +83 -0
- package/build/server/chunks/entries/endpoints/api/gh/_server.ts.js-CGvM8fn7.js +66 -0
- package/build/server/chunks/entries/endpoints/api/gh/name/_server.ts.js-CHh3tAu7.js +36 -0
- package/build/server/chunks/entries/endpoints/api/health/_server.ts.js-DLUfrHo6.js +22 -0
- package/build/server/chunks/entries/endpoints/api/login-item/_server.ts.js-Cya7S7W6.js +77 -0
- package/build/server/chunks/entries/endpoints/api/notes/_server.ts.js-DaUFVqSM.js +26 -0
- package/build/server/chunks/entries/endpoints/api/notifications/_server.ts.js-DK6NFnII.js +76 -0
- package/build/server/chunks/entries/endpoints/api/now/_server.ts.js-xW0jeJdy.js +83 -0
- package/build/server/chunks/entries/endpoints/api/package/entry/_server.ts.js-DQyZanpo.js +35 -0
- package/build/server/chunks/entries/endpoints/api/projects/_server.ts.js-CzXJTj_l.js +58 -0
- package/build/server/chunks/entries/endpoints/api/qa-setup/_server.ts.js-DujrYbEP.js +76 -0
- package/build/server/chunks/entries/endpoints/api/remove-check/_server.ts.js-1KAi9LDi.js +58 -0
- package/build/server/chunks/entries/endpoints/api/setup/_server.ts.js-D0MKtjR7.js +69 -0
- package/build/server/chunks/entries/endpoints/api/tickets/jira/_server.ts.js-Z2LdOr5l.js +39 -0
- package/build/server/chunks/entries/endpoints/api/tickets/read/_server.ts.js-BziHtc8Y.js +68 -0
- package/build/server/chunks/entries/endpoints/api/tools/_server.ts.js-oyvq8i1y.js +30 -0
- package/build/server/chunks/entries/endpoints/api/workspace/_server.ts.js-CMGBL5cX.js +58 -0
- package/build/server/chunks/entries/endpoints/api/workspace/commit/_server.ts.js-BZQQJ1YG.js +66 -0
- package/build/server/chunks/entries/endpoints/api/workspace/patch/_server.ts.js-xrjgHECx.js +64 -0
- package/build/server/chunks/entries/endpoints/api/workspace/push/_server.ts.js-CTdia7Uz.js +66 -0
- package/build/server/chunks/entries/hooks.server.js-B0jE-ELC.js +211 -0
- package/build/server/chunks/entries/pages/_error.svelte.js-DPcKI5sX.js +25 -0
- package/build/server/chunks/entries/pages/_layout.server.ts.js-Jj3i2Th9.js +134 -0
- package/build/server/chunks/entries/pages/_layout.svelte.js-Cu3ghN80.js +1251 -0
- package/build/server/chunks/entries/pages/_page.svelte.js-DEYydBCm.js +662 -0
- package/build/server/chunks/entries/pages/accept/_page.server.ts.js-BF7MrA5s.js +29 -0
- package/build/server/chunks/entries/pages/accept/_page.svelte.js-8yPsedd-.js +54 -0
- package/build/server/chunks/entries/pages/b/_board_/_page.svelte.js-S9acLF3f.js +68 -0
- package/build/server/chunks/entries/pages/b/_board_/_page.ts.js-BcKdG_Tp.js +21 -0
- package/build/server/chunks/entries/pages/b/research/_page.svelte.js-FW6Hw9g5.js +68 -0
- package/build/server/chunks/entries/pages/b/research/_page.ts.js-Ds2AjFFK.js +13 -0
- package/build/server/chunks/entries/pages/evidence/_page.server.ts.js-uwu2X7bA.js +1382 -0
- package/build/server/chunks/entries/pages/evidence/_page.svelte.js-DBCjiT59.js +594 -0
- package/build/server/chunks/entries/pages/f/_...path_/_page.svelte.js-DxwJaJzh.js +58 -0
- package/build/server/chunks/entries/pages/knowledge/_page.server.ts.js-BAUvFEcM.js +80 -0
- package/build/server/chunks/entries/pages/knowledge/_page.svelte.js-D9117gHM.js +732 -0
- package/build/server/chunks/entries/pages/new/_page.server.ts.js-BNCQQpyw.js +110 -0
- package/build/server/chunks/entries/pages/new/_page.svelte.js-Ben8-N_h.js +503 -0
- package/build/server/chunks/entries/pages/new/idea/_page.server.ts.js-jssA29y3.js +46 -0
- package/build/server/chunks/entries/pages/new/idea/_page.svelte.js-XoKspqAc.js +210 -0
- package/build/server/chunks/entries/pages/new/task/_page.server.ts.js-CmZgfvyt.js +66 -0
- package/build/server/chunks/entries/pages/new/task/_page.svelte.js-BKpERKvm.js +169 -0
- package/build/server/chunks/entries/pages/onboard/_page.server.ts.js-pmc_pXvs.js +12 -0
- package/build/server/chunks/entries/pages/onboard/_page.svelte.js-C7LNK-ba.js +5 -0
- package/build/server/chunks/entries/pages/projects/_page.server.ts.js-BEhLRfJ_.js +12 -0
- package/build/server/chunks/entries/pages/projects/_page.svelte.js-OraOjsyb.js +5 -0
- package/build/server/chunks/entries/pages/scout/_page.server.ts.js-hQYnMHwY.js +10 -0
- package/build/server/chunks/entries/pages/scout/_page.svelte.js-7q4d044Z.js +40 -0
- package/build/server/chunks/entries/pages/scout/f/_id_/_page.server.ts.js-BN4TnSpB.js +22 -0
- package/build/server/chunks/entries/pages/scout/f/_id_/_page.svelte.js-GzpLhARi.js +40 -0
- package/build/server/chunks/entries/pages/settings/_layout.server.ts.js-B5LgqMMT.js +12 -0
- package/build/server/chunks/entries/pages/settings/_layout.svelte.js-CSCpV6qA.js +81 -0
- package/build/server/chunks/entries/pages/settings/_page.svelte.js-DNpsNFo0.js +25 -0
- package/build/server/chunks/entries/pages/settings/_section_/_page.server.ts.js-nRDEV3i_.js +348 -0
- package/build/server/chunks/entries/pages/settings/_section_/_page.svelte.js-BihUf-nY.js +1052 -0
- package/build/server/chunks/entries/pages/settings/integrations/_page.server.ts.js-BTuRpg8m.js +58 -0
- package/build/server/chunks/entries/pages/settings/integrations/_page.svelte.js-C8i8ZmZR.js +161 -0
- package/build/server/chunks/entries/pages/settings/mcp/_page.server.ts.js-TFISfO1a.js +925 -0
- package/build/server/chunks/entries/pages/settings/mcp/_page.svelte.js-D1X0TNOm.js +433 -0
- package/build/server/chunks/entries/pages/settings/phases/_page.server.ts.js-CgK7MTZf.js +48 -0
- package/build/server/chunks/entries/pages/settings/phases/_page.svelte.js-u-sTQ-ue.js +80 -0
- package/build/server/chunks/entries/pages/settings/project/_page.server.ts.js-CCnk9WbO.js +363 -0
- package/build/server/chunks/entries/pages/settings/project/_page.svelte.js-MxvNqYlQ.js +1269 -0
- package/build/server/chunks/entries/pages/settings/wall/_page.server.ts.js-Bt5siY_N.js +12 -0
- package/build/server/chunks/entries/pages/settings/wall/_page.svelte.js-CMR4zSAt.js +43 -0
- package/build/server/chunks/entries/pages/t/_key_/_layout.server.ts.js-W6YPvOCA.js +124 -0
- package/build/server/chunks/entries/pages/t/_key_/_layout.svelte.js-CK0PiWsz.js +543 -0
- package/build/server/chunks/entries/pages/t/_key_/_page.server.ts.js-CdB7v0WX.js +15 -0
- package/build/server/chunks/entries/pages/t/_key_/_tab_/_page.server.ts.js-Bksaje8R.js +75 -0
- package/build/server/chunks/entries/pages/t/_key_/_tab_/_page.svelte.js-9OQ2eQxu.js +4607 -0
- package/build/server/chunks/entries/pages/team/_page.svelte.js-BdUSXC04.js +18 -0
- package/build/server/chunks/entries/pages/team/_page.ts.js-DfhJmoZI.js +20 -0
- package/build/server/chunks/entries/pages/workspace/_page.svelte.js-DLaWe23r.js +579 -0
- package/build/server/chunks/handler-Dlwmumt5.js +1735 -0
- package/build/server/chunks/index.js-BX0fZD5G.js +3701 -0
- package/build/server/chunks/manifest.js-B2Of6Dj7.js +761 -0
- package/build/server/chunks/nodes/0.js-DSzhdY0D.js +87 -0
- package/build/server/chunks/nodes/1.js-j4osL1br.js +9 -0
- package/build/server/chunks/nodes/10.js-jkvevEFY.js +75 -0
- package/build/server/chunks/nodes/11.js-plyiDP2n.js +72 -0
- package/build/server/chunks/nodes/12.js-DwtvDAyM.js +78 -0
- package/build/server/chunks/nodes/13.js-BpxwqFh4.js +72 -0
- package/build/server/chunks/nodes/14.js-B5iNIKGy.js +15 -0
- package/build/server/chunks/nodes/15.js-CXCAqUsG.js +15 -0
- package/build/server/chunks/nodes/16.js-oxkLEH0n.js +76 -0
- package/build/server/chunks/nodes/17.js-B-ZJEo9K.js +76 -0
- package/build/server/chunks/nodes/18.js-C0OUCEux.js +9 -0
- package/build/server/chunks/nodes/19.js-M8EAQJdW.js +76 -0
- package/build/server/chunks/nodes/2.js-ZedduK-3.js +33 -0
- package/build/server/chunks/nodes/20.js-BHvsLNjD.js +72 -0
- package/build/server/chunks/nodes/21.js-eOaW4si1.js +76 -0
- package/build/server/chunks/nodes/22.js-CbJ6tQSs.js +38 -0
- package/build/server/chunks/nodes/23.js-DXk8ejlx.js +81 -0
- package/build/server/chunks/nodes/24.js-C4qGJc4X.js +33 -0
- package/build/server/chunks/nodes/25.js-Cal8uT5V.js +21 -0
- package/build/server/chunks/nodes/26.js-Cp5jBcrN.js +80 -0
- package/build/server/chunks/nodes/27.js-Do55o_cb.js +17 -0
- package/build/server/chunks/nodes/28.js-SNz3QVix.js +9 -0
- package/build/server/chunks/nodes/3.js-DyivQ5dN.js +75 -0
- package/build/server/chunks/nodes/4.js-BGgTTQFR.js +9 -0
- package/build/server/chunks/nodes/5.js-DQYA2BBI.js +31 -0
- package/build/server/chunks/nodes/6.js-BVTi2KFL.js +24 -0
- package/build/server/chunks/nodes/7.js-CnprIn3p.js +12 -0
- package/build/server/chunks/nodes/8.js-Bdicn369.js +50 -0
- package/build/server/chunks/nodes/9.js-DVclPGXf.js +9 -0
- package/build/shims.js +33 -0
- package/dist/THIRD-PARTY-NOTICES.md +659 -0
- package/dist/detect-BmI_gskA.js +585 -0
- package/dist/fonts/OFL.txt +92 -0
- package/dist/nolzu.js +48 -0
- package/dist/package-vezZOzhD.js +181 -0
- package/dist/shared/finish.md +110 -0
- package/dist/shared/knowledge.md +72 -0
- package/dist/shared/verdict.md +42 -0
- package/dist/skills/.gitkeep +0 -0
- package/dist/skills/nolzu-architecture/SKILL.md +140 -0
- package/dist/skills/nolzu-architecture/finish.md +110 -0
- package/dist/skills/nolzu-assess/SKILL.md +99 -0
- package/dist/skills/nolzu-assess/finish.md +110 -0
- package/dist/skills/nolzu-design/SKILL.md +115 -0
- package/dist/skills/nolzu-design/finish.md +110 -0
- package/dist/skills/nolzu-feedback/SKILL.md +107 -0
- package/dist/skills/nolzu-feedback/finish.md +110 -0
- package/dist/skills/nolzu-implement/SKILL.md +138 -0
- package/dist/skills/nolzu-implement/finish.md +110 -0
- package/dist/skills/nolzu-investigate/SKILL.md +139 -0
- package/dist/skills/nolzu-investigate/finish.md +110 -0
- package/dist/skills/nolzu-learn-repo/SKILL.md +115 -0
- package/dist/skills/nolzu-learn-repo/finish.md +110 -0
- package/dist/skills/nolzu-learn-repo/knowledge.md +72 -0
- package/dist/skills/nolzu-optimize/SKILL.md +82 -0
- package/dist/skills/nolzu-optimize/finish.md +110 -0
- package/dist/skills/nolzu-optimize/knowledge.md +72 -0
- package/dist/skills/nolzu-orient/SKILL.md +115 -0
- package/dist/skills/nolzu-orient/finish.md +110 -0
- package/dist/skills/nolzu-orient/knowledge.md +72 -0
- package/dist/skills/nolzu-plan/SKILL.md +165 -0
- package/dist/skills/nolzu-plan/finish.md +110 -0
- package/dist/skills/nolzu-pr-review/SKILL.md +150 -0
- package/dist/skills/nolzu-pr-review/finish.md +110 -0
- package/dist/skills/nolzu-qa/SKILL.md +177 -0
- package/dist/skills/nolzu-qa/finish.md +110 -0
- package/dist/skills/nolzu-qa/verdict.md +42 -0
- package/dist/skills/nolzu-refine/SKILL.md +145 -0
- package/dist/skills/nolzu-refine/finish.md +110 -0
- package/dist/skills/nolzu-research/SKILL.md +140 -0
- package/dist/skills/nolzu-research/finish.md +110 -0
- package/dist/skills/nolzu-wrapup/SKILL.md +126 -0
- package/dist/skills/nolzu-wrapup/finish.md +110 -0
- package/dist/skills/nolzu-wrapup/knowledge.md +72 -0
- package/dist/src-BG8LaXLS.js +723 -0
- package/dist/src-DPfcvRqs.js +4 -0
- package/dist/start-ItZOcBtM.js +362 -0
- package/package.json +49 -9
- package/bin/nolzu.js +0 -8
|
@@ -0,0 +1,1382 @@
|
|
|
1
|
+
import { s as shows, E as EXPORT_FEATURE } from '../../../chunks/display.js-Bf-vGQ7Q.js';
|
|
2
|
+
import { o as siteOrigin, C as basicAuth } from '../../../chunks/estimate.js-BHTYVTaQ.js';
|
|
3
|
+
import { r as resolveDataDir, g as getSetting, w as writeSetting } from '../../../chunks/node.js-Bz2jT5wt.js';
|
|
4
|
+
import '../../../chunks/src.js-Cm8RAH_q.js';
|
|
5
|
+
import '../../../chunks/src2.js-CV8tsClO.js';
|
|
6
|
+
import { w as weekOf, a as timesheetEntries, i as isDay } from '../../../chunks/timesheet.js-DfhIokoE.js';
|
|
7
|
+
import { Q as createKeychain, R as runKeychain } from '../../../chunks/src3.js-h9tTEbVb.js';
|
|
8
|
+
import { p as projectName } from '../../../chunks/app-header.js-CCflgeEQ.js';
|
|
9
|
+
import { a as database } from '../../../chunks/db.js-pqoVpAzG.js';
|
|
10
|
+
import { e as evidenceFor, s as standupFor, r as runPhases, c as currentDisplay, l as localCloud } from '../../../chunks/evidence.js-CT3tWdbB.js';
|
|
11
|
+
import { s as saveBilling, b as billingFor, a as billingPrompt, w as weekShift, t as timesheetFor } from '../../../chunks/timesheet2.js-Cu95ddl3.js';
|
|
12
|
+
import { w as weekEvidence, d as dayShift } from '../../../chunks/evidence-timeline.js-Dk0dTZIy.js';
|
|
13
|
+
import { A as fail } from '../../../chunks/utils.js-DQTBh7_6.js';
|
|
14
|
+
import { randomUUID } from 'node:crypto';
|
|
15
|
+
|
|
16
|
+
//#region src/lib/timesheet-call.ts
|
|
17
|
+
/**
|
|
18
|
+
* What an adapter throws for an entry this destination can never take, with the reason as its
|
|
19
|
+
* message. The entry keeps the reason on its row and is not counted as a failure, so a week of
|
|
20
|
+
* local cards does not end a Jira export on `MAX_FAILURES_PER_EXPORT` or get stuck on
|
|
21
|
+
* `MAX_ATTEMPTS`. It is asked again on the next export, which costs no call.
|
|
22
|
+
*/
|
|
23
|
+
var ExportSkipped = class extends Error {};
|
|
24
|
+
var isHtml = (body) => body.trimStart().startsWith("<");
|
|
25
|
+
var webPage = (label) => `${label} answered with a web page instead of data, so the entry was not sent.`;
|
|
26
|
+
/**
|
|
27
|
+
* The destination's own words about a refusal, cut short. They come as a JSON string, as an object
|
|
28
|
+
* with a message, or as plain text, and no sentence written here can guess which field was refused.
|
|
29
|
+
* Jira puts them in `errorMessages` or in `errors` by field, and Harvest's token refusal in
|
|
30
|
+
* `error_description`.
|
|
31
|
+
*/
|
|
32
|
+
function detail(label, body, secrets) {
|
|
33
|
+
let words = body;
|
|
34
|
+
try {
|
|
35
|
+
words = JSON.parse(body);
|
|
36
|
+
} catch {}
|
|
37
|
+
if (words !== null && typeof words === "object") {
|
|
38
|
+
const held = words;
|
|
39
|
+
const listed = Array.isArray(held.errorMessages) ? held.errorMessages[0] : void 0;
|
|
40
|
+
const fields = held.errors !== null && typeof held.errors === "object" ? Object.values(held.errors)[0] : void 0;
|
|
41
|
+
words = held.message ?? held.error_description ?? held.error ?? listed ?? fields;
|
|
42
|
+
}
|
|
43
|
+
if (typeof words !== "string") return "";
|
|
44
|
+
const clean = secrets.reduce((text, secret) => text.split(secret).join("…"), words).trim();
|
|
45
|
+
return clean === "" ? "" : ` ${label} said: ${clean.slice(0, 200)}`;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* One call on a destination's API, answering the body of the one status it expects.
|
|
49
|
+
*
|
|
50
|
+
* The token never goes in the path and never in a sentence: a path reaches a log, and a sentence is
|
|
51
|
+
* stored and shown. A redirect is not followed, because a hop off the destination is some other
|
|
52
|
+
* host's page, and read as the destination's answer it would look like a day with nothing on it.
|
|
53
|
+
*/
|
|
54
|
+
async function callDestination(to, method, path, body, signal, expect = 200) {
|
|
55
|
+
const target = new URL(path, to.origin);
|
|
56
|
+
if (target.origin !== to.origin.origin) throw new Error(`A ${to.label} call names a path on ${to.origin.host}, and not another address.`);
|
|
57
|
+
const send = to.fetcher ?? ((url, init) => fetch(url, init));
|
|
58
|
+
const headers = {
|
|
59
|
+
...to.headers,
|
|
60
|
+
accept: "application/json"
|
|
61
|
+
};
|
|
62
|
+
if (body !== void 0) headers["content-type"] = "application/json";
|
|
63
|
+
let answer;
|
|
64
|
+
let text;
|
|
65
|
+
try {
|
|
66
|
+
answer = await send(target.toString(), {
|
|
67
|
+
method,
|
|
68
|
+
headers,
|
|
69
|
+
...body === void 0 ? {} : { body },
|
|
70
|
+
signal,
|
|
71
|
+
redirect: "manual"
|
|
72
|
+
});
|
|
73
|
+
text = await answer.text();
|
|
74
|
+
} catch {
|
|
75
|
+
throw new Error(signal.aborted ? `${to.label} did not answer in time, so the entry was not sent.` : `Nolzu could not reach ${to.label}, so the entry was not sent. Export again later.`);
|
|
76
|
+
}
|
|
77
|
+
if (answer.status >= 300 && answer.status < 400) throw new Error(`${to.label} answered with a redirect, so the entry was not sent.`);
|
|
78
|
+
if (method === "POST" && answer.status >= 200 && answer.status < 300 && answer.status !== expect) throw new Error(`${to.label} answered ${answer.status} where ${expect} was expected, so the entry is not marked as sent. The next export looks for it in ${to.label} before it posts again.`);
|
|
79
|
+
if (answer.status !== expect) throw new Error(to.refusal(answer.status, text, to.secrets.filter(Boolean)));
|
|
80
|
+
if (isHtml(text)) throw new Error(webPage(to.label));
|
|
81
|
+
return text;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* An id a person copied into a connection, or null when the setting is left out. A number is read
|
|
85
|
+
* as its digits, so a form that sent one and a form that sent a string store the same id.
|
|
86
|
+
*/
|
|
87
|
+
function idSetting(label, settings, name, shape, where = `the address of the ${name} in ${label}`) {
|
|
88
|
+
const value = settings[name];
|
|
89
|
+
if (value === void 0 || value === null || value === "") return null;
|
|
90
|
+
const text = typeof value === "number" ? String(value) : value;
|
|
91
|
+
if (typeof text !== "string" || !shape.test(text)) throw new Error(`The ${label} ${name} on this connection is not a ${label} id, so the entry was not sent. Save the ${label} connection again with the id from ${where}.`);
|
|
92
|
+
return text;
|
|
93
|
+
}
|
|
94
|
+
/** The same, for a setting an entry cannot be sent without. Refused before any call. */
|
|
95
|
+
function requiredId(label, settings, name, shape, where) {
|
|
96
|
+
const id = idSetting(label, settings, name, shape, where);
|
|
97
|
+
if (id === null) throw new Error(`This ${label} connection names no ${name}, so the entry was not sent. Save the ${label} connection again with its ${name}.`);
|
|
98
|
+
return id;
|
|
99
|
+
}
|
|
100
|
+
function startSecond(value) {
|
|
101
|
+
const at = Date.parse(value);
|
|
102
|
+
return Number.isNaN(at) ? null : Math.floor(at / 1e3);
|
|
103
|
+
}
|
|
104
|
+
/** The entry's start as a second, or a throw. The grid stamps every entry, so a throw here is a bug. */
|
|
105
|
+
function entrySecond(start) {
|
|
106
|
+
const second = startSecond(start);
|
|
107
|
+
if (second === null) throw new Error("The entry carries a start time Nolzu could not read, so it was not sent.");
|
|
108
|
+
return second;
|
|
109
|
+
}
|
|
110
|
+
/** A UTC time to the second, with no fraction, the form every one of the four reads. */
|
|
111
|
+
var utcSecond = (at) => `${new Date(at).toISOString().slice(0, 19)}Z`;
|
|
112
|
+
var DAY_MS = 864e5;
|
|
113
|
+
//#endregion
|
|
114
|
+
//#region src/lib/timesheet-clockify.ts
|
|
115
|
+
/**
|
|
116
|
+
* The Clockify exporter: one timesheet entry becomes one Clockify time entry. The `clockify` entry
|
|
117
|
+
* of `EXPORT_ADAPTERS`, with the same contract as `exportToggl`.
|
|
118
|
+
*
|
|
119
|
+
* LOOK BEFORE POSTING, for the reason the Toggl file gives. Clockify has no field for somebody
|
|
120
|
+
* else's id either, so an entry is recognised the way Toggl's is, by what this file wrote: the
|
|
121
|
+
* start and the end to the second and the description. The list is per user, so each post first
|
|
122
|
+
* asks Clockify who the token belongs to, which makes three calls per entry.
|
|
123
|
+
*
|
|
124
|
+
* NOT RECORDED. Clockify has never answered this project. Every path, header, field and status below
|
|
125
|
+
* is written from Clockify's API v1 documentation, and every body in the test file beside this one
|
|
126
|
+
* is written by hand from the same. A first real call has to confirm:
|
|
127
|
+
* 1. That `POST /api/v1/workspaces/{workspace}/time-entries` creates one entry and answers 201 with
|
|
128
|
+
* that entry as a JSON object whose `id` is a string.
|
|
129
|
+
* 2. That the API key goes in the `X-Api-Key` header.
|
|
130
|
+
* 3. The body: `start` and `end` as UTC times to the second, `description`, and `projectId`.
|
|
131
|
+
* 4. That `GET /api/v1/user` answers the key owner as an object with an `id`.
|
|
132
|
+
* 5. That `GET /api/v1/workspaces/{workspace}/user/{user}/time-entries?start=&end=&page-size=`
|
|
133
|
+
* answers a bare list of that user's entries starting inside the window, at most `page-size`
|
|
134
|
+
* of them.
|
|
135
|
+
* 6. That each listed row carries `id`, `description` and `timeInterval.start` and
|
|
136
|
+
* `timeInterval.end` under those names, with the times to the second as they were posted.
|
|
137
|
+
* 7. That 401 is a bad key, 403 a workspace the key cannot use, 404 an unknown workspace or
|
|
138
|
+
* project, 400 a refused field with a `message`, and 429 a rate limit.
|
|
139
|
+
*/
|
|
140
|
+
var CLOCKIFY_ORIGIN = "https://api.clockify.me";
|
|
141
|
+
var ID$2 = /^[0-9a-f]{24}$/;
|
|
142
|
+
var PAGE_SIZE = 200;
|
|
143
|
+
/** The workspace an entry goes into. A connection without one is refused before any call. */
|
|
144
|
+
var clockifyWorkspace = (settings) => requiredId("Clockify", settings, "workspace", ID$2);
|
|
145
|
+
/** The Clockify project, which is optional: an entry without one still lands in the workspace. */
|
|
146
|
+
var clockifyProject = (settings) => idSetting("Clockify", settings, "project", ID$2);
|
|
147
|
+
/** The card key first, so a person can find the card, then the title the grid drew. */
|
|
148
|
+
var clockifyDescription = (entry) => `${entry.card} ${entry.title}`;
|
|
149
|
+
/** The body of one post. Nothing in it comes from the token. */
|
|
150
|
+
function clockifyBody(entry, project) {
|
|
151
|
+
const at = entrySecond(entry.start) * 1e3;
|
|
152
|
+
return {
|
|
153
|
+
start: utcSecond(at),
|
|
154
|
+
end: utcSecond(at + entry.minutes * 6e4),
|
|
155
|
+
description: clockifyDescription(entry),
|
|
156
|
+
...project === null ? {} : { projectId: project }
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
/** The read that looks for an entry before it is posted: a day either side of its start. */
|
|
160
|
+
function clockifyDayPath(workspace, user, start) {
|
|
161
|
+
const at = entrySecond(start) * 1e3;
|
|
162
|
+
const window = new URLSearchParams({
|
|
163
|
+
start: utcSecond(at - DAY_MS),
|
|
164
|
+
end: utcSecond(at + DAY_MS),
|
|
165
|
+
"page-size": String(PAGE_SIZE)
|
|
166
|
+
});
|
|
167
|
+
return `/api/v1/workspaces/${workspace}/user/${encodeURIComponent(user)}/time-entries?${window}`;
|
|
168
|
+
}
|
|
169
|
+
/** The sentence one refused call leaves on the entry. One per status, because each fix differs. */
|
|
170
|
+
function clockifyRefusal(status, body, secrets = []) {
|
|
171
|
+
if (isHtml(body)) return webPage("Clockify");
|
|
172
|
+
if (status === 401) return "Clockify refused the API key, so the entry was not sent. Generate an API key in your Clockify profile and save the Clockify connection again.";
|
|
173
|
+
if (status === 403) return "Clockify says this API key cannot use that workspace, so the entry was not sent. Check the workspace on the Clockify connection.";
|
|
174
|
+
if (status === 404) return "Clockify does not know that workspace or project, or the key cannot see it, so the entry was not sent. Check the Clockify connection.";
|
|
175
|
+
if (status === 429) return "Clockify is rate limiting this API key, so the entry was not sent. Export again in a minute.";
|
|
176
|
+
if (status >= 500) return `Clockify answered ${status}, so the entry was not sent. Export again later.`;
|
|
177
|
+
return `Clockify refused the entry with ${status}, so it was not sent.${detail("Clockify", body, secrets)}`;
|
|
178
|
+
}
|
|
179
|
+
var idOf$3 = (value) => typeof value === "string" && /^[0-9A-Za-z]{1,64}$/.test(value) ? value : null;
|
|
180
|
+
/** The key owner's id, which the list of entries is filed under. */
|
|
181
|
+
function readClockifyUser(body) {
|
|
182
|
+
let user;
|
|
183
|
+
try {
|
|
184
|
+
user = JSON.parse(body);
|
|
185
|
+
} catch {}
|
|
186
|
+
const id = user !== null && typeof user === "object" ? idOf$3(user.id) : null;
|
|
187
|
+
if (id === null) throw new Error("Clockify answered who owns the API key with something Nolzu could not read, so the entry was not sent.");
|
|
188
|
+
return id;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* The id of the entry Clockify already holds for this one, or null when it holds none.
|
|
192
|
+
*
|
|
193
|
+
* The same refusals as `findTogglEntry`: an answer that is not a list, a list whose rows carry no
|
|
194
|
+
* time this file can read, and a row at this entry's times whose description or id it cannot read.
|
|
195
|
+
* And a full page with no match, because the entry could be on the next one.
|
|
196
|
+
*/
|
|
197
|
+
function findClockifyEntry(body, entry) {
|
|
198
|
+
let rows;
|
|
199
|
+
try {
|
|
200
|
+
rows = JSON.parse(body);
|
|
201
|
+
} catch {
|
|
202
|
+
throw new Error("Clockify answered the day with something Nolzu could not read, so the entry was not sent.");
|
|
203
|
+
}
|
|
204
|
+
if (!Array.isArray(rows)) throw new Error("Clockify answered the day with something that is not a list of entries, so the entry was not sent.");
|
|
205
|
+
const start = entrySecond(entry.start);
|
|
206
|
+
const end = start + entry.minutes * 60;
|
|
207
|
+
const description = clockifyDescription(entry);
|
|
208
|
+
let readable = 0;
|
|
209
|
+
for (const row of rows) {
|
|
210
|
+
if (row === null || typeof row !== "object") continue;
|
|
211
|
+
const one = row;
|
|
212
|
+
const interval = one.timeInterval !== null && typeof one.timeInterval === "object" ? one.timeInterval : {};
|
|
213
|
+
const from = typeof interval.start === "string" ? startSecond(interval.start) : null;
|
|
214
|
+
const to = typeof interval.end === "string" ? startSecond(interval.end) : null;
|
|
215
|
+
if (from === null || to === null) continue;
|
|
216
|
+
readable += 1;
|
|
217
|
+
if (from !== start || to !== end) continue;
|
|
218
|
+
if (!(typeof one.description === "string" || one.description === null)) throw new Error("Clockify holds an entry at the same time on that day and Nolzu could not read its description, so the entry was not sent. Nolzu is reading the answer wrongly.");
|
|
219
|
+
if (one.description !== description) continue;
|
|
220
|
+
const id = idOf$3(one.id);
|
|
221
|
+
if (id === null) throw new Error("Clockify already holds this entry and Nolzu could not read its id, so the entry was not sent again.");
|
|
222
|
+
return id;
|
|
223
|
+
}
|
|
224
|
+
if (rows.length > 0 && readable === 0) throw new Error(`Clockify answered ${rows.length === 1 ? "one entry" : `${rows.length} entries`} on that day and Nolzu could read the time on none of them, so the entry was not sent. Nolzu is reading the answer wrongly.`);
|
|
225
|
+
if (rows.length >= PAGE_SIZE) throw new Error("Clockify answered a full page of entries around that day, so Nolzu could not tell whether it already holds the entry and did not send it.");
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Posts one entry to Clockify and answers with the id Clockify gave it.
|
|
230
|
+
*
|
|
231
|
+
* ponytail: three calls per entry, the user read included. The user could be read once per export,
|
|
232
|
+
* and the `ExportAdapter` contract gives this file one entry at a time. If the rate limit bites, the
|
|
233
|
+
* upgrade is a batch seam on the contract, the same one the Toggl file names.
|
|
234
|
+
*/
|
|
235
|
+
async function exportClockify(entry, secret, settings, signal, fetcher) {
|
|
236
|
+
const workspace = clockifyWorkspace(settings);
|
|
237
|
+
const project = clockifyProject(settings);
|
|
238
|
+
const body = JSON.stringify(clockifyBody(entry, project));
|
|
239
|
+
const to = {
|
|
240
|
+
label: "Clockify",
|
|
241
|
+
origin: new URL(CLOCKIFY_ORIGIN),
|
|
242
|
+
headers: { "x-api-key": secret },
|
|
243
|
+
secrets: [secret],
|
|
244
|
+
refusal: clockifyRefusal,
|
|
245
|
+
fetcher
|
|
246
|
+
};
|
|
247
|
+
const held = findClockifyEntry(await callDestination(to, "GET", clockifyDayPath(workspace, readClockifyUser(await callDestination(to, "GET", "/api/v1/user", void 0, signal)), entry.start), void 0, signal), entry);
|
|
248
|
+
if (held !== null) return held;
|
|
249
|
+
const posted = await callDestination(to, "POST", `/api/v1/workspaces/${workspace}/time-entries`, body, signal, 201);
|
|
250
|
+
let id = null;
|
|
251
|
+
try {
|
|
252
|
+
id = idOf$3(JSON.parse(posted)?.id);
|
|
253
|
+
} catch {}
|
|
254
|
+
if (id === null) throw new Error("Clockify answered the post with something Nolzu could not read, so the entry is not marked as sent. The next export looks for it in Clockify before it posts again.");
|
|
255
|
+
return id;
|
|
256
|
+
}
|
|
257
|
+
//#endregion
|
|
258
|
+
//#region src/lib/timesheet-harvest.ts
|
|
259
|
+
/**
|
|
260
|
+
* The Harvest exporter: one timesheet entry becomes one Harvest time entry. The `harvest` entry of
|
|
261
|
+
* `EXPORT_ADAPTERS`, with the same contract as `exportToggl`.
|
|
262
|
+
*
|
|
263
|
+
* LOOK BEFORE POSTING, for the reason the Toggl file gives: a timeout after Harvest took an entry
|
|
264
|
+
* reads as a failure here, and the next press would bill the hours again. Harvest has a field for
|
|
265
|
+
* somebody else's id, `external_reference`, so every entry goes in carrying Nolzu's external id and
|
|
266
|
+
* every post starts with a read of that day for it. That is the skip by external id, done at the
|
|
267
|
+
* destination as well as in the sent rows. The read is the whole day and not Harvest's own filter on
|
|
268
|
+
* the reference: if Harvest drops the reference, the filter would hide the entry and the hours would
|
|
269
|
+
* be posted again, while the whole day still shows it and the same day, hours and notes refuse.
|
|
270
|
+
*
|
|
271
|
+
* A DAY, NOT AN INSTANT. Harvest keeps a time entry as a date and hours, so the date sent is the UTC
|
|
272
|
+
* day the grid drew the cell under, and the entry's start is not sent.
|
|
273
|
+
*
|
|
274
|
+
* NOT RECORDED. Harvest has never answered this project. Every path, header, field and status below
|
|
275
|
+
* is written from Harvest's API v2 documentation, and every body in the test file beside this one is
|
|
276
|
+
* written by hand from the same. A first real call has to confirm:
|
|
277
|
+
* 1. That `POST /v2/time_entries` creates one entry and answers 201 with that entry as a JSON object
|
|
278
|
+
* whose `id` is a number.
|
|
279
|
+
* 2. The headers: `Authorization: Bearer <token>`, `Harvest-Account-Id: <account>`, and a
|
|
280
|
+
* `User-Agent` naming the app, which Harvest asks every client to send.
|
|
281
|
+
* 3. The body: `project_id`, `task_id`, `spent_date` as YYYY-MM-DD, `hours` as a decimal, `notes`,
|
|
282
|
+
* and `external_reference` as an object with an `id`. That a personal token may set
|
|
283
|
+
* `external_reference` at all, and that `hours` is taken on an account set to track time with
|
|
284
|
+
* start and end times. A fraction such as a third of an hour is sent as it is.
|
|
285
|
+
* 4. That `GET /v2/time_entries?from=<day>&to=<day>&per_page=2000` answers an object whose
|
|
286
|
+
* `time_entries` is a list of that day's entries, with `next_page` null on the last page.
|
|
287
|
+
* 5. That each listed row carries `id`, `spent_date`, `hours`, `notes` and `external_reference.id`
|
|
288
|
+
* under those names.
|
|
289
|
+
* 6. That 401 is a bad token, 403 a token that cannot use that account, 404 a project or task the
|
|
290
|
+
* token cannot see, 422 a refused field with a `message`, and 429 a rate limit.
|
|
291
|
+
*/
|
|
292
|
+
var HARVEST_ORIGIN = "https://api.harvestapp.com";
|
|
293
|
+
/** Who Harvest is told is calling. Its documentation asks every client for a name and a contact. */
|
|
294
|
+
var HARVEST_USER_AGENT = "Nolzu (https://nolzu.com)";
|
|
295
|
+
var ID$1 = /^[1-9]\d{0,15}$/;
|
|
296
|
+
/** The three ids a Harvest connection needs. All three are refused before any call when missing. */
|
|
297
|
+
function harvestIds(settings) {
|
|
298
|
+
return {
|
|
299
|
+
account: requiredId("Harvest", settings, "account", ID$1, "the Harvest developers page, where the token was made"),
|
|
300
|
+
project: Number(requiredId("Harvest", settings, "project", ID$1)),
|
|
301
|
+
task: Number(requiredId("Harvest", settings, "task", ID$1))
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
/** The card key first, so a person can find the card, then the title the grid drew. */
|
|
305
|
+
var harvestNotes = (entry) => `${entry.card} ${entry.title}`;
|
|
306
|
+
/** The body of one post. Nothing in it comes from the token. */
|
|
307
|
+
function harvestBody(entry, project, task) {
|
|
308
|
+
return {
|
|
309
|
+
project_id: project,
|
|
310
|
+
task_id: task,
|
|
311
|
+
spent_date: entry.day,
|
|
312
|
+
hours: entry.minutes / 60,
|
|
313
|
+
notes: harvestNotes(entry),
|
|
314
|
+
external_reference: { id: entry.externalId }
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
/** The read that looks for an entry before it is posted: that whole day, on one page. */
|
|
318
|
+
var harvestDayPath = (entry) => `/v2/time_entries?${new URLSearchParams({
|
|
319
|
+
from: entry.day,
|
|
320
|
+
to: entry.day,
|
|
321
|
+
per_page: "2000"
|
|
322
|
+
})}`;
|
|
323
|
+
/** The sentence one refused call leaves on the entry. One per status, because each fix differs. */
|
|
324
|
+
function harvestRefusal(status, body, secrets = []) {
|
|
325
|
+
if (isHtml(body)) return webPage("Harvest");
|
|
326
|
+
if (status === 401) return "Harvest refused the API token, so the entry was not sent. Create a personal access token in Harvest and save the Harvest connection again.";
|
|
327
|
+
if (status === 403) return "Harvest says this token cannot use that account, so the entry was not sent. Check the account id on the Harvest connection.";
|
|
328
|
+
if (status === 404) return "Harvest does not know that project or task, or the token cannot see it, so the entry was not sent. Check the Harvest connection.";
|
|
329
|
+
if (status === 429) return "Harvest is rate limiting this API token, so the entry was not sent. Export again in a minute.";
|
|
330
|
+
if (status >= 500) return `Harvest answered ${status}, so the entry was not sent. Export again later.`;
|
|
331
|
+
return `Harvest refused the entry with ${status}, so it was not sent.${detail("Harvest", body, secrets)}`;
|
|
332
|
+
}
|
|
333
|
+
var idOf$2 = (value) => typeof value === "number" && Number.isInteger(value) && value > 0 || typeof value === "string" && ID$1.test(value) ? String(value) : null;
|
|
334
|
+
/**
|
|
335
|
+
* The id of the entry Harvest already holds for this one, or null when it holds none.
|
|
336
|
+
*
|
|
337
|
+
* An answer that is not a list is refused and never read as an empty day, because an empty day is
|
|
338
|
+
* what lets the post go ahead. A row that is this entry by its day, hours and notes but carries no
|
|
339
|
+
* readable reference is refused too: that is a reference Harvest did not keep or a field read under
|
|
340
|
+
* the wrong name, and passing over it would post the hours again. So is a second page, because the
|
|
341
|
+
* entry could be on it.
|
|
342
|
+
*/
|
|
343
|
+
function findHarvestEntry(body, entry) {
|
|
344
|
+
let answer;
|
|
345
|
+
try {
|
|
346
|
+
answer = JSON.parse(body);
|
|
347
|
+
} catch {
|
|
348
|
+
throw new Error("Harvest answered the day with something Nolzu could not read, so the entry was not sent.");
|
|
349
|
+
}
|
|
350
|
+
const page = answer !== null && typeof answer === "object" ? answer : {};
|
|
351
|
+
if (!Array.isArray(page.time_entries)) throw new Error("Harvest answered the day with something that is not a list of time entries, so the entry was not sent.");
|
|
352
|
+
for (const row of page.time_entries) {
|
|
353
|
+
if (row === null || typeof row !== "object") continue;
|
|
354
|
+
const one = row;
|
|
355
|
+
const reference = one.external_reference;
|
|
356
|
+
const referenceId = reference !== null && typeof reference === "object" ? reference.id : void 0;
|
|
357
|
+
if (referenceId === entry.externalId) {
|
|
358
|
+
const id = idOf$2(one.id);
|
|
359
|
+
if (id === null) throw new Error("Harvest already holds this entry and Nolzu could not read its id, so the entry was not sent again.");
|
|
360
|
+
return id;
|
|
361
|
+
}
|
|
362
|
+
if (one.spent_date === entry.day && typeof one.hours === "number" && Math.abs(one.hours - entry.minutes / 60) < .01 && one.notes === harvestNotes(entry) && typeof referenceId !== "string") throw new Error("Harvest holds an entry with the same day, hours and notes and Nolzu could not read its reference, so the entry was not sent. Nolzu is reading the answer wrongly.");
|
|
363
|
+
}
|
|
364
|
+
if (page.next_page !== null && page.next_page !== void 0) throw new Error("Harvest answered the day over more than one page, so Nolzu could not tell whether it already holds the entry and did not send it.");
|
|
365
|
+
return null;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Posts one entry to Harvest and answers with the id Harvest gave it.
|
|
369
|
+
*
|
|
370
|
+
* The fetcher is the last parameter and optional, so this function is itself the adapter
|
|
371
|
+
* `EXPORT_ADAPTERS` holds and a test still drives every call by hand.
|
|
372
|
+
*/
|
|
373
|
+
async function exportHarvest(entry, secret, settings, signal, fetcher) {
|
|
374
|
+
const { account, project, task } = harvestIds(settings);
|
|
375
|
+
const to = {
|
|
376
|
+
label: "Harvest",
|
|
377
|
+
origin: new URL(HARVEST_ORIGIN),
|
|
378
|
+
headers: {
|
|
379
|
+
authorization: `Bearer ${secret}`,
|
|
380
|
+
"harvest-account-id": account,
|
|
381
|
+
"user-agent": HARVEST_USER_AGENT
|
|
382
|
+
},
|
|
383
|
+
secrets: [secret],
|
|
384
|
+
refusal: harvestRefusal,
|
|
385
|
+
fetcher
|
|
386
|
+
};
|
|
387
|
+
const held = findHarvestEntry(await callDestination(to, "GET", harvestDayPath(entry), void 0, signal), entry);
|
|
388
|
+
if (held !== null) return held;
|
|
389
|
+
const posted = await callDestination(to, "POST", "/v2/time_entries", JSON.stringify(harvestBody(entry, project, task)), signal, 201);
|
|
390
|
+
let id = null;
|
|
391
|
+
try {
|
|
392
|
+
id = idOf$2(JSON.parse(posted)?.id);
|
|
393
|
+
} catch {}
|
|
394
|
+
if (id === null) throw new Error("Harvest answered the post with something Nolzu could not read, so the entry is not marked as sent. The next export looks for it in Harvest before it posts again.");
|
|
395
|
+
return id;
|
|
396
|
+
}
|
|
397
|
+
//#endregion
|
|
398
|
+
//#region src/lib/timesheet-jira.ts
|
|
399
|
+
/**
|
|
400
|
+
* The Jira worklog exporter: one timesheet entry becomes one worklog on the card's Jira issue. The
|
|
401
|
+
* `jira` entry of `EXPORT_ADAPTERS`, with the same contract as `exportToggl`. It is not the Jira
|
|
402
|
+
* ticket reader in `@nolzu/runner` and shares no token with it: that one reads issues with the
|
|
403
|
+
* `jira-token` entry, and this one writes hours with the token a person saved for exporting.
|
|
404
|
+
*
|
|
405
|
+
* ONLY A JIRA CARD. An entry whose card came from Jira goes to the issue with that key. Every other
|
|
406
|
+
* entry is skipped with its reason, never posted: a local key is spelled like a Jira key, and
|
|
407
|
+
* posting on the spelling alone would put a person's hours on a stranger's issue. An entry with no
|
|
408
|
+
* source is a card that is gone, and is skipped too.
|
|
409
|
+
*
|
|
410
|
+
* LOOK BEFORE POSTING, for the reason the Toggl file gives. Jira keeps properties on a worklog, so
|
|
411
|
+
* every worklog goes in carrying Nolzu's external id under the property `nolzu`, and every post
|
|
412
|
+
* starts with a read of that issue's worklogs around the start, properties included, for it.
|
|
413
|
+
*
|
|
414
|
+
* NOT RECORDED. No Jira site has ever answered this exporter. Every path, header, field and status
|
|
415
|
+
* below is written from the Jira Cloud REST API v3 documentation, and every body in the test file
|
|
416
|
+
* beside this one is written by hand from the same. A first real call has to confirm:
|
|
417
|
+
* 1. That `POST /rest/api/3/issue/{key}/worklog?notifyUsers=false` adds one worklog and answers 201
|
|
418
|
+
* with it as a JSON object whose `id` is a string of digits, and that `notifyUsers=false` is
|
|
419
|
+
* allowed for a person who is not a Jira admin.
|
|
420
|
+
* 2. That Basic auth with the account email and the API token is taken, the same as the ticket read.
|
|
421
|
+
* 3. The body: `started` as `2026-03-02T14:00:00.000+0000`, `timeSpentSeconds`, `comment` as an
|
|
422
|
+
* Atlassian document, and `properties` as a list of `key` and `value`.
|
|
423
|
+
* 4. That `GET /rest/api/3/issue/{key}/worklog?startedAfter=<ms>&startedBefore=<ms>&expand=properties`
|
|
424
|
+
* answers an object whose `worklogs` is a list and whose `total` counts them all, and that each
|
|
425
|
+
* worklog carries `id` and `properties` under those names, an empty list when it has none.
|
|
426
|
+
* 5. That 401 is a bad token, 403 an issue the account may not log work on, 404 an issue that is
|
|
427
|
+
* gone or hidden from the account, 400 a refused field with `errorMessages` or `errors`, and 429
|
|
428
|
+
* a rate limit.
|
|
429
|
+
*/
|
|
430
|
+
/** The worklog property that carries Nolzu's external id. */
|
|
431
|
+
var JIRA_PROPERTY = "nolzu";
|
|
432
|
+
var KEY = /^[A-Z][A-Z0-9_]*-[1-9]\d*$/;
|
|
433
|
+
var MAX_WORKLOGS = 5e3;
|
|
434
|
+
/**
|
|
435
|
+
* The issue an entry goes to, or `ExportSkipped` with the reason. Thrown before any call and before
|
|
436
|
+
* the connection is read, so a local card costs nothing.
|
|
437
|
+
*/
|
|
438
|
+
function jiraIssue(entry) {
|
|
439
|
+
if (entry.source === null) throw new ExportSkipped(`The card ${entry.card} is gone, so Nolzu cannot tell whether it is a Jira issue and did not send its hours to Jira.`);
|
|
440
|
+
if (entry.source !== "jira") throw new ExportSkipped(`${entry.card} is not a Jira issue, so its hours were not sent to Jira.`);
|
|
441
|
+
if (!KEY.test(entry.card)) throw new Error(`${entry.card} came from Jira and is not a Jira issue key, so the entry was not sent.`);
|
|
442
|
+
return entry.card;
|
|
443
|
+
}
|
|
444
|
+
function textSetting(settings, name, says) {
|
|
445
|
+
const value = settings[name];
|
|
446
|
+
if (typeof value !== "string" || value.trim() === "") throw new Error(`This Jira connection names no ${says}, so the entry was not sent. Save the Jira connection again with it.`);
|
|
447
|
+
return value.trim();
|
|
448
|
+
}
|
|
449
|
+
/** Jira's own time form: milliseconds and a zone with no colon. It refuses a bare Z. */
|
|
450
|
+
var jiraStarted = (second) => (/* @__PURE__ */ new Date(second * 1e3)).toISOString().replace("Z", "+0000");
|
|
451
|
+
/** The body of one worklog. The comment is the title, because the issue already says the card. */
|
|
452
|
+
function jiraBody(entry) {
|
|
453
|
+
return {
|
|
454
|
+
started: jiraStarted(entrySecond(entry.start)),
|
|
455
|
+
timeSpentSeconds: entry.minutes * 60,
|
|
456
|
+
comment: {
|
|
457
|
+
type: "doc",
|
|
458
|
+
version: 1,
|
|
459
|
+
content: [{
|
|
460
|
+
type: "paragraph",
|
|
461
|
+
content: [{
|
|
462
|
+
type: "text",
|
|
463
|
+
text: entry.title
|
|
464
|
+
}]
|
|
465
|
+
}]
|
|
466
|
+
},
|
|
467
|
+
properties: [{
|
|
468
|
+
key: JIRA_PROPERTY,
|
|
469
|
+
value: { externalId: entry.externalId }
|
|
470
|
+
}]
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
var worklogPath = (key) => `/rest/api/3/issue/${encodeURIComponent(key)}/worklog`;
|
|
474
|
+
/** The read that looks for a worklog before it is posted: a day either side of its start. */
|
|
475
|
+
function jiraDayPath(key, start) {
|
|
476
|
+
const at = entrySecond(start) * 1e3;
|
|
477
|
+
const window = new URLSearchParams({
|
|
478
|
+
startedAfter: String(at - DAY_MS),
|
|
479
|
+
startedBefore: String(at + DAY_MS),
|
|
480
|
+
expand: "properties",
|
|
481
|
+
maxResults: String(MAX_WORKLOGS)
|
|
482
|
+
});
|
|
483
|
+
return `${worklogPath(key)}?${window}`;
|
|
484
|
+
}
|
|
485
|
+
/** The sentence one refused call leaves on the entry. One per status, because each fix differs. */
|
|
486
|
+
function jiraRefusal(status, body, secrets = []) {
|
|
487
|
+
if (isHtml(body)) return webPage("Jira");
|
|
488
|
+
if (status === 401) return "Jira refused the API token, so the entry was not sent. Create an API token for the account email and save the Jira connection again.";
|
|
489
|
+
if (status === 403) return "Jira says this account may not log work on that issue, so the entry was not sent. Check the account on the Jira connection.";
|
|
490
|
+
if (status === 404) return "Jira does not show that issue to this account, so the entry was not sent. The issue may be gone, or the email or API token on the Jira connection is wrong.";
|
|
491
|
+
if (status === 429) return "Jira is rate limiting this API token, so the entry was not sent. Export again in a minute.";
|
|
492
|
+
if (status >= 500) return `Jira answered ${status}, so the entry was not sent. Export again later.`;
|
|
493
|
+
return `Jira refused the worklog with ${status}, so it was not sent.${detail("Jira", body, secrets)}`;
|
|
494
|
+
}
|
|
495
|
+
var idOf$1 = (value) => typeof value === "string" && /^[1-9]\d{0,18}$/.test(value) || typeof value === "number" && Number.isInteger(value) && value > 0 ? String(value) : null;
|
|
496
|
+
/**
|
|
497
|
+
* The id of the worklog Jira already holds for this entry, or null when it holds none.
|
|
498
|
+
*
|
|
499
|
+
* A worklog at the same start and length with no `nolzu` property is refused, because that is what
|
|
500
|
+
* this entry looks like if Jira did not keep the property. An answer with no list of worklogs is
|
|
501
|
+
* refused, and so is a list in which no worklog carries a list of properties, because that is the
|
|
502
|
+
* expand being ignored and every match would be missed. So is a `total` larger than the list,
|
|
503
|
+
* because the worklog could be past the part that came back.
|
|
504
|
+
*/
|
|
505
|
+
function findJiraWorklog(body, entry) {
|
|
506
|
+
let answer;
|
|
507
|
+
try {
|
|
508
|
+
answer = JSON.parse(body);
|
|
509
|
+
} catch {
|
|
510
|
+
throw new Error("Jira answered the worklogs with something Nolzu could not read, so the entry was not sent.");
|
|
511
|
+
}
|
|
512
|
+
const page = answer !== null && typeof answer === "object" ? answer : {};
|
|
513
|
+
const rows = page.worklogs;
|
|
514
|
+
if (!Array.isArray(rows)) throw new Error("Jira answered the worklogs with something that is not a list, so the entry was not sent.");
|
|
515
|
+
let readable = 0;
|
|
516
|
+
let unmarked = false;
|
|
517
|
+
for (const row of rows) {
|
|
518
|
+
if (row === null || typeof row !== "object") continue;
|
|
519
|
+
const one = row;
|
|
520
|
+
if (!Array.isArray(one.properties)) continue;
|
|
521
|
+
readable += 1;
|
|
522
|
+
const ours = one.properties.find((property) => property !== null && typeof property === "object" && property.key === "nolzu");
|
|
523
|
+
if (ours === void 0) {
|
|
524
|
+
unmarked ||= typeof one.started === "string" && startSecond(one.started) === entrySecond(entry.start) && one.timeSpentSeconds === entry.minutes * 60;
|
|
525
|
+
continue;
|
|
526
|
+
}
|
|
527
|
+
const value = ours.value;
|
|
528
|
+
if (value === null || typeof value !== "object" || value.externalId !== entry.externalId) continue;
|
|
529
|
+
const id = idOf$1(one.id);
|
|
530
|
+
if (id === null) throw new Error("Jira already holds this worklog and Nolzu could not read its id, so the entry was not sent again.");
|
|
531
|
+
return id;
|
|
532
|
+
}
|
|
533
|
+
if (unmarked) throw new Error("Jira holds a worklog with the same start and length and without the Nolzu property, so the entry was not sent. It may be this one with its property dropped.");
|
|
534
|
+
if (rows.length > 0 && readable === 0) throw new Error("Jira answered the worklogs without their properties, so Nolzu could not tell whether it already holds this one and did not send it. Nolzu is reading the answer wrongly.");
|
|
535
|
+
if (typeof page.total === "number" && page.total > rows.length) throw new Error("Jira holds more worklogs around that day than one read returns, so Nolzu could not tell whether it already holds this one and did not send it.");
|
|
536
|
+
return null;
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* Posts one entry as a worklog on its Jira issue and answers with the id Jira gave it.
|
|
540
|
+
*
|
|
541
|
+
* The connection settings are `site` and `email`, the same two a Jira ticket query keeps, and the
|
|
542
|
+
* token is the API token of that email.
|
|
543
|
+
*/
|
|
544
|
+
async function exportJira(entry, secret, settings, signal, fetcher) {
|
|
545
|
+
const key = jiraIssue(entry);
|
|
546
|
+
const origin = siteOrigin(textSetting(settings, "site", "Jira site address"));
|
|
547
|
+
const authorization = basicAuth(textSetting(settings, "email", "account email"), secret);
|
|
548
|
+
const to = {
|
|
549
|
+
label: "Jira",
|
|
550
|
+
origin,
|
|
551
|
+
headers: { authorization },
|
|
552
|
+
secrets: [secret, authorization.slice(6)],
|
|
553
|
+
refusal: jiraRefusal,
|
|
554
|
+
fetcher
|
|
555
|
+
};
|
|
556
|
+
const held = findJiraWorklog(await callDestination(to, "GET", jiraDayPath(key, entry.start), void 0, signal), entry);
|
|
557
|
+
if (held !== null) return held;
|
|
558
|
+
const body = JSON.stringify(jiraBody(entry));
|
|
559
|
+
const posted = await callDestination(to, "POST", `${worklogPath(key)}?notifyUsers=false`, body, signal, 201);
|
|
560
|
+
let id = null;
|
|
561
|
+
try {
|
|
562
|
+
id = idOf$1(JSON.parse(posted)?.id);
|
|
563
|
+
} catch {}
|
|
564
|
+
if (id === null) throw new Error("Jira answered the worklog with something Nolzu could not read, so the entry is not marked as sent. The next export looks for it in Jira before it posts again.");
|
|
565
|
+
return id;
|
|
566
|
+
}
|
|
567
|
+
//#endregion
|
|
568
|
+
//#region src/lib/timesheet-toggl.ts
|
|
569
|
+
/**
|
|
570
|
+
* The Toggl exporter: one timesheet entry becomes one Toggl time entry. The `toggl` entry of
|
|
571
|
+
* `EXPORT_ADAPTERS`.
|
|
572
|
+
*
|
|
573
|
+
* `timesheet-export.ts` owns everything around this: the connection, the token in the keychain, the
|
|
574
|
+
* sent rows that skip an entry by its external id, the timeout and the cap on failures. This file
|
|
575
|
+
* owns the address, the two calls, the body, and the sentence each refusal leaves on the entry.
|
|
576
|
+
*
|
|
577
|
+
* LOOK BEFORE POSTING. The export loop writes the sent row after the post returns, so a timeout
|
|
578
|
+
* after Toggl accepted an entry reads as a failure and the next press would post the same hours
|
|
579
|
+
* again. The `ExportAdapter` contract hands that case to this file. So every post starts with a read
|
|
580
|
+
* of the token owner's entries on that day, and an entry Toggl already holds is answered with its id
|
|
581
|
+
* and not posted. Toggl has no field for somebody else's id, and a tag per entry would fill the
|
|
582
|
+
* workspace with tags nobody made, so the entry is recognised by what this file wrote: the
|
|
583
|
+
* workspace, the start to the second, the duration and the description. A person who edited one of
|
|
584
|
+
* those in Toggl gets a second entry only after a failed press, never after a press that worked,
|
|
585
|
+
* because a sent row is skipped before this file is asked.
|
|
586
|
+
*
|
|
587
|
+
* NOT RECORDED. Toggl has never answered this project. Every path, header, field and status below is
|
|
588
|
+
* written from Toggl's API v9 documentation, and every body in the test file beside this one is
|
|
589
|
+
* written by hand from the same. A first real call has to confirm:
|
|
590
|
+
* 1. That `POST /api/v9/workspaces/{workspace_id}/time_entries` creates one entry and answers 200
|
|
591
|
+
* with that entry as a JSON object whose `id` is a number.
|
|
592
|
+
* 2. That the API token goes in as Basic auth with `<token>:api_token`.
|
|
593
|
+
* 3. The body: `created_with` is required, `workspace_id` is a number, `start` is an RFC 3339 time
|
|
594
|
+
* in UTC, `duration` is in seconds, and a positive duration with no `stop` makes a finished
|
|
595
|
+
* entry. `description` and `project_id` go in under those names.
|
|
596
|
+
* 4. That `GET /api/v9/me/time_entries?start_date=<RFC 3339>&end_date=<RFC 3339>` takes full UTC
|
|
597
|
+
* times and not only bare dates, answers a bare JSON array of the token owner's entries that
|
|
598
|
+
* start inside that window, and how far back it reaches. An older week may be refused there
|
|
599
|
+
* with a 400. A bare date would be read in the profile's time zone, which is why the window is
|
|
600
|
+
* given as times.
|
|
601
|
+
* 5. That each listed row carries `id`, `workspace_id`, `start`, `duration` and `description`
|
|
602
|
+
* under those names, and that `start` comes back to the second as it was posted.
|
|
603
|
+
* 6. That 401 or 403 is a bad token, 402 is a used up API quota, 404 is a workspace the token
|
|
604
|
+
* cannot see, and 429 is a rate limit.
|
|
605
|
+
*/
|
|
606
|
+
var TOGGL_ORIGIN = "https://api.track.toggl.com";
|
|
607
|
+
/** What Toggl is told made the entry. Its documentation asks every client to say. */
|
|
608
|
+
var TOGGL_CREATED_WITH = "Nolzu";
|
|
609
|
+
var ID = /^[1-9]\d{0,15}$/;
|
|
610
|
+
/** The workspace an entry goes into. A connection without one is refused before any call. */
|
|
611
|
+
var togglWorkspace = (settings) => Number(requiredId("Toggl", settings, "workspace", ID));
|
|
612
|
+
/** The Toggl project, which is optional: an entry without one still lands in the workspace. */
|
|
613
|
+
function togglProject(settings) {
|
|
614
|
+
const project = idSetting("Toggl", settings, "project", ID);
|
|
615
|
+
return project === null ? null : Number(project);
|
|
616
|
+
}
|
|
617
|
+
/** The card key first, so a person can find the card, then the title the grid drew. */
|
|
618
|
+
var togglDescription = (entry) => `${entry.card} ${entry.title}`;
|
|
619
|
+
/** The body of one post. Nothing in it comes from the token or the connection row but the ids. */
|
|
620
|
+
function togglBody(entry, workspace, project) {
|
|
621
|
+
const second = entrySecond(entry.start);
|
|
622
|
+
return {
|
|
623
|
+
created_with: TOGGL_CREATED_WITH,
|
|
624
|
+
workspace_id: workspace,
|
|
625
|
+
start: (/* @__PURE__ */ new Date(second * 1e3)).toISOString(),
|
|
626
|
+
duration: entry.minutes * 60,
|
|
627
|
+
description: togglDescription(entry),
|
|
628
|
+
...project === null ? {} : { project_id: project }
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* The read that looks for an entry before it is posted: the token owner's entries from a day before
|
|
633
|
+
* its start to a day after. Given as UTC times, because a bare date is a day in the profile's time
|
|
634
|
+
* zone and an entry near midnight would fall outside it. The match is on the exact second, so the
|
|
635
|
+
* wider window finds nothing extra.
|
|
636
|
+
*/
|
|
637
|
+
function togglDayPath(start) {
|
|
638
|
+
const at = entrySecond(start) * 1e3;
|
|
639
|
+
return `/api/v9/me/time_entries?${new URLSearchParams({
|
|
640
|
+
start_date: utcSecond(at - DAY_MS),
|
|
641
|
+
end_date: utcSecond(at + DAY_MS)
|
|
642
|
+
})}`;
|
|
643
|
+
}
|
|
644
|
+
var togglPostPath = (workspace) => `/api/v9/workspaces/${workspace}/time_entries`;
|
|
645
|
+
/** The sentence one refused call leaves on the entry. One per status, because each fix differs. */
|
|
646
|
+
function togglRefusal(status, body, secrets = []) {
|
|
647
|
+
if (isHtml(body)) return webPage("Toggl");
|
|
648
|
+
if (status === 401 || status === 403) return "Toggl refused the API token, so the entry was not sent. Copy the API token from your Toggl profile and save the Toggl connection again.";
|
|
649
|
+
if (status === 402) return "Toggl says this workspace has used up its API quota, so the entry was not sent. Export again when the quota resets.";
|
|
650
|
+
if (status === 404) return "Toggl does not know that workspace, or the token cannot see it, so the entry was not sent. Check the workspace on the Toggl connection.";
|
|
651
|
+
if (status === 429) return "Toggl is rate limiting this API token, so the entry was not sent. Export again in a minute.";
|
|
652
|
+
if (status >= 500) return `Toggl answered ${status}, so the entry was not sent. Export again later.`;
|
|
653
|
+
return `Toggl refused the entry with ${status}, so it was not sent.${detail("Toggl", body, secrets)}`;
|
|
654
|
+
}
|
|
655
|
+
/** One call on api.track.toggl.com, with the token in the one header that carries it. */
|
|
656
|
+
function askToggl(token, method, path, body, signal, fetcher) {
|
|
657
|
+
const header = btoa(`${token}:api_token`);
|
|
658
|
+
return callDestination({
|
|
659
|
+
label: "Toggl",
|
|
660
|
+
origin: new URL(TOGGL_ORIGIN),
|
|
661
|
+
headers: { authorization: `Basic ${header}` },
|
|
662
|
+
secrets: [token, header],
|
|
663
|
+
refusal: togglRefusal,
|
|
664
|
+
fetcher
|
|
665
|
+
}, method, path, body, signal);
|
|
666
|
+
}
|
|
667
|
+
var idOf = (value) => typeof value === "number" && Number.isInteger(value) && value > 0 || typeof value === "string" && ID.test(value) ? String(value) : null;
|
|
668
|
+
/**
|
|
669
|
+
* The id of the entry Toggl already holds for this one, or null when it holds none.
|
|
670
|
+
*
|
|
671
|
+
* An answer that is not a list is refused and never read as an empty day, because an empty day is
|
|
672
|
+
* what lets the post go ahead, and a misread one posts the hours a second time. The same goes for a
|
|
673
|
+
* list whose rows carry no start or duration this file can read: a field name written from the
|
|
674
|
+
* documentation is wrong on every row at once, so that is refused as well. A row with this entry's
|
|
675
|
+
* start and duration is refused too when its workspace, description or id cannot be read, because
|
|
676
|
+
* passing over it would post the hours again.
|
|
677
|
+
*/
|
|
678
|
+
function findTogglEntry(body, entry, workspace) {
|
|
679
|
+
let rows;
|
|
680
|
+
try {
|
|
681
|
+
rows = JSON.parse(body);
|
|
682
|
+
} catch {
|
|
683
|
+
throw new Error("Toggl answered the day with something Nolzu could not read, so the entry was not sent.");
|
|
684
|
+
}
|
|
685
|
+
if (!Array.isArray(rows)) throw new Error("Toggl answered the day with something that is not a list of entries, so the entry was not sent.");
|
|
686
|
+
const second = startSecond(entry.start);
|
|
687
|
+
const description = togglDescription(entry);
|
|
688
|
+
let readable = 0;
|
|
689
|
+
for (const row of rows) {
|
|
690
|
+
if (row === null || typeof row !== "object") continue;
|
|
691
|
+
const one = row;
|
|
692
|
+
const start = typeof one.start === "string" ? startSecond(one.start) : null;
|
|
693
|
+
if (start === null || typeof one.duration !== "number") continue;
|
|
694
|
+
readable += 1;
|
|
695
|
+
if (start !== second || one.duration !== entry.minutes * 60) continue;
|
|
696
|
+
if (typeof one.workspace_id !== "number" || !(typeof one.description === "string" || one.description === null)) throw new Error("Toggl holds an entry at the same time on that day and Nolzu could not read its workspace or description, so the entry was not sent. Nolzu is reading the answer wrongly.");
|
|
697
|
+
if (one.workspace_id !== workspace || one.description !== description) continue;
|
|
698
|
+
const id = idOf(one.id);
|
|
699
|
+
if (id === null) throw new Error("Toggl already holds this entry and Nolzu could not read its id, so the entry was not sent again.");
|
|
700
|
+
return id;
|
|
701
|
+
}
|
|
702
|
+
if (rows.length > 0 && readable === 0) throw new Error(`Toggl answered ${rows.length === 1 ? "one entry" : `${rows.length} entries`} on that day and Nolzu could read the time on none of them, so the entry was not sent. Nolzu is reading the answer wrongly.`);
|
|
703
|
+
return null;
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* Posts one entry to Toggl and answers with the id Toggl gave it.
|
|
707
|
+
*
|
|
708
|
+
* The fetcher is the last parameter and optional, so this function is itself the adapter
|
|
709
|
+
* `EXPORT_ADAPTERS` holds and a test still drives every call by hand.
|
|
710
|
+
*
|
|
711
|
+
* ponytail: one read and one post per entry, so a week of twenty entries is forty calls. One read per
|
|
712
|
+
* day would do, and the `ExportAdapter` contract gives this file one entry at a time. If Toggl's
|
|
713
|
+
* quota bites, the upgrade is a batch seam on the contract, not a cache in here.
|
|
714
|
+
*/
|
|
715
|
+
async function exportToggl(entry, secret, settings, signal, fetcher) {
|
|
716
|
+
const workspace = togglWorkspace(settings);
|
|
717
|
+
const project = togglProject(settings);
|
|
718
|
+
const body = JSON.stringify(togglBody(entry, workspace, project));
|
|
719
|
+
const held = findTogglEntry(await askToggl(secret, "GET", togglDayPath(entry.start), void 0, signal, fetcher), entry, workspace);
|
|
720
|
+
if (held !== null) return held;
|
|
721
|
+
const posted = await askToggl(secret, "POST", togglPostPath(workspace), body, signal, fetcher);
|
|
722
|
+
let id = null;
|
|
723
|
+
try {
|
|
724
|
+
id = idOf(JSON.parse(posted)?.id);
|
|
725
|
+
} catch {}
|
|
726
|
+
if (id === null) throw new Error("Toggl answered the post with something Nolzu could not read, so the entry is not marked as sent. The next export looks for it in Toggl before it posts again.");
|
|
727
|
+
return id;
|
|
728
|
+
}
|
|
729
|
+
//#endregion
|
|
730
|
+
//#region src/lib/timesheet-export.ts
|
|
731
|
+
/**
|
|
732
|
+
* The timesheet exporters: which time trackers this machine posts a week to, what it has already
|
|
733
|
+
* sent, and what the last export failed with.
|
|
734
|
+
*
|
|
735
|
+
* Everything runs here. The token is in the OS keychain, the call leaves from this machine, and the
|
|
736
|
+
* rows that stop a week being billed twice are in the local database. Nothing about an export goes
|
|
737
|
+
* to the hub: no frame carries it, and the Data sync list has no line for it.
|
|
738
|
+
*
|
|
739
|
+
* WHERE THE ENTRIES COME FROM. The week as the database holds it when Export is pressed.
|
|
740
|
+
* `timesheetEntries` in `@nolzu/protocol` reads them off that week's grid, so an entry cannot disagree
|
|
741
|
+
* with the cell the grid draws for it. A cell with a run still going is held back, because its
|
|
742
|
+
* figure leaves that run out and a sent day is never sent again.
|
|
743
|
+
*
|
|
744
|
+
* WHAT TRIES AGAIN. A person, by pressing Export again. There is no timer and no queue behind this:
|
|
745
|
+
* an export is something somebody asks for, and hours that failed to reach Toggl are not more correct
|
|
746
|
+
* an hour later. What the stored rows give that person is a second press that costs nothing:
|
|
747
|
+
* everything that went out is skipped by its id, and only what failed is tried. `MAX_ATTEMPTS` is
|
|
748
|
+
* where that stops, so a destination that refuses one entry for ever is not asked about it on every
|
|
749
|
+
* export.
|
|
750
|
+
*
|
|
751
|
+
* WHAT HAS ALREADY GONE NEVER GOES AGAIN. The external id carries no figure, so a run added to a
|
|
752
|
+
* day that was exported keeps that day's id. This file then skips it and counts it as changed,
|
|
753
|
+
* which the panel says out loud. The other way round is a second entry for hours a client was
|
|
754
|
+
* already billed for, and no ceiling anywhere would take that money back.
|
|
755
|
+
*/
|
|
756
|
+
/** The destinations a week can go to. A name here is a column value and part of a keychain name. */
|
|
757
|
+
var EXPORT_DESTINATIONS = [
|
|
758
|
+
"toggl",
|
|
759
|
+
"harvest",
|
|
760
|
+
"clockify",
|
|
761
|
+
"jira"
|
|
762
|
+
];
|
|
763
|
+
var isExportDestination = (value) => EXPORT_DESTINATIONS.includes(value);
|
|
764
|
+
var DESTINATION_LABELS = {
|
|
765
|
+
toggl: "Toggl",
|
|
766
|
+
harvest: "Harvest",
|
|
767
|
+
clockify: "Clockify",
|
|
768
|
+
jira: "Jira"
|
|
769
|
+
};
|
|
770
|
+
/**
|
|
771
|
+
* The keychain entry one destination's token lives under, next to the Scout tokens and under the
|
|
772
|
+
* same service. One entry per destination for the whole data folder, whatever the number of projects.
|
|
773
|
+
*/
|
|
774
|
+
var exporterSecretName = (destination) => `export-${destination}`;
|
|
775
|
+
/**
|
|
776
|
+
* The adapters this client has. Each is written from its destination's documentation and not from
|
|
777
|
+
* a recorded answer, and the header of each adapter file names what the first real call has to
|
|
778
|
+
* confirm.
|
|
779
|
+
*/
|
|
780
|
+
var EXPORT_ADAPTERS = {
|
|
781
|
+
toggl: exportToggl,
|
|
782
|
+
harvest: exportHarvest,
|
|
783
|
+
clockify: exportClockify,
|
|
784
|
+
jira: exportJira
|
|
785
|
+
};
|
|
786
|
+
/** How long one entry's post may take, its read before it included. */
|
|
787
|
+
var EXPORT_TIMEOUT_MS = 2e4;
|
|
788
|
+
/** The sentence an entry gets when the destination did not answer in time. */
|
|
789
|
+
var EXPORT_TIMEOUT_SENTENCE = "The destination did not answer in time, so the entry was not sent.";
|
|
790
|
+
var MAX_ERROR_CHARS = 300;
|
|
791
|
+
var MAX_SETTINGS_CHARS = 4096;
|
|
792
|
+
var EXPORTER_FORMS = [
|
|
793
|
+
{
|
|
794
|
+
destination: "toggl",
|
|
795
|
+
label: "Toggl",
|
|
796
|
+
fields: [{
|
|
797
|
+
name: "workspace",
|
|
798
|
+
label: "Workspace id",
|
|
799
|
+
placeholder: "1234567",
|
|
800
|
+
required: true
|
|
801
|
+
}, {
|
|
802
|
+
name: "project",
|
|
803
|
+
label: "Project id",
|
|
804
|
+
placeholder: "optional",
|
|
805
|
+
required: false
|
|
806
|
+
}],
|
|
807
|
+
secret: "API token",
|
|
808
|
+
where: "The API token is at the bottom of your Toggl profile. The ids are in the address of the workspace and the project."
|
|
809
|
+
},
|
|
810
|
+
{
|
|
811
|
+
destination: "harvest",
|
|
812
|
+
label: "Harvest",
|
|
813
|
+
fields: [
|
|
814
|
+
{
|
|
815
|
+
name: "account",
|
|
816
|
+
label: "Account id",
|
|
817
|
+
placeholder: "123456",
|
|
818
|
+
required: true
|
|
819
|
+
},
|
|
820
|
+
{
|
|
821
|
+
name: "project",
|
|
822
|
+
label: "Project id",
|
|
823
|
+
placeholder: "1234567",
|
|
824
|
+
required: true
|
|
825
|
+
},
|
|
826
|
+
{
|
|
827
|
+
name: "task",
|
|
828
|
+
label: "Task id",
|
|
829
|
+
placeholder: "1234567",
|
|
830
|
+
required: true
|
|
831
|
+
}
|
|
832
|
+
],
|
|
833
|
+
secret: "personal access token",
|
|
834
|
+
where: "Create a personal access token on the Harvest developers page. The account id is on the same page."
|
|
835
|
+
},
|
|
836
|
+
{
|
|
837
|
+
destination: "clockify",
|
|
838
|
+
label: "Clockify",
|
|
839
|
+
fields: [{
|
|
840
|
+
name: "workspace",
|
|
841
|
+
label: "Workspace id",
|
|
842
|
+
placeholder: "24 characters, 0-9 and a-f",
|
|
843
|
+
required: true
|
|
844
|
+
}, {
|
|
845
|
+
name: "project",
|
|
846
|
+
label: "Project id",
|
|
847
|
+
placeholder: "optional",
|
|
848
|
+
required: false
|
|
849
|
+
}],
|
|
850
|
+
secret: "API key",
|
|
851
|
+
where: "Generate an API key in your Clockify profile settings. The ids are in the address of the workspace and the project."
|
|
852
|
+
},
|
|
853
|
+
{
|
|
854
|
+
destination: "jira",
|
|
855
|
+
label: "Jira",
|
|
856
|
+
fields: [{
|
|
857
|
+
name: "site",
|
|
858
|
+
label: "Site address",
|
|
859
|
+
placeholder: "https://your-site.atlassian.net",
|
|
860
|
+
required: true
|
|
861
|
+
}, {
|
|
862
|
+
name: "email",
|
|
863
|
+
label: "Account email",
|
|
864
|
+
placeholder: "you@example.com",
|
|
865
|
+
required: true
|
|
866
|
+
}],
|
|
867
|
+
secret: "API token",
|
|
868
|
+
where: "Create an API token for that email in your Atlassian account. Only a card made from a Jira issue is logged, on that issue."
|
|
869
|
+
}
|
|
870
|
+
];
|
|
871
|
+
var empty = () => ({
|
|
872
|
+
sent: 0,
|
|
873
|
+
already: 0,
|
|
874
|
+
changed: 0,
|
|
875
|
+
failed: 0,
|
|
876
|
+
skipped: 0,
|
|
877
|
+
stuck: 0,
|
|
878
|
+
left: 0,
|
|
879
|
+
error: null
|
|
880
|
+
});
|
|
881
|
+
var iso = (now) => new Date(now).toISOString();
|
|
882
|
+
/**
|
|
883
|
+
* The sentence with the token taken out of it.
|
|
884
|
+
*
|
|
885
|
+
* A destination that echoes the token back in its error text would otherwise put it on a row, in a
|
|
886
|
+
* log line and on the screen. The destination's own words are what a person acts on, so the words
|
|
887
|
+
* stay and the secret goes.
|
|
888
|
+
*/
|
|
889
|
+
var hide = (text, secret) => secret === "" ? text : text.split(secret).join("…");
|
|
890
|
+
/**
|
|
891
|
+
* What one entry failed with: the destination's own words, without the token and cut to a length a
|
|
892
|
+
* row can hold.
|
|
893
|
+
*
|
|
894
|
+
* The token comes out before the cut and not after it. A cut that lands inside the token leaves the
|
|
895
|
+
* first half of it on the row and in the log line, because `hide` matches the whole secret.
|
|
896
|
+
*/
|
|
897
|
+
function said(error, secret) {
|
|
898
|
+
const text = hide(error instanceof Error ? error.message.trim() : "", secret);
|
|
899
|
+
if (text === "") return "The destination refused the entry and said nothing about why.";
|
|
900
|
+
return text.length > MAX_ERROR_CHARS ? `${text.slice(0, MAX_ERROR_CHARS)}…` : text;
|
|
901
|
+
}
|
|
902
|
+
function settingsOf(stored) {
|
|
903
|
+
try {
|
|
904
|
+
const held = JSON.parse(stored);
|
|
905
|
+
if (held === null || typeof held !== "object" || Array.isArray(held)) return {};
|
|
906
|
+
return Object.fromEntries(Object.entries(held).flatMap(([name, value]) => typeof value === "string" ? [[name, value]] : []));
|
|
907
|
+
} catch {
|
|
908
|
+
return {};
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
var view = (row) => isExportDestination(row.destination) ? {
|
|
912
|
+
destination: row.destination,
|
|
913
|
+
label: DESTINATION_LABELS[row.destination],
|
|
914
|
+
settings: settingsOf(row.settings_json),
|
|
915
|
+
createdAt: row.created_at,
|
|
916
|
+
updatedAt: row.updated_at,
|
|
917
|
+
lastExportAt: row.last_export_at,
|
|
918
|
+
lastError: row.last_error
|
|
919
|
+
} : null;
|
|
920
|
+
/** Every connection on this machine, in the order the forms list the destinations. */
|
|
921
|
+
function exporters(db) {
|
|
922
|
+
const rows = db.prepare("SELECT * FROM exporters").all().flatMap((row) => view(row) ?? []);
|
|
923
|
+
return EXPORT_DESTINATIONS.flatMap((destination) => rows.filter((row) => row.destination === destination));
|
|
924
|
+
}
|
|
925
|
+
function exporter(db, destination) {
|
|
926
|
+
const row = db.prepare("SELECT * FROM exporters WHERE destination = ?").get(destination);
|
|
927
|
+
return row === void 0 ? null : view(row);
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* Stores one connection and its token, replacing what that destination held.
|
|
931
|
+
*
|
|
932
|
+
* The token is written first. A row with no token behind it is an export that fails on every entry,
|
|
933
|
+
* and the keychain refuses before anything is stored. Its messages never repeat the secret.
|
|
934
|
+
*
|
|
935
|
+
* The sent entries are not touched, and a new workspace does not reopen them. A person who moves to
|
|
936
|
+
* another workspace and exports March again is told every entry has gone, because the key is the
|
|
937
|
+
* destination and not the workspace. Clearing the rows on a saved setting would let one corrected
|
|
938
|
+
* field bill a whole week a second time.
|
|
939
|
+
*
|
|
940
|
+
* The entries that never went are dropped. A save is how a person fixes a revoked token or a wrong
|
|
941
|
+
* id, and a stuck entry has no other way back. Every adapter looks for an entry before it posts, so
|
|
942
|
+
* trying one again cannot bill it twice.
|
|
943
|
+
*/
|
|
944
|
+
async function saveExporter(db, keychain, input, now) {
|
|
945
|
+
const settings = JSON.stringify(input.settings);
|
|
946
|
+
if (settings.length > 4096) throw new Error(`The settings of a connection may not be longer than ${MAX_SETTINGS_CHARS} characters.`);
|
|
947
|
+
if (input.token !== null) await keychain.write(exporterSecretName(input.destination), input.token);
|
|
948
|
+
db.prepare(`INSERT INTO exporters (destination, settings_json, created_at, updated_at) VALUES (?, ?, ?, ?)
|
|
949
|
+
ON CONFLICT (destination) DO UPDATE SET settings_json = excluded.settings_json, updated_at = excluded.updated_at`).run(input.destination, settings, iso(now), iso(now));
|
|
950
|
+
db.prepare("DELETE FROM export_entries WHERE destination = ? AND sent_at IS NULL").run(input.destination);
|
|
951
|
+
}
|
|
952
|
+
/**
|
|
953
|
+
* Drops one connection and the token behind it, and says whether there was a row.
|
|
954
|
+
*
|
|
955
|
+
* The token goes first, so a refused remove leaves no row without a token and no token without a row.
|
|
956
|
+
* The sent entries stay: they are the record of what this project has already billed through that
|
|
957
|
+
* destination, and dropping them would let the next connection post the same week again.
|
|
958
|
+
*/
|
|
959
|
+
async function removeExporter(db, keychain, destination) {
|
|
960
|
+
if (!isExportDestination(destination)) return false;
|
|
961
|
+
await keychain.remove(exporterSecretName(destination));
|
|
962
|
+
return db.prepare("DELETE FROM exporters WHERE destination = ?").run(destination).changes > 0;
|
|
963
|
+
}
|
|
964
|
+
var asked = (form, name) => (form.get(name)?.toString() ?? "").trim();
|
|
965
|
+
var failure = (error) => error instanceof Error ? error.message : "The keychain refused.";
|
|
966
|
+
/**
|
|
967
|
+
* Save or remove one connection from the panel's form.
|
|
968
|
+
*
|
|
969
|
+
* The token is read from its own field and goes to the keychain, and the settings are the form's own
|
|
970
|
+
* fields and nothing else, so no field a page adds can put a token in the database. An empty token
|
|
971
|
+
* field keeps the stored token on a connection that has one, and is refused on a new one.
|
|
972
|
+
*/
|
|
973
|
+
async function postExporter(db, keychain, form, now) {
|
|
974
|
+
const did = asked(form, "do");
|
|
975
|
+
const destination = asked(form, "destination");
|
|
976
|
+
const no = (message) => ({
|
|
977
|
+
ok: false,
|
|
978
|
+
did,
|
|
979
|
+
destination,
|
|
980
|
+
message
|
|
981
|
+
});
|
|
982
|
+
const chosen = EXPORTER_FORMS.find((one) => one.destination === destination);
|
|
983
|
+
if (chosen === void 0) return no(`Nolzu posts to Toggl, Harvest, Clockify and Jira, and this form names ${destination === "" ? "none of them" : destination}.`);
|
|
984
|
+
if (did === "remove") {
|
|
985
|
+
try {
|
|
986
|
+
await removeExporter(db, keychain, chosen.destination);
|
|
987
|
+
} catch (error) {
|
|
988
|
+
return no(`Nothing was removed. ${failure(error)}`);
|
|
989
|
+
}
|
|
990
|
+
return {
|
|
991
|
+
ok: true,
|
|
992
|
+
did,
|
|
993
|
+
destination,
|
|
994
|
+
message: null
|
|
995
|
+
};
|
|
996
|
+
}
|
|
997
|
+
if (did !== "save") return no(`There is nothing called ${did} to do to a connection. This form can save a connection or remove it.`);
|
|
998
|
+
const settings = {};
|
|
999
|
+
for (const field of chosen.fields) {
|
|
1000
|
+
const value = asked(form, field.name);
|
|
1001
|
+
if (value === "" && field.required) return no(`A ${chosen.label} connection needs the ${field.label.toLowerCase()}.`);
|
|
1002
|
+
if (value !== "") settings[field.name] = value;
|
|
1003
|
+
}
|
|
1004
|
+
const token = asked(form, "secret");
|
|
1005
|
+
if (token === "" && exporter(db, chosen.destination) === null) return no(`A ${chosen.label} connection needs its ${chosen.secret}.`);
|
|
1006
|
+
try {
|
|
1007
|
+
await saveExporter(db, keychain, {
|
|
1008
|
+
destination: chosen.destination,
|
|
1009
|
+
settings,
|
|
1010
|
+
token: token === "" ? null : token
|
|
1011
|
+
}, now);
|
|
1012
|
+
} catch (error) {
|
|
1013
|
+
return no(`The connection was not saved. ${failure(error)}`);
|
|
1014
|
+
}
|
|
1015
|
+
return {
|
|
1016
|
+
ok: true,
|
|
1017
|
+
did,
|
|
1018
|
+
destination,
|
|
1019
|
+
message: null
|
|
1020
|
+
};
|
|
1021
|
+
}
|
|
1022
|
+
/** What this connection has tried, for the days from and to, so the panel can mark each cell. */
|
|
1023
|
+
function sentEntries(db, destination, from, to) {
|
|
1024
|
+
return db.prepare(`SELECT external_id, day, minutes, sent_at, remote_id, attempts, last_error FROM export_entries
|
|
1025
|
+
WHERE destination = ? AND day BETWEEN ? AND ? ORDER BY day, external_id`).all(destination, from, to);
|
|
1026
|
+
}
|
|
1027
|
+
/**
|
|
1028
|
+
* Runs one adapter under the timeout.
|
|
1029
|
+
*
|
|
1030
|
+
* The signal is handed over and the wait is raced against it, so an adapter that never passes the
|
|
1031
|
+
* signal to its `fetch` is stopped all the same. `AbortSignal.timeout` and not a timer of its own,
|
|
1032
|
+
* because its timer never keeps the process alive.
|
|
1033
|
+
*/
|
|
1034
|
+
function post(adapter, entry, secret, settings, timeoutMs) {
|
|
1035
|
+
const signal = AbortSignal.timeout(timeoutMs);
|
|
1036
|
+
const stopped = new Promise((_, no) => signal.addEventListener("abort", () => no(/* @__PURE__ */ new Error(EXPORT_TIMEOUT_SENTENCE)), { once: true }));
|
|
1037
|
+
return Promise.race([adapter(entry, secret, settings, signal), stopped]);
|
|
1038
|
+
}
|
|
1039
|
+
function recordExport(db, destination, error, now) {
|
|
1040
|
+
db.prepare("UPDATE exporters SET last_export_at = ?, last_error = ?, updated_at = ? WHERE destination = ?").run(iso(now), error, iso(now), destination);
|
|
1041
|
+
}
|
|
1042
|
+
function heldEntry(db, destination, externalId) {
|
|
1043
|
+
return db.prepare("SELECT external_id, day, minutes, sent_at, remote_id, attempts, last_error FROM export_entries WHERE destination = ? AND external_id = ?").get(destination, externalId);
|
|
1044
|
+
}
|
|
1045
|
+
function writeEntry(db, destination, entry, write) {
|
|
1046
|
+
db.prepare(`INSERT INTO export_entries (destination, external_id, day, minutes, sent_at, remote_id, attempts, last_error, updated_at)
|
|
1047
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
1048
|
+
ON CONFLICT (destination, external_id) DO UPDATE SET
|
|
1049
|
+
day = excluded.day, minutes = excluded.minutes, sent_at = excluded.sent_at, remote_id = excluded.remote_id,
|
|
1050
|
+
attempts = excluded.attempts, last_error = excluded.last_error, updated_at = excluded.updated_at`).run(destination, entry.externalId, entry.day, entry.minutes, write.sentAt, write.remoteId, write.attempts, write.error, iso(write.now));
|
|
1051
|
+
}
|
|
1052
|
+
/**
|
|
1053
|
+
* Posts the entries of one week to one destination, and says what happened to each.
|
|
1054
|
+
*
|
|
1055
|
+
* The three failures that stop the whole run leave their sentence on the connection row and touch
|
|
1056
|
+
* no entry: no connection, no adapter for that destination, and no token this machine can read.
|
|
1057
|
+
* None of them is one entry's fault, and a person reads them in one place.
|
|
1058
|
+
*
|
|
1059
|
+
* The token is read from the keychain here and handed to the adapter, and what comes back out is a
|
|
1060
|
+
* count. The sentence a failure leaves goes through `hide` first, because the words are the
|
|
1061
|
+
* destination's own and one of them may be the token.
|
|
1062
|
+
*
|
|
1063
|
+
* `timeoutMs` is a parameter so a test can prove the race without waiting 20 seconds for it.
|
|
1064
|
+
*/
|
|
1065
|
+
function exportEntries(db, keychain, request, now, adapters = EXPORT_ADAPTERS, timeoutMs = EXPORT_TIMEOUT_MS) {
|
|
1066
|
+
return queued(request.destination, () => oneExport(db, keychain, request, now, adapters, timeoutMs));
|
|
1067
|
+
}
|
|
1068
|
+
/**
|
|
1069
|
+
* One export at a time per destination.
|
|
1070
|
+
*
|
|
1071
|
+
* `node:sqlite` is synchronous, so while an export waits on a destination the server takes the next
|
|
1072
|
+
* request and a second press starts its own loop. The row that says an entry has gone is written
|
|
1073
|
+
* after the post, so both loops would read no row and post the same hours twice. A person who double
|
|
1074
|
+
* presses Export is exactly that pair. The second one waits here and then finds the rows the first
|
|
1075
|
+
* one wrote.
|
|
1076
|
+
*
|
|
1077
|
+
* ponytail: a map in this process, not a lock in the database. The app is one process per data
|
|
1078
|
+
* folder, so this covers the case that happens. A second process on one folder would need a row lock.
|
|
1079
|
+
*/
|
|
1080
|
+
var running = /* @__PURE__ */ new Map();
|
|
1081
|
+
function queued(key, work) {
|
|
1082
|
+
const mine = (running.get(key) ?? Promise.resolve()).then(work, work);
|
|
1083
|
+
running.set(key, mine);
|
|
1084
|
+
const done = () => {
|
|
1085
|
+
if (running.get(key) === mine) running.delete(key);
|
|
1086
|
+
};
|
|
1087
|
+
mine.then(done, done);
|
|
1088
|
+
return mine;
|
|
1089
|
+
}
|
|
1090
|
+
async function oneExport(db, keychain, request, now, adapters, timeoutMs) {
|
|
1091
|
+
const { destination, entries } = request;
|
|
1092
|
+
const label = DESTINATION_LABELS[destination];
|
|
1093
|
+
const connection = exporter(db, destination);
|
|
1094
|
+
if (connection === null) return {
|
|
1095
|
+
...empty(),
|
|
1096
|
+
left: entries.length,
|
|
1097
|
+
error: `There is no ${label} connection on this machine.`
|
|
1098
|
+
};
|
|
1099
|
+
const stopped = (error) => {
|
|
1100
|
+
recordExport(db, destination, error, now);
|
|
1101
|
+
return {
|
|
1102
|
+
...empty(),
|
|
1103
|
+
left: entries.length,
|
|
1104
|
+
error
|
|
1105
|
+
};
|
|
1106
|
+
};
|
|
1107
|
+
const adapter = adapters[destination];
|
|
1108
|
+
if (adapter === void 0) return stopped(`Nolzu does not post to ${label} yet.`);
|
|
1109
|
+
let secret;
|
|
1110
|
+
try {
|
|
1111
|
+
secret = await keychain.read(exporterSecretName(destination));
|
|
1112
|
+
} catch (error) {
|
|
1113
|
+
return stopped(said(error, ""));
|
|
1114
|
+
}
|
|
1115
|
+
if (secret === null) return stopped(`There is no ${label} token on this machine. Save the ${label} connection again with its ${formOf(destination).secret}.`);
|
|
1116
|
+
const result = await run(db, request, connection.settings, adapter, secret, now, timeoutMs);
|
|
1117
|
+
recordExport(db, destination, result.error, now);
|
|
1118
|
+
return result;
|
|
1119
|
+
}
|
|
1120
|
+
var formOf = (destination) => EXPORTER_FORMS.find((one) => one.destination === destination);
|
|
1121
|
+
async function run(db, request, settings, adapter, secret, now, timeoutMs) {
|
|
1122
|
+
const { destination, entries } = request;
|
|
1123
|
+
const result = empty();
|
|
1124
|
+
let inARow = 0;
|
|
1125
|
+
for (const [index, entry] of entries.entries()) {
|
|
1126
|
+
if (inARow >= 3) {
|
|
1127
|
+
result.left = entries.length - index;
|
|
1128
|
+
break;
|
|
1129
|
+
}
|
|
1130
|
+
const held = heldEntry(db, destination, entry.externalId);
|
|
1131
|
+
if (held?.sent_at != null) {
|
|
1132
|
+
result.already += 1;
|
|
1133
|
+
if (held.minutes !== entry.minutes) result.changed += 1;
|
|
1134
|
+
continue;
|
|
1135
|
+
}
|
|
1136
|
+
if (held !== void 0 && held.attempts >= 5) {
|
|
1137
|
+
result.stuck += 1;
|
|
1138
|
+
result.error = held.last_error ?? result.error;
|
|
1139
|
+
continue;
|
|
1140
|
+
}
|
|
1141
|
+
const attempts = (held?.attempts ?? 0) + 1;
|
|
1142
|
+
try {
|
|
1143
|
+
const remoteId = await post(adapter, entry, secret, settings, timeoutMs);
|
|
1144
|
+
writeEntry(db, destination, entry, {
|
|
1145
|
+
attempts,
|
|
1146
|
+
sentAt: iso(now),
|
|
1147
|
+
remoteId,
|
|
1148
|
+
error: null,
|
|
1149
|
+
now
|
|
1150
|
+
});
|
|
1151
|
+
result.sent += 1;
|
|
1152
|
+
inARow = 0;
|
|
1153
|
+
} catch (error) {
|
|
1154
|
+
if (error instanceof ExportSkipped) {
|
|
1155
|
+
writeEntry(db, destination, entry, {
|
|
1156
|
+
attempts: 0,
|
|
1157
|
+
sentAt: null,
|
|
1158
|
+
remoteId: null,
|
|
1159
|
+
error: said(error, secret),
|
|
1160
|
+
now
|
|
1161
|
+
});
|
|
1162
|
+
result.skipped += 1;
|
|
1163
|
+
continue;
|
|
1164
|
+
}
|
|
1165
|
+
const failure = said(error, secret);
|
|
1166
|
+
writeEntry(db, destination, entry, {
|
|
1167
|
+
attempts,
|
|
1168
|
+
sentAt: null,
|
|
1169
|
+
remoteId: null,
|
|
1170
|
+
error: failure,
|
|
1171
|
+
now
|
|
1172
|
+
});
|
|
1173
|
+
console.error(`An export to ${destination} failed on one entry. ${failure}`);
|
|
1174
|
+
result.failed += 1;
|
|
1175
|
+
result.error = failure;
|
|
1176
|
+
inARow += 1;
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
return result;
|
|
1180
|
+
}
|
|
1181
|
+
/**
|
|
1182
|
+
* The project id inside every external id, minted at the first export and kept from then on.
|
|
1183
|
+
*
|
|
1184
|
+
* Its own setting and not `projectId`, because other code reads that one as "registered with the
|
|
1185
|
+
* hub", and an export registers nothing. Not the project's name: the id is in every external id for
|
|
1186
|
+
* good, and a renamed folder would otherwise export its whole history a second time. Null with no
|
|
1187
|
+
* project folder, because an id minted then would belong to whatever folder comes later.
|
|
1188
|
+
*/
|
|
1189
|
+
function exportProjectId(db) {
|
|
1190
|
+
if (projectName(db) === null) return null;
|
|
1191
|
+
const stored = getSetting(db, "exportProjectId");
|
|
1192
|
+
if (stored !== null) return stored;
|
|
1193
|
+
const id = randomUUID();
|
|
1194
|
+
writeSetting(db, "exportProjectId", id);
|
|
1195
|
+
return id;
|
|
1196
|
+
}
|
|
1197
|
+
var count = (many, one, more) => `${many} ${many === 1 ? one : more}`;
|
|
1198
|
+
/** What one export did, in the words the panel prints under the Export button. */
|
|
1199
|
+
function exportSaid(label, result) {
|
|
1200
|
+
if (result.left > 0 && result.failed === 0) return `${label}: nothing was sent. ${result.error ?? ""}`.trim();
|
|
1201
|
+
const lines = [result.sent === 0 ? `${label}: posted nothing new.` : `${label}: posted ${count(result.sent, "entry", "entries")}.`];
|
|
1202
|
+
if (result.already > 0) lines.push(`Skipped ${count(result.already, "entry that was", "entries that were")} sent before.`);
|
|
1203
|
+
if (result.changed > 0) lines.push(`${count(result.changed, "of them has", "of them have")} other minutes now, and only you can fix that in ${label}.`);
|
|
1204
|
+
if (result.skipped > 0) lines.push(`Skipped ${count(result.skipped, "entry", "entries")} that ${label} does not take.`);
|
|
1205
|
+
if (result.failed > 0) lines.push(`${count(result.failed, "entry", "entries")} failed, and the next press tries again.`);
|
|
1206
|
+
if (result.stuck > 0) {
|
|
1207
|
+
const one = result.stuck === 1;
|
|
1208
|
+
lines.push(`${count(result.stuck, "entry", "entries")} failed 5 times and ${one ? "was" : "were"} not tried again. Save the ${label} connection again and the next export tries ${one ? "it" : "them"}.`);
|
|
1209
|
+
}
|
|
1210
|
+
if (result.left > 0) lines.push(`${count(result.left, "entry was", "entries were")} not tried, because the export stopped after 3 failures in a row.`);
|
|
1211
|
+
if (result.error !== null) lines.push(result.error);
|
|
1212
|
+
return lines.join(" ");
|
|
1213
|
+
}
|
|
1214
|
+
/**
|
|
1215
|
+
* The Export button: the week on screen, posted once to every connection on this machine.
|
|
1216
|
+
*
|
|
1217
|
+
* One destination after the other and not side by side, so two trackers never share the timeout and
|
|
1218
|
+
* a person reads the lines in the order the forms list them.
|
|
1219
|
+
*
|
|
1220
|
+
* A cell with a run still going is held back. Its figure leaves that run out, and an entry that went
|
|
1221
|
+
* is never posted again, so the rest of that day could never be sent.
|
|
1222
|
+
*/
|
|
1223
|
+
async function exportWeek(db, keychain, sheet, now, adapters = EXPORT_ADAPTERS, timeoutMs = EXPORT_TIMEOUT_MS) {
|
|
1224
|
+
const connected = exporters(db);
|
|
1225
|
+
if (connected.length === 0) return {
|
|
1226
|
+
ok: false,
|
|
1227
|
+
lines: ["No time tracker is connected. Connect one below, then press Export."]
|
|
1228
|
+
};
|
|
1229
|
+
const project = exportProjectId(db);
|
|
1230
|
+
if (project === null) return {
|
|
1231
|
+
ok: false,
|
|
1232
|
+
lines: ["This machine has no project folder, so there is no project to export hours for."]
|
|
1233
|
+
};
|
|
1234
|
+
const going = new Set(sheet.rows.flatMap((row) => sheet.days.flatMap((day, index) => (row.cells[index]?.running ?? 0) > 0 ? [`${row.key} ${day}`] : [])));
|
|
1235
|
+
const timed = timesheetEntries(sheet, project);
|
|
1236
|
+
const entries = timed.filter((entry) => !going.has(`${entry.card} ${entry.day}`));
|
|
1237
|
+
const waiting = timed.length - entries.length;
|
|
1238
|
+
const held = waiting === 0 ? [] : [`Held back ${count(waiting, "entry", "entries")} with a run still going, because the minutes are not final. Export again once nothing is running.`];
|
|
1239
|
+
if (timed.length === 0) return {
|
|
1240
|
+
ok: false,
|
|
1241
|
+
lines: ["This week has no timed runs, so there is nothing to send."]
|
|
1242
|
+
};
|
|
1243
|
+
if (entries.length === 0) return {
|
|
1244
|
+
ok: false,
|
|
1245
|
+
lines: held
|
|
1246
|
+
};
|
|
1247
|
+
const lines = [];
|
|
1248
|
+
for (const one of connected) lines.push(exportSaid(one.label, await exportEntries(db, keychain, {
|
|
1249
|
+
destination: one.destination,
|
|
1250
|
+
entries
|
|
1251
|
+
}, now, adapters, timeoutMs)));
|
|
1252
|
+
return {
|
|
1253
|
+
ok: true,
|
|
1254
|
+
lines: [...lines, ...held]
|
|
1255
|
+
};
|
|
1256
|
+
}
|
|
1257
|
+
/**
|
|
1258
|
+
* The marks the panel draws for one destination on the week on screen.
|
|
1259
|
+
*
|
|
1260
|
+
* Read off the stored rows, matched to the cells by the external id the grid builds, so a mark sits
|
|
1261
|
+
* on the cell the entry came from. No project id yet means nothing was ever exported, and reading
|
|
1262
|
+
* one here would mint it on a page load.
|
|
1263
|
+
*/
|
|
1264
|
+
function timesheetSync(db, sheet, destination) {
|
|
1265
|
+
const project = getSetting(db, "exportProjectId");
|
|
1266
|
+
if (project === null) return [];
|
|
1267
|
+
const cells = new Map(timesheetEntries(sheet, project).map((entry) => [entry.externalId, entry]));
|
|
1268
|
+
return sentEntries(db, destination, sheet.days[0] ?? sheet.week, sheet.days[6] ?? sheet.week).flatMap((row) => {
|
|
1269
|
+
const cell = cells.get(row.external_id);
|
|
1270
|
+
if (cell === void 0) return [];
|
|
1271
|
+
const at = {
|
|
1272
|
+
card: cell.card,
|
|
1273
|
+
day: cell.day
|
|
1274
|
+
};
|
|
1275
|
+
if (row.sent_at !== null) return [{
|
|
1276
|
+
...at,
|
|
1277
|
+
state: row.minutes === cell.minutes ? "sent" : "changed",
|
|
1278
|
+
reason: null
|
|
1279
|
+
}];
|
|
1280
|
+
if (row.attempts >= 5) return [{
|
|
1281
|
+
...at,
|
|
1282
|
+
state: "stuck",
|
|
1283
|
+
reason: row.last_error
|
|
1284
|
+
}];
|
|
1285
|
+
if (row.attempts === 0) return [{
|
|
1286
|
+
...at,
|
|
1287
|
+
state: "skipped",
|
|
1288
|
+
reason: row.last_error
|
|
1289
|
+
}];
|
|
1290
|
+
return [{
|
|
1291
|
+
...at,
|
|
1292
|
+
state: "failed",
|
|
1293
|
+
reason: row.last_error
|
|
1294
|
+
}];
|
|
1295
|
+
});
|
|
1296
|
+
}
|
|
1297
|
+
//#endregion
|
|
1298
|
+
//#region src/routes/evidence/+page.server.ts
|
|
1299
|
+
function askedDay(url, field) {
|
|
1300
|
+
const asked = url.searchParams.get(field);
|
|
1301
|
+
return asked !== null && isDay(asked) ? asked : void 0;
|
|
1302
|
+
}
|
|
1303
|
+
var askedWeek = (url) => {
|
|
1304
|
+
const asked = askedDay(url, "week") ?? askedDay(url, "day");
|
|
1305
|
+
return timesheetFor(database(), { week: asked === void 0 ? void 0 : weekOf(asked) });
|
|
1306
|
+
};
|
|
1307
|
+
var load = async ({ url }) => {
|
|
1308
|
+
const day = askedDay(url, "day");
|
|
1309
|
+
const week = askedWeek(url);
|
|
1310
|
+
const connected = exporters(database());
|
|
1311
|
+
const shown = connected.find((one) => one.destination === url.searchParams.get("to")) ?? connected[0] ?? null;
|
|
1312
|
+
const evidence = await evidenceFor(database(), { day });
|
|
1313
|
+
const range = url.searchParams.get("range") === "week" ? "week" : "day";
|
|
1314
|
+
const monday = weekOf(evidence.day);
|
|
1315
|
+
const period = range === "week" ? weekEvidence(monday, await Promise.all(Array.from({ length: 7 }, (_, index) => dayShift(monday, index)).map((one) => one === evidence.day ? evidence : evidenceFor(database(), { day: one })))) : null;
|
|
1316
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1317
|
+
return {
|
|
1318
|
+
day: evidence,
|
|
1319
|
+
range,
|
|
1320
|
+
period,
|
|
1321
|
+
phases: runPhases(database(), period ?? evidence),
|
|
1322
|
+
standup: await standupFor(database(), { day }),
|
|
1323
|
+
week,
|
|
1324
|
+
now,
|
|
1325
|
+
today: now.slice(0, 10),
|
|
1326
|
+
weeks: {
|
|
1327
|
+
previous: weekShift(week.week, -1),
|
|
1328
|
+
next: weekShift(week.week, 1)
|
|
1329
|
+
},
|
|
1330
|
+
exporters: connected,
|
|
1331
|
+
forms: EXPORTER_FORMS,
|
|
1332
|
+
shown: shown === null ? null : {
|
|
1333
|
+
destination: shown.destination,
|
|
1334
|
+
label: shown.label
|
|
1335
|
+
},
|
|
1336
|
+
sync: shown === null ? null : timesheetSync(database(), week, shown.destination),
|
|
1337
|
+
billingPrompt: billingPrompt(database()),
|
|
1338
|
+
billing: billingFor(database())
|
|
1339
|
+
};
|
|
1340
|
+
};
|
|
1341
|
+
var canExport = async () => shows(await currentDisplay(localCloud()), EXPORT_FEATURE);
|
|
1342
|
+
var NO_EXPORT = "Sending a week to a time tracker is part of Solo. This machine is on the free plan, so nothing was sent. The CSV works on every plan.";
|
|
1343
|
+
var NO_CONNECTION = "Connecting a time tracker is part of Solo. This machine is on the free plan, so no connection was saved or removed.";
|
|
1344
|
+
var actions = {
|
|
1345
|
+
bill: async ({ request }) => {
|
|
1346
|
+
const form = await request.formData();
|
|
1347
|
+
const typed = {
|
|
1348
|
+
client: form.get("client")?.toString() ?? "",
|
|
1349
|
+
rate: form.get("rate")?.toString() ?? "",
|
|
1350
|
+
currency: form.get("currency")?.toString() ?? ""
|
|
1351
|
+
};
|
|
1352
|
+
const refused = saveBilling(database(), typed);
|
|
1353
|
+
return refused === null ? { billed: true } : fail(400, { billing: {
|
|
1354
|
+
...refused,
|
|
1355
|
+
typed
|
|
1356
|
+
} });
|
|
1357
|
+
},
|
|
1358
|
+
export: async ({ url }) => {
|
|
1359
|
+
if (!await canExport()) return fail(400, { exported: [NO_EXPORT] });
|
|
1360
|
+
const answer = await exportWeek(database(), createKeychain(process.platform, runKeychain, resolveDataDir(process.env)), askedWeek(url), Date.now());
|
|
1361
|
+
return answer.ok ? { exported: answer.lines } : fail(400, { exported: answer.lines });
|
|
1362
|
+
},
|
|
1363
|
+
exporter: async ({ request }) => {
|
|
1364
|
+
if (!await canExport()) return fail(400, { connection: {
|
|
1365
|
+
ok: false,
|
|
1366
|
+
did: "",
|
|
1367
|
+
destination: "",
|
|
1368
|
+
message: NO_CONNECTION
|
|
1369
|
+
} });
|
|
1370
|
+
const answer = await postExporter(database(), createKeychain(process.platform, runKeychain, resolveDataDir(process.env)), await request.formData(), Date.now());
|
|
1371
|
+
return answer.ok ? { connection: answer } : fail(400, { connection: answer });
|
|
1372
|
+
}
|
|
1373
|
+
};
|
|
1374
|
+
|
|
1375
|
+
var _page_server_ts = /*#__PURE__*/Object.freeze({
|
|
1376
|
+
__proto__: null,
|
|
1377
|
+
actions: actions,
|
|
1378
|
+
load: load
|
|
1379
|
+
});
|
|
1380
|
+
|
|
1381
|
+
export { _page_server_ts as _ };
|
|
1382
|
+
//# sourceMappingURL=_page.server.ts.js-uwu2X7bA.js.map
|