Repository navigation
Conversation
tnramalho
reviewed
Aug 28, 2026
MrMaz
added a commit
that referenced
this pull request
Aug 29, 2026
… the caller's skip BufferStrategy's internal offset tracks progress across successive discovery batches for sparse relation data, but the second and later batches used that offset in place of the caller's own skip instead of added to it, letting a paginated federated query read rows from before the requested window. Reported by @tnramalho on PR #463.
MrMaz
added a commit
that referenced
this pull request
Aug 29, 2026
…ly produced wrong results
Two RELATION_FIRST discovery gaps could return incorrect results without
error:
- Filtering or sorting on an owning relation (root FK -> target PK) was
silently dropped from discovery entirely, since only non-owning
relations can yield root ids. A query like `where: { relation: 'blog',
field: 'title', ... }` returned `[[], 0]` as if nothing matched.
- Filtering a many-cardinality relation without `distinctFilter`
configured reported its total from matching child rows, not distinct
root ids, inflating the count whenever a root had more than one
matching child (the same requirement already enforced for relation
*sorts*).
Both now throw a FederationException instead. Structural NOT_NULL
injection from a plain INNER JOIN (no caller-specified filter) is exempt
from the distinctFilter requirement, since it isn't a caller filter.
README updated to document both as limitations.
Reported by @tnramalho on PR #463.
MrMaz
added a commit
that referenced
this pull request
Aug 29, 2026
package.json declares "node": ">=22.12.0", but both workflow matrices still ran only 20.x, so a green PR never actually tested the runtime being published. Reported by @tnramalho on PR #463.
The __tests__/__fixtures__ consolidation this branch also did is complete, not deferred — removed from the backlog per this file's own convention that shipped items are dropped rather than marked done.
vitest defaulted to text/html/clover/json, so coverage/lcov.info was never produced. Every workflow step that uploads lcov to Codacy or Code Climate has been failing against a file that doesn't exist.
ci-pr-report's coverage-report job has failed on every run for 30+ consecutive runs: its "Download artifacts" step calls actions/upload-artifact instead of actions/download-artifact, so download requires path (which it never gets) and the job dies before touching Codecov or Codacy. The workflow_run indirection this exists for is meant to let fork PRs reach secrets, but every open PR is a same-repo branch, so there's nothing to indirect for. Delete it and run reporting straight out of ci-pr-test: add checks: write permissions, replace the artifact round-trip with dorny/test-reporter@v3, codecov/codecov-action@v7, and codacy-coverage-reporter-action pointed at the coverage/lcov.info that now exists. Reporting steps are gated to same-repo PRs so a fork PR skips them instead of failing on missing secrets.
ci-merge has failed on all 19 of its runs, most recently 2025-12-30 — it only fires on push to main, which hasn't happened since. Three of its steps can't succeed under any circumstances: - codecov/codecov-action@v2 declares runs: using: node12, a runtime no longer available on any runner. - dorny/test-reporter@v1 predates the retirement of the ::set-output-era workflow commands it depends on internally. - paambaati/codeclimate-action downloads a test-reporter binary from codeclimate.com/downloads/..., which now 404s — Code Climate Quality is sunset, so the step is unfixable at any version. Bump codecov to v7 and test-reporter to v3, drop the Code Climate step outright, and add the checks: write permission test-reporter needs to post its check run.
CLAUDE.md's own pre-commit rule is pnpm test:all (unit + e2e), but CI only ever ran unit tests, and ci-merge skipped lint entirely — a direct push to main bypassed it. Add pnpm test:e2e to both workflows and pnpm lint:all to ci-merge so both gate the same way ci-pr-test already did for lint.
Code Climate Quality is sunset (its test-reporter binary 404s), so its README badges render stale/unknown now that the workflow steps are gone. .codecov.yml and .codacy.yml fell back to *.spec.js suffix matching for tests alongside their directory-based ignores; add __tests__/ now that the consolidation in d2c4aae makes directory exclusion complete.
… { replace: true }
Repository write hooks could only merge into caller-supplied data, so a
hook could never override a caller-controlled field (e.g. for tenant
scoping) — the caller's value always won on conflict. Add an opaque
`options` bag to hook method metadata and a `HookMethodFilter` for
`HookResolverService.execute`, and route `@BeforeCreate`/`@BeforeUpdate`/
`@BeforeUpsert`/`@BeforeReplace`/`@BeforeWrite` through a merge pass
followed by a `{ replace: true }` pass, so hooks can opt into wholesale
authority over specific fields without a new decorator or hook key.
Also warn once per process (ROCKETS_HOOKS_NOT_WIRED) when a repository
is constructed without HookResolverService, since @usehooks() hooks
silently never run in that case.
TokenOptionsInterface only exposed a shared `secret`, so RS256/ES256 setups had no way to pass privateKey/publicKey through to @nestjs/jwt's sign/verify calls. Thread privateKey through signing and publicKey through verification, and exclude secretOrKeyProvider from the interface since it's module-level-only in @nestjs/jwt while this package always registers with an empty JwtModuleOptions and resolves keys per call.
…tions
The hook examples in nestjs-core's and nestjs-repository's READMEs
treated WhereClause as a plain object and referenced APIs that don't
exist, so they didn't compile as written. Rewrite them against the real
OverlayRef/Where API and the new { replace: true } option, and add a
wiring checklist covering the CoreModule import step implementers were
missing. Document RS256/JWKS verification and the secretOrKeyProvider
exclusion in nestjs-authentication's README.
pretest already runs tsc -b before pnpm test so a clean clone doesn't fail on missing dist output, but test:e2e had no equivalent — pnpm's pre<script> hooks only match exact script names. Add pretest:e2e.
# Conflicts: # .github/workflows/ci-pr-test.yml
…tity re-reads update/replace on a versioned entity re-reads the row after the optimistic- lock guard to get its current state, and upsert re-reads the row it just wrote to return it — but both re-reads omitted withDeleted, so TypeORM's default soft-delete filter dropped a row the preceding write had just matched or created. update/replace threw "Entity not found after update" (#471); upsert threw "Upsert failed: entity not found after upsert". Both re-reads are identity lookups of a row whose existence the write already proved, so withDeleted: true is unconditionally correct here regardless of whether the row happens to be soft-deleted.
…rce escape hatch
update/replace/upsert reaching a soft-deleted row was never a deliberate
design choice, just incidental reuse of a shared lookup helper: crud's
includeDeleted query param is documented and exposed via Swagger for List
and Read only, no test anywhere mutated a soft-deleted row, and every
domain repository already treats a soft-deleted row as invisible (zero
occurrences of withDeleted outside this package). Left alone, that made
these writes invisible to every internal read path — the exact "ghost
data" a soft-delete filter exists to prevent.
Enforce immutability once, in RepositoryAdapter itself, rather than per
driver: update/replace/upsert now reject a soft-deleted target with the
new SoftDeletedImmutableException (409), restore() remains the sanctioned
way back, and { force: true } is available on update/replace/upsert
options for server-side carve-outs (pre-purge PII masking, admin
corrections) that HTTP callers can't reach. upsert has no existing row to
check against — its guard reads the target via the protected doFindOne
(bypassing the find permeator and its hooks) with withDeleted: true.
Cost of adopting this now, in v8 alpha, is close to zero: every entity
extending the documented Audit*/Common* base classes was already 100%
broken for this path (#471), so nothing depends on the old behavior for
those, and no existing test exercised it for any entity shape.
softDelete() on an already-soft-deleted row reached the driver unchanged, and TypeORM's soft-delete write unconditionally re-stamps the delete-date column — so a redundant soft-delete call silently overwrote the original deletion timestamp. Make it a no-op instead: idempotent, not rejected, since a retried HTTP DELETE must not fail.
…e, replace and delete paths The in-request optimistic lock added in #469 compares a version the server itself just read, so it only closes a race between concurrent in-flight writes — it cannot stop two separate requests that each re-read before writing, which is the case optimistic locking exists for (#472). Add an `expectedVersion` option to `update`, `replace`, `delete`, `softDelete`, and `restore`. `RepositoryAdapter` resolves whether a version guard applies and what value to check into a `RepositoryVersionGuardInterface` descriptor, so a driver never decides policy — it only executes the compare-and-swap it's handed. `update`/`replace` are guarded whether or not a caller supplies a version (matching #469's existing behavior); the three delete-path methods only take on the guard, and its transaction requirement, when a caller actually asks for one, keeping this non-breaking for every existing call site in the repo. A mismatch throws the existing `OptimisticLockException` (409). An `expectedVersion` against an entity with no version column throws a `fault: 'usage'` RuntimeException. `deleteMany` is excluded at the type level via a new `RepositoryDeleteOneOptions` — there is no single caller-held row for it to describe.
…te, soft-delete and restore Update/replace already ran the atomic version check inside a transaction (#469). Extend the same mechanism to delete, softDelete, and restore, but only when the caller supplies `expectedVersion` — `RepositoryAdapter` resolves that into a `versionGuard` descriptor, and this driver only ever executes it, never decides whether one applies. That conditional is what keeps this non-breaking: no existing caller passes `expectedVersion`, so none inherits a new transaction requirement. `saveWithVersionCheck` is split into a shared `withVersionGuard` (the transaction handling and the atomic compare-and-swap) and `saveWithVersionGuard` (update/replace's merge-and-save operation), so `doDelete`/`doSoftDelete`/`doRestore` can reuse the same guard without update/replace's re-read-and-merge logic. Also corrects two stale claims in the guard's doc comment: `save()` does not unconditionally bump the version column (TypeORM issues no SQL at all for a no-op change set), and a client-supplied version survives by suppressing the auto-increment, not by coexisting with it.
Closes #472. The in-request compare-and-swap (#469) only guards a read-then-write inside one request, so two people editing the same record from a screen still lose the earlier save silently: A and B both read version 1, B saves (-> 2), A saves and, without this change, still succeeds (-> 3). Clients now state the version they read via `If-Match`, threaded down to the repository's `expectedVersion` option (see the nestjs-repository/-typeorm commits). A mismatch returns 409 (`OptimisticLockException`, the same exception and error code the in-request guard already used) rather than RFC 9110's 412, so clients handle every version conflict on this API the same way. - `crud-precondition.parser.ts` accepts one strong entity-tag (`"3"`) or `*`; comma-separated lists and weak tags are RFC 9110 cache- revalidation features, not lost-update prevention, and 400 along with any malformed value. - `CrudContextOverlay` parses and validates `If-Match` only for Update/Replace/Delete/SoftDelete/Restore — a precondition has no meaning on a read, so a stale or malformed header on a GET is simply not evaluated. Resolving the entity's version column can legitimately fail for a hand-decorated `@CrudController` using a custom resolver (no adapter provider registered under the dynamic token) — treated the same as "no version column" (400), never a 500. - `CrudETagInterceptor` emits `ETag` on single-resource responses, registered per-controller like the serializer (not globally like `CrudContextOverlay`, which has no other way to learn a route is CRUD-decorated) — every route that could need it gets it, and no unrelated hand-written controller pays for it. Suppressed when the client narrowed the response with `?select=`, since the tag is a row validator that doesn't vary by representation. - `@CrudRequireVersion()` rejects with 428 when a route demands a precondition and none was sent — `If-Match: *` does not satisfy it, since it states no version at all. A dedicated `versioned` fixture backs the new e2e coverage rather than the `photo` fixtures: `photoSchema` doubles as a controller-level request body elsewhere, so a required `version` field there would have made it a mandatory POST field and broken that fixture's own tests. Also fixes a latent type-soundness gap in two `CrudContextInterface` mock helpers (nestjs-crud, nestjs-cache), surfaced by the interface gaining new fields: both handed a generically-typed value to a concretely-typed overlay slot.
The alpha.11 version bump (21c541c) updated only the 13 package version fields and missed the exact peerDependencies pins that every prior bump kept in lockstep, leaving eleven pins across seven v8 packages declaring a requirement on the now-superseded alpha.10.
… drivers SQLite (and 7 other TypeORM drivers: better-sqlite3, sqljs, expo, capacitor, cordova, nativescript, react-native) share one QueryRunner per DataSource, so two transactions started concurrently can both decide no transaction is open and both issue a real BEGIN — the second fails at the driver level with "cannot start a transaction within a transaction" instead of running the version guard (#476). TransactionFactoryInterface gains an optional supportsConcurrentTransactions flag (default true). TransactionFactoryRegistry owns a per-key TransactionQueue and TransactionManager now acquires it before starting a transaction and holds it for the whole BEGIN...COMMIT/ROLLBACK lifetime, so a second transaction on the same connection waits instead of racing. The queue is abort-aware, so a timed-out scope still parked in the queue rejects immediately rather than waiting for the holder. TypeOrmTransactionFactory is the only adapter-specific piece: it declares the flag based on the driver type, keeping the serialization mechanism itself in the abstraction. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
… it rests on
Row scope restricts which rows a caller may read and write. Enforcement sits at
every repository entry point, so layers above it are scoped without code of
their own — a nestjs-crud controller over a scoped entity is scoped with no
filter, guard or interceptor added.
RowScopeBase implements four rules and nothing else: reads inject the scope
columns into the WHERE; writes naming an existing row pre-check on the primary
key plus the scope columns; create — and an upsert whose key names no stored
row — is new data and gets stamped; and the scope columns take precedence over
any same-named payload value, refusing a mismatch by whichever route it
arrives.
Three repository defects were found underneath it and fixed there rather than
compensated for above. Each was reproduced on an entity with no row scope at
all:
- update/replace let `data` override the primary key supplied by the entity
argument, writing to a row the caller never named and leaving the named row
untouched. Refused by assertKeyUnchanged (PrimaryKeyImmutableException).
- A relation object on the entity argument decided which row was written, since
a driver resolves a column from its relation in preference to the column's
own scalar. withoutRelations strips them on all seven writes that name an
existing row, including softDelete's already-deleted early return.
- create read the raw payload to decide whether its key was taken, missing a
key supplied as `{ account: { id } }`. assertNotExisting now reads the
driver's transform() output.
Also included:
- core: an `immutable` option for context overlays, so a scope resolved before
hooks cannot be replaced downstream.
- repository: close a fail-open in the where-clause AST, where an empty AND/OR
collapsed to "no constraint" rather than matching nothing.
The load-bearing invariant throughout is that a column is read through the
repository's transform(), never off the caller's raw payload: a value can
arrive as its own scalar or through a relation object, and reading the payload
directly has defeated five separate guards.
…ial composite key
Four fixes found by auditing the READMEs against the code. Two were options
the docs promised and the implementation ignored, which is worse than an
unimplemented option because nothing tells the caller.
- core: `@UseHooks({ hook, spec })` accepted a specification that was never
evaluated, so the hook ran on every operation. The value was stored on the
resolved hook and read nowhere; gating comes from the hook-method argument, a
method-level `@Specification`, or the class-level `@Hook`/`@RepoHook`.
`spec` is removed from `HookWithSpec` — nothing used the object form.
- repository-typeorm: a `joinType: 'INNER'` clause was discarded, so
`Join.inner()` behaved exactly like `Join.left()` and returned the rows the
caller asked to exclude. TypeORM's `relations` find option is always a LEFT
JOIN, so the driver now refuses INNER rather than answering wrongly.
Federation is unaffected: it implements INNER itself and strips federated
joins before the driver sees them.
- repository: `create` with only part of a composite primary key failed as a
500 reporting that it could not *update* a row, naming no column. A partial
key also cannot be looked up, so the existence check never ran. Now a 400
(`PartialPrimaryKeyException`) naming the missing columns. Supplying none of
them is still the ordinary generated-key create.
- crud: export `createCrudAdapterProvider`, `createQueryHandler` and
`createCommandHandler`. The package demonstrates hand-written CRUD
controllers by example but reached these through deep relative imports, so an
external consumer could not reproduce the pattern.
Also corrects two TSDoc blocks that contradicted the code: `@AfterRead` is
wired only into `find` and `findOne`, and `RepositoryAdapter`'s `@example`
overrode the public operation methods its own documentation forbids.
An audit of every README overlapping `@concepta/nestjs-repository`, checking each claim against the implementation rather than against neighbouring comments. Snippets were compiled rather than re-read, which is what found the ones that could not have worked. Could not compile as written: - repository: the driver example used an unconstrained `<Entity>` against a base declared `<Entity extends PlainLiteralObject>`. - cache, user: wiring snippets named entity classes that do not exist (`UserCacheEntity`, `UserEntity`, `UserCredentialEntity`) instead of the exported `*SqliteEntity` classes their own tables list. - crud: `@CrudCommandHandler` takes an options object, not a bare class. Could not have worked: - otp: the HTTP wiring example never registered the entity with `RepositoryModule`, which the OTP repository provider injects — the module as documented fails dependency resolution at startup. - role: the entity example declared `version` and `dateDeleted` with plain `@Column()`. The repository finds them via TypeORM's `isVersion` / `isDeleteDate` flags, which only `@VersionColumn` / `@DeleteDateColumn` set, so the example booted with optimistic locking and soft-delete immutability both silently off. - cache: the repository-resolution snippet resolved by `ctx.entity`; handlers resolve by the operation's `namespace`. Claims the code contradicts: - crud: `includeDeleted` was documented as read-only and always 409. It reaches writes too — without it they 404, with it update/replace 409. - repository-typeorm: `expectedVersion` on an already-soft-deleted row was documented as voiding idempotency. The guard resolves before the no-op, so a stale version conflicts and a matching one still no-ops. - repository: `@AfterRead` covers `find` and `findOne` only; the two READMEs disagreed and the TypeORM one was right. `resolveJoinClauses()` validates relation names rather than resolving structural properties. - otp: three wrong entries in the repository table (`get` returns a nullable, and two options named `cutoffDate`). Plus: the exception tables gain the rows they were missing, `joinType` now documents the driver refusing INNER, and each consumer README says where `rowScope` is declared for entities carrying an owner column.
…overage with the code Follow-ups from the README accuracy audit, none of them behaviour changes. - crud README's hook example used `ctx.params` and `ctx.operation`, which are not on what a repository hook receives: the CRUD request is a `CrudCtx` overlay. Its parameters were also untyped (two TS7006 errors under a consumer's `strict` tsconfig), and `with()` throws when an overlay is absent, so the example would have broken any service reaching the same repository outside a CRUD route. Rewritten typed, through the overlay, and guarded on `supports()`; compiled verbatim to confirm. - Controller-level `transactional` was undocumented. It applies a class-level `@Transactional()` and opts read operations out; an operation's own setting overrides it. - The bare-id relation note claimed the driver rejects that form on a declared join column. Probed against a real driver: nothing is stored, but over HTTP the request schema refuses it first, and through the repository it surfaces as a query error. Reduced to what is true. - Row-scope fixtures named `PlainLiteralObject` instead of their entity, which discards the compile-time column check the README promises. The constraint accepts a TypeORM entity class, so the weaker typing was never necessary; a misspelled scope column is now a compile error rather than a boot failure. - `assertKeyUnchanged` runs after hooks and nothing covered it. The new cases pass no key at all, so a hook is the only source of the change.
The flakiness item is the one with a running cost: a red suite that goes green on retry trains everyone to re-run rather than look, so a real regression in a transactional path would be dismissed as it. The Join.inner note claimed implementing it meant routing joined reads through TypeORM's QueryBuilder. A NOT_NULL predicate on the related key would also do it, since a LEFT join plus a predicate on the joined column already excludes non-matching roots — cheaper than the recorded estimate, and never explored when the item was deferred.
…r may not read A row the actor read holds only the columns they may read, so a generated CRUD update by a role hiding the version or delete date failed with a 500. The repository now refuses such a write at its entry with a 403 naming the column. A row that holds the column is written whatever the actor may read, so write-only actors and cascades are unchanged.
…typed grant verbs
…e as a request A guard built with AuthGuard() let passport read the request through its default getRequest, which on a message handler returned the caller's payload: a message shaped like a request with a valid token signed the caller in, and any other message crashed the guard (500). The global JWT guard runs on message handlers whenever a microservice inherits the app's config. getRequest now returns the HTTP request only, and refuses any other call with AuthTransportUnsupportedException (401 over HTTP, fault usage) before a strategy runs. A guard that can be turned off still lets an @authpublic() handler through, as nobody when optional, and guards turned off by settings or the disable callback are unchanged. A guard that overrides getRequest authenticates its own transport, as passport documents; AuthUserCtx is still defined on HTTP only. The JWT guard e2e spec also pins AuthUserCtx with a guard of yours setting only request.user, and a failing user lookup on guarded and optional routes.
…CRUD route facts - can, assert and effectiveRules ask the actor resolver with the ctx and no execution context; the actor overlay never asks it off HTTP. - Under a shared CaslAuthority, fields are checked against access control's own denies only, and the authority's unusable rules fail with its own exception; effectiveRules shows the actor's own rules and never asks the authority. - An empty within from a column-limited actor is a 403; a replace is refused when a scope column is not writable, though row scope sets it. - The JWT and refresh strategies fail startup without a UserPort. - Through the attack app: a grant-less route is decided for whoever signed in and refused to nobody; a generated write by a role that may not read is refused at its pre-read, as is one filtering on a hidden column; a route param the caller may not write refuses the write; a response schema requiring a hidden column fails without showing it; an unknown ?s= is a 400 and Read ignores ?sort=. - AccessControlCrudPolicy leaves select unchecked, and refuses an unknown filter, sort or search field under a field-limited allow.
AuthRouterGuard read the HTTP request without checking the call type, so on a message handler it took the provider, code and state from the caller's own payload and ran the provider guard that payload named. It now refuses any call that isn't HTTP with AuthTransportUnsupportedException before reading anything, as guards built with AuthGuard() do; both share one HTTP check. The exception's TSDoc and the README name the router too.
Every case in the 14 packages' exception-fault specs now states the errorCode its exception sets today, beside its fault: 149 cases. 51 of those codes still lack the _ERROR suffix, left for the rename sweep.
…and authentication - Repository authority: joins decided and narrowed on find, findOne, findAndCount and count; upsert, replace, softDelete, restore and deleteMany results narrowed to the readable columns; the delete date decided on any row of a batch and on replace; joins decided as the caller when a hook hands the read another ctx; many-to-many joins through a governed junction decided, and refused at startup when eager; cascades decided before the parent is written; the internal-call mark held to its own call. - Row scope: findAndCount, findOne and count read only the caller's rows; a join pair naming the scope column on one side only, and a many-to-many join, refused; joins judged by the caller's scope, not a hook's ctx; relax by column; replace and upsert of another tenant's row answer 404. - Access control: a nested field filtered from responses; a decision defined by something else does not skip the guard; inherited getters hidden; batch-create route params and positional query paths checked; the overlay defines a frozen copy of the actor. - Authentication: a user whose active is undefined or null refused by every sign-in; AuthRouterGuard honours a Promise or Observable false; a guard built without canDisable cannot be turned off. - Core: fields stored as null, and multi-digit positions, refused.
- The strict-schema leak check looks for the column's name in the 500 body, not a value the row never held. - The sort test is named for the caller it covers (denied only some columns), since a field-limited read is refused a sort instead. - The join tests on every read drop rows repeating the single-path tests and pick rows by name. - The replace's left-out delete is shown decided as the caller, once after the write, rather than by a count. - Names match what is asserted; spies are restored in try/finally and cleared before each refused call, with the exception class checked; the employees fixture finds a row by id, so a narrowed-join test can fail; testing modules are closed.
- access control: under a shared authority a per-user grid narrows only by denying; the response filter and assertFields check access control's own rules, the authority's column rules hold in a governed repository - repository: an undeclared entity is open, so a governed app turns on requireAuthorityDeclaration; columns another system owns, as rules; a column a hook adds to a cascaded row is checked at that row's write - core: RPC (preview) is the one place saying what protects a message handler; route audit runs production in throw mode with a short allow list and doesn't check CRUD's request policy
CaslAuthority and access control each worked out a refusal's gate the same way. Core's authorityGateOf now holds the rule once, for both and for an authority of an application's own.
…eWrites audit rule Core's route audit now runs requirePrivateWrites: a route marked public on any method but GET, HEAD, OPTIONS, SEARCH, PROPFIND or QUERY, ALL included, fails startup until listed in allow.requirePrivateWrites. Each route the audit collects now carries its request method.
…ate on columns and fields A rule's pending names the gate a deny waits on; reason now only explains a rule and is never reported. A refusal names the gate when every deny refusing it is pending and an allow covers what was refused: as gate for an action or an access-control field, and in gates by column for a repository's column refusal. authorityPendingGates lists every pending decision in a rule set. pending on a rule that isn't a deny is refused.
…hority does not know
A misspelled deny denied nothing. CaslAuthority now refuses, as it does
rules of the wrong shape, a rule naming a subject that is neither an
entity it governs nor declared, a verb outside the six and its declared
actions, or a field that isn't a column of every governed entity it names.
Each repository tells the authority its entity's key and columns at
startup (AuthorityInterface.govern); subjects and verbs of your own are
declared with new CaslAuthority(rules, { subjects, actions }), and
ruleProblems checks stored rules the same way before they are saved.
authorityRuleProblems takes the known names as an optional argument.
… effectiveRules Under an authority that gives its rules (AuthorityInterface.rulesFor, which CaslAuthority implements from the snapshot it decides by), effectiveRules combines them as the checks do: outside except, the authority's allows and every deny; in except, the actor's own rules. Each rule shown holds only action, subject, fields and inverted, as a copy: a gate or a reason never reaches the caller.
…ns with no write in core A write's options take its domain operation (action: 'void'), decided beside the write's own action, columns included, so naming it only narrows; reads and cascaded child writes are decided as before. Core's assertAuthority asks the authority an operation with no write of its own, such as approve or export, for the actor on ctx, throwing AuthorityActionRefusedException (403) when it refuses or nobody acts.
…itoryModule.forRoot
authority: { required: true } replaces requireAuthorityDeclaration as an
explicit switch saying the application is governed: every registered
entity declares an authority or open with a reason, or startup fails. The
governed examples and the attack app turn it on.
…, report rule gaps - access control: an authority.except entry naming a subject the authority governs fails startup, and the authority decides it on every call regardless; AuthorityInterface gains optional governs(subject), answered by CaslAuthority for attached entities and declared subjects - requireWriteGrants: a new route-audit rule failing startup on a write-method route with any read grant, since any one grant lets a caller in; core exports isReadMethod, shared with requirePrivateWrites - authorityRuleGaps and CaslAuthority.ruleGaps list each subject and action no rule decides, with the fields when rules name the pair only for some
…ay not read Joining, filtering or sorting by a relation reads the root columns it is matched on, so an actor who may not read departmentId could see it as department.id, or match on it through Where.rel. Every relation a read names now counts its root-side join columns against the actor's readable columns, as federated joins already did.
… control on it - Repository: an authority decides every read and write, column by column, including joins, cascades and domain operations; authority.required in forRoot. - Access control: rebuilt on CASL and decided by the shared authority; except, effectiveRules, pending gates, and checks for unknown rules. - CRUD: generated requests go through a request policy; reads are narrowed to what the actor may read. - Authentication: later guards see the user; inactive users are refused; non-HTTP calls are refused. - Core: opt-in route audit (requireAuth, requireAcl, requireWriteGrants, requirePrivateWrites), with assertAuthority and authorityRuleGaps. - Errors on this branch end in _ERROR; READMEs corrected to match.
…conformance/adapter BREAKING CHANGE: RepositoryModule.forRoot()/forRootAsync() take `adapters` instead of `drivers`. Import the conformance suite from @concepta/nestjs-repository/conformance/adapter.
…on and exported types
BREAKING CHANGE: the repository implementation vocabulary is now "adapter".
Migration:
- RepositoryModule.forRoot()/forRootAsync() entries: `{ driver: X, entities }`
becomes `{ adapter: X, entities }`.
- Rename the imports:
- RepositoryDriverInterface → RepositoryAdapterInterface
- RepositoryDriverRegistration(s) → RepositoryAdapterRegistration(s)
- RepositoryDriverEntityOptions → RepositoryAdapterEntityOptions
- RepositoryDriverOptions → RepositoryAdapterOptions
- TypeOrmPostgresDriverOptionsInterface → TypeOrmPostgresAdapterOptionsInterface
- TypeOrmOracleDriverOptionsInterface → TypeOrmOracleAdapterOptionsInterface
- TypeOrmSqlServerDriverOptionsInterface → TypeOrmSqlServerAdapterOptionsInterface
- DrizzlePostgresDriverOptionsInterface → DrizzlePostgresAdapterOptionsInterface
- Conformance harness (@concepta/nestjs-repository/conformance/adapter): `driver` becomes `adapter`,
`driverOptions` becomes `adapterOptions`.
- README anchor #testing-your-driver is now #testing-your-adapter.
Each *AdapterOptionsInterface holds only the adapter's own settings, none of the database
client's, so none keeps "Driver". Durable messaging names are unchanged.
…t titles and messages "Driver" now means only a database client (pg, mysql2, better-sqlite3, oracledb, mssql) or an ORM's own driver layer. Boot and warning messages that named the implementation say "adapter"; the specs asserting them are updated. Durable messaging prose and RepositoryAdapter's own TSDoc and messages are unchanged.
This branch has not been deployed
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.
No description provided.