@peanut-admin/admin 0.1.0-alpha.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/LICENSE +202 -0
- package/admin-core/src/access/access.ts +27 -0
- package/admin-core/src/api/client.ts +200 -0
- package/admin-core/src/api/problem.ts +67 -0
- package/admin-core/src/api/refresh.ts +122 -0
- package/admin-core/src/auth/stores.ts +121 -0
- package/admin-core/src/generated/api.d.ts +22106 -0
- package/admin-core/src/governance/audit.ts +56 -0
- package/admin-core/src/governance/catalog.ts +86 -0
- package/admin-core/src/governance/index.ts +26 -0
- package/admin-core/src/governance/menu.ts +63 -0
- package/admin-core/src/governance/roles.ts +144 -0
- package/admin-core/src/governance/types.ts +64 -0
- package/admin-core/src/index.ts +105 -0
- package/admin-core/src/lifecycle/tenant.ts +59 -0
- package/admin-core/src/module/contribution.ts +124 -0
- package/admin-core/src/runtime/config.ts +55 -0
- package/admin-core/src/runtime/errors.ts +81 -0
- package/admin-core/src/runtime/guard.ts +40 -0
- package/admin-core/src/runtime/navigation.ts +105 -0
- package/admin-core/src/runtime/overrides.ts +214 -0
- package/admin-core/src/targets/store.ts +153 -0
- package/admin-shell/src/config.ts +84 -0
- package/admin-shell/src/index.ts +40 -0
- package/admin-shell/src/layout.ts +332 -0
- package/admin-shell/src/overrides.ts +53 -0
- package/admin-shell/src/states.ts +93 -0
- package/admin-shell/src/targets.ts +128 -0
- package/admin-shell/src/theme.ts +15 -0
- package/client-core/src/index.ts +325 -0
- package/client-nuxt/src/index.ts +40 -0
- package/client-uniapp/src/index.ts +50 -0
- package/file-media/src/FileAssetSelector.vue +117 -0
- package/file-media/src/FileMediaPage.vue +158 -0
- package/file-media/src/contracts.ts +220 -0
- package/file-media/src/index.ts +19 -0
- package/file-media/src/runtime.ts +210 -0
- package/import-export/src/ImportExportPage.vue +155 -0
- package/import-export/src/contracts.ts +96 -0
- package/import-export/src/index.ts +3 -0
- package/import-export/src/runtime.ts +128 -0
- package/integration-security/src/IntegrationSecurityPage.vue +402 -0
- package/integration-security/src/contracts.ts +171 -0
- package/integration-security/src/index.ts +3 -0
- package/integration-security/src/runtime.ts +180 -0
- package/notification-sms/src/NotificationInboxPage.vue +266 -0
- package/notification-sms/src/contracts.ts +195 -0
- package/notification-sms/src/index.ts +4 -0
- package/notification-sms/src/runtime.ts +143 -0
- package/ops-console/src/OpsConsolePage.vue +337 -0
- package/ops-console/src/contracts.ts +169 -0
- package/ops-console/src/index.ts +3 -0
- package/ops-console/src/runtime.ts +199 -0
- package/package.json +108 -0
- package/reference-codes/src/ReferenceCodesPage.vue +942 -0
- package/reference-codes/src/contracts.ts +484 -0
- package/reference-codes/src/index.ts +53 -0
- package/reference-codes/src/runtime.ts +855 -0
- package/settings/src/SettingsPage.vue +536 -0
- package/settings/src/contracts.ts +331 -0
- package/settings/src/index.ts +45 -0
- package/settings/src/runtime.ts +545 -0
- package/task-job/src/TaskJobPage.vue +120 -0
- package/task-job/src/contracts.ts +117 -0
- package/task-job/src/index.ts +2 -0
- package/task-job/src/runtime.ts +105 -0
- package/testing/src/index.ts +141 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { defineStore } from 'pinia'
|
|
2
|
+
|
|
3
|
+
export interface TenantContextData {
|
|
4
|
+
audience: 'tenant'
|
|
5
|
+
accountId: string
|
|
6
|
+
tenantId: string
|
|
7
|
+
memberId: string
|
|
8
|
+
moduleKeys: readonly string[]
|
|
9
|
+
permissionKeys: readonly string[]
|
|
10
|
+
authorizationRevision: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface PlatformContextData {
|
|
14
|
+
audience: 'platform'
|
|
15
|
+
accountId: string
|
|
16
|
+
operatorId: string
|
|
17
|
+
permissionKeys: readonly string[]
|
|
18
|
+
authorizationRevision: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface AuthState {
|
|
22
|
+
accessToken: string | null
|
|
23
|
+
generation: number
|
|
24
|
+
status: 'anonymous' | 'authenticated' | 'refreshing'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const authState = (): AuthState => ({
|
|
28
|
+
accessToken: null,
|
|
29
|
+
generation: 0,
|
|
30
|
+
status: 'anonymous',
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const authActions = {
|
|
34
|
+
replaceAccessToken(this: AuthState, token: string): void {
|
|
35
|
+
if (token === '') {
|
|
36
|
+
throw new Error('AUTH_ACCESS_TOKEN_EMPTY')
|
|
37
|
+
}
|
|
38
|
+
this.accessToken = token
|
|
39
|
+
this.status = 'authenticated'
|
|
40
|
+
},
|
|
41
|
+
markRefreshing(this: AuthState): void {
|
|
42
|
+
this.status = 'refreshing'
|
|
43
|
+
},
|
|
44
|
+
clear(this: AuthState): void {
|
|
45
|
+
this.accessToken = null
|
|
46
|
+
this.status = 'anonymous'
|
|
47
|
+
this.generation += 1
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const useTenantAuth = defineStore('peanut-admin-tenant-auth', {
|
|
52
|
+
state: authState,
|
|
53
|
+
actions: authActions,
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
export const usePlatformAuth = defineStore('peanut-admin-platform-auth', {
|
|
57
|
+
state: authState,
|
|
58
|
+
actions: authActions,
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
interface TenantContextState {
|
|
62
|
+
value: TenantContextData | null
|
|
63
|
+
generation: number
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const useTenantContext = defineStore('peanut-admin-tenant-context', {
|
|
67
|
+
state: (): TenantContextState => ({ value: null, generation: 0 }),
|
|
68
|
+
getters: {
|
|
69
|
+
accountId: state => state.value?.accountId ?? null,
|
|
70
|
+
tenantId: state => state.value?.tenantId ?? null,
|
|
71
|
+
memberId: state => state.value?.memberId ?? null,
|
|
72
|
+
authorizationRevision: state => state.value?.authorizationRevision ?? null,
|
|
73
|
+
moduleSet: state => new Set(state.value?.moduleKeys ?? []),
|
|
74
|
+
permissionSet: state => new Set(state.value?.permissionKeys ?? []),
|
|
75
|
+
},
|
|
76
|
+
actions: {
|
|
77
|
+
replace(context: TenantContextData): void {
|
|
78
|
+
if (context.audience !== 'tenant') {
|
|
79
|
+
throw new Error('CONTEXT_AUDIENCE_MISMATCH')
|
|
80
|
+
}
|
|
81
|
+
this.value = {
|
|
82
|
+
...context,
|
|
83
|
+
moduleKeys: [...context.moduleKeys],
|
|
84
|
+
permissionKeys: [...context.permissionKeys],
|
|
85
|
+
}
|
|
86
|
+
this.generation += 1
|
|
87
|
+
},
|
|
88
|
+
clear(): void {
|
|
89
|
+
this.value = null
|
|
90
|
+
this.generation += 1
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
interface PlatformContextState {
|
|
96
|
+
value: PlatformContextData | null
|
|
97
|
+
generation: number
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export const usePlatformContext = defineStore('peanut-admin-platform-context', {
|
|
101
|
+
state: (): PlatformContextState => ({ value: null, generation: 0 }),
|
|
102
|
+
getters: {
|
|
103
|
+
accountId: state => state.value?.accountId ?? null,
|
|
104
|
+
operatorId: state => state.value?.operatorId ?? null,
|
|
105
|
+
authorizationRevision: state => state.value?.authorizationRevision ?? null,
|
|
106
|
+
permissionSet: state => new Set(state.value?.permissionKeys ?? []),
|
|
107
|
+
},
|
|
108
|
+
actions: {
|
|
109
|
+
replace(context: PlatformContextData): void {
|
|
110
|
+
if (context.audience !== 'platform') {
|
|
111
|
+
throw new Error('CONTEXT_AUDIENCE_MISMATCH')
|
|
112
|
+
}
|
|
113
|
+
this.value = { ...context, permissionKeys: [...context.permissionKeys] }
|
|
114
|
+
this.generation += 1
|
|
115
|
+
},
|
|
116
|
+
clear(): void {
|
|
117
|
+
this.value = null
|
|
118
|
+
this.generation += 1
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
})
|