Skip to content

feat(knowledge-base): article + category authoring subsystem - #122

Merged
mpge merged 1 commit into
mainfrom
feat/knowledge-base
Aug 2, 2026
Merged

feat(knowledge-base): article + category authoring subsystem#122
mpge merged 1 commit into
mainfrom
feat/knowledge-base

Conversation

@mpge

@mpge mpge commented Aug 2, 2026

Copy link
Copy Markdown
Member

What

Ports the knowledge-base authoring subsystem from the Laravel reference. KB was a stub (empty article list, 404 detail, no tables/models). This adds authoring, storage, and a working public read surface.

Changes

Schemadatabase/migrations/0062_create_escalated_knowledge_base_tables.ts

  • escalated_article_categories: name, unique slug, self-referencing parent_id (SET NULL), position, description.
  • escalated_articles: category FK (SET NULL), title, unique slug, longtext body, status (draft/published), host author_id, view/helpful/not-helpful counters, published_at, [status, published_at] index.
  • DDL verified to compile on Postgres, MySQL, and SQLite.

Modelssrc/models/article.ts, src/models/article_category.ts

  • Lucid ports of the reference: published/draft/search and roots/ordered scopes, category/parent/children/articles relations, atomic incrementViews/markHelpful/markNotHelpful, slug-on-create hooks.

Admin CRUDadmin_articles_controller.ts (index/create/store/edit/update/destroy), admin_article_categories_controller.ts (index/store/update/destroy), routes under /admin/kb/*, and admin.article_* / admin.article_category_* flash strings. Mirrors the automation/canned-responses admin controllers.

Public readsrc/controllers/widget_controller.ts

  • GET /widget/articles now lists/searches published articles; GET /widget/articles/:slug returns a published article by slug (increments views, includes related). Previously stubs.

Shared logicsrc/support/knowledge_base.ts

  • Pure helpers for slug resolution, publish semantics, and the public read contract (published-only selection, search, category filter, show-by-slug), used by the controllers and the models' status constants.

Tests

tests/unit/knowledge_base.spec.ts (TDD, written first) proves: admin-created published articles appear in the public list/show; unpublished (draft) articles are excluded from list and show-by-slug; category assignment filtering; slug + publish-timestamp semantics; case-insensitive search.

  • Full suite green: 579 node --test tests + 21 Japa tests, 0 failures. No regressions.
  • tsc --noEmit clean; ESLint clean on all touched files.

Notes

Lint flags 3 pre-existing files outside this diff (import_job.ts, newsletter/newsletter_delivery.ts, validators/admin/skill_payload.ts) under the local prettier build; left untouched — only the files in this PR were formatted against the locked version.

Port the knowledge-base authoring feature from the Laravel reference so
KB content can be authored, stored, and served.

- Migration 0062 creates escalated_article_categories and
  escalated_articles (slug, status, publish/view/feedback counters,
  self-referencing category tree, author + category FKs).
- Lucid models Article and ArticleCategory with published/draft/search
  and roots/ordered scopes, atomic view/feedback counters, slug hooks.
- Admin CRUD controllers for articles (index/create/store/edit/update/
  destroy) and categories (index/store/update/destroy) plus routes and
  i18n flash messages.
- Wire the public widget read path to real data: list/search published
  articles and fetch a published article by slug (was a stub).
- Shared pure helpers in support/knowledge_base.ts (slug, publish
  semantics, public read selection) covered by unit tests proving admin
  create to public list/show, draft exclusion, and category filtering.
@mpge
mpge merged commit 458b63b into main Aug 2, 2026
4 checks passed
@mpge
mpge deleted the feat/knowledge-base branch August 2, 2026 03:21
mpge added a commit that referenced this pull request Aug 2, 2026
Port the knowledge-base authoring feature from the Laravel reference so
KB content can be authored, stored, and served.

- Migration 0062 creates escalated_article_categories and
  escalated_articles (slug, status, publish/view/feedback counters,
  self-referencing category tree, author + category FKs).
- Lucid models Article and ArticleCategory with published/draft/search
  and roots/ordered scopes, atomic view/feedback counters, slug hooks.
- Admin CRUD controllers for articles (index/create/store/edit/update/
  destroy) and categories (index/store/update/destroy) plus routes and
  i18n flash messages.
- Wire the public widget read path to real data: list/search published
  articles and fetch a published article by slug (was a stub).
- Shared pure helpers in support/knowledge_base.ts (slug, publish
  semantics, public read selection) covered by unit tests proving admin
  create to public list/show, draft exclusion, and category filtering.

Co-authored-by: Matt Gros <mpge@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant