@rowstile/prisma 0.1.0-alpha.4 → 0.1.0-alpha.5
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/dist/index.js +9 -2
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
* in with authz.act_as() as whoever the code acts for (actingAs, a job), else user(), else nobody; a query
|
|
9
9
|
* outside a transaction runs in one of its own. `authz()` turns the answers into errors: an update or delete
|
|
10
10
|
* of a row the user can't see is NotFound (Prisma's P2025), of one they may not change Refused with the
|
|
11
|
-
* reason, a refused create Refused naming the rule
|
|
11
|
+
* reason, a refused create Refused naming the rule, a findUniqueOrThrow or findFirstOrThrow that finds no row
|
|
12
|
+
* NotFound; and adds db.$authz (can, ids, permsOf, ...). It refuses
|
|
12
13
|
* array transactions, $transaction([...]): Prisma starts them from another caller's context.
|
|
13
14
|
*
|
|
14
15
|
* Use the client `$extends(authz())` returns, and only that one: the client it was made from is refused
|
|
@@ -19,7 +20,7 @@
|
|
|
19
20
|
*/
|
|
20
21
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
21
22
|
import { Prisma } from "@prisma/client/extension";
|
|
22
|
-
import { actAs, calls, idText, signingIn, translate, verdict, } from "@rowstile/client";
|
|
23
|
+
import { actAs, calls, idText, NotFound, signingIn, translate, verdict, } from "@rowstile/client";
|
|
23
24
|
const ARG_TEXT = { scalarType: "string", dbType: undefined, arity: "scalar" };
|
|
24
25
|
// Unless the adapter says otherwise (usePhantomQuery), Prisma sends COMMIT and ROLLBACK itself, and the
|
|
25
26
|
// adapter's commit() and rollback() only give the connection back: so these send them too
|
|
@@ -211,6 +212,12 @@ export function authz(options = {}) {
|
|
|
211
212
|
}
|
|
212
213
|
}
|
|
213
214
|
}
|
|
215
|
+
// a read that must find a row and found none: the row isn't there, or this user can't see it (the
|
|
216
|
+
// two answer alike). Left as Prisma's P2025 it is a 500, where an update or a delete is a 404
|
|
217
|
+
if (model && isP2025(e) && (operation === "findUniqueOrThrow" || operation === "findFirstOrThrow")) {
|
|
218
|
+
const key = keyOf(model, args.where);
|
|
219
|
+
throw new NotFound(tableOf(model), key === undefined ? undefined : idText(key), { cause: e });
|
|
220
|
+
}
|
|
214
221
|
throw translate(e, schemaOf) ?? e;
|
|
215
222
|
}
|
|
216
223
|
},
|
package/package.json
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rowstile/prisma",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.5",
|
|
4
4
|
"description": "rowstile with Prisma: a client extension that signs every query in, and turns refusals into errors",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
+
"homepage": "https://rowstile.dev",
|
|
7
|
+
"keywords": ["rowstile", "postgres", "postgresql", "authorization", "row-level-security", "rls", "permissions", "access-control", "rbac", "rebac", "multi-tenant", "prisma"],
|
|
6
8
|
"repository": { "type": "git", "url": "git+https://github.com/rowstile/rowstile.git", "directory": "sdk/typescript/prisma" },
|
|
7
9
|
"type": "module",
|
|
8
10
|
"main": "./dist/index.js",
|
|
@@ -10,6 +12,6 @@
|
|
|
10
12
|
"exports": { ".": { "types": "./dist/index.d.ts", "default": "./dist/index.js" } },
|
|
11
13
|
"files": ["dist"],
|
|
12
14
|
"sideEffects": false,
|
|
13
|
-
"dependencies": { "@rowstile/client": "0.1.0-alpha.
|
|
15
|
+
"dependencies": { "@rowstile/client": "0.1.0-alpha.5" },
|
|
14
16
|
"peerDependencies": { "@prisma/client": ">=7" }
|
|
15
17
|
}
|