You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* refactor: emulator simplification from code review
- Cache getWorkOSStore() on Store instance (avoids 37 map lookups per call)
- Use indexed findOneBy() for auth code + SSO code lookup (O(1) vs O(n))
- Hoist authMiddleware to single instance (was creating ~25 closures)
- Add Collection.deleteBy() for cascade delete patterns
- Consistent getWorkOSStore placement (once at setup, not per-handler)
- Remove dead seedDefaults no-op and phase marker comments
* refactor: emulator simplification phase 1 — shared infrastructure
- Create constants.ts with typed STORE_KEYS, STORE_KEY_PREFIXES, and EVENTS
- Unify ID_PREFIXES in core/id.ts with workos/store.ts (add 15 missing entries, fix event prefix)
- Optimize Collection.count() to iterate in-place instead of materializing full array
- Move parseListParams to core/pagination.ts, remove redundant limit clamping
- Add generic formatEntity() and formatListResponse() helpers
- Replace 34 trivial formatters with formatEntity() calls (5 with custom exclude sets)
- Update 22 list response sites to use formatListResponse()
- Replace all magic strings with typed constants across 31 files
Review: 1 cycle, 4 findings (0 critical, 0 high, 2 medium, 2 low — all addressed)
* refactor: emulator simplification phase 2 — domain helpers and route dedup
Extract role lookup helpers (findEnvRole, findOrgRole, requireEnvRole,
requireOrgRole) and role-permission CRUD helpers (getRolePermissions,
replaceRolePermissions) into role-helpers.ts.
Create registerRoleRoutes() factory that deduplicates ~120 lines of
shared CRUD + permissions logic between authorization-roles.ts and
authorization-org-roles.ts. Both files are now thin wrappers.
Adopt Collection.deleteBy() at all 9 cascade delete sites across 5 files.
Add formatFlagTarget() formatter and extract evaluateFlags() to deduplicate
identical flag evaluation logic for orgs and users.
Review: cycle 1/3, PASS. 0 critical, 0 high findings.
* refactor: emulator simplification phase 3 — server infrastructure and efficiency
- Replace ~35 individual auth middleware registrations with single catch-all
using PUBLIC_PATHS set and PUBLIC_PATH_PREFIXES array
- Adopt unauthorized() helper in auth middleware (removes 3 inline 401s)
- Remove defensive array spread in cursorPaginate when no filter applied
- Add optional pre-fetched domains to formatOrganization, batch in list endpoint
- Add event-type index to EventBus with rebuildIndex() for pre-filtering
- Fix N+1 in priority reorder endpoint with slug-to-role Map
- Add Store.deleteDataByPrefix() for temporal store data cleanup
* chore: formatting:
0 commit comments