feat: add backward-compatible account and contact search #284

Merged
erik merged 1 commit from feat/task-8532b75d-account-contact-find into main 2026-09-24 18:50:13 -05:00
Owner

Summary

Adds accounts find <query> [--owner-type contact|source|site] [--owner-id <id>] [--json] and singular contact find <query> [--json], consistent with the merged sources-find feature.

  • Case-insensitive literal substring matching on account labels/URLs and contact names/URLs, trimming queries and handling missing contact URLs.
  • Optional q on existing authenticated list APIs; CLI filters locally too so older sites remain compatible without a mandatory upgrade.
  • Preserve complete records, existing ordering, account owner-filter semantics, successful empty results, and normal authentication/API/network errors. No record mutations or database migrations.
  • Successful API logs show effective queries, supplied account owner filters, and counts without credentials or unrelated query parameters.
  • CLI help, README, command/API/OpenAPI specs, and reviewed/manual existing-site upgrade guidance.

Task: task-8532b75d

Verification

  • ./scripts/pre-pr.sh: passed formatting, generated CSS, lint, typecheck, and all workspace tests, including 274 CLI and 409 template-site tests.
  • npm run build: passed all workspaces.
  • 92 new focused CLI/API tests cover updated/older sites, Unicode case conversion, literal special characters, multiple/zero matches, missing URLs, combined/independent owner filters, usage errors, HTTP/network errors, JSON, logs, and read-only behavior; existing account/contact/source tests remain green.
  • Live tests on localhost:3000 using node cli/dist/index.js --site slugkit-dev: contact name/null URL and URL searches, account labels/URLs, source owner filters, literal %_ [ query, JSON/human output, zero matches, direct authenticated HTTP requests, and unchanged records before/after searches all passed.
  • Captured live API logs include Contacts listed with q=ÉCOLE, results=1, Accounts listed with q=FIND-DEMO-URL, ownerType=source, ownerId=1, results=1, and zero-result queries. No credentials were captured in the evidence.

Local evidence: /tmp/slug-account-contact-pre-pr.log, /tmp/slug-account-contact-build.log, /tmp/slug-account-contact-live.log, /tmp/slug-account-contact-live-api.log.

Compatibility

Existing list/show/create/edit/delete commands and requests without q remain unchanged. Blank API q stays unfiltered; blank CLI queries fail before requests. Resource routes remain in generated-site code rather than moving into slug-api. Package updates alone do not rewrite copied endpoints; optional server-side filtering/logging requires reviewed site changes and redeployment. CLI publication is separate from this PR.

## Summary Adds `accounts find <query> [--owner-type contact|source|site] [--owner-id <id>] [--json]` and singular `contact find <query> [--json]`, consistent with the merged sources-find feature. - Case-insensitive literal substring matching on account labels/URLs and contact names/URLs, trimming queries and handling missing contact URLs. - Optional `q` on existing authenticated list APIs; CLI filters locally too so older sites remain compatible without a mandatory upgrade. - Preserve complete records, existing ordering, account owner-filter semantics, successful empty results, and normal authentication/API/network errors. No record mutations or database migrations. - Successful API logs show effective queries, supplied account owner filters, and counts without credentials or unrelated query parameters. - CLI help, README, command/API/OpenAPI specs, and reviewed/manual existing-site upgrade guidance. Task: task-8532b75d ## Verification - `./scripts/pre-pr.sh`: passed formatting, generated CSS, lint, typecheck, and all workspace tests, including 274 CLI and 409 template-site tests. - `npm run build`: passed all workspaces. - 92 new focused CLI/API tests cover updated/older sites, Unicode case conversion, literal special characters, multiple/zero matches, missing URLs, combined/independent owner filters, usage errors, HTTP/network errors, JSON, logs, and read-only behavior; existing account/contact/source tests remain green. - Live tests on localhost:3000 using `node cli/dist/index.js --site slugkit-dev`: contact name/null URL and URL searches, account labels/URLs, source owner filters, literal `%_ [` query, JSON/human output, zero matches, direct authenticated HTTP requests, and unchanged records before/after searches all passed. - Captured live API logs include `Contacts listed` with `q=ÉCOLE, results=1`, `Accounts listed` with `q=FIND-DEMO-URL, ownerType=source, ownerId=1, results=1`, and zero-result queries. No credentials were captured in the evidence. Local evidence: `/tmp/slug-account-contact-pre-pr.log`, `/tmp/slug-account-contact-build.log`, `/tmp/slug-account-contact-live.log`, `/tmp/slug-account-contact-live-api.log`. ## Compatibility Existing list/show/create/edit/delete commands and requests without `q` remain unchanged. Blank API `q` stays unfiltered; blank CLI queries fail before requests. Resource routes remain in generated-site code rather than moving into `slug-api`. Package updates alone do not rewrite copied endpoints; optional server-side filtering/logging requires reviewed site changes and redeployment. CLI publication is separate from this PR.
feat: find accounts and contacts on existing sites
All checks were successful
CI / build-lint-test (pull_request) Successful in 2m13s
55efa67eac
Task: #task-8532b75d
Author
Owner

Review update

  • PR: #284 — open, independently verified with fj pr view 284.
  • Task: task-8532b75d.
  • Reviewed head: 55efa67eac24d2f2e5fa6b4f0cb474911a4dcaba, verified through fj pr view 284 commits; reviewed the actual Forgejo PR diff.
  • Result: approved. All 10 current acceptance criteria are met; no blocking issues or warnings identified.
  • Scope: additive CLI/API search, regression tests, logging, and documentation. Existing template-site route/service boundaries, authentication, owner filtering, and record shapes are preserved. No implementation changes or broad checks were performed by this reviewer.

Acceptance criteria

  1. met — Account label/URL search. cli/src/commands.ts adds accounts find, trims the query, URL-encodes q, and matches literal substrings using JavaScript lowercasing against both fields. CLI/API tests cover mixed case, partial labels, URLs, Unicode, and literal special characters.
  2. met — Contact name/URL search and absent URLs. Singular contact find uses the same matching and explicitly handles null/absent URLs with optional chaining. Tests and live evidence include a matching contact with a null URL.
  3. met — Combined owner filters and existing semantics. CLI parsing reuses owner-type/positive-integer validation; API SQL retains independent owner predicates combined with AND before text filtering. Tests cover type only, ID only, both, site ownership, valid site-plus-ID empty results, and invalid filters.
  4. met — Optional API q without list regressions. Both existing authenticated list routes accept trimmed optional q. Empty/absent queries remain unfiltered; services retain existing SQL ordering and response mappings. API tests verify complete records, order, blank/absent queries, and authentication failures.
  5. met — Updated and older sites. Both commands send URL-encoded q and locally filter successful responses without discarding metadata. Parameterized CLI tests exercise both server-filtered and older unfiltered responses; account compatibility retains existing server-side owner filters. No website upgrade is required for CLI correctness.
  6. met — Multiple/empty results, identifying metadata, JSON, and read-only behavior. Existing output helpers retain IDs, labels/names, URLs, and account owner information. JSON preserves the response envelope and full matching records in order. Empty results succeed. Tests and live before/after listings verify no mutations; the diff contains no database migration.
  7. met — Usage errors versus operational failures. Missing/blank queries and invalid/unsupported filters fail before client requests. Existing configured-client/error handling remains in use. Tests distinguish HTTP 401/403 authentication errors, 422/500 API errors, and network errors from successful empty results.
  8. met — Automated regression coverage. cli/src/__tests__/find-commands.test.ts and template/site/src/api/__tests__/account-contact-search.test.ts cover matching fields, Unicode lowercasing, literal %_ [ and URL characters, absent URLs, multiple/zero matches, invalid input, independent/combined owner filters, JSON, errors, ordering, unchanged records, and older-site compatibility. OpenAPI assertions are extended in routes.test.ts; existing suites remain green in the supplied pre-PR evidence.
  9. met — Safe successful-request logs, automated and live evidence. Routes construct allowlisted contexts containing effective trimmed q, method/path/status, result count, and supplied account owner filters, not request headers, arbitrary parameters, or record contents. Tests assert exact contexts, zero counts, excluded credentials/unrelated parameters/record URLs, and absence of success logs on failures. Sanitized live logs show ÉCOLE with 1 contact, FIND-DEMO-URL with ownerType=source, ownerId=1, and 1 account, blank-query full counts, and zero-result searches including the site-plus-ID case.
  10. met — Help, command/API/OpenAPI docs, upgrade guidance, existing commands. CLI help, CLI README, both command specs, both API specs, and OpenAPI document the additive searches. docs/package-updates.md gives customization-safe reviewed-file changes, test/build, redeployment, and verification steps, explicitly explaining that package-only updates and slug upgrade do not rewrite copied endpoints. Existing handlers remain unchanged apart from a behavior-preserving shared sources/contact query parser; regression suites and live list output provide compatibility evidence.

Verification and pipeline state

  • CI: success — fj actions tasks reports Forgejo build-lint-test #475, pull_request, successful for 55efa67eac (the reviewed full head above), duration 2m13s.
  • /tmp/slug-account-contact-pre-pr.log: ./scripts/pre-pr.sh passed generated CSS, formatting, lint, typecheck, and all workspace tests, including 274 CLI tests and 409 template-site tests.
  • /tmp/slug-account-contact-build.log: all-workspace npm run build completed successfully.
  • /tmp/slug-account-contact-live.log: successful development CLI and direct HTTP checks, human/JSON output, Unicode/literal matching, owner filters, empty results, and unchanged records.
  • /tmp/slug-account-contact-live-api.log: actual effective query/filter/count log entries, including zero, without secret credentials.
  • Local/live checks were reviewed as supplied execution evidence, not rerun. CI state was independently queried with fj.

Findings and verdict

  • Blocking issues: 0.
  • Warnings: 0.
  • Final verdict: approved.
  • Worker review fields: pr=open, review=approved, blocking_issues=0, warnings=0, criteria_total=10, criteria_met=10, criteria_missing=0.
  • PR/task artifact delivery states and IDs are recorded in /tmp/slug-account-contact-review-284-result.txt after posting both matching comments.
  • Merge approval: waiting-human. This review does not merge the PR, close the task, or authorize release.
  • Next: obtain explicit human merge approval; stop at the merge gate.
### Review update - PR: https://forge.caradoc.com/erik/slugkit/pulls/284 — open, independently verified with `fj pr view 284`. - Task: `task-8532b75d`. - Reviewed head: `55efa67eac24d2f2e5fa6b4f0cb474911a4dcaba`, verified through `fj pr view 284 commits`; reviewed the actual Forgejo PR diff. - Result: **approved**. All 10 current acceptance criteria are met; no blocking issues or warnings identified. - Scope: additive CLI/API search, regression tests, logging, and documentation. Existing template-site route/service boundaries, authentication, owner filtering, and record shapes are preserved. No implementation changes or broad checks were performed by this reviewer. ### Acceptance criteria 1. **met — Account label/URL search.** `cli/src/commands.ts` adds `accounts find`, trims the query, URL-encodes `q`, and matches literal substrings using JavaScript lowercasing against both fields. CLI/API tests cover mixed case, partial labels, URLs, Unicode, and literal special characters. 2. **met — Contact name/URL search and absent URLs.** Singular `contact find` uses the same matching and explicitly handles null/absent URLs with optional chaining. Tests and live evidence include a matching contact with a null URL. 3. **met — Combined owner filters and existing semantics.** CLI parsing reuses owner-type/positive-integer validation; API SQL retains independent owner predicates combined with AND before text filtering. Tests cover type only, ID only, both, site ownership, valid site-plus-ID empty results, and invalid filters. 4. **met — Optional API q without list regressions.** Both existing authenticated list routes accept trimmed optional `q`. Empty/absent queries remain unfiltered; services retain existing SQL ordering and response mappings. API tests verify complete records, order, blank/absent queries, and authentication failures. 5. **met — Updated and older sites.** Both commands send URL-encoded `q` and locally filter successful responses without discarding metadata. Parameterized CLI tests exercise both server-filtered and older unfiltered responses; account compatibility retains existing server-side owner filters. No website upgrade is required for CLI correctness. 6. **met — Multiple/empty results, identifying metadata, JSON, and read-only behavior.** Existing output helpers retain IDs, labels/names, URLs, and account owner information. JSON preserves the response envelope and full matching records in order. Empty results succeed. Tests and live before/after listings verify no mutations; the diff contains no database migration. 7. **met — Usage errors versus operational failures.** Missing/blank queries and invalid/unsupported filters fail before client requests. Existing configured-client/error handling remains in use. Tests distinguish HTTP 401/403 authentication errors, 422/500 API errors, and network errors from successful empty results. 8. **met — Automated regression coverage.** `cli/src/__tests__/find-commands.test.ts` and `template/site/src/api/__tests__/account-contact-search.test.ts` cover matching fields, Unicode lowercasing, literal `%_ [` and URL characters, absent URLs, multiple/zero matches, invalid input, independent/combined owner filters, JSON, errors, ordering, unchanged records, and older-site compatibility. OpenAPI assertions are extended in `routes.test.ts`; existing suites remain green in the supplied pre-PR evidence. 9. **met — Safe successful-request logs, automated and live evidence.** Routes construct allowlisted contexts containing effective trimmed `q`, method/path/status, result count, and supplied account owner filters, not request headers, arbitrary parameters, or record contents. Tests assert exact contexts, zero counts, excluded credentials/unrelated parameters/record URLs, and absence of success logs on failures. Sanitized live logs show `ÉCOLE` with 1 contact, `FIND-DEMO-URL` with `ownerType=source`, `ownerId=1`, and 1 account, blank-query full counts, and zero-result searches including the site-plus-ID case. 10. **met — Help, command/API/OpenAPI docs, upgrade guidance, existing commands.** CLI help, CLI README, both command specs, both API specs, and OpenAPI document the additive searches. `docs/package-updates.md` gives customization-safe reviewed-file changes, test/build, redeployment, and verification steps, explicitly explaining that package-only updates and `slug upgrade` do not rewrite copied endpoints. Existing handlers remain unchanged apart from a behavior-preserving shared sources/contact query parser; regression suites and live list output provide compatibility evidence. ### Verification and pipeline state - **CI: success** — `fj actions tasks` reports Forgejo **build-lint-test #475**, pull_request, successful for `55efa67eac` (the reviewed full head above), duration 2m13s. - `/tmp/slug-account-contact-pre-pr.log`: `./scripts/pre-pr.sh` passed generated CSS, formatting, lint, typecheck, and all workspace tests, including **274 CLI tests and 409 template-site tests**. - `/tmp/slug-account-contact-build.log`: all-workspace `npm run build` completed successfully. - `/tmp/slug-account-contact-live.log`: successful development CLI and direct HTTP checks, human/JSON output, Unicode/literal matching, owner filters, empty results, and unchanged records. - `/tmp/slug-account-contact-live-api.log`: actual effective query/filter/count log entries, including zero, without secret credentials. - Local/live checks were reviewed as supplied execution evidence, not rerun. CI state was independently queried with `fj`. ### Findings and verdict - Blocking issues: **0**. - Warnings: **0**. - Final verdict: **approved**. - Worker review fields: `pr=open`, `review=approved`, `blocking_issues=0`, `warnings=0`, `criteria_total=10`, `criteria_met=10`, `criteria_missing=0`. - PR/task artifact delivery states and IDs are recorded in `/tmp/slug-account-contact-review-284-result.txt` after posting both matching comments. - Merge approval: **waiting-human**. This review does not merge the PR, close the task, or authorize release. - Next: obtain explicit human merge approval; stop at the merge gate.
erik merged commit 419d0e67a3 into main 2026-09-24 18:50:13 -05:00
erik deleted branch feat/task-8532b75d-account-contact-find 2026-09-24 18:50:13 -05:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
erik/slugkit!284
No description provided.