@casl/vue 2.1.2 → 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.
@@ -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<Record<string | number | symbol, unknown>>>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{} & {
28
- on?: string | Record<string | number | symbol, any> | import("@casl/ability").SubjectClass<string> | undefined;
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
- }> | Readonly<{} & {
34
- a?: string | import("@casl/ability").SubjectClass<string> | undefined;
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
- }> | Readonly<{} & {
39
+ }) | ({} & {
40
40
  I?: string | undefined;
41
41
  field?: string | undefined;
42
- an?: string | import("@casl/ability").SubjectClass<string> | undefined;
42
+ an?: SubjectType | undefined;
43
43
  not?: boolean | undefined;
44
44
  passThrough?: boolean | undefined;
45
- }> | Readonly<{} & {
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@casl/vue",
3
- "version": "2.1.2",
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": "^5.1.0",
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,354 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- ## [2.1.2](https://github.com/stalniy/casl/compare/@casl/vue@2.1.1...@casl/vue@2.1.2) (2021-10-07)
6
-
7
-
8
- ### Bug Fixes
9
-
10
- * **vue:** makes sure Abilities `can` and `cannot` methods are bound ([86f9157](https://github.com/stalniy/casl/commit/86f91570d3e1709449cfded37c153fb21e56c474)), closes [#530](https://github.com/stalniy/casl/issues/530)
11
-
12
- ## [2.1.1](https://github.com/stalniy/casl/compare/@casl/vue@2.1.0...@casl/vue@2.1.1) (2021-07-05)
13
-
14
-
15
- ### Bug Fixes
16
-
17
- * **vue:** binds ability to $can method ([cbb3c13](https://github.com/stalniy/casl/commit/cbb3c133c3d9583e6fdbc95c068e2e6343befdc9)), closes [#522](https://github.com/stalniy/casl/issues/522)
18
-
19
- # [2.1.0](https://github.com/stalniy/casl/compare/@casl/vue@2.0.2...@casl/vue@2.1.0) (2021-05-12)
20
-
21
-
22
- ### Bug Fixes
23
-
24
- * adjusts package tags to improve discoverability ([73e88b0](https://github.com/stalniy/casl/commit/73e88b0a256625b193b2cd9dc4a219f2e1193cbc))
25
-
26
- ## [2.0.2](https://github.com/stalniy/casl/compare/@casl/vue@2.0.1...@casl/vue@2.0.2) (2021-01-25)
27
-
28
- ## [2.0.1](https://github.com/stalniy/casl/compare/@casl/vue@2.0.0...@casl/vue@2.0.1) (2021-01-23)
29
-
30
- # [2.0.0](https://github.com/stalniy/casl/compare/@casl/vue@1.2.1...@casl/vue@2.0.0) (2021-01-22)
31
-
32
-
33
- ### Code Refactoring
34
-
35
- * **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)
36
-
37
-
38
- ### BREAKING CHANGES
39
-
40
- * **vue:** refactor to use Vue 3 what introduces a bunch of breaking changes:
41
-
42
- * `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:
43
-
44
- **Before**
45
-
46
- ```js
47
- import { abilitiesPlugin } from '@casl/vue';
48
- import Vue from 'vue';
49
- import { ability } from './services/AppAbility';
50
-
51
- Vue.use(abilitiesPlugin);
52
- new Vue({
53
- ability
54
- }).$mount('#app')
55
- ```
56
-
57
- **After**
58
-
59
- ```js
60
- import { abilitiesPlugin } from '@casl/vue';
61
- import { createApp } from 'vue';
62
- import { ability } from './services/AppAbility';
63
-
64
- createApp()
65
- .use(abilitiesPlugin, ability)
66
- .mount('#app');
67
- ```
68
-
69
- * `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:
70
-
71
- **Before**
72
-
73
- ```js
74
- import { abilitiesPlugin } from '@casl/vue';
75
- import Vue from 'vue';
76
- import { ability } from './services/AppAbility';
77
-
78
- Vue.use(abilitiesPlugin);
79
- const root = new Vue({
80
- ability
81
- }).$mount('#app')
82
-
83
- console.log(root.$ability)
84
- ```
85
-
86
- **After**
87
-
88
- Recommended way:
89
-
90
- ```js
91
- import { abilitiesPlugin, ABILITY_TOKEN } from '@casl/vue';
92
- import { createApp } from 'vue';
93
- import { ability } from './services/AppAbility';
94
-
95
- const App = {
96
- name: 'App',
97
- inject: {
98
- $ability: { from: ABILITY_TOKEN }
99
- }
100
- };
101
-
102
- const root = createApp(App)
103
- .use(abilitiesPlugin, ability, {
104
- useGlobalProperties: true
105
- })
106
- .mount('#app');
107
-
108
- console.log(root.$ability)
109
- ```
110
-
111
- Backward compatible way:
112
-
113
- ```js
114
- import { abilitiesPlugin } from '@casl/vue';
115
- import { createApp } from 'vue';
116
- import { ability } from './services/AppAbility';
117
-
118
- const root = createApp()
119
- .use(abilitiesPlugin, ability, {
120
- useGlobalProperties: true
121
- })
122
- .mount('#app');
123
-
124
- console.log(root.$ability)
125
- ```
126
-
127
- * `AllCanProps<TAbility>` type was renamed to `CanProps<TAbility>`
128
-
129
- * `@casl/vue` no more augment vue types, so if you decide to use global properties, you will need to augment types by yourself
130
-
131
- **Before**
132
-
133
- @casl/vue augments type of `$ability` to `AnyAbility` and `$can` to `typeof $ability['can']`
134
-
135
- **After**
136
-
137
- create a separate file `src/ability-shim.d.ts` with the next content:
138
-
139
- ```ts
140
- import { AppAbility } from './AppAbility'
141
-
142
- declare module 'vue' {
143
- interface ComponentCustomProperties {
144
- $ability: AppAbility;
145
- $can(this: this, ...args: Parameters<this['$ability']['can']>): boolean;
146
- }
147
- }
148
- ```
149
-
150
- ## [1.2.1](https://github.com/stalniy/casl/compare/@casl/vue@1.2.0...@casl/vue@1.2.1) (2020-12-28)
151
-
152
-
153
- ### Bug Fixes
154
-
155
- * **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)
156
-
157
- # [1.2.0](https://github.com/stalniy/casl/compare/@casl/vue@1.1.1...@casl/vue@1.2.0) (2020-12-26)
158
-
159
-
160
- ### Bug Fixes
161
-
162
- * **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)
163
- * **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)
164
-
165
-
166
- ### Features
167
-
168
- * **builder:** improves typings for AbilityBuilder [skip release] ([ebd4d17](https://github.com/stalniy/casl/commit/ebd4d17a355a2646467033118a3d6efee4321d27)), closes [#379](https://github.com/stalniy/casl/issues/379)
169
- * **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)
170
-
171
-
172
- ### BREAKING CHANGES
173
-
174
- * **builder:** changes main generic parameter to be a class instead of instance and makes `defineAbility` to accept options as the 2nd argument.
175
-
176
- **Before**
177
-
178
- ```ts
179
- import { AbilityBuilder, defineAbility, Ability } from '@casl/ability';
180
-
181
- const resolveAction = (action: string) => {/* custom implementation */ };
182
- const ability = defineAbility({ resolveAction }, (can) => can('read', 'Item'));
183
- const builder = new AbilityBuilder<Ability>(Ability);
184
- ```
185
-
186
- **After**
187
-
188
- ```ts
189
- import { AbilityBuilder, defineAbility, Ability } from '@casl/ability';
190
-
191
- const resolveAction = (action: string) => {/* custom implementation */ };
192
- const ability = defineAbility((can) => can('read', 'Item'), { resolveAction });
193
- const builder = new AbilityBuilder(Ability); // first argument is now mandatory!
194
- ```
195
-
196
- 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.
197
-
198
- ## [1.1.1](https://github.com/stalniy/casl/compare/@casl/vue@1.1.0...@casl/vue@1.1.1) (2020-06-09)
199
-
200
-
201
- ### Bug Fixes
202
-
203
- * **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)
204
-
205
- # [1.1.0](https://github.com/stalniy/casl/compare/@casl/vue@1.0.3...@casl/vue@1.1.0) (2020-05-12)
206
-
207
-
208
- ### Features
209
-
210
- * **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)
211
-
212
- ## [1.0.3](https://github.com/stalniy/casl/compare/@casl/vue@1.0.2...@casl/vue@1.0.3) (2020-04-22)
213
-
214
-
215
- ### Bug Fixes
216
-
217
- * **types:** use `AnyAbility` in ComponentOptions and in Vue augmentation modules ([7f9be6f](https://github.com/stalniy/casl/commit/7f9be6f13248c1df6df1b41a6d7e2edb62928bca))
218
-
219
- ## [1.0.2](https://github.com/stalniy/casl/compare/@casl/vue@1.0.1...@casl/vue@1.0.2) (2020-04-10)
220
-
221
-
222
- ### Bug Fixes
223
-
224
- * **vue:** ensure that terser doesn't mangle reserved required props ([7fa234c](https://github.com/stalniy/casl/commit/7fa234c06cc133bdffe485bfcb972dc595167899))
225
-
226
- ## [1.0.1](https://github.com/stalniy/casl/compare/@casl/vue@1.0.0...@casl/vue@1.0.1) (2020-04-09)
227
-
228
-
229
- ### Bug Fixes
230
-
231
- * **vue:** removes `of` alias from `<can>` component ([bd658e2](https://github.com/stalniy/casl/commit/bd658e21a34cbea8b6b70739f533453ebf95d20a))
232
-
233
- # [1.0.0](https://github.com/stalniy/casl/compare/@casl/vue@0.5.1...@casl/vue@1.0.0) (2020-04-09)
234
-
235
-
236
- ### Bug Fixes
237
-
238
- * **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)
239
-
240
-
241
- ### Features
242
-
243
- * **ability:** updates typings for vue ([8ac4ca1](https://github.com/stalniy/casl/commit/8ac4ca14a59ed87bc0f84a853466418e6a74cd74)), closes [#256](https://github.com/stalniy/casl/issues/256)
244
- * **vue:** adds better generics typying for Vue ([5cc7b60](https://github.com/stalniy/casl/commit/5cc7b60d8a2a53db217f8ad1a4673a28f67aefce)), closes [#107](https://github.com/stalniy/casl/issues/107)
245
- * **vue:** migrates vue to typescript ([7bacadd](https://github.com/stalniy/casl/commit/7bacadd8878afe14898929ebeb7c3efd9af88d3c)), closes [#248](https://github.com/stalniy/casl/issues/248)
246
- * **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)
247
-
248
-
249
- ### BREAKING CHANGES
250
-
251
- * **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
252
- * **Can:** `of` alias is removed and field was extracted to a separate prop
253
-
254
- **Before**
255
-
256
- ```html
257
- <can I="read title" of="Post">...</can>
258
- ```
259
-
260
- **After**
261
-
262
- ```html
263
- <can I="read" a="Post" field="title">...</can>
264
- ```
265
-
266
- # [@casl/vue-v0.5.1](https://github.com/stalniy/casl/compare/@casl/vue@0.5.0...@casl/vue@0.5.1) (2019-02-10)
267
-
268
-
269
- ### Bug Fixes
270
-
271
- * **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)
272
-
273
- # [@casl/vue-v0.5.0](https://github.com/stalniy/casl/compare/@casl/vue@0.4.3...@casl/vue@0.5.0) (2018-11-25)
274
-
275
-
276
- ### Bug Fixes
277
-
278
- * **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)
279
-
280
-
281
- ### Features
282
-
283
- * **react:can:** updates typescript declarations ([213dcde](https://github.com/stalniy/casl/commit/213dcde))
284
- * **vue:** adds `passThrough` prop to `Can` ([28ca883](https://github.com/stalniy/casl/commit/28ca883)), closes [#105](https://github.com/stalniy/casl/issues/105)
285
-
286
- <a name="@casl/vue-v0.4.3"></a>
287
- # [@casl/vue-v0.4.3](https://github.com/stalniy/casl/compare/@casl/vue@0.4.2...@casl/vue@0.4.3) (2018-07-14)
288
-
289
-
290
- ### Bug Fixes
291
-
292
- * **vue:** fixes ts declaration for `abilitiesPlugin` ([7d8e9ca](https://github.com/stalniy/casl/commit/7d8e9ca)), closes [#92](https://github.com/stalniy/casl/issues/92)
293
-
294
- <a name="@casl/vue-v0.4.2"></a>
295
- # [@casl/vue-v0.4.2](https://github.com/stalniy/casl/compare/@casl/vue@0.4.1...@casl/vue@0.4.2) (2018-07-02)
296
-
297
-
298
- ### Bug Fixes
299
-
300
- * **package:** changes location of ES5M modules ([2b1ad4e](https://github.com/stalniy/casl/commit/2b1ad4e)), closes [#89](https://github.com/stalniy/casl/issues/89)
301
-
302
- <a name="@casl/vue-v0.4.1"></a>
303
- # [@casl/vue-v0.4.1](https://github.com/stalniy/casl/compare/@casl/vue@0.4.0...@casl/vue@0.4.1) (2018-06-04)
304
-
305
-
306
- ### Bug Fixes
307
-
308
- * **vue:** extends `ComponentOptions` with `ability` member ([#73](https://github.com/stalniy/casl/issues/73)) ([94d4c24](https://github.com/stalniy/casl/commit/94d4c24))
309
-
310
- <a name="@casl/vue-v0.4.0"></a>
311
- # [@casl/vue-v0.4.0](https://github.com/stalniy/casl/compare/@casl/vue@0.3.0...@casl/vue@0.4.0) (2018-06-01)
312
-
313
-
314
- ### Features
315
-
316
- * **vue:** pass ability down components tree ([28e3d8d](https://github.com/stalniy/casl/commit/28e3d8d)), closes [#72](https://github.com/stalniy/casl/issues/72)
317
-
318
-
319
- <a name="@casl/vue-v0.3.0"></a>
320
- # [@casl/vue-v0.3.0](https://github.com/stalniy/casl/compare/@casl/vue@0.2.1...@casl/vue@0.3.0) (2018-05-30)
321
-
322
-
323
- ### Features
324
-
325
- * **vue:** adds can component ([42ee540](https://github.com/stalniy/casl/commit/42ee540)), closes [#63](https://github.com/stalniy/casl/issues/63)
326
-
327
-
328
- <a name="@casl/vue-v0.2.1"></a>
329
- # [@casl/vue-v0.2.1](https://github.com/stalniy/casl/compare/@casl/vue@0.2.0...@casl/vue@0.2.1) (2018-05-29)
330
-
331
-
332
- ### Bug Fixes
333
-
334
- * **vue:** fixes issue with wrong type definition for `abilitiesPlugin` ([a7e2251](https://github.com/stalniy/casl/commit/a7e2251))
335
-
336
-
337
- <a name="0.2.0"></a>
338
- # 0.2.0 (2018-04-16)
339
-
340
-
341
- ### Features
342
-
343
- * **vue:** adds typescript definitions ([a7eac4b](https://github.com/stalniy/casl/commit/a7eac4b)), closes [#38](https://github.com/stalniy/casl/issues/38)
344
-
345
-
346
- <a name="0.1.0"></a>
347
- # 0.1.0 (2018-03-23)
348
-
349
-
350
- ### Features
351
-
352
- * **integration:** adds new folder for vue integration, closes [#22](https://github.com/stalniy/casl/issues/22)
353
- * **vue:** adds empty ability instance in case if such is not provided ([a971f05](https://github.com/stalniy/casl/commit/a971f05))
354
- * **ability:** adds reactivity to ability rules