@casl/vue 2.1.0 → 2.1.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/dist/es5m/index.js +1 -1
- package/dist/es5m/index.js.map +1 -1
- package/dist/es6m/index.mjs +1 -1
- package/dist/es6m/index.mjs.map +1 -1
- package/dist/types/component/can.d.ts +8 -8
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +6 -4
- package/CHANGELOG.md +0 -345
package/dist/es5m/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ref as i,inject as n,provide as r,defineComponent as t}from"vue";import{PureAbility as e}from"@casl/ability";function reactiveAbility(n){if(n.hasOwnProperty("possibleRulesFor"))return n;var r=i(true);n.on("updated",(function(){r.value=!r.value}));var t=n.possibleRulesFor.bind(n);n.possibleRulesFor=function(i,n){r.value=r.value;return t(i,n)};return n}var o=Symbol("ability");function useAbility(){var i=n(o);if(!i)throw new Error("Cannot inject Ability instance because it was not provided");return i}function provideAbility(i){r(o,reactiveAbility(i))}function a(i){if("a"in i)return"a";if("this"in i)return"this";if("an"in i)return"an";return""}var u=t({name:"Can",props:{I:String,do:String,a:[String,Function],an:[String,Function],this:[String,Function,Object],on:[String,Function,Object],not:Boolean,passThrough:Boolean,field:String},setup:function i(n,r){var t=r.slots;var e=n;var o="do";var u="on";if(!(o in n)){o="I";u=a(n)}if(!e[o])throw new Error("Neither `I` nor `do` prop was passed in <Can>");if(!t.default)throw new Error("Expects to receive default slot");var l=useAbility();return function(){var i=l.can(e[o],e[u],e.field);var r=n.not?!i:i;if(!n.passThrough)return r?t.default():null;return t.default({allowed:r,ability:l})}}});function l(i,n,r){if(!n||!(n instanceof e))throw new Error("Please provide an Ability instance to abilitiesPlugin plugin");i.provide(o,reactiveAbility(n));if(r&&r.useGlobalProperties){i.config.globalProperties.$ability=n;i.config.globalProperties.$can=n.can}}export{o as ABILITY_TOKEN,u as Can,l as abilitiesPlugin,provideAbility,useAbility};
|
|
1
|
+
import{ref as i,inject as n,provide as r,defineComponent as t}from"vue";import{PureAbility as e}from"@casl/ability";function reactiveAbility(n){if(n.hasOwnProperty("possibleRulesFor"))return n;var r=i(true);n.on("updated",(function(){r.value=!r.value}));var t=n.possibleRulesFor.bind(n);n.possibleRulesFor=function(i,n){r.value=r.value;return t(i,n)};n.can=n.can.bind(n);n.cannot=n.cannot.bind(n);return n}var o=Symbol("ability");function useAbility(){var i=n(o);if(!i)throw new Error("Cannot inject Ability instance because it was not provided");return i}function provideAbility(i){r(o,reactiveAbility(i))}function a(i){if("a"in i)return"a";if("this"in i)return"this";if("an"in i)return"an";return""}var u=t({name:"Can",props:{I:String,do:String,a:[String,Function],an:[String,Function],this:[String,Function,Object],on:[String,Function,Object],not:Boolean,passThrough:Boolean,field:String},setup:function i(n,r){var t=r.slots;var e=n;var o="do";var u="on";if(!(o in n)){o="I";u=a(n)}if(!e[o])throw new Error("Neither `I` nor `do` prop was passed in <Can>");if(!t.default)throw new Error("Expects to receive default slot");var l=useAbility();return function(){var i=l.can(e[o],e[u],e.field);var r=n.not?!i:i;if(!n.passThrough)return r?t.default():null;return t.default({allowed:r,ability:l})}}});function l(i,n,r){if(!n||!(n instanceof e))throw new Error("Please provide an Ability instance to abilitiesPlugin plugin");i.provide(o,reactiveAbility(n));if(r&&r.useGlobalProperties){i.config.globalProperties.$ability=n;i.config.globalProperties.$can=n.can.bind(n)}}export{o as ABILITY_TOKEN,u as Can,l as abilitiesPlugin,provideAbility,useAbility};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/es5m/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/reactiveAbility.ts","../../src/useAbility.ts","../../src/component/can.ts","../../src/plugin.ts"],"sourcesContent":["import { AnyAbility, SubjectType } from '@casl/ability';\nimport { ref } from 'vue';\n\nexport function reactiveAbility(ability: AnyAbility) {\n if (ability.hasOwnProperty('possibleRulesFor')) {\n return ability;\n }\n\n const watcher = ref(true);\n ability.on('updated', () => {\n watcher.value = !watcher.value;\n });\n\n const possibleRulesFor = ability.possibleRulesFor.bind(ability);\n ability.possibleRulesFor = (action: string, subject: SubjectType) => {\n watcher.value = watcher.value; // eslint-disable-line\n return possibleRulesFor(action, subject);\n };\n\n return ability;\n}\n","import { inject, InjectionKey, provide } from 'vue';\nimport type { AnyAbility, Ability } from '@casl/ability';\nimport { reactiveAbility } from './reactiveAbility';\n\nexport const ABILITY_TOKEN: InjectionKey<Ability> = Symbol('ability');\n\nexport function useAbility<T extends AnyAbility = Ability>(): T {\n const ability = inject<T>(ABILITY_TOKEN);\n\n if (!ability) {\n throw new Error('Cannot inject Ability instance because it was not provided');\n }\n\n return ability;\n}\n\nexport function provideAbility(ability: AnyAbility) {\n provide(ABILITY_TOKEN, reactiveAbility(ability));\n}\n","import { defineComponent, ComponentCustomProperties } from 'vue';\nimport {\n SubjectType,\n Generics,\n AnyAbility,\n Ability,\n Abilities,\n IfString,\n AbilityTuple,\n} from '@casl/ability';\nimport { useAbility } from '../useAbility';\n\ntype AbilityCanProps<\n T extends Abilities,\n Else = IfString<T, { do: T } | { I: T }>\n> = T extends AbilityTuple\n ? { do: T[0], on: T[1], field?: string } |\n { I: T[0], a: Extract<T[1], SubjectType>, field?: string } |\n { I: T[0], an: Extract<T[1], SubjectType>, field?: string } |\n { I: T[0], this: Exclude<T[1], SubjectType>, field?: string }\n : Else;\n\nexport type CanProps<T extends AnyAbility> = AbilityCanProps<Generics<T>['abilities']> & {\n not?: boolean,\n passThrough?: boolean\n};\n\ntype VueAbility = ComponentCustomProperties extends { $ability: AnyAbility }\n ? ComponentCustomProperties['$ability']\n : Ability;\n\nfunction detectSubjectProp(props: Record<string, unknown>) {\n if ('a' in props) {\n return 'a';\n }\n\n if ('this' in props) {\n return 'this';\n }\n\n if ('an' in props) {\n return 'an';\n }\n\n return '';\n}\n\nexport const Can = defineComponent<CanProps<VueAbility>>({\n name: 'Can',\n props: {\n I: String,\n do: String,\n a: [String, Function],\n an: [String, Function],\n this: [String, Function, Object],\n on: [String, Function, Object],\n not: Boolean,\n passThrough: Boolean,\n field: String\n } as any,\n setup(props, { slots }) {\n const $props = props as Record<string, any>;\n let actionProp = 'do';\n let subjectProp = 'on';\n\n if (!(actionProp in props)) {\n actionProp = 'I';\n subjectProp = detectSubjectProp(props);\n }\n\n if (!$props[actionProp]) {\n throw new Error('Neither `I` nor `do` prop was passed in <Can>');\n }\n\n if (!slots.default) {\n throw new Error('Expects to receive default slot');\n }\n\n const ability = useAbility<VueAbility>();\n\n return () => {\n const isAllowed = ability.can($props[actionProp], $props[subjectProp], $props.field);\n const canRender = props.not ? !isAllowed : isAllowed;\n\n if (!props.passThrough) {\n return canRender ? slots.default!() : null;\n }\n\n return slots.default!({\n allowed: canRender,\n ability,\n });\n };\n }\n});\n","import { App } from 'vue';\nimport { AnyAbility, PureAbility } from '@casl/ability';\nimport { ABILITY_TOKEN } from './useAbility';\nimport { reactiveAbility } from './reactiveAbility';\n\nexport interface AbilityPluginOptions {\n useGlobalProperties?: boolean\n}\n\nexport function abilitiesPlugin(app: App, ability: AnyAbility, options?: AbilityPluginOptions) {\n if (!ability || !(ability instanceof PureAbility)) {\n throw new Error('Please provide an Ability instance to abilitiesPlugin plugin');\n }\n\n app.provide(ABILITY_TOKEN, reactiveAbility(ability));\n\n if (options && options.useGlobalProperties) {\n app.config.globalProperties.$ability = ability;\n app.config.globalProperties.$can = ability.can;\n }\n}\n"],"names":["reactiveAbility","ability","hasOwnProperty","watcher","ref","on","value","possibleRulesFor","bind","action","subject","ABILITY_TOKEN","Symbol","useAbility","inject","Error","provideAbility","provide","detectSubjectProp","props","Can","defineComponent","name","I","String","do","a","Function","an","this","Object","not","Boolean","passThrough","field","setup","slots","$props","actionProp","subjectProp","default","isAllowed","
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/reactiveAbility.ts","../../src/useAbility.ts","../../src/component/can.ts","../../src/plugin.ts"],"sourcesContent":["import { AnyAbility, SubjectType } from '@casl/ability';\nimport { ref } from 'vue';\n\nexport function reactiveAbility(ability: AnyAbility) {\n if (ability.hasOwnProperty('possibleRulesFor')) {\n return ability;\n }\n\n const watcher = ref(true);\n ability.on('updated', () => {\n watcher.value = !watcher.value;\n });\n\n const possibleRulesFor = ability.possibleRulesFor.bind(ability);\n ability.possibleRulesFor = (action: string, subject: SubjectType) => {\n watcher.value = watcher.value; // eslint-disable-line\n return possibleRulesFor(action, subject);\n };\n ability.can = ability.can.bind(ability);\n ability.cannot = ability.cannot.bind(ability);\n\n return ability;\n}\n","import { inject, InjectionKey, provide } from 'vue';\nimport type { AnyAbility, Ability } from '@casl/ability';\nimport { reactiveAbility } from './reactiveAbility';\n\nexport const ABILITY_TOKEN: InjectionKey<Ability> = Symbol('ability');\n\nexport function useAbility<T extends AnyAbility = Ability>(): T {\n const ability = inject<T>(ABILITY_TOKEN);\n\n if (!ability) {\n throw new Error('Cannot inject Ability instance because it was not provided');\n }\n\n return ability;\n}\n\nexport function provideAbility(ability: AnyAbility) {\n provide(ABILITY_TOKEN, reactiveAbility(ability));\n}\n","import { defineComponent, ComponentCustomProperties } from 'vue';\nimport {\n SubjectType,\n Generics,\n AnyAbility,\n Ability,\n Abilities,\n IfString,\n AbilityTuple,\n} from '@casl/ability';\nimport { useAbility } from '../useAbility';\n\ntype AbilityCanProps<\n T extends Abilities,\n Else = IfString<T, { do: T } | { I: T }>\n> = T extends AbilityTuple\n ? { do: T[0], on: T[1], field?: string } |\n { I: T[0], a: Extract<T[1], SubjectType>, field?: string } |\n { I: T[0], an: Extract<T[1], SubjectType>, field?: string } |\n { I: T[0], this: Exclude<T[1], SubjectType>, field?: string }\n : Else;\n\nexport type CanProps<T extends AnyAbility> = AbilityCanProps<Generics<T>['abilities']> & {\n not?: boolean,\n passThrough?: boolean\n};\n\ntype VueAbility = ComponentCustomProperties extends { $ability: AnyAbility }\n ? ComponentCustomProperties['$ability']\n : Ability;\n\nfunction detectSubjectProp(props: Record<string, unknown>) {\n if ('a' in props) {\n return 'a';\n }\n\n if ('this' in props) {\n return 'this';\n }\n\n if ('an' in props) {\n return 'an';\n }\n\n return '';\n}\n\nexport const Can = defineComponent<CanProps<VueAbility>>({\n name: 'Can',\n props: {\n I: String,\n do: String,\n a: [String, Function],\n an: [String, Function],\n this: [String, Function, Object],\n on: [String, Function, Object],\n not: Boolean,\n passThrough: Boolean,\n field: String\n } as any,\n setup(props, { slots }) {\n const $props = props as Record<string, any>;\n let actionProp = 'do';\n let subjectProp = 'on';\n\n if (!(actionProp in props)) {\n actionProp = 'I';\n subjectProp = detectSubjectProp(props);\n }\n\n if (!$props[actionProp]) {\n throw new Error('Neither `I` nor `do` prop was passed in <Can>');\n }\n\n if (!slots.default) {\n throw new Error('Expects to receive default slot');\n }\n\n const ability = useAbility<VueAbility>();\n\n return () => {\n const isAllowed = ability.can($props[actionProp], $props[subjectProp], $props.field);\n const canRender = props.not ? !isAllowed : isAllowed;\n\n if (!props.passThrough) {\n return canRender ? slots.default!() : null;\n }\n\n return slots.default!({\n allowed: canRender,\n ability,\n });\n };\n }\n});\n","import { App } from 'vue';\nimport { AnyAbility, PureAbility } from '@casl/ability';\nimport { ABILITY_TOKEN } from './useAbility';\nimport { reactiveAbility } from './reactiveAbility';\n\nexport interface AbilityPluginOptions {\n useGlobalProperties?: boolean\n}\n\nexport function abilitiesPlugin(app: App, ability: AnyAbility, options?: AbilityPluginOptions) {\n if (!ability || !(ability instanceof PureAbility)) {\n throw new Error('Please provide an Ability instance to abilitiesPlugin plugin');\n }\n\n app.provide(ABILITY_TOKEN, reactiveAbility(ability));\n\n if (options && options.useGlobalProperties) {\n app.config.globalProperties.$ability = ability;\n app.config.globalProperties.$can = ability.can.bind(ability);\n }\n}\n"],"names":["reactiveAbility","ability","hasOwnProperty","watcher","ref","on","value","possibleRulesFor","bind","action","subject","can","cannot","ABILITY_TOKEN","Symbol","useAbility","inject","Error","provideAbility","provide","detectSubjectProp","props","Can","defineComponent","name","I","String","do","a","Function","an","this","Object","not","Boolean","passThrough","field","setup","slots","$props","actionProp","subjectProp","default","isAllowed","canRender","allowed","abilitiesPlugin","app","options","PureAbility","useGlobalProperties","config","globalProperties","$ability","$can"],"mappings":"oHAGO,SAASA,gBAAgBC,MAC1BA,EAAQC,eAAe,2BAClBD,MAGHE,EAAUC,EAAI,MACpBH,EAAQI,GAAG,WAAW,WACpBF,EAAQG,OAASH,EAAQG,aAGrBC,EAAmBN,EAAQM,iBAAiBC,KAAKP,GACvDA,EAAQM,iBAAmB,SAACE,EAAgBC,GAC1CP,EAAQG,MAAQH,EAAQG,aACjBC,EAAiBE,EAAQC,IAElCT,EAAQU,IAAMV,EAAQU,IAAIH,KAAKP,GAC/BA,EAAQW,OAASX,EAAQW,OAAOJ,KAAKP,UAE9BA,MCjBIY,EAAuCC,OAAO,WAEpD,SAASC,iBACRd,EAAUe,EAAUH,OAErBZ,QACG,IAAIgB,MAAM,qEAGXhB,EAGF,SAASiB,eAAejB,GAC7BkB,EAAQN,EAAeb,gBAAgBC,ICczC,SAASmB,EAAkBC,MACrB,MAAOA,QACF,OAGL,SAAUA,QACL,UAGL,OAAQA,QACH,WAGF,OAGIC,EAAMC,EAAsC,CACvDC,KAAM,MACNH,MAAO,CACLI,EAAGC,OACHC,GAAID,OACJE,EAAG,CAACF,OAAQG,UACZC,GAAI,CAACJ,OAAQG,UACbE,KAAM,CAACL,OAAQG,SAAUG,QACzB3B,GAAI,CAACqB,OAAQG,SAAUG,QACvBC,IAAKC,QACLC,YAAaD,QACbE,MAAOV,QAETW,iBAAMhB,SAASiB,IAAAA,UACPC,EAASlB,MACXmB,EAAa,SACbC,EAAc,UAEZD,KAAcnB,GAAQ,CAC1BmB,EAAa,IACbC,EAAcrB,EAAkBC,OAG7BkB,EAAOC,SACJ,IAAIvB,MAAM,qDAGbqB,EAAMI,cACH,IAAIzB,MAAM,uCAGZhB,EAAUc,oBAET,eACC4B,EAAY1C,EAAQU,IAAI4B,EAAOC,GAAaD,EAAOE,GAAcF,EAAOH,WACxEQ,EAAYvB,EAAMY,KAAOU,EAAYA,MAEtCtB,EAAMc,mBACFS,EAAYN,EAAMI,UAAa,YAGjCJ,EAAMI,QAAS,CACpBG,QAASD,EACT3C,QAAAA,QCjFD,SAAS6C,EAAgBC,EAAU9C,EAAqB+C,OACxD/C,KAAaA,aAAmBgD,SAC7B,IAAIhC,MAAM,gEAGlB8B,EAAI5B,QAAQN,EAAeb,gBAAgBC,OAEvC+C,GAAWA,EAAQE,oBAAqB,CAC1CH,EAAII,OAAOC,iBAAiBC,SAAWpD,EACvC8C,EAAII,OAAOC,iBAAiBE,KAAOrD,EAAQU,IAAIH,KAAKP"}
|
package/dist/es6m/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ref as t,inject as i,provide as n,defineComponent as r}from"vue";import{PureAbility as e}from"@casl/ability";function reactiveAbility(i){if(i.hasOwnProperty("possibleRulesFor"))return i;const n=t(true);i.on("updated",(()=>{n.value=!n.value}));const r=i.possibleRulesFor.bind(i);i.possibleRulesFor=(t,i)=>{n.value=n.value;return r(t,i)};return i}const o=Symbol("ability");function useAbility(){const t=i(o);if(!t)throw new Error("Cannot inject Ability instance because it was not provided");return t}function provideAbility(t){n(o,reactiveAbility(t))}function s(t){if("a"in t)return"a";if("this"in t)return"this";if("an"in t)return"an";return""}const u=r({name:"Can",props:{I:String,do:String,a:[String,Function],an:[String,Function],this:[String,Function,Object],on:[String,Function,Object],not:Boolean,passThrough:Boolean,field:String},setup(t,{slots:i}){const n=t;let r="do";let e="on";if(!(r in t)){r="I";e=s(t)}if(!n[r])throw new Error("Neither `I` nor `do` prop was passed in <Can>");if(!i.default)throw new Error("Expects to receive default slot");const o=useAbility();return()=>{const s=o.can(n[r],n[e],n.field);const u=t.not?!s:s;if(!t.passThrough)return u?i.default():null;return i.default({allowed:u,ability:o})}}});function a(t,i,n){if(!i||!(i instanceof e))throw new Error("Please provide an Ability instance to abilitiesPlugin plugin");t.provide(o,reactiveAbility(i));if(n&&n.useGlobalProperties){t.config.globalProperties.$ability=i;t.config.globalProperties.$can=i.can}}export{o as ABILITY_TOKEN,u as Can,a as abilitiesPlugin,provideAbility,useAbility};
|
|
1
|
+
import{ref as t,inject as i,provide as n,defineComponent as r}from"vue";import{PureAbility as e}from"@casl/ability";function reactiveAbility(i){if(i.hasOwnProperty("possibleRulesFor"))return i;const n=t(true);i.on("updated",(()=>{n.value=!n.value}));const r=i.possibleRulesFor.bind(i);i.possibleRulesFor=(t,i)=>{n.value=n.value;return r(t,i)};i.can=i.can.bind(i);i.cannot=i.cannot.bind(i);return i}const o=Symbol("ability");function useAbility(){const t=i(o);if(!t)throw new Error("Cannot inject Ability instance because it was not provided");return t}function provideAbility(t){n(o,reactiveAbility(t))}function s(t){if("a"in t)return"a";if("this"in t)return"this";if("an"in t)return"an";return""}const u=r({name:"Can",props:{I:String,do:String,a:[String,Function],an:[String,Function],this:[String,Function,Object],on:[String,Function,Object],not:Boolean,passThrough:Boolean,field:String},setup(t,{slots:i}){const n=t;let r="do";let e="on";if(!(r in t)){r="I";e=s(t)}if(!n[r])throw new Error("Neither `I` nor `do` prop was passed in <Can>");if(!i.default)throw new Error("Expects to receive default slot");const o=useAbility();return()=>{const s=o.can(n[r],n[e],n.field);const u=t.not?!s:s;if(!t.passThrough)return u?i.default():null;return i.default({allowed:u,ability:o})}}});function a(t,i,n){if(!i||!(i instanceof e))throw new Error("Please provide an Ability instance to abilitiesPlugin plugin");t.provide(o,reactiveAbility(i));if(n&&n.useGlobalProperties){t.config.globalProperties.$ability=i;t.config.globalProperties.$can=i.can.bind(i)}}export{o as ABILITY_TOKEN,u as Can,a as abilitiesPlugin,provideAbility,useAbility};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/es6m/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/reactiveAbility.ts","../../src/useAbility.ts","../../src/component/can.ts","../../src/plugin.ts"],"sourcesContent":["import { AnyAbility, SubjectType } from '@casl/ability';\nimport { ref } from 'vue';\n\nexport function reactiveAbility(ability: AnyAbility) {\n if (ability.hasOwnProperty('possibleRulesFor')) {\n return ability;\n }\n\n const watcher = ref(true);\n ability.on('updated', () => {\n watcher.value = !watcher.value;\n });\n\n const possibleRulesFor = ability.possibleRulesFor.bind(ability);\n ability.possibleRulesFor = (action: string, subject: SubjectType) => {\n watcher.value = watcher.value; // eslint-disable-line\n return possibleRulesFor(action, subject);\n };\n\n return ability;\n}\n","import { inject, InjectionKey, provide } from 'vue';\nimport type { AnyAbility, Ability } from '@casl/ability';\nimport { reactiveAbility } from './reactiveAbility';\n\nexport const ABILITY_TOKEN: InjectionKey<Ability> = Symbol('ability');\n\nexport function useAbility<T extends AnyAbility = Ability>(): T {\n const ability = inject<T>(ABILITY_TOKEN);\n\n if (!ability) {\n throw new Error('Cannot inject Ability instance because it was not provided');\n }\n\n return ability;\n}\n\nexport function provideAbility(ability: AnyAbility) {\n provide(ABILITY_TOKEN, reactiveAbility(ability));\n}\n","import { defineComponent, ComponentCustomProperties } from 'vue';\nimport {\n SubjectType,\n Generics,\n AnyAbility,\n Ability,\n Abilities,\n IfString,\n AbilityTuple,\n} from '@casl/ability';\nimport { useAbility } from '../useAbility';\n\ntype AbilityCanProps<\n T extends Abilities,\n Else = IfString<T, { do: T } | { I: T }>\n> = T extends AbilityTuple\n ? { do: T[0], on: T[1], field?: string } |\n { I: T[0], a: Extract<T[1], SubjectType>, field?: string } |\n { I: T[0], an: Extract<T[1], SubjectType>, field?: string } |\n { I: T[0], this: Exclude<T[1], SubjectType>, field?: string }\n : Else;\n\nexport type CanProps<T extends AnyAbility> = AbilityCanProps<Generics<T>['abilities']> & {\n not?: boolean,\n passThrough?: boolean\n};\n\ntype VueAbility = ComponentCustomProperties extends { $ability: AnyAbility }\n ? ComponentCustomProperties['$ability']\n : Ability;\n\nfunction detectSubjectProp(props: Record<string, unknown>) {\n if ('a' in props) {\n return 'a';\n }\n\n if ('this' in props) {\n return 'this';\n }\n\n if ('an' in props) {\n return 'an';\n }\n\n return '';\n}\n\nexport const Can = defineComponent<CanProps<VueAbility>>({\n name: 'Can',\n props: {\n I: String,\n do: String,\n a: [String, Function],\n an: [String, Function],\n this: [String, Function, Object],\n on: [String, Function, Object],\n not: Boolean,\n passThrough: Boolean,\n field: String\n } as any,\n setup(props, { slots }) {\n const $props = props as Record<string, any>;\n let actionProp = 'do';\n let subjectProp = 'on';\n\n if (!(actionProp in props)) {\n actionProp = 'I';\n subjectProp = detectSubjectProp(props);\n }\n\n if (!$props[actionProp]) {\n throw new Error('Neither `I` nor `do` prop was passed in <Can>');\n }\n\n if (!slots.default) {\n throw new Error('Expects to receive default slot');\n }\n\n const ability = useAbility<VueAbility>();\n\n return () => {\n const isAllowed = ability.can($props[actionProp], $props[subjectProp], $props.field);\n const canRender = props.not ? !isAllowed : isAllowed;\n\n if (!props.passThrough) {\n return canRender ? slots.default!() : null;\n }\n\n return slots.default!({\n allowed: canRender,\n ability,\n });\n };\n }\n});\n","import { App } from 'vue';\nimport { AnyAbility, PureAbility } from '@casl/ability';\nimport { ABILITY_TOKEN } from './useAbility';\nimport { reactiveAbility } from './reactiveAbility';\n\nexport interface AbilityPluginOptions {\n useGlobalProperties?: boolean\n}\n\nexport function abilitiesPlugin(app: App, ability: AnyAbility, options?: AbilityPluginOptions) {\n if (!ability || !(ability instanceof PureAbility)) {\n throw new Error('Please provide an Ability instance to abilitiesPlugin plugin');\n }\n\n app.provide(ABILITY_TOKEN, reactiveAbility(ability));\n\n if (options && options.useGlobalProperties) {\n app.config.globalProperties.$ability = ability;\n app.config.globalProperties.$can = ability.can;\n }\n}\n"],"names":["reactiveAbility","ability","hasOwnProperty","watcher","ref","on","value","possibleRulesFor","bind","action","subject","ABILITY_TOKEN","Symbol","useAbility","inject","Error","provideAbility","provide","detectSubjectProp","props","Can","defineComponent","name","I","String","do","a","Function","an","this","Object","not","Boolean","passThrough","field","setup","slots","$props","actionProp","subjectProp","default","isAllowed","
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/reactiveAbility.ts","../../src/useAbility.ts","../../src/component/can.ts","../../src/plugin.ts"],"sourcesContent":["import { AnyAbility, SubjectType } from '@casl/ability';\nimport { ref } from 'vue';\n\nexport function reactiveAbility(ability: AnyAbility) {\n if (ability.hasOwnProperty('possibleRulesFor')) {\n return ability;\n }\n\n const watcher = ref(true);\n ability.on('updated', () => {\n watcher.value = !watcher.value;\n });\n\n const possibleRulesFor = ability.possibleRulesFor.bind(ability);\n ability.possibleRulesFor = (action: string, subject: SubjectType) => {\n watcher.value = watcher.value; // eslint-disable-line\n return possibleRulesFor(action, subject);\n };\n ability.can = ability.can.bind(ability);\n ability.cannot = ability.cannot.bind(ability);\n\n return ability;\n}\n","import { inject, InjectionKey, provide } from 'vue';\nimport type { AnyAbility, Ability } from '@casl/ability';\nimport { reactiveAbility } from './reactiveAbility';\n\nexport const ABILITY_TOKEN: InjectionKey<Ability> = Symbol('ability');\n\nexport function useAbility<T extends AnyAbility = Ability>(): T {\n const ability = inject<T>(ABILITY_TOKEN);\n\n if (!ability) {\n throw new Error('Cannot inject Ability instance because it was not provided');\n }\n\n return ability;\n}\n\nexport function provideAbility(ability: AnyAbility) {\n provide(ABILITY_TOKEN, reactiveAbility(ability));\n}\n","import { defineComponent, ComponentCustomProperties } from 'vue';\nimport {\n SubjectType,\n Generics,\n AnyAbility,\n Ability,\n Abilities,\n IfString,\n AbilityTuple,\n} from '@casl/ability';\nimport { useAbility } from '../useAbility';\n\ntype AbilityCanProps<\n T extends Abilities,\n Else = IfString<T, { do: T } | { I: T }>\n> = T extends AbilityTuple\n ? { do: T[0], on: T[1], field?: string } |\n { I: T[0], a: Extract<T[1], SubjectType>, field?: string } |\n { I: T[0], an: Extract<T[1], SubjectType>, field?: string } |\n { I: T[0], this: Exclude<T[1], SubjectType>, field?: string }\n : Else;\n\nexport type CanProps<T extends AnyAbility> = AbilityCanProps<Generics<T>['abilities']> & {\n not?: boolean,\n passThrough?: boolean\n};\n\ntype VueAbility = ComponentCustomProperties extends { $ability: AnyAbility }\n ? ComponentCustomProperties['$ability']\n : Ability;\n\nfunction detectSubjectProp(props: Record<string, unknown>) {\n if ('a' in props) {\n return 'a';\n }\n\n if ('this' in props) {\n return 'this';\n }\n\n if ('an' in props) {\n return 'an';\n }\n\n return '';\n}\n\nexport const Can = defineComponent<CanProps<VueAbility>>({\n name: 'Can',\n props: {\n I: String,\n do: String,\n a: [String, Function],\n an: [String, Function],\n this: [String, Function, Object],\n on: [String, Function, Object],\n not: Boolean,\n passThrough: Boolean,\n field: String\n } as any,\n setup(props, { slots }) {\n const $props = props as Record<string, any>;\n let actionProp = 'do';\n let subjectProp = 'on';\n\n if (!(actionProp in props)) {\n actionProp = 'I';\n subjectProp = detectSubjectProp(props);\n }\n\n if (!$props[actionProp]) {\n throw new Error('Neither `I` nor `do` prop was passed in <Can>');\n }\n\n if (!slots.default) {\n throw new Error('Expects to receive default slot');\n }\n\n const ability = useAbility<VueAbility>();\n\n return () => {\n const isAllowed = ability.can($props[actionProp], $props[subjectProp], $props.field);\n const canRender = props.not ? !isAllowed : isAllowed;\n\n if (!props.passThrough) {\n return canRender ? slots.default!() : null;\n }\n\n return slots.default!({\n allowed: canRender,\n ability,\n });\n };\n }\n});\n","import { App } from 'vue';\nimport { AnyAbility, PureAbility } from '@casl/ability';\nimport { ABILITY_TOKEN } from './useAbility';\nimport { reactiveAbility } from './reactiveAbility';\n\nexport interface AbilityPluginOptions {\n useGlobalProperties?: boolean\n}\n\nexport function abilitiesPlugin(app: App, ability: AnyAbility, options?: AbilityPluginOptions) {\n if (!ability || !(ability instanceof PureAbility)) {\n throw new Error('Please provide an Ability instance to abilitiesPlugin plugin');\n }\n\n app.provide(ABILITY_TOKEN, reactiveAbility(ability));\n\n if (options && options.useGlobalProperties) {\n app.config.globalProperties.$ability = ability;\n app.config.globalProperties.$can = ability.can.bind(ability);\n }\n}\n"],"names":["reactiveAbility","ability","hasOwnProperty","watcher","ref","on","value","possibleRulesFor","bind","action","subject","can","cannot","ABILITY_TOKEN","Symbol","useAbility","inject","Error","provideAbility","provide","detectSubjectProp","props","Can","defineComponent","name","I","String","do","a","Function","an","this","Object","not","Boolean","passThrough","field","setup","slots","$props","actionProp","subjectProp","default","isAllowed","canRender","allowed","abilitiesPlugin","app","options","PureAbility","useGlobalProperties","config","globalProperties","$ability","$can"],"mappings":"oHAGO,SAASA,gBAAgBC,MAC1BA,EAAQC,eAAe,2BAClBD,QAGHE,EAAUC,EAAI,MACpBH,EAAQI,GAAG,WAAW,KACpBF,EAAQG,OAASH,EAAQG,eAGrBC,EAAmBN,EAAQM,iBAAiBC,KAAKP,GACvDA,EAAQM,iBAAmB,CAACE,EAAgBC,KAC1CP,EAAQG,MAAQH,EAAQG,aACjBC,EAAiBE,EAAQC,IAElCT,EAAQU,IAAMV,EAAQU,IAAIH,KAAKP,GAC/BA,EAAQW,OAASX,EAAQW,OAAOJ,KAAKP,UAE9BA,QCjBIY,EAAuCC,OAAO,WAEpD,SAASC,mBACRd,EAAUe,EAAUH,OAErBZ,QACG,IAAIgB,MAAM,qEAGXhB,EAGF,SAASiB,eAAejB,GAC7BkB,EAAQN,EAAeb,gBAAgBC,ICczC,SAASmB,EAAkBC,MACrB,MAAOA,QACF,OAGL,SAAUA,QACL,UAGL,OAAQA,QACH,WAGF,SAGIC,EAAMC,EAAsC,CACvDC,KAAM,MACNH,MAAO,CACLI,EAAGC,OACHC,GAAID,OACJE,EAAG,CAACF,OAAQG,UACZC,GAAI,CAACJ,OAAQG,UACbE,KAAM,CAACL,OAAQG,SAAUG,QACzB3B,GAAI,CAACqB,OAAQG,SAAUG,QACvBC,IAAKC,QACLC,YAAaD,QACbE,MAAOV,QAETW,MAAMhB,GAAOiB,MAAEA,UACPC,EAASlB,MACXmB,EAAa,SACbC,EAAc,UAEZD,KAAcnB,GAAQ,CAC1BmB,EAAa,IACbC,EAAcrB,EAAkBC,OAG7BkB,EAAOC,SACJ,IAAIvB,MAAM,qDAGbqB,EAAMI,cACH,IAAIzB,MAAM,yCAGZhB,EAAUc,mBAET,WACC4B,EAAY1C,EAAQU,IAAI4B,EAAOC,GAAaD,EAAOE,GAAcF,EAAOH,aACxEQ,EAAYvB,EAAMY,KAAOU,EAAYA,MAEtCtB,EAAMc,mBACFS,EAAYN,EAAMI,UAAa,YAGjCJ,EAAMI,QAAS,CACpBG,QAASD,EACT3C,QAAAA,QCjFD,SAAS6C,EAAgBC,EAAU9C,EAAqB+C,OACxD/C,KAAaA,aAAmBgD,SAC7B,IAAIhC,MAAM,gEAGlB8B,EAAI5B,QAAQN,EAAeb,gBAAgBC,OAEvC+C,GAAWA,EAAQE,oBAAqB,CAC1CH,EAAII,OAAOC,iBAAiBC,SAAWpD,EACvC8C,EAAII,OAAOC,iBAAiBE,KAAOrD,EAAQU,IAAIH,KAAKP"}
|
|
@@ -24,29 +24,29 @@ export declare type CanProps<T extends AnyAbility> = AbilityCanProps<Generics<T>
|
|
|
24
24
|
not?: boolean;
|
|
25
25
|
passThrough?: boolean;
|
|
26
26
|
};
|
|
27
|
-
export declare const Can: import("vue").DefineComponent<CanProps<Ability<AbilityTuple<string, import("@casl/ability").Subject>, import("@casl/ability").MongoQuery<
|
|
28
|
-
on?:
|
|
27
|
+
export declare const Can: import("vue").DefineComponent<CanProps<Ability<AbilityTuple<string, import("@casl/ability").Subject>, import("@casl/ability").MongoQuery<import("@casl/ability/dist/types/types").AnyObject>>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<({} & {
|
|
28
|
+
on?: import("@casl/ability").Subject | undefined;
|
|
29
29
|
field?: string | undefined;
|
|
30
30
|
do?: string | undefined;
|
|
31
31
|
not?: boolean | undefined;
|
|
32
32
|
passThrough?: boolean | undefined;
|
|
33
|
-
}
|
|
34
|
-
a?:
|
|
33
|
+
}) | ({} & {
|
|
34
|
+
a?: SubjectType | undefined;
|
|
35
35
|
I?: string | undefined;
|
|
36
36
|
field?: string | undefined;
|
|
37
37
|
not?: boolean | undefined;
|
|
38
38
|
passThrough?: boolean | undefined;
|
|
39
|
-
}
|
|
39
|
+
}) | ({} & {
|
|
40
40
|
I?: string | undefined;
|
|
41
41
|
field?: string | undefined;
|
|
42
|
-
an?:
|
|
42
|
+
an?: SubjectType | undefined;
|
|
43
43
|
not?: boolean | undefined;
|
|
44
44
|
passThrough?: boolean | undefined;
|
|
45
|
-
}
|
|
45
|
+
}) | ({} & {
|
|
46
46
|
this?: unknown;
|
|
47
47
|
I?: string | undefined;
|
|
48
48
|
field?: string | undefined;
|
|
49
49
|
not?: boolean | undefined;
|
|
50
50
|
passThrough?: boolean | undefined;
|
|
51
|
-
}>, {} | {} | {} | {}>;
|
|
51
|
+
})>, {} | {} | {} | {}>;
|
|
52
52
|
export {};
|
package/dist/umd/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(i,n){"object"===typeof exports&&"undefined"!==typeof module?n(exports,require("vue"),require("@casl/ability")):"function"===typeof define&&define.amd?define(["exports","vue","@casl/ability"],n):(i="undefined"!==typeof globalThis?globalThis:i||self,n((i.casl=i.casl||{},i.casl.vue={}),i.Vue,i.casl))})(this,(function(i,n,t){"use strict";function reactiveAbility(i){if(i.hasOwnProperty("possibleRulesFor"))return i;var t=n.ref(true);i.on("updated",(function(){t.value=!t.value}));var e=i.possibleRulesFor.bind(i);i.possibleRulesFor=function(i,n){t.value=t.value;return e(i,n)};return i}var e=Symbol("ability");function useAbility(){var i=n.inject(e);if(!i)throw new Error("Cannot inject Ability instance because it was not provided");return i}function provideAbility(i){n.provide(e,reactiveAbility(i))}function r(i){if("a"in i)return"a";if("this"in i)return"this";if("an"in i)return"an";return""}var o=n.defineComponent({name:"Can",props:{I:String,do:String,a:[String,Function],an:[String,Function],this:[String,Function,Object],on:[String,Function,Object],not:Boolean,passThrough:Boolean,field:String},setup:function i(n,t){var e=t.slots;var o=n;var u="do";var a="on";if(!(u in n)){u="I";a=r(n)}if(!o[u])throw new Error("Neither `I` nor `do` prop was passed in <Can>");if(!e.default)throw new Error("Expects to receive default slot");var l=useAbility();return function(){var i=l.can(o[u],o[a],o.field);var t=n.not?!i:i;if(!n.passThrough)return t?e.default():null;return e.default({allowed:t,ability:l})}}});function u(i,n,r){if(!n||!(n instanceof t.PureAbility))throw new Error("Please provide an Ability instance to abilitiesPlugin plugin");i.provide(e,reactiveAbility(n));if(r&&r.useGlobalProperties){i.config.globalProperties.$ability=n;i.config.globalProperties.$can=n.can}}i.ABILITY_TOKEN=e;i.Can=o;i.abilitiesPlugin=u;i.provideAbility=provideAbility;i.useAbility=useAbility;Object.defineProperty(i,"__esModule",{value:true})}));
|
|
1
|
+
(function(i,n){"object"===typeof exports&&"undefined"!==typeof module?n(exports,require("vue"),require("@casl/ability")):"function"===typeof define&&define.amd?define(["exports","vue","@casl/ability"],n):(i="undefined"!==typeof globalThis?globalThis:i||self,n((i.casl=i.casl||{},i.casl.vue={}),i.Vue,i.casl))})(this,(function(i,n,t){"use strict";function reactiveAbility(i){if(i.hasOwnProperty("possibleRulesFor"))return i;var t=n.ref(true);i.on("updated",(function(){t.value=!t.value}));var e=i.possibleRulesFor.bind(i);i.possibleRulesFor=function(i,n){t.value=t.value;return e(i,n)};i.can=i.can.bind(i);i.cannot=i.cannot.bind(i);return i}var e=Symbol("ability");function useAbility(){var i=n.inject(e);if(!i)throw new Error("Cannot inject Ability instance because it was not provided");return i}function provideAbility(i){n.provide(e,reactiveAbility(i))}function r(i){if("a"in i)return"a";if("this"in i)return"this";if("an"in i)return"an";return""}var o=n.defineComponent({name:"Can",props:{I:String,do:String,a:[String,Function],an:[String,Function],this:[String,Function,Object],on:[String,Function,Object],not:Boolean,passThrough:Boolean,field:String},setup:function i(n,t){var e=t.slots;var o=n;var u="do";var a="on";if(!(u in n)){u="I";a=r(n)}if(!o[u])throw new Error("Neither `I` nor `do` prop was passed in <Can>");if(!e.default)throw new Error("Expects to receive default slot");var l=useAbility();return function(){var i=l.can(o[u],o[a],o.field);var t=n.not?!i:i;if(!n.passThrough)return t?e.default():null;return e.default({allowed:t,ability:l})}}});function u(i,n,r){if(!n||!(n instanceof t.PureAbility))throw new Error("Please provide an Ability instance to abilitiesPlugin plugin");i.provide(e,reactiveAbility(n));if(r&&r.useGlobalProperties){i.config.globalProperties.$ability=n;i.config.globalProperties.$can=n.can.bind(n)}}i.ABILITY_TOKEN=e;i.Can=o;i.abilitiesPlugin=u;i.provideAbility=provideAbility;i.useAbility=useAbility;Object.defineProperty(i,"__esModule",{value:true})}));
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/umd/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/reactiveAbility.ts","../../src/useAbility.ts","../../src/component/can.ts","../../src/plugin.ts"],"sourcesContent":["import { AnyAbility, SubjectType } from '@casl/ability';\nimport { ref } from 'vue';\n\nexport function reactiveAbility(ability: AnyAbility) {\n if (ability.hasOwnProperty('possibleRulesFor')) {\n return ability;\n }\n\n const watcher = ref(true);\n ability.on('updated', () => {\n watcher.value = !watcher.value;\n });\n\n const possibleRulesFor = ability.possibleRulesFor.bind(ability);\n ability.possibleRulesFor = (action: string, subject: SubjectType) => {\n watcher.value = watcher.value; // eslint-disable-line\n return possibleRulesFor(action, subject);\n };\n\n return ability;\n}\n","import { inject, InjectionKey, provide } from 'vue';\nimport type { AnyAbility, Ability } from '@casl/ability';\nimport { reactiveAbility } from './reactiveAbility';\n\nexport const ABILITY_TOKEN: InjectionKey<Ability> = Symbol('ability');\n\nexport function useAbility<T extends AnyAbility = Ability>(): T {\n const ability = inject<T>(ABILITY_TOKEN);\n\n if (!ability) {\n throw new Error('Cannot inject Ability instance because it was not provided');\n }\n\n return ability;\n}\n\nexport function provideAbility(ability: AnyAbility) {\n provide(ABILITY_TOKEN, reactiveAbility(ability));\n}\n","import { defineComponent, ComponentCustomProperties } from 'vue';\nimport {\n SubjectType,\n Generics,\n AnyAbility,\n Ability,\n Abilities,\n IfString,\n AbilityTuple,\n} from '@casl/ability';\nimport { useAbility } from '../useAbility';\n\ntype AbilityCanProps<\n T extends Abilities,\n Else = IfString<T, { do: T } | { I: T }>\n> = T extends AbilityTuple\n ? { do: T[0], on: T[1], field?: string } |\n { I: T[0], a: Extract<T[1], SubjectType>, field?: string } |\n { I: T[0], an: Extract<T[1], SubjectType>, field?: string } |\n { I: T[0], this: Exclude<T[1], SubjectType>, field?: string }\n : Else;\n\nexport type CanProps<T extends AnyAbility> = AbilityCanProps<Generics<T>['abilities']> & {\n not?: boolean,\n passThrough?: boolean\n};\n\ntype VueAbility = ComponentCustomProperties extends { $ability: AnyAbility }\n ? ComponentCustomProperties['$ability']\n : Ability;\n\nfunction detectSubjectProp(props: Record<string, unknown>) {\n if ('a' in props) {\n return 'a';\n }\n\n if ('this' in props) {\n return 'this';\n }\n\n if ('an' in props) {\n return 'an';\n }\n\n return '';\n}\n\nexport const Can = defineComponent<CanProps<VueAbility>>({\n name: 'Can',\n props: {\n I: String,\n do: String,\n a: [String, Function],\n an: [String, Function],\n this: [String, Function, Object],\n on: [String, Function, Object],\n not: Boolean,\n passThrough: Boolean,\n field: String\n } as any,\n setup(props, { slots }) {\n const $props = props as Record<string, any>;\n let actionProp = 'do';\n let subjectProp = 'on';\n\n if (!(actionProp in props)) {\n actionProp = 'I';\n subjectProp = detectSubjectProp(props);\n }\n\n if (!$props[actionProp]) {\n throw new Error('Neither `I` nor `do` prop was passed in <Can>');\n }\n\n if (!slots.default) {\n throw new Error('Expects to receive default slot');\n }\n\n const ability = useAbility<VueAbility>();\n\n return () => {\n const isAllowed = ability.can($props[actionProp], $props[subjectProp], $props.field);\n const canRender = props.not ? !isAllowed : isAllowed;\n\n if (!props.passThrough) {\n return canRender ? slots.default!() : null;\n }\n\n return slots.default!({\n allowed: canRender,\n ability,\n });\n };\n }\n});\n","import { App } from 'vue';\nimport { AnyAbility, PureAbility } from '@casl/ability';\nimport { ABILITY_TOKEN } from './useAbility';\nimport { reactiveAbility } from './reactiveAbility';\n\nexport interface AbilityPluginOptions {\n useGlobalProperties?: boolean\n}\n\nexport function abilitiesPlugin(app: App, ability: AnyAbility, options?: AbilityPluginOptions) {\n if (!ability || !(ability instanceof PureAbility)) {\n throw new Error('Please provide an Ability instance to abilitiesPlugin plugin');\n }\n\n app.provide(ABILITY_TOKEN, reactiveAbility(ability));\n\n if (options && options.useGlobalProperties) {\n app.config.globalProperties.$ability = ability;\n app.config.globalProperties.$can = ability.can;\n }\n}\n"],"names":["reactiveAbility","ability","hasOwnProperty","watcher","ref","on","value","possibleRulesFor","bind","action","subject","ABILITY_TOKEN","Symbol","useAbility","inject","Error","provideAbility","provide","detectSubjectProp","props","Can","defineComponent","name","I","String","do","a","Function","an","this","Object","not","Boolean","passThrough","field","setup","slots","$props","actionProp","subjectProp","default","isAllowed","
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/reactiveAbility.ts","../../src/useAbility.ts","../../src/component/can.ts","../../src/plugin.ts"],"sourcesContent":["import { AnyAbility, SubjectType } from '@casl/ability';\nimport { ref } from 'vue';\n\nexport function reactiveAbility(ability: AnyAbility) {\n if (ability.hasOwnProperty('possibleRulesFor')) {\n return ability;\n }\n\n const watcher = ref(true);\n ability.on('updated', () => {\n watcher.value = !watcher.value;\n });\n\n const possibleRulesFor = ability.possibleRulesFor.bind(ability);\n ability.possibleRulesFor = (action: string, subject: SubjectType) => {\n watcher.value = watcher.value; // eslint-disable-line\n return possibleRulesFor(action, subject);\n };\n ability.can = ability.can.bind(ability);\n ability.cannot = ability.cannot.bind(ability);\n\n return ability;\n}\n","import { inject, InjectionKey, provide } from 'vue';\nimport type { AnyAbility, Ability } from '@casl/ability';\nimport { reactiveAbility } from './reactiveAbility';\n\nexport const ABILITY_TOKEN: InjectionKey<Ability> = Symbol('ability');\n\nexport function useAbility<T extends AnyAbility = Ability>(): T {\n const ability = inject<T>(ABILITY_TOKEN);\n\n if (!ability) {\n throw new Error('Cannot inject Ability instance because it was not provided');\n }\n\n return ability;\n}\n\nexport function provideAbility(ability: AnyAbility) {\n provide(ABILITY_TOKEN, reactiveAbility(ability));\n}\n","import { defineComponent, ComponentCustomProperties } from 'vue';\nimport {\n SubjectType,\n Generics,\n AnyAbility,\n Ability,\n Abilities,\n IfString,\n AbilityTuple,\n} from '@casl/ability';\nimport { useAbility } from '../useAbility';\n\ntype AbilityCanProps<\n T extends Abilities,\n Else = IfString<T, { do: T } | { I: T }>\n> = T extends AbilityTuple\n ? { do: T[0], on: T[1], field?: string } |\n { I: T[0], a: Extract<T[1], SubjectType>, field?: string } |\n { I: T[0], an: Extract<T[1], SubjectType>, field?: string } |\n { I: T[0], this: Exclude<T[1], SubjectType>, field?: string }\n : Else;\n\nexport type CanProps<T extends AnyAbility> = AbilityCanProps<Generics<T>['abilities']> & {\n not?: boolean,\n passThrough?: boolean\n};\n\ntype VueAbility = ComponentCustomProperties extends { $ability: AnyAbility }\n ? ComponentCustomProperties['$ability']\n : Ability;\n\nfunction detectSubjectProp(props: Record<string, unknown>) {\n if ('a' in props) {\n return 'a';\n }\n\n if ('this' in props) {\n return 'this';\n }\n\n if ('an' in props) {\n return 'an';\n }\n\n return '';\n}\n\nexport const Can = defineComponent<CanProps<VueAbility>>({\n name: 'Can',\n props: {\n I: String,\n do: String,\n a: [String, Function],\n an: [String, Function],\n this: [String, Function, Object],\n on: [String, Function, Object],\n not: Boolean,\n passThrough: Boolean,\n field: String\n } as any,\n setup(props, { slots }) {\n const $props = props as Record<string, any>;\n let actionProp = 'do';\n let subjectProp = 'on';\n\n if (!(actionProp in props)) {\n actionProp = 'I';\n subjectProp = detectSubjectProp(props);\n }\n\n if (!$props[actionProp]) {\n throw new Error('Neither `I` nor `do` prop was passed in <Can>');\n }\n\n if (!slots.default) {\n throw new Error('Expects to receive default slot');\n }\n\n const ability = useAbility<VueAbility>();\n\n return () => {\n const isAllowed = ability.can($props[actionProp], $props[subjectProp], $props.field);\n const canRender = props.not ? !isAllowed : isAllowed;\n\n if (!props.passThrough) {\n return canRender ? slots.default!() : null;\n }\n\n return slots.default!({\n allowed: canRender,\n ability,\n });\n };\n }\n});\n","import { App } from 'vue';\nimport { AnyAbility, PureAbility } from '@casl/ability';\nimport { ABILITY_TOKEN } from './useAbility';\nimport { reactiveAbility } from './reactiveAbility';\n\nexport interface AbilityPluginOptions {\n useGlobalProperties?: boolean\n}\n\nexport function abilitiesPlugin(app: App, ability: AnyAbility, options?: AbilityPluginOptions) {\n if (!ability || !(ability instanceof PureAbility)) {\n throw new Error('Please provide an Ability instance to abilitiesPlugin plugin');\n }\n\n app.provide(ABILITY_TOKEN, reactiveAbility(ability));\n\n if (options && options.useGlobalProperties) {\n app.config.globalProperties.$ability = ability;\n app.config.globalProperties.$can = ability.can.bind(ability);\n }\n}\n"],"names":["reactiveAbility","ability","hasOwnProperty","watcher","ref","on","value","possibleRulesFor","bind","action","subject","can","cannot","ABILITY_TOKEN","Symbol","useAbility","inject","Error","provideAbility","provide","detectSubjectProp","props","Can","defineComponent","name","I","String","do","a","Function","an","this","Object","not","Boolean","passThrough","field","setup","slots","$props","actionProp","subjectProp","default","isAllowed","canRender","allowed","abilitiesPlugin","app","options","PureAbility","useGlobalProperties","config","globalProperties","$ability","$can"],"mappings":"0VAGO,SAASA,gBAAgBC,MAC1BA,EAAQC,eAAe,2BAClBD,MAGHE,EAAUC,MAAI,MACpBH,EAAQI,GAAG,WAAW,WACpBF,EAAQG,OAASH,EAAQG,aAGrBC,EAAmBN,EAAQM,iBAAiBC,KAAKP,GACvDA,EAAQM,iBAAmB,SAACE,EAAgBC,GAC1CP,EAAQG,MAAQH,EAAQG,aACjBC,EAAiBE,EAAQC,IAElCT,EAAQU,IAAMV,EAAQU,IAAIH,KAAKP,GAC/BA,EAAQW,OAASX,EAAQW,OAAOJ,KAAKP,UAE9BA,MCjBIY,EAAuCC,OAAO,WAEpD,SAASC,iBACRd,EAAUe,SAAUH,OAErBZ,QACG,IAAIgB,MAAM,qEAGXhB,EAGF,SAASiB,eAAejB,GAC7BkB,UAAQN,EAAeb,gBAAgBC,ICczC,SAASmB,EAAkBC,MACrB,MAAOA,QACF,OAGL,SAAUA,QACL,UAGL,OAAQA,QACH,WAGF,OAGIC,EAAMC,kBAAsC,CACvDC,KAAM,MACNH,MAAO,CACLI,EAAGC,OACHC,GAAID,OACJE,EAAG,CAACF,OAAQG,UACZC,GAAI,CAACJ,OAAQG,UACbE,KAAM,CAACL,OAAQG,SAAUG,QACzB3B,GAAI,CAACqB,OAAQG,SAAUG,QACvBC,IAAKC,QACLC,YAAaD,QACbE,MAAOV,QAETW,iBAAMhB,SAASiB,IAAAA,UACPC,EAASlB,MACXmB,EAAa,SACbC,EAAc,UAEZD,KAAcnB,GAAQ,CAC1BmB,EAAa,IACbC,EAAcrB,EAAkBC,OAG7BkB,EAAOC,SACJ,IAAIvB,MAAM,qDAGbqB,EAAMI,cACH,IAAIzB,MAAM,uCAGZhB,EAAUc,oBAET,eACC4B,EAAY1C,EAAQU,IAAI4B,EAAOC,GAAaD,EAAOE,GAAcF,EAAOH,WACxEQ,EAAYvB,EAAMY,KAAOU,EAAYA,MAEtCtB,EAAMc,mBACFS,EAAYN,EAAMI,UAAa,YAGjCJ,EAAMI,QAAS,CACpBG,QAASD,EACT3C,QAAAA,QCjFD,SAAS6C,EAAgBC,EAAU9C,EAAqB+C,OACxD/C,KAAaA,aAAmBgD,qBAC7B,IAAIhC,MAAM,gEAGlB8B,EAAI5B,QAAQN,EAAeb,gBAAgBC,OAEvC+C,GAAWA,EAAQE,oBAAqB,CAC1CH,EAAII,OAAOC,iBAAiBC,SAAWpD,EACvC8C,EAAII,OAAOC,iBAAiBE,KAAOrD,EAAQU,IAAIH,KAAKP"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@casl/vue",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "Vue plugin for CASL which makes it easy to add permissions in any Vue application",
|
|
5
5
|
"main": "dist/umd/index.js",
|
|
6
6
|
"module": "dist/es5m/index.js",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
|
-
"url": "https://github.com/stalniy/casl.git"
|
|
17
|
+
"url": "https://github.com/stalniy/casl.git",
|
|
18
|
+
"directory": "packages/casl-vue"
|
|
18
19
|
},
|
|
19
20
|
"homepage": "https://casl.js.org",
|
|
20
21
|
"publishConfig": {
|
|
@@ -39,12 +40,13 @@
|
|
|
39
40
|
"author": "Sergii Stotskyi <sergiy.stotskiy@gmail.com>",
|
|
40
41
|
"license": "MIT",
|
|
41
42
|
"peerDependencies": {
|
|
42
|
-
"@casl/ability": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.1.0",
|
|
43
|
+
"@casl/ability": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.1.0 || ^6.0.0",
|
|
43
44
|
"vue": "^3.0.0"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
|
-
"@casl/ability": "^
|
|
47
|
+
"@casl/ability": "^6.0.0",
|
|
47
48
|
"@casl/dx": "workspace:^1.0.0",
|
|
49
|
+
"@types/jest": "^26.0.22",
|
|
48
50
|
"chai": "^4.1.0",
|
|
49
51
|
"chai-spies": "^1.0.0",
|
|
50
52
|
"vue": "^3.0.5"
|
package/CHANGELOG.md
DELETED
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
5
|
-
# [2.1.0](https://github.com/stalniy/casl/compare/@casl/vue@2.0.2...@casl/vue@2.1.0) (2021-05-12)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
### Bug Fixes
|
|
9
|
-
|
|
10
|
-
* adjusts package tags to improve discoverability ([73e88b0](https://github.com/stalniy/casl/commit/73e88b0a256625b193b2cd9dc4a219f2e1193cbc))
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
### Features
|
|
14
|
-
|
|
15
|
-
* **prisma:** adds prisma integration ([#505](https://github.com/stalniy/casl/issues/505)) ([9f91ac4](https://github.com/stalniy/casl/commit/9f91ac403f05c8fac5229b1c9e243909379efbc6)), closes [#161](https://github.com/stalniy/casl/issues/161) [#161](https://github.com/stalniy/casl/issues/161)
|
|
16
|
-
|
|
17
|
-
## [2.0.2](https://github.com/stalniy/casl/compare/@casl/vue@2.0.1...@casl/vue@2.0.2) (2021-01-25)
|
|
18
|
-
|
|
19
|
-
## [2.0.1](https://github.com/stalniy/casl/compare/@casl/vue@2.0.0...@casl/vue@2.0.1) (2021-01-23)
|
|
20
|
-
|
|
21
|
-
# [2.0.0](https://github.com/stalniy/casl/compare/@casl/vue@1.2.1...@casl/vue@2.0.0) (2021-01-22)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
### Code Refactoring
|
|
25
|
-
|
|
26
|
-
* **vue:** adds support for vue 3 ([#444](https://github.com/stalniy/casl/issues/444)) ([e742bcf](https://github.com/stalniy/casl/commit/e742bcf0d187f8283ff171ec9760431759b55910)), closes [#396](https://github.com/stalniy/casl/issues/396)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
### BREAKING CHANGES
|
|
30
|
-
|
|
31
|
-
* **vue:** refactor to use Vue 3 what introduces a bunch of breaking changes:
|
|
32
|
-
|
|
33
|
-
* `Ability` instance is not a required plugin parameter. Previously, we could decide whether to pass ability as plugin parameter or as root component option. Now, the only way is to pass it in plugin:
|
|
34
|
-
|
|
35
|
-
**Before**
|
|
36
|
-
|
|
37
|
-
```js
|
|
38
|
-
import { abilitiesPlugin } from '@casl/vue';
|
|
39
|
-
import Vue from 'vue';
|
|
40
|
-
import { ability } from './services/AppAbility';
|
|
41
|
-
|
|
42
|
-
Vue.use(abilitiesPlugin);
|
|
43
|
-
new Vue({
|
|
44
|
-
ability
|
|
45
|
-
}).$mount('#app')
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
**After**
|
|
49
|
-
|
|
50
|
-
```js
|
|
51
|
-
import { abilitiesPlugin } from '@casl/vue';
|
|
52
|
-
import { createApp } from 'vue';
|
|
53
|
-
import { ability } from './services/AppAbility';
|
|
54
|
-
|
|
55
|
-
createApp()
|
|
56
|
-
.use(abilitiesPlugin, ability)
|
|
57
|
-
.mount('#app');
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
* `abilitiesPlugin` no more define global `$ability` and `$can` properties, instead a recommended way to get `AppAbility` instance is by injecting it through [provide/inject API](https://v3.vuejs.org/guide/component-provide-inject.html). To get previous behavior, pass `useGlobalProperties: true` option:
|
|
61
|
-
|
|
62
|
-
**Before**
|
|
63
|
-
|
|
64
|
-
```js
|
|
65
|
-
import { abilitiesPlugin } from '@casl/vue';
|
|
66
|
-
import Vue from 'vue';
|
|
67
|
-
import { ability } from './services/AppAbility';
|
|
68
|
-
|
|
69
|
-
Vue.use(abilitiesPlugin);
|
|
70
|
-
const root = new Vue({
|
|
71
|
-
ability
|
|
72
|
-
}).$mount('#app')
|
|
73
|
-
|
|
74
|
-
console.log(root.$ability)
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
**After**
|
|
78
|
-
|
|
79
|
-
Recommended way:
|
|
80
|
-
|
|
81
|
-
```js
|
|
82
|
-
import { abilitiesPlugin, ABILITY_TOKEN } from '@casl/vue';
|
|
83
|
-
import { createApp } from 'vue';
|
|
84
|
-
import { ability } from './services/AppAbility';
|
|
85
|
-
|
|
86
|
-
const App = {
|
|
87
|
-
name: 'App',
|
|
88
|
-
inject: {
|
|
89
|
-
$ability: { from: ABILITY_TOKEN }
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const root = createApp(App)
|
|
94
|
-
.use(abilitiesPlugin, ability, {
|
|
95
|
-
useGlobalProperties: true
|
|
96
|
-
})
|
|
97
|
-
.mount('#app');
|
|
98
|
-
|
|
99
|
-
console.log(root.$ability)
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
Backward compatible way:
|
|
103
|
-
|
|
104
|
-
```js
|
|
105
|
-
import { abilitiesPlugin } from '@casl/vue';
|
|
106
|
-
import { createApp } from 'vue';
|
|
107
|
-
import { ability } from './services/AppAbility';
|
|
108
|
-
|
|
109
|
-
const root = createApp()
|
|
110
|
-
.use(abilitiesPlugin, ability, {
|
|
111
|
-
useGlobalProperties: true
|
|
112
|
-
})
|
|
113
|
-
.mount('#app');
|
|
114
|
-
|
|
115
|
-
console.log(root.$ability)
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
* `AllCanProps<TAbility>` type was renamed to `CanProps<TAbility>`
|
|
119
|
-
|
|
120
|
-
* `@casl/vue` no more augment vue types, so if you decide to use global properties, you will need to augment types by yourself
|
|
121
|
-
|
|
122
|
-
**Before**
|
|
123
|
-
|
|
124
|
-
@casl/vue augments type of `$ability` to `AnyAbility` and `$can` to `typeof $ability['can']`
|
|
125
|
-
|
|
126
|
-
**After**
|
|
127
|
-
|
|
128
|
-
create a separate file `src/ability-shim.d.ts` with the next content:
|
|
129
|
-
|
|
130
|
-
```ts
|
|
131
|
-
import { AppAbility } from './AppAbility'
|
|
132
|
-
|
|
133
|
-
declare module 'vue' {
|
|
134
|
-
interface ComponentCustomProperties {
|
|
135
|
-
$ability: AppAbility;
|
|
136
|
-
$can(this: this, ...args: Parameters<this['$ability']['can']>): boolean;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
## [1.2.1](https://github.com/stalniy/casl/compare/@casl/vue@1.2.0...@casl/vue@1.2.1) (2020-12-28)
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
### Bug Fixes
|
|
145
|
-
|
|
146
|
-
* **dist:** adds separate `tsconfig.build.json` to every completementary project ([87742ce](https://github.com/stalniy/casl/commit/87742cec518a8a68d5fc29be2bbc9561cbc7da6c)), closes [#419](https://github.com/stalniy/casl/issues/419)
|
|
147
|
-
|
|
148
|
-
# [1.2.0](https://github.com/stalniy/casl/compare/@casl/vue@1.1.1...@casl/vue@1.2.0) (2020-12-26)
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
### Bug Fixes
|
|
152
|
-
|
|
153
|
-
* **angular:** fixes sourcemap generation for the code built by ngc ([7715263](https://github.com/stalniy/casl/commit/771526379ff8203170a433d71b68644a48ff44eb)), closes [#387](https://github.com/stalniy/casl/issues/387) [#382](https://github.com/stalniy/casl/issues/382)
|
|
154
|
-
* **package:** removes `engine` section that points to npm@6 ([eecd12a](https://github.com/stalniy/casl/commit/eecd12ac49f56d6a0f57d1a57fb37487335b5f03)), closes [#417](https://github.com/stalniy/casl/issues/417)
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
### Features
|
|
158
|
-
|
|
159
|
-
* **builder:** improves typings for AbilityBuilder [skip release] ([ebd4d17](https://github.com/stalniy/casl/commit/ebd4d17a355a2646467033118a3d6efee4321d27)), closes [#379](https://github.com/stalniy/casl/issues/379)
|
|
160
|
-
* **esm:** adds ESM support for latest Node.js through `exports` prop in package.json ([cac2506](https://github.com/stalniy/casl/commit/cac2506a80c18f194210c2d89108d1d094751fa4)), closes [#331](https://github.com/stalniy/casl/issues/331)
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
### BREAKING CHANGES
|
|
164
|
-
|
|
165
|
-
* **builder:** changes main generic parameter to be a class instead of instance and makes `defineAbility` to accept options as the 2nd argument.
|
|
166
|
-
|
|
167
|
-
**Before**
|
|
168
|
-
|
|
169
|
-
```ts
|
|
170
|
-
import { AbilityBuilder, defineAbility, Ability } from '@casl/ability';
|
|
171
|
-
|
|
172
|
-
const resolveAction = (action: string) => {/* custom implementation */ };
|
|
173
|
-
const ability = defineAbility({ resolveAction }, (can) => can('read', 'Item'));
|
|
174
|
-
const builder = new AbilityBuilder<Ability>(Ability);
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
**After**
|
|
178
|
-
|
|
179
|
-
```ts
|
|
180
|
-
import { AbilityBuilder, defineAbility, Ability } from '@casl/ability';
|
|
181
|
-
|
|
182
|
-
const resolveAction = (action: string) => {/* custom implementation */ };
|
|
183
|
-
const ability = defineAbility((can) => can('read', 'Item'), { resolveAction });
|
|
184
|
-
const builder = new AbilityBuilder(Ability); // first argument is now mandatory!
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
The 1st parameter to `AbilityBuilder` is now madatory. This allows to infer generic parameters from it and makes AbilityType that is built to be explicit.
|
|
188
|
-
|
|
189
|
-
## [1.1.1](https://github.com/stalniy/casl/compare/@casl/vue@1.1.0...@casl/vue@1.1.1) (2020-06-09)
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
### Bug Fixes
|
|
193
|
-
|
|
194
|
-
* **docs:** ensure README and docs for all packages are in sync ([8df3684](https://github.com/stalniy/casl/commit/8df3684b139de0af60c9c37f284a5028ffbf2224)), closes [#338](https://github.com/stalniy/casl/issues/338)
|
|
195
|
-
|
|
196
|
-
# [1.1.0](https://github.com/stalniy/casl/compare/@casl/vue@1.0.3...@casl/vue@1.1.0) (2020-05-12)
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
### Features
|
|
200
|
-
|
|
201
|
-
* **types:** extract vue augmentation modules into pseudo submodule ([a75296c](https://github.com/stalniy/casl/commit/a75296c3f73af432f500eb8e153cf0e7cde67796)), closes [#312](https://github.com/stalniy/casl/issues/312)
|
|
202
|
-
|
|
203
|
-
## [1.0.3](https://github.com/stalniy/casl/compare/@casl/vue@1.0.2...@casl/vue@1.0.3) (2020-04-22)
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
### Bug Fixes
|
|
207
|
-
|
|
208
|
-
* **types:** use `AnyAbility` in ComponentOptions and in Vue augmentation modules ([7f9be6f](https://github.com/stalniy/casl/commit/7f9be6f13248c1df6df1b41a6d7e2edb62928bca))
|
|
209
|
-
|
|
210
|
-
## [1.0.2](https://github.com/stalniy/casl/compare/@casl/vue@1.0.1...@casl/vue@1.0.2) (2020-04-10)
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
### Bug Fixes
|
|
214
|
-
|
|
215
|
-
* **vue:** ensure that terser doesn't mangle reserved required props ([7fa234c](https://github.com/stalniy/casl/commit/7fa234c06cc133bdffe485bfcb972dc595167899))
|
|
216
|
-
|
|
217
|
-
## [1.0.1](https://github.com/stalniy/casl/compare/@casl/vue@1.0.0...@casl/vue@1.0.1) (2020-04-09)
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
### Bug Fixes
|
|
221
|
-
|
|
222
|
-
* **vue:** removes `of` alias from `<can>` component ([bd658e2](https://github.com/stalniy/casl/commit/bd658e21a34cbea8b6b70739f533453ebf95d20a))
|
|
223
|
-
|
|
224
|
-
# [1.0.0](https://github.com/stalniy/casl/compare/@casl/vue@0.5.1...@casl/vue@1.0.0) (2020-04-09)
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
### Bug Fixes
|
|
228
|
-
|
|
229
|
-
* **vue:** adds `an` alias, so types are compatible between React and Vue ([8276942](https://github.com/stalniy/casl/commit/8276942da1660ac3eb1cd928cc80db891ed7e275)), closes [#248](https://github.com/stalniy/casl/issues/248)
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
### Features
|
|
233
|
-
|
|
234
|
-
* **ability:** updates typings for vue ([8ac4ca1](https://github.com/stalniy/casl/commit/8ac4ca14a59ed87bc0f84a853466418e6a74cd74)), closes [#256](https://github.com/stalniy/casl/issues/256)
|
|
235
|
-
* **vue:** adds better generics typying for Vue ([5cc7b60](https://github.com/stalniy/casl/commit/5cc7b60d8a2a53db217f8ad1a4673a28f67aefce)), closes [#107](https://github.com/stalniy/casl/issues/107)
|
|
236
|
-
* **vue:** migrates vue to typescript ([7bacadd](https://github.com/stalniy/casl/commit/7bacadd8878afe14898929ebeb7c3efd9af88d3c)), closes [#248](https://github.com/stalniy/casl/issues/248)
|
|
237
|
-
* **vue:** throws exception if `Ability` is not provided ([aacd952](https://github.com/stalniy/casl/commit/aacd9520cfd3a35ea2dc3f44e8043734494f3c2a)), closes [#248](https://github.com/stalniy/casl/issues/248)
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
### BREAKING CHANGES
|
|
241
|
-
|
|
242
|
-
* **typescript:** weak hand written declaration files are removed as `@casl/vue` has been completely rewritten to TypeScript. TypeScript now checks that you correctly use property aliases
|
|
243
|
-
* **Can:** `of` alias is removed and field was extracted to a separate prop
|
|
244
|
-
|
|
245
|
-
**Before**
|
|
246
|
-
|
|
247
|
-
```html
|
|
248
|
-
<can I="read title" of="Post">...</can>
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
**After**
|
|
252
|
-
|
|
253
|
-
```html
|
|
254
|
-
<can I="read" a="Post" field="title">...</can>
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
# [@casl/vue-v0.5.1](https://github.com/stalniy/casl/compare/@casl/vue@0.5.0...@casl/vue@0.5.1) (2019-02-10)
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
### Bug Fixes
|
|
261
|
-
|
|
262
|
-
* **packages:** increases peerDependency of [@casl](https://github.com/casl)/ability ([9f6a7b8](https://github.com/stalniy/casl/commit/9f6a7b8)), closes [#119](https://github.com/stalniy/casl/issues/119)
|
|
263
|
-
|
|
264
|
-
# [@casl/vue-v0.5.0](https://github.com/stalniy/casl/compare/@casl/vue@0.4.3...@casl/vue@0.5.0) (2018-11-25)
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
### Bug Fixes
|
|
268
|
-
|
|
269
|
-
* **README:** changes links to [@casl](https://github.com/casl)/ability to point to npm package instead to git root [skip ci] ([a74086b](https://github.com/stalniy/casl/commit/a74086b)), closes [#102](https://github.com/stalniy/casl/issues/102)
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
### Features
|
|
273
|
-
|
|
274
|
-
* **react:can:** updates typescript declarations ([213dcde](https://github.com/stalniy/casl/commit/213dcde))
|
|
275
|
-
* **vue:** adds `passThrough` prop to `Can` ([28ca883](https://github.com/stalniy/casl/commit/28ca883)), closes [#105](https://github.com/stalniy/casl/issues/105)
|
|
276
|
-
|
|
277
|
-
<a name="@casl/vue-v0.4.3"></a>
|
|
278
|
-
# [@casl/vue-v0.4.3](https://github.com/stalniy/casl/compare/@casl/vue@0.4.2...@casl/vue@0.4.3) (2018-07-14)
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
### Bug Fixes
|
|
282
|
-
|
|
283
|
-
* **vue:** fixes ts declaration for `abilitiesPlugin` ([7d8e9ca](https://github.com/stalniy/casl/commit/7d8e9ca)), closes [#92](https://github.com/stalniy/casl/issues/92)
|
|
284
|
-
|
|
285
|
-
<a name="@casl/vue-v0.4.2"></a>
|
|
286
|
-
# [@casl/vue-v0.4.2](https://github.com/stalniy/casl/compare/@casl/vue@0.4.1...@casl/vue@0.4.2) (2018-07-02)
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
### Bug Fixes
|
|
290
|
-
|
|
291
|
-
* **package:** changes location of ES5M modules ([2b1ad4e](https://github.com/stalniy/casl/commit/2b1ad4e)), closes [#89](https://github.com/stalniy/casl/issues/89)
|
|
292
|
-
|
|
293
|
-
<a name="@casl/vue-v0.4.1"></a>
|
|
294
|
-
# [@casl/vue-v0.4.1](https://github.com/stalniy/casl/compare/@casl/vue@0.4.0...@casl/vue@0.4.1) (2018-06-04)
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
### Bug Fixes
|
|
298
|
-
|
|
299
|
-
* **vue:** extends `ComponentOptions` with `ability` member ([#73](https://github.com/stalniy/casl/issues/73)) ([94d4c24](https://github.com/stalniy/casl/commit/94d4c24))
|
|
300
|
-
|
|
301
|
-
<a name="@casl/vue-v0.4.0"></a>
|
|
302
|
-
# [@casl/vue-v0.4.0](https://github.com/stalniy/casl/compare/@casl/vue@0.3.0...@casl/vue@0.4.0) (2018-06-01)
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
### Features
|
|
306
|
-
|
|
307
|
-
* **vue:** pass ability down components tree ([28e3d8d](https://github.com/stalniy/casl/commit/28e3d8d)), closes [#72](https://github.com/stalniy/casl/issues/72)
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
<a name="@casl/vue-v0.3.0"></a>
|
|
311
|
-
# [@casl/vue-v0.3.0](https://github.com/stalniy/casl/compare/@casl/vue@0.2.1...@casl/vue@0.3.0) (2018-05-30)
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
### Features
|
|
315
|
-
|
|
316
|
-
* **vue:** adds can component ([42ee540](https://github.com/stalniy/casl/commit/42ee540)), closes [#63](https://github.com/stalniy/casl/issues/63)
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
<a name="@casl/vue-v0.2.1"></a>
|
|
320
|
-
# [@casl/vue-v0.2.1](https://github.com/stalniy/casl/compare/@casl/vue@0.2.0...@casl/vue@0.2.1) (2018-05-29)
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
### Bug Fixes
|
|
324
|
-
|
|
325
|
-
* **vue:** fixes issue with wrong type definition for `abilitiesPlugin` ([a7e2251](https://github.com/stalniy/casl/commit/a7e2251))
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
<a name="0.2.0"></a>
|
|
329
|
-
# 0.2.0 (2018-04-16)
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
### Features
|
|
333
|
-
|
|
334
|
-
* **vue:** adds typescript definitions ([a7eac4b](https://github.com/stalniy/casl/commit/a7eac4b)), closes [#38](https://github.com/stalniy/casl/issues/38)
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
<a name="0.1.0"></a>
|
|
338
|
-
# 0.1.0 (2018-03-23)
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
### Features
|
|
342
|
-
|
|
343
|
-
* **integration:** adds new folder for vue integration, closes [#22](https://github.com/stalniy/casl/issues/22)
|
|
344
|
-
* **vue:** adds empty ability instance in case if such is not provided ([a971f05](https://github.com/stalniy/casl/commit/a971f05))
|
|
345
|
-
* **ability:** adds reactivity to ability rules
|