@dudousxd/nestjs-authz-inertia 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @dudousxd/nestjs-authz-inertia
2
2
 
3
+ ## 0.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#15](https://github.com/DavideCarvalho/nestjs-authz/pull/15) [`7294ff5`](https://github.com/DavideCarvalho/nestjs-authz/commit/7294ff5c01454d9fea6d42a6c3f80eff2f00dc48) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Fix the exported `VERSION` const shipping as `'0.0.0'`.
8
+
9
+ The build is plain `tsc` with no version injection, and `changeset version` only bumps `package.json` — leaving the `export const VERSION` in `src/index.ts` stale, so the published dist reported `'0.0.0'`. The const is now corrected to match each package's `package.json`, and a new `scripts/sync-version.mjs` (chained into the `version-packages` script) re-syncs it on every release bump to prevent future drift. Run with `--check` to fail a build on mismatch.
10
+
11
+ - Updated dependencies [[`7294ff5`](https://github.com/DavideCarvalho/nestjs-authz/commit/7294ff5c01454d9fea6d42a6c3f80eff2f00dc48)]:
12
+ - @dudousxd/nestjs-authz-client@0.2.1
13
+
14
+ ## 0.1.1
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies [[`07d01de`](https://github.com/DavideCarvalho/nestjs-authz/commit/07d01de286e7dfcae5fbeb10b7e8d48533214087)]:
19
+ - @dudousxd/nestjs-authz-client@0.2.0
20
+
3
21
  ## 0.1.0
4
22
 
5
23
  ### Minor Changes
package/README.md CHANGED
@@ -80,12 +80,23 @@ AuthzModule.forRoot({ canEndpoint: true }) // POST /authz/can → { allowed }
80
80
  It runs `gate.allows(ability, resource?)` for the current context user and returns
81
81
  `{ allowed }`. Off by default. This is the path the codegen-emitted `can()` targets.
82
82
 
83
- > **Class-level only.** The endpoint can resolve **class-level abilities and ad-hoc gates**
84
- > only — the `{ type, id }` resource shim it receives never matches a `@Policy` by constructor.
85
- > Per-instance decisions MUST be hydrated via tiers 1-2 (shared props / `authorizeResource`);
86
- > a **resource-bound** ability that misses the cache and falls through to `/authz/can` will
87
- > **deny** (and `createCan` logs a one-time `console.warn`). Treat tier 3 as a class-level /
88
- > ad-hoc fallback, not a per-instance one.
83
+ > **Class-level by default; per-instance with a loader.** Out of the box the endpoint resolves
84
+ > **class-level abilities and ad-hoc gates** only — the `{ type, id }` shim it receives never
85
+ > matches a `@Policy` by constructor, so a **resource-bound** ability that misses the cache and
86
+ > falls through to `/authz/can` will **deny**. To make per-instance decisions resolve at tier 3,
87
+ > register `resourceLoaders` keyed by the resource `type`:
88
+ >
89
+ > ```ts
90
+ > AuthzModule.forRoot({
91
+ > canEndpoint: true,
92
+ > resourceLoaders: { Post: (id) => postRepo.findOneBy({ id: Number(id) }) },
93
+ > })
94
+ > ```
95
+ >
96
+ > The endpoint then loads the real entity before authorizing, so the instance `@Policy` matches
97
+ > and decides correctly (a loader returning nullish → deny / not found). Prefer hydrating via
98
+ > tiers 1-2 (shared props / `authorizeResource`) when you can; use `resourceLoaders` for the
99
+ > abilities that genuinely need a tier-3 round-trip.
89
100
 
90
101
  ## Client store (framework-neutral)
91
102
 
@@ -109,8 +120,9 @@ can('mystery'); // fallback: 'deny' → false; 'fetch'
109
120
  - **Cache hit** → returns a `boolean` synchronously, never touches the network.
110
121
  - **Cache miss** → `fallback: 'deny'` (default) returns `false`; `fallback: 'fetch'`
111
122
  POSTs to the tier-3 endpoint and returns a `Promise<boolean>`. A **resource-bound**
112
- miss under `'fetch'` can only deny (the endpoint resolves class-level abilities only)
113
- and logs a one-time `console.warn` — hydrate per-instance decisions via tiers 1-2.
123
+ miss under `'fetch'` resolves on the server only if the app registered a `resourceLoaders`
124
+ entry for that `type`; otherwise it denies (and `createCan` logs a one-time `console.warn`)
125
+ — hydrate per-instance decisions via tiers 1-2 or register a loader.
114
126
 
115
127
  ## License
116
128
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const VERSION = "0.0.0";
1
+ export declare const VERSION = "0.1.2";
2
2
  export { AuthzInertiaModule } from './module.js';
3
3
  export { AuthzInertiaInterceptor } from './authz-inertia.interceptor.js';
4
4
  export { AuthzDenialFilter, DEFAULT_LOGIN_URL, DEFAULT_FORBIDDEN_URL, } from './authz-denial.filter.js';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export const VERSION = '0.0.0';
1
+ export const VERSION = '0.1.2';
2
2
  export { AuthzInertiaModule } from './module.js';
3
3
  export { AuthzInertiaInterceptor } from './authz-inertia.interceptor.js';
4
4
  export { AuthzDenialFilter, DEFAULT_LOGIN_URL, DEFAULT_FORBIDDEN_URL, } from './authz-denial.filter.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dudousxd/nestjs-authz-inertia",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Inertia.js integration for @dudousxd/nestjs-authz — share a user's abilities as props so client `can()` checks need no network request.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -30,7 +30,7 @@
30
30
  "CHANGELOG.md"
31
31
  ],
32
32
  "dependencies": {
33
- "@dudousxd/nestjs-authz-client": "^0.1.0"
33
+ "@dudousxd/nestjs-authz-client": "^0.2.1"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "@dudousxd/nestjs-authz": ">=0.2.0",
@@ -55,7 +55,7 @@
55
55
  "rxjs": "^7.8.1",
56
56
  "typescript": "^5.4.0",
57
57
  "vitest": "^3.0.0",
58
- "@dudousxd/nestjs-authz": "^0.3.0"
58
+ "@dudousxd/nestjs-authz": "^0.6.4"
59
59
  },
60
60
  "engines": {
61
61
  "node": ">=20"