feat(backend): submissions module + scope filter + compression
- Submissions module (routes/repository/service/types/domain) with draft → submitted state machine, transition endpoint, Azure SAS file attachment via blob-storage service, conduct score, and org-scope filters (orgId/companyId/countryId/entityId/buId/deptId/areaId). - Forms: GET /api/forms/by-scope alias + scope filter on listForms (empty-array OR id-in-array semantics); GET /api/forms/managers joining auth.users + user_org_assignment with active-user fallback. - Form settings: persist frequencyCycle, visibility, country/sub/ company/entity/BU scope arrays, role arrays via buildSettings assignments. Checksum no-op skips full survey_json TOAST rewrite on draft PATCH when checksum matches. - Performance: register @fastify/compress (br/gzip/deflate, 1 KiB threshold) — large surveyJson GETs drop 85–98% on the wire. Body limit bumped to 16 MB so PATCH/POST of full form schemas no longer trips 413 (which the browser was surfacing as CORS errors). - CORS: explicit allowedHeaders (incl. if-match/etag, x-tenant-id, x-confirm-delete-all), expose etag, credentials, 10 min preflight cache. - Migrations 004_form_settings + 005_seed_test_forms and a scripts/migrate-webforms helper for legacy form import.
Showing
migrations/004_form_settings.sql
0 → 100644
migrations/005_seed_test_forms.sql
0 → 100644
| ... | ... | @@ -10,6 +10,7 @@ |
| }, | ||
| "dependencies": { | ||
| "@azure/storage-blob": "^12.31.0", | ||
| "@fastify/compress": "^8.3.1", | ||
| "@fastify/cors": "^11.2.0", | ||
| "@fastify/multipart": "^10.0.0", | ||
| "fastify": "^5.6.1", | ||
| ... | ... | @@ -18,8 +19,10 @@ |
| "zod": "^4.1.12" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/js-yaml": "^4.0.9", | ||
| "@types/node": "^24.10.0", | ||
| "@types/pg": "^8.20.0", | ||
| "js-yaml": "^4.1.1", | ||
| "tsx": "^4.20.6", | ||
| "typescript": "^5.9.3" | ||
| } | ||
| ... | ... |
scripts/migrate-webforms.ts
0 → 100644
src/modules/submissions/domain.ts
0 → 100644
src/modules/submissions/repository.ts
0 → 100644
src/modules/submissions/routes.ts
0 → 100644
src/modules/submissions/service.ts
0 → 100644
src/modules/submissions/types.ts
0 → 100644
src/services/blob-storage.ts
0 → 100644
Please
register
or
sign in
to comment