locator-ars-lib 1.0.0 → 1.0.1

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/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "locator-ars-lib",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Permissions library for Vue 3 applications",
5
5
  "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
6
+ "types": "types/index.d.ts",
7
7
  "scripts": {
8
8
  "build": "vue-tsc && vite build",
9
9
  "test": "vitest run",
package/tsconfig.json CHANGED
@@ -5,6 +5,7 @@
5
5
  "module": "ESNext",
6
6
  "lib": ["ES2020", "DOM", "DOM.Iterable"],
7
7
  "skipLibCheck": true,
8
+ "typeRoots": ["./node_modules/@types", "./types"],
8
9
 
9
10
  /* Bundler mode */
10
11
  "moduleResolution": "node",
@@ -0,0 +1,42 @@
1
+ import { App, Component, Ref, ComputedRef, ObjectDirective } from 'vue'
2
+
3
+ export interface PermissionsOptions {
4
+ baseUrl?: string
5
+ endpoint?: string
6
+ }
7
+
8
+ export interface UsePermissionsOptions {
9
+ autoCheck?: boolean
10
+ }
11
+
12
+ export interface UsePermissionsResult {
13
+ isAllowed: Ref<boolean | null>
14
+ isLoading: Ref<boolean>
15
+ error: Ref<Error | null>
16
+ check: () => Promise<void>
17
+ can: ComputedRef<boolean>
18
+ }
19
+
20
+ export class PermissionsService {
21
+ constructor(options?: PermissionsOptions)
22
+ can(action: string): Promise<boolean>
23
+ clearCache(action?: string): void
24
+ }
25
+
26
+ export const Check: Component
27
+ export const vCan: ObjectDirective
28
+
29
+ export function usePermissions(
30
+ action: string | Ref<string>,
31
+ options?: UsePermissionsOptions
32
+ ): UsePermissionsResult
33
+
34
+ export function setupPermissions(
35
+ options?: PermissionsOptions
36
+ ): PermissionsService
37
+
38
+ declare const _default: {
39
+ install(app: App, options?: PermissionsOptions): void
40
+ }
41
+
42
+ export default _default
@@ -0,0 +1,44 @@
1
+ declare module 'locator-ars-lib' {
2
+ import { App, Component, Ref, ComputedRef, ObjectDirective } from 'vue'
3
+
4
+ export interface PermissionsOptions {
5
+ baseUrl?: string
6
+ endpoint?: string
7
+ }
8
+
9
+ export interface UsePermissionsOptions {
10
+ autoCheck?: boolean
11
+ }
12
+
13
+ export interface UsePermissionsResult {
14
+ isAllowed: Ref<boolean | null>
15
+ isLoading: Ref<boolean>
16
+ error: Ref<Error | null>
17
+ check: () => Promise<void>
18
+ can: ComputedRef<boolean>
19
+ }
20
+
21
+ export class PermissionsService {
22
+ constructor(options?: PermissionsOptions)
23
+ can(action: string): Promise<boolean>
24
+ clearCache(action?: string): void
25
+ }
26
+
27
+ export const Check: Component
28
+ export const vCan: ObjectDirective
29
+
30
+ export function usePermissions(
31
+ action: string | Ref<string>,
32
+ options?: UsePermissionsOptions
33
+ ): UsePermissionsResult
34
+
35
+ export function setupPermissions(
36
+ options?: PermissionsOptions
37
+ ): PermissionsService
38
+
39
+ const plugin: {
40
+ install(app: App, options?: PermissionsOptions): void
41
+ }
42
+
43
+ export default plugin
44
+ }