monoscope/test/integration/Pages/Endpoints
Anthony Alaribe bccc1bbacd
Github 2-way sync with a repo (#244)
* add git sync for dashboards

* fix: improve git sync reliability and code quality

- Fix race condition: store root tree SHA instead of file entry SHA

- Fix empty token handling: preserve existing token when form empty

- Improve decryption: return Nothing on failure

- Replace inefficient JSON parsing with parseMaybe

- Replace manual toHex with base16-bytestring

- Add uuid-quasi for compile-time UUID validation in tests

* refactor: consolidate git sync helpers and reduce code duplication

* Auto-format code with fourmolu

* refactor: improve git sync code quality

- Webhook validation now returns Either for better error messages
- Add SQL column constant to reduce duplication
- Simplify Map construction with inline lambda
- Improve pattern matching exhaustiveness in gitSyncPushDashboard
- PackageImports kept for explicit crypto package disambiguation

* Auto-format code with fourmolu

* refactor: improve code quality and fix SQL injection risk

- Use pg-entity _selectWhere/_delete instead of manual column lists
- Fix SQL injection in selectDashboardsSortedBy with whitelist approach
- Add Entity instance for GitHubSync for type-safe queries
- Replace two-pass partition with single-pass foldl' in git sync
- Parallelize file fetching during git sync using Ki.scoped
- Qualify SqlQQ import to avoid collision with Variable.sql field
- Rename key params to encKey to avoid shadowing Data.Aeson.Lens.key

* Auto-format code with fourmolu

* feat: add comprehensive GitHub sync setup instructions

- Show full webhook URL with copy button
- Add step-by-step guide for creating GitHub personal access token
- Document expected repository structure (dashboards/*.yaml)
- Show example dashboard YAML format
- Include webhook setup instructions for auto-sync

* refactor: use markdown for git sync setup instructions

- Replace verbose HTML with markdown quasi-quotes
- Use MMark to render markdown to HTML
- Much cleaner and easier to maintain documentation
- Removes mmark from unused packages warning

* refactor: improve code quality and add decryption logging

- Add logging when GitHub sync token decryption fails to aid debugging
- Replace foldl' partition with idiomatic list comprehensions
- DRY duplicated SQL queries in selectDashboardsSortedBy
- Use pg-entity _selectWhere for type-safe query building
- Use RecordDot syntax instead of fromOnly in getDashboardByBaseTemplate

* Auto-format code with fourmolu

* refactor: improve code quality and security

- Add warning log when webhook accepted without secret validation
- Extract withDecryption helper to DRY decrypted getter functions
- Use foldMap for efficient buildSyncPlan implementation
- Extract delete fields in list comprehension to avoid pattern warnings
- Remove unused imports (foldl', Data.Map.Strict)

* style: fix hlint suggestions

- Use point-free style for Ki.fork composition
- Remove redundant toStrict call
- Parenthesize unary negation for clarity
- Remove redundant brackets around V.fromList

* style: remove unnecessary package qualification for base16-bytestring

* Auto-format code with fourmolu

* fix: resolve CI warnings and errors

- Add fromJust import to GitSyncSpec.hs
- Remove unused Job parameter from processBackgroundJob
- Fix ambiguous record fields in DashboardsSpec.hs using lens syntax
- Remove undefined usage in BusinessFlowsSpec.hs

* refactor: simplify withDecryption using maybe and either

* Auto-format code with fourmolu

* refactor: simplify git sync error handling and use pg-entity

* fix: resolve CI compile errors in tests

* fix: resolve DashboardVM field access ambiguity in tests

* fix: use record dot syntax for DashboardVM, qualified for DashboardForm

* security: use constant-time comparison for HMAC validation

* refactor: use point-free style for encryptToken

* refactor: flatten nested case with tuple pattern matching

* refactor: use lens for decryptSync, fix constEq type ambiguity

* refactor: use bimap for base64 errors, Ki.awaitAll for parallel exec

* Auto-format code with fourmolu

* refactor: simplify sort field handling with lookup table

* perf: fix N+1 query by pre-fetching teams before parallel sync

* fix: use mkDashboard helper to avoid ambiguous record update

* perf: use T.filter instead of T.replace for newline removal

* refactor: use point-free style for titleToFilePath

* feat: add GitHub sync E2E tests and fix empty repo handling

- Add comprehensive E2E integration tests for GitHub sync

- Handle 404 from GitHub tree API as empty tree (for repos with all files deleted)

- Add updateTags function to update dashboard tags during sync

- Fix SyncUpdate to also update tags when pulling from GitHub

- Add Default instance for GitHubSync

- Add detectDefaultBranch function for auto-detecting repo branch

* Auto-format code with fourmolu

* Github.hs

* Auto-format code with fourmolu

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
History 2025-12-26 01:19:12 +01:00
..
ApiCatalogSpec.hs Github 2-way sync with a repo (#244) 2025-12-26 01:19:12 +01:00