-
Notifications
You must be signed in to change notification settings - Fork 32
refactor: move category types and validation logic to shared package #2877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
98eec1b
346a6e5
ff39d1e
cff0a94
3c6dd2c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| export * from "./types/activityViewer.js"; | ||
| export * from "./types/categories.js"; | ||
| export * from "./utils/ipfs.js"; | ||
| export * from "./utils/test.js"; | ||
| export * from "./apiTypes.js"; | ||
| export * from "./logic/browsable.js"; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,38 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import type { Category, CategoryGroup } from "../types/categories.js"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type BrowsableData = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| allCategories: CategoryGroup[]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| categories: Category[]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Determine whether this activity should be discoverable. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Currently this checks category completeness; additional browsable criteria may be added here later. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * TODO: check for no errors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * TODO: check for no accessibility violations | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export function isBrowsable(data: BrowsableData) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return isActivityFullyCategorized(data); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Detect whether or not this activity has the required categories filled out. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * For each group that is required, make sure this activity has at least 1 category in that group. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function isActivityFullyCategorized({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+14
to
+22
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export function isBrowsable(data: BrowsableData) { | |
| const fullyCategorized = isActivityFullyCategorized(data); | |
| // TODO: check for no errors | |
| // TODO: check for no accessibility violations | |
| return fullyCategorized; | |
| } | |
| /** | |
| * Detect whether or not this activity has the required categories filled out. | |
| * For each group that is required, make sure this activity has at least 1 category in that group. | |
| */ | |
| function isActivityFullyCategorized({ | |
| /** | |
| * @deprecated This helper currently only checks category completeness. | |
| * Prefer `isActivityFullyCategorized` until broader "browsable" criteria are | |
| * fully defined and implemented. | |
| */ | |
| export function isBrowsable(data: BrowsableData) { | |
| return isActivityFullyCategorized(data); | |
| } | |
| /** | |
| * Detect whether or not this activity has the required categories filled out. | |
| * For each group that is required, make sure this activity has at least 1 category in that group. | |
| */ | |
| export function isActivityFullyCategorized({ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| export type CategoryGroup = { | ||
| name: string; | ||
| isRequired: boolean; | ||
| isExclusive: boolean; | ||
| categories: Category[]; | ||
| }; | ||
|
|
||
| export type Category = { | ||
| code: string; | ||
| description: string; | ||
| term: string; | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isActivityFullyCategorizedis implemented here but not exported, so it can’t actually be reused by other packages even though the PR description says this logic was moved to shared. Either export/re-exportisActivityFullyCategorized(and/or renameisBrowsableto match the exported API), or update the shared API/PR description to reflect that onlyisBrowsableis intended to be public.