[Import/Export] Parse JSON with the existing plan schema
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 92/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
Research direction
Read src/lib/planFile/schema.ts and its tests in src/lib/planFile/schema.test.ts, then add src/lib/planFile/parse.ts and parse.test.ts beside them. Implement the specified size, JSON, version, schema, and known-term checks, returning a result without throwing. Run pnpm test; done means the listed acceptance cases pass with non-empty errors for failures.
Written by the indexing model from the issue text.
Description
What to build
Read the contents of an imported DogDays plan file and check them against the existing file format. Return either the accepted plan or a short error the import dialog can show, instead of letting invalid files crash the page.
Files
src/lib/planFile/parse.ts(new file)- Starting example: src/lib/planFile/schema.ts
Code to add or extend:parsePlanFile(text: string, knownTerms?: readonly number[]): ParseResult.
Steps
- Add parsePlanFile(text, knownTerms?) and
ParseResult: either {ok:true, plan} or {ok:false, error}. Use the existingPlanFiletype. - Inside try/catch, read text with
JSON.parseand check the value withplanFileSchema.safeParse. On success, return {ok:true, plan:parsed.data}. - For invalid JSON return {ok:false, error:"This file is not valid JSON."}. For a failed format check return {ok:false, error:"This is not a valid DogDays plan file."}. Keep
schema.tsrules unchanged.
Example
{"version":1,"term":202702,"name":"Sample","crns":[12345],"pinned":false} is accepted. Text that is not JSON and an object missing crns return the specified errors.
Check it works
In src/lib/planFile/parse.test.ts, check the example above and the failure or limit described in the steps. Run pnpm test -- src/lib/planFile/parse.test.ts, pnpm lint and pnpm typecheck.
References
Assign yourself before starting, or comment to claim the issue. Project setup.
- Dominant language
- TypeScript
- Stars
- 19
- Forks
- 94
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from DevDogsUGA/DogDays
-
map
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
DevDogsUGA/DogDays#868 ·
-
map
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
DevDogsUGA/DogDays#865 ·
-
sharing
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
DevDogsUGA/DogDays#854 ·
-
import-export
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
DevDogsUGA/DogDays#850 ·
-
import-export
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
DevDogsUGA/DogDays#842 ·
All issues in DevDogsUGA/DogDays
Similar issues
-
test: make the #3408 Claude OAuth token fixture obviously fake so secret scanners stop flagging itOpen
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
code-yeongyu/senpi#3436 ·
Maintainers usually reply within 1 day
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 78/100
lingdojo/kana-dojo#32505 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
github/gh-aw-firewall#10040 ·
Maintainers usually reply within 1 day
-
review-followup
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
griffinwork40/agent-afk#3868 ·
Maintainers usually reply within 1 day
-
area: import-export bug status: needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
amatya-aditya/obsidian-rss-dashboard#1191 ·
Maintainers usually reply within 1 day