芝麻web文件管理V1.00
编辑当前文件:/home/freeclou/app.optimyar.com/backend/node_modules/@casl/ability/dist/es6c/index.js
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@ucast/mongo2js");function s(t){return Array.isArray(t)?t:[t]}const e="__caslSubjectType__";function i(t){if(!t)return"all";if("string"==typeof t)return t;if(t.hasOwnProperty(e))return t[e];const s="function"==typeof t?t:t.constructor;return s.modelName||s.name}const r=t=>t;function n(t,s,e){for(let i=e;i
({rules:[],merged:!1}),l=()=>new Map,f=()=>({emits:!1,last:null,destroy:null});class d extends class{constructor(t=[],s={}){this.o=!1,this.h=new Map,this.u={conditionsMatcher:s.conditionsMatcher,fieldMatcher:s.fieldMatcher,resolveAction:s.resolveAction||r},this.detectSubjectType=s.detectSubjectType||i,this.l=t,this.p=this.g(t)}get rules(){return this.l}update(t){const s={rules:t,ability:this,target:this};return this.$("update",s),this.l=t,this.p=this.g(t),this.$("updated",s),this}g(t){const e=new Map;for(let i=t.length-1;i>=0;i--){const r=t.length-i-1,n=new c(t[i],this.u,r),o=s(n.action),u=s(n.subject);this.m(n);for(let t=0;t
t.matchesField(e)):i}on(t,s){const e=h(this.h,t,f),i=new u(s,e.last);e.last=i;const r=()=>{if(e.emits)return e.destroy=e.destroy||[],void e.destroy.push(r);i.next||i.prev||e.last!==i?i.destroy():e.last=null};return r}$(t,s){const e=this.h.get(t);if(e)try{e.emits=!0;let t=e.last;for(;null!==t;)t.value(s),t=t.prev}finally{e.emits=!1,e.destroy&&e.destroy.forEach(t=>t())}}}{can(...t){const s=this.relevantRuleFor(...t);return!!s&&!s.inverted}relevantRuleFor(...t){const s=this.rulesFor(...t),e=t[1];for(let t=0;t
{let s;return e=>(void 0===s&&(s=-1===t.join("").indexOf("*")?null:function(t){const s=t.map(t=>t.replace(w,v).replace(b,m)),e=s.length>1?`(?:${s.join("|")})`:s[0];return new RegExp(`^${e}$`)}(t)),null===s||-1!==e.indexOf("*")?-1!==t.indexOf(e):s.test(e))};class E extends d{constructor(t,s){super(t,Object.assign({conditionsMatcher:y,fieldMatcher:M},s))}}class j{constructor(t){this.v=t}because(t){return this.v.reason=t,this}}class _{constructor(t){this.rules=[],this.M=t;this.can=this.can.bind(this),this.cannot=this.cannot.bind(this),this.build=this.build.bind(this)}can(t,s,e,i){const r={action:t};return s&&(r.subject=s,Array.isArray(e)||"string"==typeof e?r.fields=e:void 0!==e&&(r.conditions=e),void 0!==i&&(r.conditions=i)),this.rules.push(r),new j(r)}cannot(t,s,e,i){const r=this.can(t,s,e,i);return r.v.inverted=!0,r}build(t){return new this.M(this.rules,t)}}const F=t=>`Cannot execute "${t.action}" on "${t.subjectType}"`,O=function(t){this.message=t};O.prototype=Object.create(Error.prototype);class A extends O{static setDefaultMessage(t){this.j="string"==typeof t?()=>t:t}static from(t){return new this(t)}constructor(t){super(""),this.field=void 0,this.ability=t,"function"==typeof Error.captureStackTrace&&(this.name="ForbiddenError",Error.captureStackTrace(this,this.constructor))}setMessage(t){return this.message=t,this}throwUnlessCan(...t){const s=this.ability.relevantRuleFor(...t);if(s&&!s.inverted)return;this.action=t[0],this.subject=t[1],this.subjectType=this.ability.detectSubjectType(t[1]),this.field=t[2];const e=s?s.reason:"";throw this.message=this.message||e||this.constructor.j(this),this}}A.j=F,exports.Ability=E,exports.AbilityBuilder=_,exports.ForbiddenError=A,exports.PureAbility=d,exports.buildMongoQueryMatcher=(s,e,i)=>t.createFactory(Object.assign({},p,s),Object.assign({},g,e),i),exports.createAliasResolver=function(t){return"production"!==process.env.NODE_ENV&&function(t){if(t.manage)throw new Error('Cannot add alias for "manage" action because it is reserved');Object.keys(t).forEach(s=>{if(s===t[s]||Array.isArray(t[s])&&(-1!==t[s].indexOf(s)||-1!==t[s].indexOf("manage")))throw new Error(`Attempt to alias action to itself: ${s} -> ${t[s]}`)})}(t),e=>function(t,e){let i=s(e),r=0;for(;r
e.build(s)):e.build(s)},exports.detectSubjectType=i,exports.fieldPatternMatcher=M,exports.getDefaultErrorMessage=F,exports.mongoQueryMatcher=y,exports.subject=function(t,s){if(s)if(s.hasOwnProperty(e)){if(t!==s[e])throw new Error(`Trying to cast object to subject type ${t} but previously it was casted to ${s[e]}`)}else Object.defineProperty(s,e,{value:t});return s},exports.wrapArray=s; //# sourceMappingURL=index.js.map