Skip to content

Commit c0ab532

Browse files
committed
feat(PolicyWorkbench): implement types behavior
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent c73ef0e commit c0ab532

1 file changed

Lines changed: 112 additions & 0 deletions

File tree

  • src/views/Settings/PolicyWorkbench
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/**
2+
* SPDX-FileCopyrightText: 2026 LibreCode coop and LibreCode contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
import type { Component } from 'vue'
7+
8+
export type AdminViewMode = 'system-admin' | 'group-admin'
9+
export type PolicyScope = 'system' | 'group' | 'user'
10+
export type PolicySettingKey =
11+
| 'signature_flow'
12+
| 'confetti'
13+
| 'signature_stamp'
14+
| 'identify_factors'
15+
| 'auto_reminders'
16+
| 'request_notifications'
17+
| 'document_download_after_sign'
18+
export type SignatureFlowMode = 'parallel' | 'ordered_numeric'
19+
export type SignatureStampRenderMode = 'DESCRIPTION_ONLY' | 'GRAPHIC_AND_DESCRIPTION' | 'SIGNAME_AND_DESCRIPTION' | 'GRAPHIC_ONLY'
20+
export type SignatureStampBackgroundMode = 'default' | 'custom' | 'none'
21+
export type IdentifyFactorKey = 'email' | 'sms' | 'whatsapp' | 'document'
22+
export type IdentifyFactorSignatureMethod = 'email_token' | 'sms_token' | 'whatsapp_token' | 'document_validation'
23+
24+
export type SignatureFlowRuleValue = {
25+
enabled: boolean
26+
flow: SignatureFlowMode
27+
}
28+
29+
export type ConfettiRuleValue = {
30+
enabled: boolean
31+
}
32+
33+
export type SignatureStampRuleValue = {
34+
enabled: boolean
35+
renderMode: SignatureStampRenderMode
36+
template: string
37+
templateFontSize: number
38+
signatureFontSize: number
39+
signatureWidth: number
40+
signatureHeight: number
41+
backgroundMode: SignatureStampBackgroundMode
42+
showSigningDate: boolean
43+
}
44+
45+
export type IdentifyFactorOption = {
46+
key: IdentifyFactorKey
47+
label: string
48+
enabled: boolean
49+
required: boolean
50+
allowCreateAccount: boolean
51+
signatureMethod: IdentifyFactorSignatureMethod
52+
}
53+
54+
export type IdentifyFactorsRuleValue = {
55+
enabled: boolean
56+
requireAnyTwo: boolean
57+
factors: IdentifyFactorOption[]
58+
}
59+
60+
export type PolicySettingValueMap = {
61+
signature_flow: SignatureFlowRuleValue
62+
confetti: ConfettiRuleValue
63+
signature_stamp: SignatureStampRuleValue
64+
identify_factors: IdentifyFactorsRuleValue
65+
auto_reminders: ConfettiRuleValue
66+
request_notifications: ConfettiRuleValue
67+
document_download_after_sign: ConfettiRuleValue
68+
}
69+
70+
export type PolicyRuleRecord<K extends PolicySettingKey = PolicySettingKey> = {
71+
id: string
72+
scope: PolicyScope
73+
targetId: string | null
74+
allowChildOverride: boolean
75+
value: PolicySettingValueMap[K]
76+
}
77+
78+
export type PolicyEditorDraft = {
79+
id: string | null
80+
settingKey: PolicySettingKey
81+
scope: PolicyScope
82+
targetId: string | null
83+
allowChildOverride: boolean
84+
value: PolicySettingValueMap[PolicySettingKey]
85+
}
86+
87+
export type PolicyTargetOption = {
88+
id: string
89+
label: string
90+
groupId?: string
91+
}
92+
93+
export type PolicySettingDefinition<K extends PolicySettingKey = PolicySettingKey> = {
94+
key: K
95+
title: string
96+
description: string
97+
menuHint: string
98+
editor: Component
99+
createEmptyValue: (scope: PolicyScope) => PolicySettingValueMap[K]
100+
summarizeValue: (value: PolicySettingValueMap[K]) => string
101+
formatAllowOverride: (allowChildOverride: boolean) => string | null
102+
}
103+
104+
export type PolicySettingSummary = {
105+
key: PolicySettingKey
106+
title: string
107+
description: string
108+
menuHint: string
109+
defaultSummary: string
110+
groupCount: number
111+
userCount: number
112+
}

0 commit comments

Comments
 (0)