feat: global exercise library foundation with admin-only writes - #64
Merged
Conversation
Adds the /exerciseLibrary Firestore collection as the canonical exercise catalog (closes #61): - LibraryExercise Dart model; optional libraryExerciseId back-reference on embedded plan exercises - firestore.rules: authenticated read, writes gated on the `admin` custom claim; emulator rules tests via `npm run test:rules` - scripts/set_admin_claim.js to grant/revoke the admin claim - scripts/seed_exercise_library.js with 16 common exercises (idempotent) - docs/exercise-library.md covering schema, access control, seeding Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #61.
What
Foundation for the global exercise library: a top-level
exerciseLibraryFirestore collection readable by any signed-in user, writable only by admins (Firebase Auth custom claimadmin: true).lib/models/library_exercise.dart(LibraryExercise) — name, description, videoUrl, tags, aliases, audit fields. Embedded plan exercises (lib/models/exercise.dart) gain an optionallibraryExerciseIdback-reference for Plan builder: choose exercises from the exercise library #62.firestore.rulesblock forexerciseLibrary— authenticated read, admin-claim-only create/update/delete.test/rules/exercise_library_rules.test.js(node:test +@firebase/rules-unit-testing), runnable withnpm run test:rules(wrapsfirebase emulators:exec). 10 tests covering read/create/update/delete for admin, regular user,admin: falseclaim, and unauthenticated.scripts/set_admin_claim.js grant|revoke <uid-or-email> [--prod]— preserves other custom claims.scripts/seed_exercise_library.js— 16 common exercises, idempotent (slug-keyed, merge writes), emulator by default,--prodopt-in.docs/exercise-library.md(schema, access control, claim propagation caveat, seeding, tests); README testing section mentionsnpm run test:rules.Verification
npm run test:rules— 10/10 pass against the Firestore emulatordart analyze lib/models/…— no issuesNotes
package.json/package-lock.jsongain dev depsfirebase+@firebase/rules-unit-testingfor the rules tests.🤖 Generated with Claude Code