@opensaas/stack-core 0.40.0 → 0.41.0
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +39 -0
- package/CLAUDE.md +52 -0
- package/dist/access/access-filter.d.ts +88 -18
- package/dist/access/access-filter.d.ts.map +1 -1
- package/dist/access/access-filter.js +343 -36
- package/dist/access/access-filter.js.map +1 -1
- package/dist/access/access-filter.test.js +759 -6
- package/dist/access/access-filter.test.js.map +1 -1
- package/dist/access/denied-relation-visibility.test.d.ts +2 -0
- package/dist/access/denied-relation-visibility.test.d.ts.map +1 -0
- package/dist/access/denied-relation-visibility.test.js +114 -0
- package/dist/access/denied-relation-visibility.test.js.map +1 -0
- package/dist/access/engine.d.ts +11 -0
- package/dist/access/engine.d.ts.map +1 -1
- package/dist/access/engine.js +26 -0
- package/dist/access/engine.js.map +1 -1
- package/dist/access/errors.d.ts +34 -0
- package/dist/access/errors.d.ts.map +1 -1
- package/dist/access/errors.js +47 -0
- package/dist/access/errors.js.map +1 -1
- package/dist/access/field-visibility.d.ts +2 -2
- package/dist/access/field-visibility.d.ts.map +1 -1
- package/dist/access/field-visibility.js +73 -23
- package/dist/access/field-visibility.js.map +1 -1
- package/dist/access/index.d.ts +7 -3
- package/dist/access/index.d.ts.map +1 -1
- package/dist/access/index.js +9 -2
- package/dist/access/index.js.map +1 -1
- package/dist/access/multi-column-read-write.test.js.map +1 -1
- package/dist/access/query-validation.d.ts +31 -0
- package/dist/access/query-validation.d.ts.map +1 -1
- package/dist/access/query-validation.js +75 -16
- package/dist/access/query-validation.js.map +1 -1
- package/dist/access/relationship-count.d.ts +41 -3
- package/dist/access/relationship-count.d.ts.map +1 -1
- package/dist/access/relationship-count.js +44 -7
- package/dist/access/relationship-count.js.map +1 -1
- package/dist/access/relationship-count.test.js +62 -0
- package/dist/access/relationship-count.test.js.map +1 -1
- package/dist/access/synthetic-include-read.test.d.ts +2 -0
- package/dist/access/synthetic-include-read.test.d.ts.map +1 -0
- package/dist/access/synthetic-include-read.test.js +121 -0
- package/dist/access/synthetic-include-read.test.js.map +1 -0
- package/dist/config/types.d.ts +22 -22
- package/dist/config/types.d.ts.map +1 -1
- package/dist/context/hook-pipeline.d.ts +2 -2
- package/dist/context/hook-pipeline.d.ts.map +1 -1
- package/dist/context/hook-pipeline.js.map +1 -1
- package/dist/context/index.d.ts +16 -1
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +76 -26
- package/dist/context/index.js.map +1 -1
- package/dist/context/nested-operations.d.ts +2 -2
- package/dist/context/nested-operations.d.ts.map +1 -1
- package/dist/context/nested-operations.js +21 -3
- package/dist/context/nested-operations.js.map +1 -1
- package/dist/context/write-pipeline.d.ts.map +1 -1
- package/dist/context/write-pipeline.js +23 -29
- package/dist/context/write-pipeline.js.map +1 -1
- package/dist/hooks/index.d.ts +16 -15
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js.map +1 -1
- package/package.json +2 -2
- package/src/access/access-filter.test.ts +1403 -159
- package/src/access/access-filter.ts +525 -47
- package/src/access/denied-relation-visibility.test.ts +173 -0
- package/src/access/engine.ts +28 -0
- package/src/access/errors.ts +55 -0
- package/src/access/field-visibility.ts +105 -24
- package/src/access/index.ts +11 -0
- package/src/access/multi-column-read-write.test.ts +3 -2
- package/src/access/query-validation.ts +136 -9
- package/src/access/relationship-count.test.ts +75 -0
- package/src/access/relationship-count.ts +53 -10
- package/src/access/synthetic-include-read.test.ts +179 -0
- package/src/config/types.ts +22 -22
- package/src/context/hook-pipeline.ts +4 -2
- package/src/context/index.ts +120 -39
- package/src/context/nested-operations.ts +35 -11
- package/src/context/write-pipeline.ts +52 -32
- package/src/hooks/index.ts +22 -15
- package/tests/context.test.ts +193 -5
- package/tests/hook-context-secured.test.ts +424 -0
- package/tests/nested-access-and-hooks.test.ts +324 -0
- package/tsconfig.tsbuildinfo +1 -1
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# @opensaas/stack-core
|
|
2
2
|
|
|
3
|
+
## 0.41.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1179](https://github.com/OpenSaasAU/stack/pull/1179) [`67dce2e`](https://github.com/OpenSaasAU/stack/commit/67dce2e9d96afdc5c69f0a2f1c8b395346d4e942) Thanks [@borisno2](https://github.com/borisno2)! - A list/field `resolveInput` / `validate` / `beforeOperation` / `afterOperation` hook's `context` is now a full secured context — `sudo()`, `withSession()`, `transaction()` and `serverAction` — bound to the write's OWN transaction client, exactly like the `txContext` a `context.transaction()` callback receives.
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
Order: list({
|
|
11
|
+
hooks: {
|
|
12
|
+
beforeOperation: async ({ context }) => {
|
|
13
|
+
// Elevated AND atomic with this write — rolls back together if it throws.
|
|
14
|
+
await context.sudo().db.auditLog.create({ data: { action: 'order-write' } })
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
})
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Previously this `context` had no `sudo()`/`withSession()`/`transaction()` at all, forcing a workaround (`getContext(session).sudo()`) that opened a SEPARATE connection from the write's transaction — its writes could survive a rollback, and it could deadlock on a single-connection adapter. `context.transaction()` called from inside one of these hooks now joins the write's transaction rather than opening a nested one. `beforeTransaction`/`afterTransaction` are unaffected — they keep the plain access-checked context bound to the base client, always. A field's `resolveOutput` keeps the same context type as before; which client it's bound to already depended on how the read arose (a plain read: the base client; a create/update's own Field Visibility pass: that write's transaction client), unchanged by this release.
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- [#1108](https://github.com/OpenSaasAU/stack/pull/1108) [`2260539`](https://github.com/OpenSaasAU/stack/commit/2260539c5488dae0ee6e7f86ccd913e5c898ccdb) Thanks [@borisno2](https://github.com/borisno2)! - Fix: a relation quantifier (`some`/`every`/`none`/`is`/`isNot`) nested inside an `include` entry's own `where` is now scoped by the deeper related list's `query` access and field-read access too, reusing `buildAccessScopedWhere` ([#916](https://github.com/OpenSaasAU/stack/issues/916)) — closing a residual probing-oracle gap in [#1092](https://github.com/OpenSaasAU/stack/issues/1092)'s fix.
|
|
25
|
+
|
|
26
|
+
- [#1102](https://github.com/OpenSaasAU/stack/pull/1102) [`aa34cca`](https://github.com/OpenSaasAU/stack/commit/aa34cca65877759b9625da1538c65c53ed54385a) Thanks [@borisno2](https://github.com/borisno2)! - Fix: a `where`/`orderBy` nested inside a caller's `include` entry now validates against the related list's config, closing a probing oracle over undeclared or read-denied fields one hop into a relation ([#1092](https://github.com/OpenSaasAU/stack/issues/1092)).
|
|
27
|
+
|
|
28
|
+
- [#1041](https://github.com/OpenSaasAU/stack/pull/1041) [`182153c`](https://github.com/OpenSaasAU/stack/commit/182153cb976b14ef67673d0eeef7925d950bfa10) Thanks [@borisno2](https://github.com/borisno2)! - Upgrade Prisma packages to `^7.9.1`, keeping the CLI, client, and driver adapters on the same release. Scaffolded PostgreSQL projects now pin `@prisma/adapter-pg` to `^7.9.1`.
|
|
29
|
+
|
|
30
|
+
- [#1101](https://github.com/OpenSaasAU/stack/pull/1101) [`682795f`](https://github.com/OpenSaasAU/stack/commit/682795f7c7f0d0194ffd08e993d452c368bcd847) Thanks [@borisno2](https://github.com/borisno2)! - Fix a query fragment read (`{ query: fragment }`) skipping the Access Filter's scoping walk, so a related list's `query` access, row filters, and the read-include depth cap were never enforced. Fragment reads may now return fewer related rows — those rows were never authorised.
|
|
31
|
+
|
|
32
|
+
- [#1110](https://github.com/OpenSaasAU/stack/pull/1110) [`73d1b6a`](https://github.com/OpenSaasAU/stack/commit/73d1b6aba9a9b789a8111105d56257a1de66a883) Thanks [@borisno2](https://github.com/borisno2)! - A caller-supplied `_count` in `include` is now scoped by each named relation's own `query` access (a row filter is folded into the count, a fully denied relation counts `0`), closing a cardinality leak where counts previously reached the caller unscoped.
|
|
33
|
+
|
|
34
|
+
- [#1091](https://github.com/OpenSaasAU/stack/pull/1091) [`f1e8792`](https://github.com/OpenSaasAU/stack/commit/f1e8792ce580d92a5874599dfb8a8ccde4d6c8b3) Thanks [@borisno2](https://github.com/borisno2)! - Fix a read naming a list-only ref's synthetic back-relation (`from_<List>_<field>`) in `include`: it now resolves to the declared relationship it stands for and is scoped by that list's `query` access, its field-level `read` gates, and its virtual fields — instead of being returned unscoped. An `include` key that resolves to neither a declared relationship, a synthetic back-relation, nor `_count` is now rejected rather than silently passed through. Responses will shrink for callers relying on either gap — the extra rows and fields they received were never authorised.
|
|
35
|
+
|
|
36
|
+
- [#1120](https://github.com/OpenSaasAU/stack/pull/1120) [`9eb7c77`](https://github.com/OpenSaasAU/stack/commit/9eb7c7766d212e92b02d53a1ba3aaead4faf1496) Thanks [@borisno2](https://github.com/borisno2)! - Fix `_count` ignoring a relationship's field-level `read` access, letting the true count of a hidden relationship leak through both the admin list view and a caller-supplied `_count`.
|
|
37
|
+
|
|
38
|
+
- [#1090](https://github.com/OpenSaasAU/stack/pull/1090) [`5b478de`](https://github.com/OpenSaasAU/stack/commit/5b478de64f3564d837d2f9f912972e49008be884) Thanks [@borisno2](https://github.com/borisno2)! - Fix nested update/delete (e.g. `post.update({ data: { author: { update: {...} } } })`) silently treating a Prisma filter returned by the target list's `update`/`delete` access as an unconditional allow. It is now re-checked against the target row in the database, matching top-level write behavior.
|
|
39
|
+
|
|
40
|
+
- [#1115](https://github.com/OpenSaasAU/stack/pull/1115) [`d335122`](https://github.com/OpenSaasAU/stack/commit/d335122323b3402c0838aa50873fab0c085fbb01) Thanks [@borisno2](https://github.com/borisno2)! - Fix a denied to-many relation coming back `undefined` instead of `[]` on both the caller-`include:` and fragment `query` read paths.
|
|
41
|
+
|
|
3
42
|
## 0.40.0
|
|
4
43
|
|
|
5
44
|
### Minor Changes
|
package/CLAUDE.md
CHANGED
|
@@ -192,6 +192,58 @@ Key points:
|
|
|
192
192
|
optimistically at write time, unchanged. See ADR-0028 and the hooks concept
|
|
193
193
|
doc.
|
|
194
194
|
|
|
195
|
+
#### Hook context is the same secured context as a transaction's (#1176)
|
|
196
|
+
|
|
197
|
+
A list/field `resolveInput` / `validate` / `beforeOperation` / `afterOperation`
|
|
198
|
+
hook's `context` argument is a full `StackContext` — `sudo()`, `withSession()`,
|
|
199
|
+
`transaction()` and `serverAction` are all present, exactly like the `txContext`
|
|
200
|
+
a `context.transaction()` callback receives — bound to the WRITE'S OWN
|
|
201
|
+
transaction client, not the base one. This amends ADR-0012: the Write
|
|
202
|
+
Pipeline's transaction rebind (`bindContextToTransaction`) goes through the
|
|
203
|
+
same `getContext` factory `context.transaction()` already rebuilds through,
|
|
204
|
+
instead of hand-assembling a bare `AccessContext` object literal.
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
Order: list({
|
|
208
|
+
hooks: {
|
|
209
|
+
beforeOperation: async ({ context }) => {
|
|
210
|
+
// Elevated AND atomic with this write: rolls back together if the
|
|
211
|
+
// write (or a later hook in it) throws — unlike `getContext(session)
|
|
212
|
+
// .sudo()`, which would bind to a SEPARATE connection.
|
|
213
|
+
await context.sudo().db.auditLog.create({ data: { action: 'order-write' } })
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
})
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
- `context.sudo()` / `context.withSession(s)` from one of these hooks stays
|
|
220
|
+
bound to the SAME transaction client the hook itself was given — carrying
|
|
221
|
+
the write's transaction owner (ADR-0028, so a write through them defers its
|
|
222
|
+
`afterTransaction` to that owner) and the hook's own resolve chain
|
|
223
|
+
(ADR-0023, so a write issued from inside a `resolveOutput` hook keeps that
|
|
224
|
+
hook's cycle-guard chain into its own Field Visibility pass).
|
|
225
|
+
- `context.transaction(fn)` called from inside one of these hooks **joins**
|
|
226
|
+
the write's transaction (the existing "no interactive client → run
|
|
227
|
+
directly" fallback) — it never opens a nested one.
|
|
228
|
+
- Plugin runtimes are **not** re-executed on this rebind (same rule as the
|
|
229
|
+
nested-write rebind ADR-0010 already established).
|
|
230
|
+
- **Unaffected:** `beforeTransaction` / `afterTransaction` (list and field) keep
|
|
231
|
+
the plain `AccessContext`, bound to the BASE client, always — see ADR-0028
|
|
232
|
+
for why boundary hooks must not run through a client that may already be
|
|
233
|
+
closed by flush time.
|
|
234
|
+
- **A field's `resolveOutput` keeps the plain `AccessContext` type**, but which
|
|
235
|
+
client it's bound to already depended — before this record and after it
|
|
236
|
+
alike — on how the read that triggered it arose: a plain top-level read
|
|
237
|
+
resolves against the base client; a `resolveOutput` that runs as part of a
|
|
238
|
+
create/update's OWN result (the write's Field Visibility pass, Phase 11)
|
|
239
|
+
resolves against THAT write's transaction client (ADR-0010) — so a
|
|
240
|
+
`context.db` read/write from inside such a hook is already atomic with the
|
|
241
|
+
write, same as `beforeOperation`/`afterOperation`. Not a consequence of this
|
|
242
|
+
record; stated here only so it isn't mistaken for one.
|
|
243
|
+
|
|
244
|
+
See ADR-0066 and the hooks concept doc's "In-transaction vs
|
|
245
|
+
transaction-boundary hooks" section.
|
|
246
|
+
|
|
195
247
|
#### Substituting a session (`context.withSession`, #980)
|
|
196
248
|
|
|
197
249
|
`context.withSession(session)` sits beside `sudo()` on the other axis:
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import type { Session, AccessContext, PrismaFilter } from './types.js';
|
|
2
2
|
import type { OpenSaasConfig, FieldConfig, ListConfig } from '../config/types.js';
|
|
3
|
-
|
|
3
|
+
import { type ResolveSyntheticRelation } from './query-validation.js';
|
|
4
|
+
/**
|
|
5
|
+
* One relation's recorded access filter, or an outright denial — see the
|
|
6
|
+
* module doc's "To-one relations" section. `kind: 'scoped'` is to-one only
|
|
7
|
+
* (a to-many filter is attached as Prisma `where` instead, never recorded
|
|
8
|
+
* here); `kind: 'denied'` is recorded for BOTH arities (issue #1103) — a
|
|
9
|
+
* to-many relation has no `where`-based way to record "zero rows, and the
|
|
10
|
+
* key itself absent" either, so it shares the same post-query mechanism a
|
|
11
|
+
* denied to-one already used.
|
|
12
|
+
*/
|
|
4
13
|
export type ToOneAccessFilterEntry = {
|
|
5
14
|
kind: 'scoped';
|
|
6
15
|
relatedListName: string;
|
|
@@ -9,35 +18,75 @@ export type ToOneAccessFilterEntry = {
|
|
|
9
18
|
kind: 'denied';
|
|
10
19
|
};
|
|
11
20
|
/**
|
|
12
|
-
* Which
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
21
|
+
* Which relations, at which nesting level of an `include`, need a post-query
|
|
22
|
+
* fixup rather than a Prisma-side `where` — a to-one relation whose related
|
|
23
|
+
* list's `query` access resolved to a filter (`kind: 'scoped'`) or a denial
|
|
24
|
+
* (`kind: 'denied'`), Prisma cannot express either as a nested `where` on a
|
|
25
|
+
* to-one include; a to-many relation whose related list denies `query`
|
|
26
|
+
* access outright (`kind: 'denied'` only — a to-many filter is attached as
|
|
27
|
+
* `where` and never reaches this tree) is dropped from `include` entirely,
|
|
28
|
+
* so nothing marks its key present in the raw row either (issue #1103).
|
|
29
|
+
* `resolveToOneAccessVisibility` consumes this tree; `filterReadableFields`
|
|
30
|
+
* (`field-visibility.ts`) applies its result — forcing a denied key to `null`
|
|
31
|
+
* for a to-one relation, `[]` for a to-many one.
|
|
18
32
|
*/
|
|
19
33
|
export type ToOneAccessFilterTree = {
|
|
20
|
-
/**
|
|
34
|
+
/** Relation keys at THIS level needing a post-query fixup. */
|
|
21
35
|
filters: Record<string, ToOneAccessFilterEntry>;
|
|
22
|
-
/** Per-key trees for relations present in the include for other reasons, whose own nested include may contain further
|
|
36
|
+
/** Per-key trees for relations present in the include for other reasons, whose own nested include may contain further filters. */
|
|
23
37
|
nested: Record<string, ToOneAccessFilterTree>;
|
|
24
38
|
};
|
|
25
39
|
export declare function emptyToOneAccessFilterTree(): ToOneAccessFilterTree;
|
|
40
|
+
/**
|
|
41
|
+
* Whether a relationship field is to-one (at most one related row) rather
|
|
42
|
+
* than to-many. Exported so `field-visibility.ts` can pick the same `null`
|
|
43
|
+
* (to-one) vs `[]` (to-many) shape for a denied relation's forced value
|
|
44
|
+
* (issue #1103) that this module used to decide whether to record the
|
|
45
|
+
* denial in the first place — one source of truth for arity, not two.
|
|
46
|
+
*/
|
|
47
|
+
export declare function isToOneRelationship(fieldConfig: FieldConfig): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Which `_count.select` keys, at which nesting level of an `include`, were
|
|
50
|
+
* denied outright by their related list's `query` access — omitted from the
|
|
51
|
+
* `_count.select` sent to Prisma (issue #1087), so the row Prisma returns
|
|
52
|
+
* either lacks the key entirely or lacks a `_count` object at all. Consumed
|
|
53
|
+
* post-query by `filterReadableFields` (`field-visibility.ts`), which injects
|
|
54
|
+
* `0` for each — a count is a session-relative value, and `0` is what "no
|
|
55
|
+
* visible rows" means for it, never an absent key (mirroring the to-one
|
|
56
|
+
* `null` injection this module already does for issue #974, though a denied
|
|
57
|
+
* count needs no existence check: `0` requires no query at all).
|
|
58
|
+
*/
|
|
59
|
+
export type CountAccessDenialTree = {
|
|
60
|
+
/** `_count.select` keys denied at THIS level. */
|
|
61
|
+
keys: Set<string>;
|
|
62
|
+
/** Per-relation trees for relations present in the include for other reasons, whose own nested include may contain a further `_count`. */
|
|
63
|
+
nested: Record<string, CountAccessDenialTree>;
|
|
64
|
+
};
|
|
65
|
+
export declare function emptyCountAccessDenialTree(): CountAccessDenialTree;
|
|
26
66
|
/**
|
|
27
67
|
* Build the access-scoped `include` for exactly the relations a read
|
|
28
68
|
* requested, recursing only into branches `requestedInclude` itself names.
|
|
29
69
|
*
|
|
30
70
|
* For each key in `requestedInclude`:
|
|
31
|
-
* -
|
|
32
|
-
* passed through unchanged (
|
|
33
|
-
*
|
|
71
|
+
* - A declared field that isn't a relationship (scalar, virtual, …) → access
|
|
72
|
+
* control does not govern it; passed through unchanged (a virtual key is
|
|
73
|
+
* stripped later by `stripVirtualFieldsFromInclude`, #628).
|
|
74
|
+
* - Not declared at all → resolved via `resolveSyntheticReverseRelation`
|
|
75
|
+
* (the synthetic-back-relation case above); `_count` is scoped by
|
|
76
|
+
* `buildAccessScopedCountSelect` (issue #1087 — each named relation's own
|
|
77
|
+
* `query` access, exactly like any other relation this walk scopes; a
|
|
78
|
+
* denied one is recorded for `filterReadableFields` to inject `0` for,
|
|
79
|
+
* post-query, since Prisma cannot be asked for a guaranteed `0`); anything
|
|
80
|
+
* else throws `UndeclaredIncludeKeyError` rather than reaching the
|
|
81
|
+
* database unscoped.
|
|
34
82
|
* - A declared relationship whose related list's `query` access denies it
|
|
35
83
|
* (`=== false`) → dropped entirely, no matter what the request asked for
|
|
36
84
|
* nested beneath it (#566): the caller chooses *which* relations, access
|
|
37
|
-
* control chooses *whether* and *with what filter*.
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
85
|
+
* control chooses *whether* and *with what filter*. This denial is also
|
|
86
|
+
* recorded in `toOneAccessFilters` (`kind: 'denied'`), for either arity, so
|
|
87
|
+
* `filterReadableFields` can still surface an explicit `null` (to-one,
|
|
88
|
+
* issue #974) or `[]` (to-many, issue #1103) for it rather than an absent
|
|
89
|
+
* key.
|
|
41
90
|
* - Otherwise, for a to-**many** relation → the access `where` is
|
|
42
91
|
* AND-combined with any caller-supplied nested `where` (never replaced —
|
|
43
92
|
* the other half of #566), and a caller-supplied `take` rides through
|
|
@@ -65,8 +114,15 @@ export declare function buildAccessScopedInclude(requestedInclude: Record<string
|
|
|
65
114
|
}, config: OpenSaasConfig, listKey: string, depth?: number): Promise<{
|
|
66
115
|
include: Record<string, unknown>;
|
|
67
116
|
toOneAccessFilters: ToOneAccessFilterTree;
|
|
117
|
+
countDenials: CountAccessDenialTree;
|
|
68
118
|
}>;
|
|
69
|
-
/**
|
|
119
|
+
/**
|
|
120
|
+
* One relation's resolved post-query visibility — see
|
|
121
|
+
* `resolveToOneAccessVisibility`. `kind: 'visible'` (an existence check
|
|
122
|
+
* against a set of ids) only ever arises for a to-one relation, since only a
|
|
123
|
+
* to-one `kind: 'scoped'` filter entry produces one; `kind: 'denied'` passes
|
|
124
|
+
* straight through unresolved for either arity.
|
|
125
|
+
*/
|
|
70
126
|
export type ToOneVisibility = {
|
|
71
127
|
kind: 'denied';
|
|
72
128
|
} | {
|
|
@@ -146,11 +202,25 @@ export declare function resolveToOneAccessVisibility(items: readonly unknown[],
|
|
|
146
202
|
* caller can observe that an inaccessible related row exists (an `every`
|
|
147
203
|
* that "should" pass instead fails), but never that row's field values,
|
|
148
204
|
* which is the property this ticket exists to close.
|
|
205
|
+
*
|
|
206
|
+
* A quantifier's value of literal `null` (`is: null`/`isNot: null`, a to-one
|
|
207
|
+
* relation's existence check) is passed through untouched rather than folded:
|
|
208
|
+
* it names no fields to read-check or scope, and AND-folding an access filter
|
|
209
|
+
* into it would silently invert the caller's own predicate (see the inline
|
|
210
|
+
* comment at that branch).
|
|
211
|
+
*
|
|
212
|
+
* `resolveSyntheticRelation` (#1092/#1108) extends this to a key that
|
|
213
|
+
* resolves to a synthetic back-relation (#1082) rather than a declared
|
|
214
|
+
* field, recursing against its SOURCE list. Only `buildAccessScopedInclude`
|
|
215
|
+
* passes it, for the include-nested `where` position; the top-level `where`
|
|
216
|
+
* this function was originally built for (`context/index.ts`) omits it, so
|
|
217
|
+
* a synthetic key there is unaffected — matching #1092's own scope, which
|
|
218
|
+
* deliberately left the top-level checks unchanged.
|
|
149
219
|
*/
|
|
150
220
|
export declare function buildAccessScopedWhere(where: unknown, listConfig: ListConfig<any>, listName: string, config: OpenSaasConfig, args: {
|
|
151
221
|
session: Session | null;
|
|
152
222
|
context: AccessContext;
|
|
153
|
-
}): Promise<unknown>;
|
|
223
|
+
}, resolveSyntheticRelation?: ResolveSyntheticRelation): Promise<unknown>;
|
|
154
224
|
/**
|
|
155
225
|
* Remove keys that correspond to `virtual` fields from a Prisma `include`
|
|
156
226
|
* object, recursing into nested relationship includes using the related
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"access-filter.d.ts","sourceRoot":"","sources":["../../src/access/access-filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"access-filter.d.ts","sourceRoot":"","sources":["../../src/access/access-filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAcjF,OAAO,EAOL,KAAK,wBAAwB,EAE9B,MAAM,uBAAuB,CAAA;AAkK9B;;;;;;;;GAQG;AACH,MAAM,MAAM,sBAAsB,GAChC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,eAAe,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,YAAY,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAA;AAE7F;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,8DAA8D;IAC9D,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAA;IAC/C,kIAAkI;IAClI,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAA;CAC9C,CAAA;AAED,wBAAgB,0BAA0B,IAAI,qBAAqB,CAElE;AAMD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAErE;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,iDAAiD;IACjD,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACjB,0IAA0I;IAC1I,MAAM,EAAE,MAA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