qdadm 0.14.1 → 0.14.2

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,6 +1,6 @@
1
1
  {
2
2
  "name": "qdadm",
3
- "version": "0.14.1",
3
+ "version": "0.14.2",
4
4
  "description": "Vue 3 framework for admin dashboards with PrimeVue",
5
5
  "author": "quazardous",
6
6
  "license": "MIT",
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- import { ref, onMounted, watch, inject } from 'vue'
2
+ import { ref, computed, onMounted, watch, inject } from 'vue'
3
3
  import AutoComplete from 'primevue/autocomplete'
4
4
  import Select from 'primevue/select'
5
5
  import Button from 'primevue/button'
@@ -13,29 +13,40 @@ const props = defineProps({
13
13
  type: Boolean,
14
14
  default: false
15
15
  },
16
- // Scope configuration
16
+ // Scope configuration (can be overridden globally via provide('scopeConfig', {...}))
17
17
  scopeEndpoint: {
18
18
  type: String,
19
- default: '/reference/scopes' // Endpoint to load scope definition from API
19
+ default: null
20
20
  },
21
21
  scopePrefix: {
22
22
  type: String,
23
- default: 'app' // Prefix for scope strings (e.g., "app.resource:action")
23
+ default: null
24
24
  },
25
25
  // Default resources/actions if API not available
26
26
  defaultResources: {
27
27
  type: Array,
28
- default: () => ['api', 'users', 'roles', 'apikeys']
28
+ default: null
29
29
  },
30
30
  defaultActions: {
31
31
  type: Array,
32
- default: () => ['read', 'write', 'grant']
32
+ default: null
33
33
  }
34
34
  })
35
35
 
36
36
  // Get API adapter (optional)
37
37
  const api = inject('apiAdapter', null)
38
38
 
39
+ // Get global scope config (optional) - allows app-level configuration
40
+ const globalScopeConfig = inject('scopeConfig', {})
41
+
42
+ // Computed config with priority: props > globalConfig > defaults
43
+ const config = computed(() => ({
44
+ endpoint: props.scopeEndpoint ?? globalScopeConfig.endpoint ?? '/reference/scopes',
45
+ prefix: props.scopePrefix ?? globalScopeConfig.prefix ?? 'app',
46
+ resources: props.defaultResources ?? globalScopeConfig.resources ?? ['api', 'users', 'roles', 'apikeys'],
47
+ actions: props.defaultActions ?? globalScopeConfig.actions ?? ['read', 'write', 'grant']
48
+ }))
49
+
39
50
  const emit = defineEmits(['update:modelValue'])
40
51
 
41
52
  // Scope structure from API
@@ -57,8 +68,6 @@ const allResources = computed(() => ['*', ...scopeDefinition.value.resources])
57
68
  // All actions with access prefix
58
69
  const allActions = computed(() => ['access', ...scopeDefinition.value.actions])
59
70
 
60
- import { computed } from 'vue'
61
-
62
71
  /**
63
72
  * Search resources for autocomplete
64
73
  */
@@ -79,7 +88,7 @@ function searchResources(event) {
79
88
  function parseScope(scope) {
80
89
  if (!scope) return { resource: '', action: '' }
81
90
  // prefix.resource:action
82
- const regex = new RegExp(`^${props.scopePrefix}\\.([^:]+):(.+)$`)
91
+ const regex = new RegExp(`^${config.value.prefix}\\.([^:]+):(.+)$`)
83
92
  const match = scope.match(regex)
84
93
  if (match) {
85
94
  return { resource: match[1], action: match[2] }
@@ -92,7 +101,7 @@ function parseScope(scope) {
92
101
  */
93
102
  function buildScope(resource, action) {
94
103
  if (!resource || !action) return ''
95
- return `${props.scopePrefix}.${resource}:${action}`
104
+ return `${config.value.prefix}.${resource}:${action}`
96
105
  }
97
106
 
98
107
  // Initialize from modelValue
@@ -154,22 +163,22 @@ async function loadScopeDefinition() {
154
163
  if (!api) {
155
164
  // No API adapter, use defaults
156
165
  scopeDefinition.value = {
157
- resources: [...props.defaultResources],
158
- actions: [...props.defaultActions],
166
+ resources: [...config.value.resources],
167
+ actions: [...config.value.actions],
159
168
  }
160
169
  return
161
170
  }
162
171
 
163
- const data = await api.request('GET', props.scopeEndpoint)
172
+ const data = await api.request('GET', config.value.endpoint)
164
173
  scopeDefinition.value = {
165
- resources: data.resources || [...props.defaultResources],
166
- actions: data.actions || [...props.defaultActions],
174
+ resources: data.resources || [...config.value.resources],
175
+ actions: data.actions || [...config.value.actions],
167
176
  }
168
177
  } catch (error) {
169
178
  console.error('[ScopeEditor] Failed to load scope definition:', error)
170
179
  scopeDefinition.value = {
171
- resources: [...props.defaultResources],
172
- actions: [...props.defaultActions],
180
+ resources: [...config.value.resources],
181
+ actions: [...config.value.actions],
173
182
  }
174
183
  } finally {
175
184
  loading.value = false