Repository navigation
feat(showcase): safe simulated uploads demo (#586, phase 5) - #673
Merged
Merged
Conversation
Fifth module demo, and the first one that must NOT do what the module does: uploading needs auth + S3, so the page demonstrates the policy and the progress/success/error states locally instead of writing anything. - Shared policy: the MIME allowlist moves out of the endpoint into `src/lib/uploads/policy.ts` (isomorphic, SVG still deliberately excluded), exposing `ALLOWED_MIME_TYPES`, `MAX_FILE_SIZE` and `validateUploadFile()`. The endpoint now delegates type/size validation to it and keeps the exact codes/statuses (400 for type/size, 413 for too large), so a client pre-check can never disagree with the server. - `@svforge/uploads` ships `src/routes/showcase/uploads/+page.svelte` plus its `meta.ts` (order 50): file picker + drop zone, validation through the shared policy, the Skeleton `Progress` affordance during a simulated upload, a success state with the (clearly labelled) simulated key, the module's own localized error copy for rejected files, and a note that the real `FileUpload.svelte` is what posts to the authenticated endpoint. No request, no storage, no credentials. - Catalog copy for the page merged into both locales; the module now declares `ui.svforge` alongside its auth/i18n requirements. - Canonical `svforge-modules.json` / `MODULE_CONTRACTS` updated; `templates.ts` and `module-recipes.ts` regenerated through prebuild. - Tests: new `uploads-policy` behaviour suite (allowed/oversized/empty/ disallowed, endpoint delegation), a rendered jsdom suite for the demo (progress -> success, localized type/size errors, `fetch` never called), the showcase suite extended (delivery on a dashboard fixture, catalog parity, capability) plus a compile guard for EVERY showcase demo page. - `tests/upload-security.test.ts` now asserts the SVG-exclusion comment and allowlist in the shared policy while requiring the endpoint to delegate. - Harness: `dashboard-integrations` (the profile that installs uploads) asserts the demo route, metadata and both catalogs; `base` and `base-ui-modules` stay green. Verification: full suite 146 files / 1453 tests; lint; typecheck; `base` and `base-ui-modules` scaffold profiles; graphify stable. `dashboard-integrations` needs PostgreSQL and was not run locally (its new assertions run in the publish/drift matrices). Changeset: `@svforge/uploads` minor, `svforge` patch, `@svforge/addon-kit` patch.
Merged
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.
What changed and why
Phase 5 of #586. This module is the first whose real flow needs a backend (auth + S3/R2), so the demo deliberately shows the policy and the states, never the write. That required one small, honest refactor so the demo cannot drift from the server.
Shared upload policy (single source)
+server.tsintosrc/lib/uploads/policy.ts(isomorphic, SVG still deliberately excluded):ALLOWED_MIME_TYPES,MAX_FILE_SIZE, andvalidateUploadFile()returning the endpoint's own codes.400forfile_type_not_allowed/invalid_size,413forfile_too_large. Field-presence errors stay server-side.tests/upload-security.test.tswas adapted (not weakened): the SVG/XSS assertion and the "deliberately EXCLUDED" documentation now target the shared policy, and the test additionally requires the endpoint to delegate.Demo
/showcase/uploads(+page.svelte+meta.ts,order: 50)Progressduring a simulated upload → success state with the file name/size and a clearly labelled simulated key;FileUpload.svelteis what posts to the authenticated endpoint and stores in S3/R2 — this page never does: nofetch, no storage, no credentials.Contracts, docs, artifacts
@svforge/uploadsnow declaresui.svforge(the route uses the kit) alongsideauth.currentUser+i18n.messages; canonicalsvforge-modules.json,MODULE_CONTRACTS,templates.ts,module-recipes.tsregenerated through prebuild.skeleton-baseline.mdrecords the new page (SkeletonProgress, shared policy, no custom CSS).Tests and checks
tests/uploads-policy.test.ts(behaviour, not class strings): accepts at the limit; rejects SVG/unknown types, oversized, empty/NaN/Infinity; asserts the endpoint imports the shared policy and keeps 400/413 semantics with no duplicated allowlist.tests/uploads-demo.test.ts(jsdom, rendered): allowed file → Skeletonprogressbar(witharia-valuenow) then “Selection accepted” + simulated key; SVG → localized type error; oversized → localized size error;fetchis stubbed to throw and asserted never called.tests/showcase.test.ts: uploads delivery on a dashboard fixture (route + metadata + both catalogs, key parity, module error copy preserved) + capability assertion; and a new compile guard for every showcase demo page (catches the Svelte-syntax class of error these phases hit twice).bash scripts/test-scaffold.sh baseandbase-ui-modules→ green (no regression; uploads is not installable on a plain Base by design).bun run test→ 146 files / 1453 tests passed;bun run lintclean;bun run typecheckclean;bun run build:allOK; graphify stable across repeat runs.dashboard-integrations(the profile that installs uploads) now asserts the demo route,meta.tsand both catalogs.Remaining limitations / known problems
dashboard-integrationswas not executed locally: it needs a reachable PostgreSQL, which this environment does not provide. Its new assertions run in the publish/ecosystem-drift matrices, and the same install path is covered locally by the dashboard-fixture delivery test. This is the one gate I could not run myself.Part of #586 — phase 5 only. Remaining demos:
blog,notifications,chat,oauth,email,audit(jobs/realtimeonly with a meaningful simulation), each on its own branch.