Skip to content

feat: filter hooks per call in createWrapper via getOptions - #46

Merged
vkarpov15 merged 5 commits into
mongoosejs:masterfrom
AbdelrahmanHafez:feat/wrap-filter-option
Aug 19, 2026
Merged

vkarpov15 merged 5 commits into
mongoosejs:masterfrom
AbdelrahmanHafez:feat/wrap-filter-option

Conversation

@AbdelrahmanHafez

@AbdelrahmanHafez AbdelrahmanHafez commented Jun 29, 2026 •

Copy link
Copy Markdown
Member

re #43 and #44

Adds getOptions support to createWrapper()/wrap(), mirroring #44 for createWrapperSync(). wrap() reads per-call options from options.getOptions(args) and passes the filter to execPre/execPost (including the error path), so createWrapper-based hooks (Mongoose statics and methods) can skip user middleware for a single call. Without getOptions, nothing changes.

Also fixes index.d.ts, which had drifted from the runtime: corrected the execPre/execPost/*Sync signatures, added getOptions and postError, renamed overwriteMiddlewareResult -> overwriteResult to match the real export, and wired up the missing types field.

Heads up: the overwriteResult rename is a type-level change for anything referencing Kareem.OverwriteMiddlewareResult (Mongoose's types/ does). I have the matching Mongoose change ready.

Also documented getOptions.

Mirror createWrapperSync's getOptions support on the async path. wrap()
now derives pre/post options from options.getOptions(args) and passes the
resulting filters to execPre/execPost (including the error-handler path),
so createWrapper-based hooks (custom statics and methods in Mongoose) can
be selectively skipped per call. Backwards compatible: without getOptions,
all hooks run as before.
- Correct execPre/execPost/execPreSync/execPostSync to their async/options
  signatures (callbacks were dropped, filter option added)
- Add getOptions to createWrapper/createWrapperSync option types
- Fix stale overwriteMiddlewareResult -> overwriteResult, add postError
- Expose types via package.json "types" field
@vkarpov15
vkarpov15 merged commit d70350a into mongoosejs:master Aug 19, 2026
4 checks passed
@AbdelrahmanHafez
AbdelrahmanHafez deleted the feat/wrap-filter-option branch August 19, 2026 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants