refactor(types): export PermissionResolverParams + surface defaultDecision (SD-673)#3504
Merged
caio-pizzol merged 1 commit intoMay 26, 2026
Merged
Conversation
…ision (SD-673) Promotes PermissionResolverParams from a non-exported type alias to an exported interface so consumers can import the resolver-callback contract by name. Currently consumers writing a resolver have to either rely on Config.permissionResolver inference or use Parameters<NonNullable<Config['permissionResolver']>>[0]; both are clumsy and neither is discoverable. One real omission landed alongside the export: the runtime always forwards defaultDecision: boolean to the resolver (computed locally in permissions.js:isAllowed). The non-exported helper omitted it, so resolver authors who wanted to defer to (or branch off) the built-in policy had to re-derive it. Field-presence tightened to match runtime exactly. The runtime spreads every field into the object literal it passes to the resolver, so every key is always present. role and isInternal can hold undefined values; comment, trackedChange, currentUser, and superdoc are coalesced to null and never undefined. Switched from optional (?:) properties to non-optional with explicit | undefined / | null types so the type reflects what the resolver actually receives, not what the consumer might construct. Distinct from CanPerformPermissionParams (consumer input shape): - CanPerformPermissionParams is what consumers pass INTO SuperDoc#canPerformPermission. - PermissionResolverParams is what consumer resolvers RECEIVE, enriched with defaultDecision, currentUser, and superdoc. Also fixes the CanPerformPermissionParams doc that still referred to PermissionResolverParams as 'non-exported.' Consumer fixture (permission-resolver-params-apis.ts) asserts both resolver slots use the named type: - Config.permissionResolver - Modules.comments.permissionResolver Verified: pnpm check:types -> PASS; pnpm check:public:superdoc --skip-build -> PASS (9 ran, 1 skipped, 129.6s).
Contributor
|
🎉 This PR is included in superdoc-cli v0.13.0 The release is available on GitHub release |
Contributor
|
🎉 This PR is included in superdoc-sdk v1.12.0 |
Contributor
|
🎉 This PR is included in @superdoc-dev/mcp v0.8.0 The release is available on GitHub release |
Contributor
|
🎉 This PR is included in superdoc v1.36.0 The release is available on GitHub release |
Contributor
|
🎉 This PR is included in @superdoc-dev/react v1.7.0 The release is available on GitHub release |
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.
Promotes
PermissionResolverParamsfrom a non-exportedtypealias to an exportedinterfaceso consumers can import the resolver-callback contract by name. Today, resolver authors have to either rely onConfig.permissionResolverinference or writeParameters<NonNullable<Config['permissionResolver']>>[0]— neither is discoverable.One real omission landed alongside the export. The runtime always forwards
defaultDecision: booleanto the resolver (computed locally inpermissions.js:isAllowed), but the non-exported helper omitted it. Resolver authors who wanted to defer to (or branch off) the built-in policy had to re-derive it. Adding it surfaces the value at the type level.Field-presence tightened to match runtime exactly. The runtime spreads every field into the object literal it passes to the resolver, so every key is always present.
roleandisInternalcan holdundefinedvalues;comment,trackedChange,currentUser, andsuperdocare coalesced tonulland neverundefined. Switched from optional (?:) properties to non-optional with explicit| undefined/| nulltypes so the type reflects what the resolver actually receives, not what the consumer might construct. This is a tighter contract — existing resolvers reading these fields withparams.rolecontinue to work becausestring | undefinedis structurally the same for reads.Distinct from
CanPerformPermissionParams(consumer input shape):CanPerformPermissionParamsis what consumers pass intoSuperDoc#canPerformPermission.PermissionResolverParamsis what consumer resolvers receive, enriched withdefaultDecision,currentUser, andsuperdoc.Also fixes a stale doc on
CanPerformPermissionParamsthat still referred toPermissionResolverParamsas "non-exported" — that became false in this PR.Consumer fixture (
permission-resolver-params-apis.ts) asserts both resolver slots use the named type:Config.permissionResolverModules.comments.permissionResolverDrift between the two slots would slip past the public-method-coverage gate (callbacks aren't gate-tracked) but fails on
AssertEqualhere.Stacked on #3503; retarget to
mainafter that PR merges.Verified:
pnpm check:types-> PASS;pnpm check:public:superdoc --skip-build-> PASS (9 ran, 1 skipped, 129.6s);pnpm --filter superdoc test --run-> PASS (1054/1054).