@casl/prisma
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});var e=require("@casl/ability");var r=require("./runtime");const t=r.createAbilityFactory();const s=r.createAccessibleByFactory();class PrismaAbility extends e.PureAbility{constructor(t,s){super(t,Object.assign({conditionsMatcher:r.prismaQuery,fieldMatcher:e.fieldPatternMatcher},s))}}Object.defineProperty(exports,"ParsingQueryError",{enumerable:true,get:function(){return r.ParsingQueryError}});Object.defineProperty(exports,"prismaQuery",{enumerable:true,get:function(){return r.prismaQuery}});exports.PrismaAbility=PrismaAbility;exports.accessibleBy=s;exports.createPrismaAbility=t; | ||
"use strict";var r=require("@casl/ability");var e=require("./runtime");const t=e.createAbilityFactory();const s=e.createAccessibleByFactory();class PrismaAbility extends r.PureAbility{constructor(t,s){super(t,Object.assign({conditionsMatcher:e.prismaQuery,fieldMatcher:r.fieldPatternMatcher},s))}}Object.defineProperty(exports,"ParsingQueryError",{enumerable:true,get:function(){return e.ParsingQueryError}});Object.defineProperty(exports,"prismaQuery",{enumerable:true,get:function(){return e.prismaQuery}});exports.PrismaAbility=PrismaAbility;exports.accessibleBy=s;exports.createPrismaAbility=t; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});var t=require("@ucast/core");var e=require("@ucast/js");var r=require("@casl/ability/extra");var n=require("@casl/ability");class o extends Error{static invalidArgument(t,e,r){const n=`${typeof e}(${JSON.stringify(e,null,2)})`;return new this(`"${t}" expects to receive ${r} but instead got "${n}"`)}}const s=t=>t&&(t.constructor===Object||!t.constructor);const a={type:"field",validate(t,e){if(Array.isArray(e)||s(e))throw new o(`"${t.name}" does not supports comparison of arrays and objects`)}};const i={type:"field",parse(e,r,{hasOperators:n,field:a,parse:i}){if(s(r)&&!n(r)||Array.isArray(r))throw new o(`"${e.name}" does not supports comparison of arrays and objects`);if(!s(r))return new t.FieldCondition("notEquals",a,r);return new t.CompoundCondition("NOT",[i(r,{field:a})])}};const c={type:"field",validate(t,e){if(!Array.isArray(e))throw o.invalidArgument(t.name,e,"an array")}};const u={type:"field",validate(t,e){const r=typeof e;const n="string"===r||"number"===r&&Number.isFinite(e)||e instanceof Date;if(!n)throw o.invalidArgument(t.name,e,"comparable value")}};const l=new Set(["insensitive","default"]);const p={type:"field",validate(t,e){if(!l.has(e))throw o.invalidArgument(t.name,e,`one of ${Array.from(l).join(", ")}`)},parse:()=>t.NULL_CONDITION};const y={type:"field",validate(t,e){if("string"!==typeof e)throw o.invalidArgument(t.name,e,"string")},parse(e,r,{query:n,field:o}){const s="insensitive"===n.mode?`i${e.name}`:e.name;return new t.FieldCondition(s,o,r)}};const f={type:"compound",validate(t,e){if(!e||"object"!==typeof e)throw o.invalidArgument(t.name,e,"an array or object")},parse(e,r,{parse:n}){const o=Array.isArray(r)?r:[r];const s=o.map((t=>n(t)));return new t.CompoundCondition(e.name,s)}};const d={type:"field",validate(t,e){if("boolean"!==typeof e)throw o.invalidArgument(t.name,e,"a boolean")}};const h={type:"field"};const w={type:"field",validate(t,e){if(!Array.isArray(e))throw o.invalidArgument(t.name,e,"an array")}};const b={type:"field",parse(e,r,{field:n,parse:a}){if(!s(r))throw o.invalidArgument(e.name,r,"a query for nested relation");return new t.FieldCondition(e.name,n,a(r))}};const g=(e,r)=>{const n=r.parse;if(!n)return Object.assign({},r,{parse(r,n,o){return new t.CompoundCondition("NOT",[new t.FieldCondition(e,o.field,n)])}});return Object.assign({},r,{parse(r,o,s){const a=n(r,o,s);if(a.operator!==r.name)throw new Error(`Cannot invert "${e}" operator parser because it returns a complex Condition`);a.operator=e;return new t.CompoundCondition("NOT",[a])}})};const v={equals:a,not:i,in:c,notIn:g("in",c),lt:u,lte:u,gt:u,gte:u,mode:p,startsWith:y,endsWith:y,contains:y,isEmpty:d,has:h,hasSome:w,hasEvery:w,NOT:f,AND:f,OR:f,every:b,some:b,none:g("some",b),is:b,isNot:g("is",b)};class A extends t.ObjectQueryParser{constructor(){super(v,{defaultOperatorName:"equals"})}parse(e,r){if(r&&r.field)return t.buildAnd(this.parseFieldOperators(r.field,e));return super.parse(e)}}const m=(t,e,{get:r})=>r(e,t.field).startsWith(t.value);const O=(t,e,{get:r})=>r(e,t.field).toLowerCase().startsWith(t.value.toLowerCase());const j=(t,e,{get:r})=>r(e,t.field).endsWith(t.value);const N=(t,e,{get:r})=>r(e,t.field).toLowerCase().endsWith(t.value.toLowerCase());const $=(t,e,{get:r})=>r(e,t.field).includes(t.value);const q=(t,e,{get:r})=>r(e,t.field).toLowerCase().includes(t.value.toLowerCase());const x=(t,e,{get:r})=>{const n=r(e,t.field);const o=Array.isArray(n)&&0===n.length;return o===t.value};const E=(t,e,{get:r})=>{const n=r(e,t.field);return Array.isArray(n)&&n.includes(t.value)};const T=(t,e,{get:r})=>{const n=r(e,t.field);return Array.isArray(n)&&t.value.some((t=>n.includes(t)))};const W=(t,e,{get:r})=>{const n=r(e,t.field);return Array.isArray(n)&&t.value.every((t=>n.includes(t)))};const S=(t,e,{get:r,interpret:n})=>{const o=r(e,t.field);return Array.isArray(o)&&o.length>0&&o.every((e=>n(t.value,e)))};const _=(t,e,{get:r,interpret:n})=>{const o=r(e,t.field);return Array.isArray(o)&&o.some((e=>n(t.value,e)))};const D=(t,e,{get:r,interpret:n})=>{const o=r(e,t.field);return o&&"object"===typeof o&&n(t.value,o)};const M=(t,e,{interpret:r})=>t.value.every((t=>!r(t,e)));function C(t){return t&&"object"===typeof t?t.valueOf():t}const F=(t,r)=>e.compare(C(t),C(r));const I=e.createJsInterpreter({equals:e.eq,notEquals:e.ne,in:e.within,lt:e.lt,lte:e.lte,gt:e.gt,gte:e.gte,startsWith:m,istartsWith:O,endsWith:j,iendsWith:N,contains:$,icontains:q,isEmpty:x,has:E,hasSome:T,hasEvery:W,and:e.and,or:e.or,AND:e.and,OR:e.or,NOT:M,every:S,some:_,is:D},{get:(t,e)=>t[e],compare:F});const R=new A;const J=t.createTranslatorFactory(R.parse,I);function P(t){return t.inverted?{NOT:t.conditions}:t.conditions}const k={get(t,e){const o=r.rulesToQuery(t.t,t.o,e,P);if(null===o){const r=n.ForbiddenError.from(t.t).setMessage(`It's not allowed to run "${t.o}" on "${e}"`);r.action=t.o;r.subjectType=r.subject=e;throw r}const s=Object.create(null);if(o.$or)s.OR=o.$or;if(o.$and)s.AND=o.$and;return s}};const z=()=>function t(e,r="read"){return new Proxy({t:e,o:r},k)};function createAbilityFactory(){function createAbility(t=[],e={}){return new n.PureAbility(t,Object.assign({},e,{conditionsMatcher:J,fieldMatcher:n.fieldPatternMatcher}))}return createAbility}exports.ParsingQueryError=o;exports.createAbilityFactory=createAbilityFactory;exports.createAccessibleByFactory=z;exports.prismaQuery=J; | ||
"use strict";var t=require("@ucast/core");var e=require("@ucast/js");var r=require("@casl/ability/extra");var n=require("@casl/ability");class o extends Error{static invalidArgument(t,e,r){const n=`${typeof e}(${JSON.stringify(e,null,2)})`;return new this(`"${t}" expects to receive ${r} but instead got "${n}"`)}}const s=t=>t&&(t.constructor===Object||!t.constructor);const a={type:"field",validate(t,e){if(Array.isArray(e)||s(e))throw new o(`"${t.name}" does not supports comparison of arrays and objects`)}};const i={type:"field",parse(e,r,{hasOperators:n,field:a,parse:i}){if(s(r)&&!n(r)||Array.isArray(r))throw new o(`"${e.name}" does not supports comparison of arrays and objects`);if(!s(r))return new t.FieldCondition("notEquals",a,r);return new t.CompoundCondition("NOT",[i(r,{field:a})])}};const c={type:"field",validate(t,e){if(!Array.isArray(e))throw o.invalidArgument(t.name,e,"an array")}};const u={type:"field",validate(t,e){const r=typeof e;const n=r==="string"||r==="number"&&Number.isFinite(e)||e instanceof Date;if(!n)throw o.invalidArgument(t.name,e,"comparable value")}};const l=new Set(["insensitive","default"]);const p={type:"field",validate(t,e){if(!l.has(e))throw o.invalidArgument(t.name,e,`one of ${Array.from(l).join(", ")}`)},parse:()=>t.NULL_CONDITION};const y={type:"field",validate(t,e){if(typeof e!=="string")throw o.invalidArgument(t.name,e,"string")},parse(e,r,{query:n,field:o}){const s=n.mode==="insensitive"?`i${e.name}`:e.name;return new t.FieldCondition(s,o,r)}};const f={type:"compound",validate(t,e){if(!e||typeof e!=="object")throw o.invalidArgument(t.name,e,"an array or object")},parse(e,r,{parse:n}){const o=Array.isArray(r)?r:[r];const s=o.map((t=>n(t)));return new t.CompoundCondition(e.name,s)}};const d={type:"field",validate(t,e){if(typeof e!=="boolean")throw o.invalidArgument(t.name,e,"a boolean")}};const h={type:"field"};const w={type:"field",validate(t,e){if(!Array.isArray(e))throw o.invalidArgument(t.name,e,"an array")}};const b={type:"field",parse(e,r,{field:n,parse:a}){if(!s(r))throw o.invalidArgument(e.name,r,"a query for nested relation");return new t.FieldCondition(e.name,n,a(r))}};const g=(e,r)=>{const n=r.parse;if(!n)return Object.assign({},r,{parse(r,n,o){return new t.CompoundCondition("NOT",[new t.FieldCondition(e,o.field,n)])}});return Object.assign({},r,{parse(r,o,s){const a=n(r,o,s);if(a.operator!==r.name)throw new Error(`Cannot invert "${e}" operator parser because it returns a complex Condition`);a.operator=e;return new t.CompoundCondition("NOT",[a])}})};const v={equals:a,not:i,in:c,notIn:g("in",c),lt:u,lte:u,gt:u,gte:u,mode:p,startsWith:y,endsWith:y,contains:y,isEmpty:d,has:h,hasSome:w,hasEvery:w,NOT:f,AND:f,OR:f,every:b,some:b,none:g("some",b),is:b,isNot:g("is",b)};class A extends t.ObjectQueryParser{constructor(){super(v,{defaultOperatorName:"equals"})}parse(e,r){if(r&&r.field)return t.buildAnd(this.parseFieldOperators(r.field,e));return super.parse(e)}}const m=(t,e,{get:r})=>r(e,t.field).startsWith(t.value);const O=(t,e,{get:r})=>r(e,t.field).toLowerCase().startsWith(t.value.toLowerCase());const j=(t,e,{get:r})=>r(e,t.field).endsWith(t.value);const N=(t,e,{get:r})=>r(e,t.field).toLowerCase().endsWith(t.value.toLowerCase());const $=(t,e,{get:r})=>r(e,t.field).includes(t.value);const q=(t,e,{get:r})=>r(e,t.field).toLowerCase().includes(t.value.toLowerCase());const x=(t,e,{get:r})=>{const n=r(e,t.field);const o=Array.isArray(n)&&n.length===0;return o===t.value};const E=(t,e,{get:r})=>{const n=r(e,t.field);return Array.isArray(n)&&n.includes(t.value)};const T=(t,e,{get:r})=>{const n=r(e,t.field);return Array.isArray(n)&&t.value.some((t=>n.includes(t)))};const W=(t,e,{get:r})=>{const n=r(e,t.field);return Array.isArray(n)&&t.value.every((t=>n.includes(t)))};const S=(t,e,{get:r,interpret:n})=>{const o=r(e,t.field);return Array.isArray(o)&&o.length>0&&o.every((e=>n(t.value,e)))};const D=(t,e,{get:r,interpret:n})=>{const o=r(e,t.field);return Array.isArray(o)&&o.some((e=>n(t.value,e)))};const C=(t,e,{get:r,interpret:n})=>{const o=r(e,t.field);return o&&typeof o==="object"&&n(t.value,o)};const F=(t,e,{interpret:r})=>t.value.every((t=>!r(t,e)));function I(t){return t&&typeof t==="object"?t.valueOf():t}const M=(t,r)=>e.compare(I(t),I(r));const R=e.createJsInterpreter({equals:e.eq,notEquals:e.ne,in:e.within,lt:e.lt,lte:e.lte,gt:e.gt,gte:e.gte,startsWith:m,istartsWith:O,endsWith:j,iendsWith:N,contains:$,icontains:q,isEmpty:x,has:E,hasSome:T,hasEvery:W,and:e.and,or:e.or,AND:e.and,OR:e.or,NOT:F,every:S,some:D,is:C},{get:(t,e)=>t[e],compare:M});const _=new A;const J=t.createTranslatorFactory(_.parse,R);function P(t){return t.inverted?{NOT:t.conditions}:t.conditions}const k={get(t,e){const o=r.rulesToQuery(t.t,t.o,e,P);if(o===null){const r=n.ForbiddenError.from(t.t).setMessage(`It's not allowed to run "${t.o}" on "${e}"`);r.action=t.o;r.subjectType=r.subject=e;throw r}const s=Object.create(null);if(o.$or)s.OR=o.$or;if(o.$and)s.AND=o.$and;return s}};const z=()=>function t(e,r="read"){return new Proxy({t:e,o:r},k)};function createAbilityFactory(){function createAbility(t=[],e={}){return new n.PureAbility(t,Object.assign({},e,{conditionsMatcher:J,fieldMatcher:n.fieldPatternMatcher}))}return createAbility}exports.ParsingQueryError=o;exports.createAbilityFactory=createAbilityFactory;exports.createAccessibleByFactory=z;exports.prismaQuery=J; | ||
//# sourceMappingURL=runtime.js.map |
import { AbilityOptions, AbilityOptionsOf, AbilityTuple, PureAbility, RawRuleFrom, RawRuleOf } from '@casl/ability'; | ||
export declare function createAbilityFactory<TModelName extends string, TPrismaQuery extends Record<string, any>>(): { | ||
<T extends PureAbility<any, TPrismaQuery>>(rules?: (import("@casl/ability/dist/types/types").ToAbilityTypes<T[typeof import("@casl/ability/dist/types/RuleIndex").ɵabilities]> extends infer T_1 ? T_1 extends import("@casl/ability/dist/types/types").ToAbilityTypes<T[typeof import("@casl/ability/dist/types/RuleIndex").ɵabilities]> ? T_1 extends import("@casl/ability/dist/types/types").AbilityTupleType<string, import("@casl/ability").SubjectType> ? import("@casl/ability").SubjectRawRule<T_1[0], T_1[1], T[typeof import("@casl/ability/dist/types/RuleIndex").ɵconditions]> : import("@casl/ability").ClaimRawRule<Extract<import("@casl/ability/dist/types/types").ToAbilityTypes<T[typeof import("@casl/ability/dist/types/RuleIndex").ɵabilities]>, string>> : never : never)[] | undefined, options?: AbilityOptionsOf<T> | undefined): T; | ||
<A extends AbilityTuple<string, import("@casl/ability").Subject> = [string, TModelName], C extends TPrismaQuery = TPrismaQuery>(rules?: (import("@casl/ability/dist/types/types").ToAbilityTypes<A> extends infer T_2 ? T_2 extends import("@casl/ability/dist/types/types").ToAbilityTypes<A> ? T_2 extends import("@casl/ability/dist/types/types").AbilityTupleType<string, import("@casl/ability").SubjectType> ? import("@casl/ability").SubjectRawRule<T_2[0], T_2[1], C> : import("@casl/ability").ClaimRawRule<Extract<import("@casl/ability/dist/types/types").ToAbilityTypes<A>, string>> : never : never)[] | undefined, options?: AbilityOptions<A, C> | undefined): PureAbility<A, C>; | ||
<T extends PureAbility<any, TPrismaQuery>>(rules?: RawRuleOf<T>[] | undefined, options?: AbilityOptionsOf<T> | undefined): T; | ||
<A extends AbilityTuple = [string, TModelName], C extends TPrismaQuery = TPrismaQuery>(rules?: RawRuleFrom<A, C>[] | undefined, options?: AbilityOptions<A, C> | undefined): PureAbility<A, C>; | ||
}; |
import { AbilityOptions, AbilityTuple, PureAbility, RawRuleFrom } from '@casl/ability'; | ||
import { WhereInputPerModel, ModelName, PrismaQuery } from './prismaClientBoundTypes'; | ||
import type { WhereInputPerModel, ModelName, PrismaQuery } from './prismaClientBoundTypes'; | ||
export type { PrismaQuery, WhereInput } from './prismaClientBoundTypes'; | ||
@@ -7,6 +7,6 @@ export type { Model, Subjects } from './runtime'; | ||
declare const createPrismaAbility: { | ||
<T extends PureAbility<any, PrismaQuery<Record<string, any> & import("@casl/ability").ForcedSubject<string>>>>(rules?: (import("@casl/ability/dist/types/types").ToAbilityTypes<T[typeof import("@casl/ability/dist/types/RuleIndex").ɵabilities]> extends infer T_1 ? T_1 extends import("@casl/ability/dist/types/types").ToAbilityTypes<T[typeof import("@casl/ability/dist/types/RuleIndex").ɵabilities]> ? T_1 extends import("@casl/ability/dist/types/types").AbilityTupleType<string, import("@casl/ability").SubjectType> ? import("@casl/ability").SubjectRawRule<T_1[0], T_1[1], T[typeof import("@casl/ability/dist/types/RuleIndex").ɵconditions]> : import("@casl/ability").ClaimRawRule<Extract<import("@casl/ability/dist/types/types").ToAbilityTypes<T[typeof import("@casl/ability/dist/types/RuleIndex").ɵabilities]>, string>> : never : never)[] | undefined, options?: import("@casl/ability").AbilityOptionsOf<T> | undefined): T; | ||
<A extends AbilityTuple<string, import("@casl/ability").Subject> = [string, import("@prisma/client").Prisma.ModelName], C extends PrismaQuery<Record<string, any> & import("@casl/ability").ForcedSubject<string>> = PrismaQuery<Record<string, any> & import("@casl/ability").ForcedSubject<string>>>(rules?: (import("@casl/ability/dist/types/types").ToAbilityTypes<A> extends infer T_2 ? T_2 extends import("@casl/ability/dist/types/types").ToAbilityTypes<A> ? T_2 extends import("@casl/ability/dist/types/types").AbilityTupleType<string, import("@casl/ability").SubjectType> ? import("@casl/ability").SubjectRawRule<T_2[0], T_2[1], C> : import("@casl/ability").ClaimRawRule<Extract<import("@casl/ability/dist/types/types").ToAbilityTypes<A>, string>> : never : never)[] | undefined, options?: AbilityOptions<A, C> | undefined): PureAbility<A, C>; | ||
<T extends PureAbility<any, PrismaQuery>>(rules?: (import("@casl/ability/dist/types/types").ToAbilityTypes<T[typeof import("@casl/ability/dist/types/RuleIndex").ɵabilities]> extends infer T_1 ? T_1 extends import("@casl/ability/dist/types/types").ToAbilityTypes<T[typeof import("@casl/ability/dist/types/RuleIndex").ɵabilities]> ? T_1 extends import("@casl/ability/dist/types/types").AbilityTupleType ? import("@casl/ability").SubjectRawRule<T_1[0], T_1[1], T[typeof import("@casl/ability/dist/types/RuleIndex").ɵconditions]> : import("@casl/ability").ClaimRawRule<Extract<import("@casl/ability/dist/types/types").ToAbilityTypes<T[typeof import("@casl/ability/dist/types/RuleIndex").ɵabilities]>, string>> : never : never)[] | undefined, options?: import("@casl/ability").AbilityOptionsOf<T> | undefined): T; | ||
<A extends AbilityTuple = [string, import("@prisma/client").Prisma.ModelName], C extends PrismaQuery = PrismaQuery>(rules?: (import("@casl/ability/dist/types/types").ToAbilityTypes<A> extends infer T_2 ? T_2 extends import("@casl/ability/dist/types/types").ToAbilityTypes<A> ? T_2 extends import("@casl/ability/dist/types/types").AbilityTupleType ? import("@casl/ability").SubjectRawRule<T_2[0], T_2[1], C> : import("@casl/ability").ClaimRawRule<Extract<import("@casl/ability/dist/types/types").ToAbilityTypes<A>, string>> : never : never)[] | undefined, options?: AbilityOptions<A, C> | undefined): PureAbility<A, C>; | ||
}; | ||
declare const accessibleBy: (ability: PureAbility<any, PrismaQuery<Record<string, any> & import("@casl/ability").ForcedSubject<string>>>, action?: string) => WhereInputPerModel; | ||
declare const accessibleBy: (ability: PureAbility<any, PrismaQuery>, action?: string) => WhereInputPerModel; | ||
export { createPrismaAbility, accessibleBy, }; | ||
@@ -16,3 +16,3 @@ /** | ||
*/ | ||
declare type ExtendedAbilityTuple<T extends AbilityTuple> = T extends AbilityTuple ? [T[0], 'all' | T[1]] : never; | ||
type ExtendedAbilityTuple<T extends AbilityTuple> = T extends AbilityTuple ? [T[0], 'all' | T[1]] : never; | ||
/** | ||
@@ -19,0 +19,0 @@ * @deprecated use createPrismaAbility instead |
@@ -8,4 +8,4 @@ import { ForcedSubject } from '@casl/ability'; | ||
}; | ||
export declare type Model<T, TName extends string> = T & ForcedSubject<TName>; | ||
export declare type Subjects<T extends Partial<Record<string, Record<string, unknown>>>> = keyof T | { | ||
export type Model<T, TName extends string> = T & ForcedSubject<TName>; | ||
export type Subjects<T extends Partial<Record<string, Record<string, unknown>>>> = keyof T | { | ||
[K in keyof T]: Model<T[K], K & string>; | ||
@@ -16,3 +16,3 @@ }[keyof T]; | ||
*/ | ||
export declare type ExtractModelName<TObject, TModelName extends string> = TObject extends { | ||
export type ExtractModelName<TObject, TModelName extends string> = TObject extends { | ||
kind: TModelName; | ||
@@ -19,0 +19,0 @@ } ? TObject['kind'] : TObject extends ForcedSubject<TModelName> ? TObject['__caslSubjectType__'] : TObject extends { |
@@ -5,3 +5,3 @@ import { Condition, ObjectQueryParser } from '@ucast/core'; | ||
} | ||
declare type Query = Record<string, any>; | ||
type Query = Record<string, any>; | ||
export declare class PrismaQueryParser extends ObjectQueryParser<Query> { | ||
@@ -8,0 +8,0 @@ constructor(); |
import type { Prisma, PrismaClient } from '@prisma/client'; | ||
import type { hkt } from '@casl/ability'; | ||
import type { ExtractModelName, Model } from './prisma/prismaQuery'; | ||
export declare type ModelName = Prisma.ModelName; | ||
declare type ModelWhereInput = { | ||
export type ModelName = Prisma.ModelName; | ||
type ModelWhereInput = { | ||
[K in Prisma.ModelName]: Uncapitalize<K> extends keyof PrismaClient ? Extract<Parameters<PrismaClient[Uncapitalize<K>]['findFirst']>[0], { | ||
@@ -10,11 +10,11 @@ where?: any; | ||
}; | ||
export declare type WhereInput<TModelName extends Prisma.ModelName> = Extract<ModelWhereInput[TModelName], Record<any, any>>; | ||
export type WhereInput<TModelName extends Prisma.ModelName> = Extract<ModelWhereInput[TModelName], Record<any, any>>; | ||
interface PrismaQueryTypeFactory extends hkt.GenericFactory { | ||
produce: WhereInput<ExtractModelName<this[0], ModelName>>; | ||
} | ||
declare type PrismaModel = Model<Record<string, any>, string>; | ||
export declare type PrismaQuery<T = PrismaModel> = WhereInput<ExtractModelName<T, ModelName>> & hkt.Container<PrismaQueryTypeFactory>; | ||
export declare type WhereInputPerModel = { | ||
type PrismaModel = Model<Record<string, any>, string>; | ||
export type PrismaQuery<T = PrismaModel> = WhereInput<ExtractModelName<T, ModelName>> & hkt.Container<PrismaQueryTypeFactory>; | ||
export type WhereInputPerModel = { | ||
[K in ModelName]: WhereInput<K>; | ||
}; | ||
export {}; |
{ | ||
"name": "@casl/prisma", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "Allows to query accessible records using Prisma client based on CASL rules", | ||
@@ -51,3 +51,3 @@ "main": "dist/es6c/index.js", | ||
"@casl/ability": "^5.3.0 || ^6.0.0", | ||
"@prisma/client": "^2.14.0 || ^3.0.0 || ^4.0.0" | ||
"@prisma/client": "^2.14.0 || ^3.0.0 || ^4.0.0 || ^5.0.0" | ||
}, | ||
@@ -57,5 +57,5 @@ "devDependencies": { | ||
"@casl/dx": "workspace:^1.0.0", | ||
"@prisma/client": "^4.3.1", | ||
"@prisma/client": "^5.0.0", | ||
"@types/jest": "^29.0.0", | ||
"prisma": "^4.3.1" | ||
"prisma": "^5.0.0" | ||
}, | ||
@@ -62,0 +62,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
77191
144