@appxdigital/appx-core 0.1.128-beta.2 → 0.1.128-beta.3
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
|
@@ -30,6 +30,10 @@ Read-only GraphQL, reworked into a **namespaced, opt-in-per-module** API.
|
|
|
30
30
|
- **Self-documenting operations.** `find` / `get` / `count` and their `where` arg carry GraphQL descriptions (visible in the Apollo Sandbox); model-field descriptions come from Prisma `///` doc comments as before. See [docs/graphql.md](./docs/graphql.md) for the full `where`/`orderBy`/pagination reference.
|
|
31
31
|
- **Malformed filter values return `400`, not `500`.** A `where`/`orderBy` value Prisma can't parse (e.g. `createdAt: { gt: 2024 }` — a number where a date is expected) now surfaces a clean `400`, instead of an internal error that leaked the raw Prisma invocation.
|
|
32
32
|
|
|
33
|
+
### Fixed
|
|
34
|
+
|
|
35
|
+
- **Compound-name models now work over GraphQL.** `getModelDelegate` lowercased the whole model name (`AlbumMember` → `albummember`) instead of just the first character, so it missed Prisma's camelCase delegate key (`albumMember`) and every `find`/`get`/`count` on a model with an internal capital threw `Model <X> not found in PrismaClient.`. Single-word models (`Album`) worked only by coincidence. It now lowercases only the first character, matching Prisma's delegate naming (and the resolver's own root-name rule). REST was never affected. Regression covered by a compound-name model (`ProjectMember`) in `test/http/graphql-abac.spec.ts`.
|
|
36
|
+
|
|
33
37
|
### Changed / Removed
|
|
34
38
|
|
|
35
39
|
- The old root-level `findAll<Model>s` / `findOne<Model>` / `findFirst<Model>` queries and the `GenericResolverFactory` export are **removed**, replaced by the generated per-model `<Model>Resolver` (built on the exported `CoreGraphqlResolver`).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prisma.service.d.ts","sourceRoot":"","sources":["../../src/prisma/prisma.service.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,MAAM,EAAE,YAAY,EAAC,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAC,qBAAqB,EAAkB,MA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W,oBAAoB;IA6ClC;;;;OAIG;IACH,OAAO,CAAC,SAAS;IAKjB;;;;;;OAMG;YACW,2BAA2B;IAqBzC;;;;;;OAMG;IACH,OAAO,CAAC,yBAAyB;IAmBjC;;;;;;;OAOG;YACW,uBAAuB;IA8BrC,oGAAoG;IACpG,OAAO,CAAC,mBAAmB;IAwB3B;;;;;;;OAOG;WACW,gBAAgB,CAAC,UAAU,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,GAAG,GAAG;IAgBjE;;;;;;;OAOG;IACH,OAAO,CAAC,MAAM,CAAC,mBAAmB;IA2BlC;;;;;;;OAOG;IACH,OAAO,CAAC,eAAe;IAUvB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,iBAAiB;IA8EzB,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,IAAI,GAAG;QAC5E,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,UAAU,EAAE,OAAO,CAAA;KACtB;IAoBD,gBAAgB,CAAC,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAyBzF"}
|
|
@@ -180,7 +180,15 @@ let PrismaService = exports.PrismaService = PrismaService_1 = class PrismaServic
|
|
|
180
180
|
* @param model
|
|
181
181
|
*/
|
|
182
182
|
getModelDelegate(model) {
|
|
183
|
-
|
|
183
|
+
// Prisma exposes delegates in camelCase (`client.albumMember`), lowercasing
|
|
184
|
+
// only the FIRST character of the model name. Callers pass the PascalCase
|
|
185
|
+
// class name (`model.name`), so lowercase just the first char — NOT the
|
|
186
|
+
// whole string, which would flatten any internal capital (`AlbumMember` →
|
|
187
|
+
// `albummember`) and miss the delegate. (The framework's own model-name
|
|
188
|
+
// namespace is deliberately whole-lowercase for case-insensitivity, but
|
|
189
|
+
// that is a separate lookup; this one indexes the real Prisma client.)
|
|
190
|
+
const name = model;
|
|
191
|
+
const modelName = name.charAt(0).toLowerCase() + name.slice(1);
|
|
184
192
|
const client = this.prismaClient;
|
|
185
193
|
if (modelName in client) {
|
|
186
194
|
return client[modelName];
|
package/docs/graphql.md
CHANGED
|
@@ -141,7 +141,7 @@ The **generated GraphQL input type is the authoritative allowlist** — an opera
|
|
|
141
141
|
|
|
142
142
|
Two framework rules on top of that:
|
|
143
143
|
|
|
144
|
-
- **You can only filter/sort by fields your role can read.** A `where`/`orderBy` on a `@Role`-hidden column is rejected with `403
|
|
144
|
+
- **You can only filter/sort by fields your role can read.** A `where`/`orderBy` on a `@Role`-hidden column is rejected with `403`. The **only** exception is a **bare-null presence check** — `{ field: null }`, `{ field: { equals: null } }`, `{ field: { not: null } }`, or `{ NOT: { field: null } }` — which reveals only whether a value is set. **Any value-bearing predicate on a hidden field still `403`s**, including `{ field: { not: "x" } }` and `{ field: { equals: "x" } }` — anything that compares against a real value. `orderBy` and `distinct` on a hidden field are always rejected (no presence exception).
|
|
145
145
|
- **A malformed value returns a clean `400`.** `createdAt: { gt: 2024 }` (a number where a date is expected) is a `400`, never a `500` or a leaked Prisma error.
|
|
146
146
|
|
|
147
147
|
---
|
|
@@ -153,7 +153,7 @@ All three operations route through `PrismaService.getModelDelegate`, so the rule
|
|
|
153
153
|
- **Unauthorized rows are not returned.** `find` returns only rows the role may read; `get` returns `null` for a row the caller can't access even if asked for by unique field; `count` counts only accessible rows.
|
|
154
154
|
- **Restricted fields are omitted.** A column the role can't read (`/// @Role(...)`) comes back **`null`** even though the GraphQL type exposes it — at the top level *and* nested. (`prisma-nestjs-graphql` types every scalar; the proxy is what strips the values.)
|
|
155
155
|
- **Inaccessible nested records are filtered.** If a nested relation points at a record the caller can't read, that relation is filtered out — a to-many yields only the visible rows; an inaccessible to-one drops the parent row. You can hold access to a record while a record it links to is withheld.
|
|
156
|
-
- **You can only filter/sort by fields you can read.** A `where` / `orderBy` / `distinct` that references a field the role can't read (`@Role`) is rejected with `403` — top level or nested
|
|
156
|
+
- **You can only filter/sort by fields you can read.** A `where` / `orderBy` / `distinct` that references a field the role can't read (`@Role`) is rejected with `403` — top level or nested. The **only** exception is a **bare-null presence check** in `where` (`{ field: null }` / `{ field: { equals: null } }` / `{ field: { not: null } }` / `{ NOT: { field: null } }`) — it reveals only whether a value is set, so `hasX` / `isDeleted` work without a bypass. A **value-bearing** predicate still `403`s (even `{ field: { not: "x" } }`), and `orderBy`/`distinct` on a hidden field have no presence exception.
|
|
157
157
|
- **Anonymous callers are `GUEST`.** With no valid `Authorization: Bearer <jwt>` (or session), the request is a GUEST; a model with no GUEST rule is denied.
|
|
158
158
|
|
|
159
159
|
> Because relation records and fields are filtered by ABAC, "empty / null" means "not visible to you", not "does not exist". Design queries and UI accordingly.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appxdigital/appx-core",
|
|
3
|
-
"version": "0.1.128-beta.
|
|
3
|
+
"version": "0.1.128-beta.3",
|
|
4
4
|
"description": "Appx Core is a library that provides a set of tools to help you build your application faster.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|