{"_id":"@open-policy-agent/ucast-prisma","name":"@open-policy-agent/ucast-prisma","dist-tags":{"latest":"0.1.6"},"versions":{"0.1.6":{"name":"@open-policy-agent/ucast-prisma","version":"0.1.6","repository":{"type":"git","url":"git+https://github.com/open-policy-agent/opa-typescript.git","directory":"packages/ucast-prisma"},"description":"Interpreter for using ucast conditions with Prisma.","scripts":{"clean":"rm -rf ./dist/*","build":"tshy","prepublishOnly":"npm run build","attw":"attw --pack","test":"vitest","docs":"typedoc --out docs"},"author":{"name":"The OPA Authors"},"license":"Apache-2.0","devDependencies":{"@types/lodash.merge":"^4.6.9","tshy":"^3.0.2","typescript":"^5.8.3","typescript-eslint":"^8.21.0","vitest":"^3.1.1"},"dependencies":{"@ucast/core":"^1.10.1","lodash.merge":"^4.6.2"},"publishConfig":{"access":"public"},"keywords":["OPA","Open Policy Agent","authorization","policy","permissions","rbac","role based access control","data filtering"],"type":"module","tshy":{"exports":{"./package.json":"./package.json",".":"./src/index.ts"}},"exports":{"./package.json":"./package.json",".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}}},"main":"./dist/commonjs/index.js","types":"./dist/commonjs/index.d.ts","module":"./dist/esm/index.js","_id":"@open-policy-agent/ucast-prisma@0.1.6","gitHead":"9a9228391fcb5dbec085e06cdd6f68daf4ee3ba3","bugs":{"url":"https://github.com/open-policy-agent/opa-typescript/issues"},"homepage":"https://github.com/open-policy-agent/opa-typescript#readme","_nodeVersion":"22.18.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-4bnz9aZzQQyfoo6OrXCWA8IH6Kp6pB34e4A2vGv2B0S/dbfFVN8TzmUn+WTJg7Eyr/NiF2EPFShiFgBwbUhhrA==","shasum":"7245712bcd04373919c53586bbd55bb08b528975","tarball":"https://registry.npmjs.org/@open-policy-agent/ucast-prisma/-/ucast-prisma-0.1.6.tgz","fileCount":58,"unpackedSize":71914,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDQuxdMRS8wPuvehips0K9M+Ir3u3Fdog8fi0/cVohtxAIgZP0SrsZ/TKcqLshaLLPGFIvhXpb2V01IiPanhqAmQQE="}]},"_npmUser":{"name":"styrainc","email":"npm@styra.com"},"directories":{},"maintainers":[{"name":"patrick-styra","email":"patrick@styra.com"},{"name":"styrainc","email":"npm@styra.com"},{"name":"srenatus","email":"stephan@styra.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ucast-prisma_0.1.6_1756799743209_0.6201202830981887"},"_hasShrinkwrap":false}},"time":{"created":"2025-09-02T07:55:43.071Z","0.1.6":"2025-09-02T07:55:43.415Z","modified":"2025-09-02T07:55:43.829Z"},"maintainers":[{"name":"patrick-styra","email":"patrick@styra.com"},{"name":"styrainc","email":"npm@styra.com"},{"name":"srenatus","email":"stephan@styra.com"}],"description":"Interpreter for using ucast conditions with Prisma.","homepage":"https://github.com/open-policy-agent/opa-typescript#readme","keywords":["OPA","Open Policy Agent","authorization","policy","permissions","rbac","role based access control","data filtering"],"repository":{"type":"git","url":"git+https://github.com/open-policy-agent/opa-typescript.git","directory":"packages/ucast-prisma"},"author":{"name":"The OPA Authors"},"bugs":{"url":"https://github.com/open-policy-agent/opa-typescript/issues"},"license":"Apache-2.0","readme":"# @open-policy-agent/ucast-prisma\n\n[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![NPM Version](https://img.shields.io/npm/v/%40open-policy-agent%2Fucast-prisma?style=flat&color=%2324b6e0)](https://www.npmjs.com/package/@open-policy-agent/ucast-prisma)\n\nThis package contains helpers for using UCAST conditions with Prisma queries.\n\n\n## Usage\n\nThis package can be used to add filtering to Prisma queries from UCAST conditions.\nThe conditions returned by the [EOPA](https://github.com/open-policy-agent/eopa) Compile API look like this:\n\n```json\n{\n  \"conditions\": {\n    \"or\": [\n      { \"tickets.resolved\": false },\n      { \"users.name\": \"ceasar\" }\n    ]\n  }\n}\n```\n\nA call to `ucastToPrisma(conditions, \"tickets\")` turns it into this\nPrisma query:\n\n```json\n{\n  \"OR\": [\n    {\n      \"resolved\": {\n        \"equals\": false\n      }\n    },\n    {\n      \"users\": {\n        \"name\": {\n          \"equals\": \"ceasar\"\n        }\n      }\n    }\n  ]\n}\n```\n\nA similar translation for _masking rules_ is provided through the `mask` helper:\nE.g. the mask rules returned from the Compile API,\n\n```json\n{\n  \"tickets.assignee\": {\n    \"replace\": {\n      \"value\": \"***\"\n    }\n  },\n  \"users.name\": {\n    \"replace\": {\n      \"value\": \"<username>\"\n    }\n  }\n}\n```\n\ncan be applied to a Prisma-returned object like\n\n```json\n{\n  \"id\": 200,\n  \"assignee\": \"bob\",\n  \"users\": {\n    \"id\": 10,\n    \"name\": \"bobby\"\n  }\n}\n```\n\nvia `mask(maskRules, obj, \"tickets\")`, masking the appropriate fields.\n\n\n## Community\n\nFor questions, discussions and announcements related to this project, please join Slack!\n","readmeFilename":"README.md","_rev":"1-64dcfb0320b86e8b7d5afacd715e40cf"}