fix: merge mandatory filters and add loaded-model Get guard - #25
Merged
Conversation
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.
Summary
Implements Upd4ting's approved upstream changes for native invoice list/get scoping in cms-saas. The cms-saas wrappers remain unchanged until the upstream changes merge and are released.
Companion CMS integration: https://github.com/AntelopeJS/cms/pull/359 (draft, blocked on publishing this API).
Parameters.ExtractFilterscombines request filters with mandatoryWithOptions(..., { filters })filters. Mandatory field keys win the whole tuple. Returned maps and tuples are fresh.ExtractGenericruns the native filter extractor even when route options contain filters. All other option precedence, conversion, and parameter behavior stays unchanged.DefaultRoutes.WithGetGuard(guard)creates the standard Get route with an awaited callback(ctx, current, params). It preserves controllerthis, forwards the request context, and receives the loaded/unlocked model before readable-field selection and response transformations. Throwing preserves the HTTP error; missing rows remain 404 without calling the guard. Treatcurrentas read-only.The Get pipeline remains one query with existing joined/computed/foreign handling, fromDatabase modifiers, unlock, ReadProperties and internal-field cleanup. No mutation hooks or universal read-scope abstraction.
Compatibility / boundaries
Behavior change: previously setting
options.filters(even{}) suppressed all request filters inParameters.List. Additional client filters now narrow the mandatory scope; same-field client filters cannot replace the mandatory tuple. Code relying on suppressing client filters must adapt. DirectExtractFilterscallers now also receive mandatory route filters. NestedWithOptionscalls retain their existing shallow option composition; this change concerns route options versus request filters, not deep merging route configurations.Filters still require registered filter metadata to affect queries. Get still ignores filters: its new guard is separate. Explicit-ID exports are not protected by this Get hook, and no export behavior changes here.
CMS list/select/count use
Parameters.List; batch count directly usesExtractFilterson a per-query context preserving route metadata. Both extraction paths now honor mandatory filters without CMS duplicating merge logic. Select's existingpluckMode: "select"envelope remains untouched.Verification
pnpm test: 96 passing, including new mandatory coexistence/conflicts/empty/absent options/ordinary precedence/repeated-request isolation tests, and HTTP Get guard tests for hidden fields, transforms, no-guard parity, 404/403 and missing rows. Existing modifier/access/foreign/joined/computed suites pass.pnpm lint: passes.pnpm pack --out /tmp/companion-data-api.tgz: passes (includes TypeScript build).Merge/release ordering
Merge and publish this companion first. Then update the draft CMS PR's dependency minimum and lockfile to the actual published version, rerun checks without local overrides, and merge/release CMS. Only then remove cms-saas wrappers. No version is invented or bumped here, no release is requested, and interface-data-api 0.1.8 does not provide this hook.