@innertia-solutions/innertia-nuxt 0.1.21 → 0.1.22
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/composables/useEntity.js
CHANGED
|
@@ -37,12 +37,12 @@ export function useEntity() {
|
|
|
37
37
|
|
|
38
38
|
const list = (params = {}) => useQuery({
|
|
39
39
|
queryKey: computed(() => ['entities', toValue(params)]),
|
|
40
|
-
queryFn: () => api.post('
|
|
40
|
+
queryFn: () => api.post('entities', toValue(params)),
|
|
41
41
|
})
|
|
42
42
|
|
|
43
43
|
const detail = (id) => useQuery({
|
|
44
44
|
queryKey: computed(() => ['entities', toValue(id)]),
|
|
45
|
-
queryFn: () => api.get(`
|
|
45
|
+
queryFn: () => api.get(`entities/${toValue(id)}`),
|
|
46
46
|
enabled: computed(() => !!toValue(id)),
|
|
47
47
|
})
|
|
48
48
|
|
|
@@ -51,12 +51,12 @@ export function useEntity() {
|
|
|
51
51
|
const invalidate = () => queryClient.invalidateQueries({ queryKey: ['entities'] })
|
|
52
52
|
|
|
53
53
|
const create = () => useMutation({
|
|
54
|
-
mutationFn: (data) => api.post('
|
|
54
|
+
mutationFn: (data) => api.post('entities', data),
|
|
55
55
|
onSuccess: invalidate,
|
|
56
56
|
})
|
|
57
57
|
|
|
58
58
|
const update = () => useMutation({
|
|
59
|
-
mutationFn: ({ id, ...data }) => api.put(`
|
|
59
|
+
mutationFn: ({ id, ...data }) => api.put(`entities/${id}`, data),
|
|
60
60
|
onSuccess: (_, { id }) => {
|
|
61
61
|
queryClient.invalidateQueries({ queryKey: ['entities', id] })
|
|
62
62
|
invalidate()
|
|
@@ -64,14 +64,14 @@ export function useEntity() {
|
|
|
64
64
|
})
|
|
65
65
|
|
|
66
66
|
const remove = () => useMutation({
|
|
67
|
-
mutationFn: (id) => api.delete(`
|
|
67
|
+
mutationFn: (id) => api.delete(`entities/${id}`),
|
|
68
68
|
onSuccess: invalidate,
|
|
69
69
|
})
|
|
70
70
|
|
|
71
71
|
// Agregar acciones adicionales siguiendo el mismo patrón:
|
|
72
72
|
//
|
|
73
73
|
// const activate = () => useMutation({
|
|
74
|
-
// mutationFn: (id) => api.post(`
|
|
74
|
+
// mutationFn: (id) => api.post(`entities/${id}/activate`),
|
|
75
75
|
// onSuccess: invalidate,
|
|
76
76
|
// })
|
|
77
77
|
|
|
@@ -17,7 +17,7 @@ export function usePermissions() {
|
|
|
17
17
|
const hasAll = (permissions) => permissions.every(p => authStore.permissions.includes(p))
|
|
18
18
|
|
|
19
19
|
/** Fetch all permission groups from backoffice — returns [{ category, category_alias, permissions[] }] */
|
|
20
|
-
const all = (params = {}) => api.get('
|
|
20
|
+
const all = (params = {}) => api.get('permissions', { params })
|
|
21
21
|
|
|
22
22
|
return { can, hasRole, hasAny, hasAll, all }
|
|
23
23
|
}
|
package/composables/useRoles.js
CHANGED
|
@@ -6,12 +6,12 @@ export function useRoles() {
|
|
|
6
6
|
|
|
7
7
|
const list = (params = {}) => useQuery({
|
|
8
8
|
queryKey: computed(() => ['roles', toValue(params)]),
|
|
9
|
-
queryFn: () => api.post('
|
|
9
|
+
queryFn: () => api.post('roles', toValue(params)),
|
|
10
10
|
})
|
|
11
11
|
|
|
12
12
|
const detail = (id) => useQuery({
|
|
13
13
|
queryKey: computed(() => ['roles', toValue(id)]),
|
|
14
|
-
queryFn: () => api.get(`
|
|
14
|
+
queryFn: () => api.get(`roles/${toValue(id)}`),
|
|
15
15
|
enabled: computed(() => !!toValue(id)),
|
|
16
16
|
})
|
|
17
17
|
|
|
@@ -20,12 +20,12 @@ export function useRoles() {
|
|
|
20
20
|
const invalidateRoles = () => queryClient.invalidateQueries({ queryKey: ['roles'] })
|
|
21
21
|
|
|
22
22
|
const create = () => useMutation({
|
|
23
|
-
mutationFn: (data) => api.post('
|
|
23
|
+
mutationFn: (data) => api.post('roles', data),
|
|
24
24
|
onSuccess: invalidateRoles,
|
|
25
25
|
})
|
|
26
26
|
|
|
27
27
|
const update = () => useMutation({
|
|
28
|
-
mutationFn: ({ id, ...data }) => api.put(`
|
|
28
|
+
mutationFn: ({ id, ...data }) => api.put(`roles/${id}`, data),
|
|
29
29
|
onSuccess: (_, { id }) => {
|
|
30
30
|
queryClient.invalidateQueries({ queryKey: ['roles', id] })
|
|
31
31
|
invalidateRoles()
|
|
@@ -33,13 +33,13 @@ export function useRoles() {
|
|
|
33
33
|
})
|
|
34
34
|
|
|
35
35
|
const remove = () => useMutation({
|
|
36
|
-
mutationFn: (id) => api.delete(`
|
|
36
|
+
mutationFn: (id) => api.delete(`roles/${id}`),
|
|
37
37
|
onSuccess: invalidateRoles,
|
|
38
38
|
})
|
|
39
39
|
|
|
40
40
|
const syncPermissions = () => useMutation({
|
|
41
41
|
mutationFn: ({ id, permissions }) =>
|
|
42
|
-
api.post(`
|
|
42
|
+
api.post(`roles/${id}/permissions`, { permissions }),
|
|
43
43
|
onSuccess: (_, { id }) =>
|
|
44
44
|
queryClient.invalidateQueries({ queryKey: ['roles', id] }),
|
|
45
45
|
})
|
package/composables/useUsers.js
CHANGED
|
@@ -6,36 +6,36 @@ export function useUsers() {
|
|
|
6
6
|
|
|
7
7
|
const list = (params = {}) => useQuery({
|
|
8
8
|
queryKey: computed(() => ['users', toValue(params)]),
|
|
9
|
-
queryFn: () => api.post('
|
|
9
|
+
queryFn: () => api.post('users', toValue(params)),
|
|
10
10
|
})
|
|
11
11
|
|
|
12
12
|
const detail = (id) => useQuery({
|
|
13
13
|
queryKey: computed(() => ['users', toValue(id)]),
|
|
14
|
-
queryFn: () => api.get(`
|
|
14
|
+
queryFn: () => api.get(`users/${toValue(id)}`),
|
|
15
15
|
enabled: computed(() => !!toValue(id)),
|
|
16
16
|
})
|
|
17
17
|
|
|
18
18
|
const roles = (userId) => useQuery({
|
|
19
19
|
queryKey: computed(() => ['users', toValue(userId), 'roles']),
|
|
20
|
-
queryFn: () => api.get(`
|
|
20
|
+
queryFn: () => api.get(`users/${toValue(userId)}/roles`),
|
|
21
21
|
enabled: computed(() => !!toValue(userId)),
|
|
22
22
|
})
|
|
23
23
|
|
|
24
24
|
const apps = (userId) => useQuery({
|
|
25
25
|
queryKey: computed(() => ['users', toValue(userId), 'apps']),
|
|
26
|
-
queryFn: () => api.get(`
|
|
26
|
+
queryFn: () => api.get(`users/${toValue(userId)}/apps`),
|
|
27
27
|
enabled: computed(() => !!toValue(userId)),
|
|
28
28
|
})
|
|
29
29
|
|
|
30
30
|
const sessions = (userId) => useQuery({
|
|
31
31
|
queryKey: computed(() => ['users', toValue(userId), 'sessions']),
|
|
32
|
-
queryFn: () => api.get(`
|
|
32
|
+
queryFn: () => api.get(`users/${toValue(userId)}/sessions`),
|
|
33
33
|
enabled: computed(() => !!toValue(userId)),
|
|
34
34
|
})
|
|
35
35
|
|
|
36
36
|
const activityLog = (userId, params = {}) => useQuery({
|
|
37
37
|
queryKey: computed(() => ['users', toValue(userId), 'activity', toValue(params)]),
|
|
38
|
-
queryFn: () => api.get(`
|
|
38
|
+
queryFn: () => api.get(`users/${toValue(userId)}/activity`, toValue(params)),
|
|
39
39
|
enabled: computed(() => !!toValue(userId)),
|
|
40
40
|
})
|
|
41
41
|
|
|
@@ -44,12 +44,12 @@ export function useUsers() {
|
|
|
44
44
|
const invalidateUsers = () => queryClient.invalidateQueries({ queryKey: ['users'] })
|
|
45
45
|
|
|
46
46
|
const create = () => useMutation({
|
|
47
|
-
mutationFn: (data) => api.post('
|
|
47
|
+
mutationFn: (data) => api.post('users', data),
|
|
48
48
|
onSuccess: invalidateUsers,
|
|
49
49
|
})
|
|
50
50
|
|
|
51
51
|
const update = () => useMutation({
|
|
52
|
-
mutationFn: ({ id, ...data }) => api.put(`
|
|
52
|
+
mutationFn: ({ id, ...data }) => api.put(`users/${id}`, data),
|
|
53
53
|
onSuccess: (_, { id }) => {
|
|
54
54
|
queryClient.invalidateQueries({ queryKey: ['users', id] })
|
|
55
55
|
invalidateUsers()
|
|
@@ -57,46 +57,46 @@ export function useUsers() {
|
|
|
57
57
|
})
|
|
58
58
|
|
|
59
59
|
const remove = () => useMutation({
|
|
60
|
-
mutationFn: (id) => api.delete(`
|
|
60
|
+
mutationFn: (id) => api.delete(`users/${id}`),
|
|
61
61
|
onSuccess: invalidateUsers,
|
|
62
62
|
})
|
|
63
63
|
|
|
64
64
|
const reactivate = () => useMutation({
|
|
65
|
-
mutationFn: (id) => api.post(`
|
|
65
|
+
mutationFn: (id) => api.post(`users/${id}/reactivate`),
|
|
66
66
|
onSuccess: invalidateUsers,
|
|
67
67
|
})
|
|
68
68
|
|
|
69
69
|
const resetPassword = () => useMutation({
|
|
70
|
-
mutationFn: ({ id, ...data }) => api.post(`
|
|
70
|
+
mutationFn: ({ id, ...data }) => api.post(`users/${id}/reset-password`, data),
|
|
71
71
|
})
|
|
72
72
|
|
|
73
73
|
const assignRole = () => useMutation({
|
|
74
|
-
mutationFn: ({ userId, role }) => api.post(`
|
|
74
|
+
mutationFn: ({ userId, role }) => api.post(`users/${userId}/roles`, { role }),
|
|
75
75
|
onSuccess: (_, { userId }) =>
|
|
76
76
|
queryClient.invalidateQueries({ queryKey: ['users', userId, 'roles'] }),
|
|
77
77
|
})
|
|
78
78
|
|
|
79
79
|
const removeRole = () => useMutation({
|
|
80
|
-
mutationFn: ({ userId, role }) => api.delete(`
|
|
80
|
+
mutationFn: ({ userId, role }) => api.delete(`users/${userId}/roles/${role}`),
|
|
81
81
|
onSuccess: (_, { userId }) =>
|
|
82
82
|
queryClient.invalidateQueries({ queryKey: ['users', userId, 'roles'] }),
|
|
83
83
|
})
|
|
84
84
|
|
|
85
85
|
const syncApps = () => useMutation({
|
|
86
|
-
mutationFn: ({ userId, apps }) => api.post(`
|
|
86
|
+
mutationFn: ({ userId, apps }) => api.post(`users/${userId}/apps/sync`, { apps }),
|
|
87
87
|
onSuccess: (_, { userId }) =>
|
|
88
88
|
queryClient.invalidateQueries({ queryKey: ['users', userId, 'apps'] }),
|
|
89
89
|
})
|
|
90
90
|
|
|
91
91
|
const revokeSession = () => useMutation({
|
|
92
92
|
mutationFn: ({ userId, sessionId }) =>
|
|
93
|
-
api.delete(`
|
|
93
|
+
api.delete(`users/${userId}/sessions/${sessionId}`),
|
|
94
94
|
onSuccess: (_, { userId }) =>
|
|
95
95
|
queryClient.invalidateQueries({ queryKey: ['users', userId, 'sessions'] }),
|
|
96
96
|
})
|
|
97
97
|
|
|
98
98
|
const revokeAllSessions = () => useMutation({
|
|
99
|
-
mutationFn: (userId) => api.delete(`
|
|
99
|
+
mutationFn: (userId) => api.delete(`users/${userId}/sessions`),
|
|
100
100
|
onSuccess: (_, userId) =>
|
|
101
101
|
queryClient.invalidateQueries({ queryKey: ['users', userId, 'sessions'] }),
|
|
102
102
|
})
|