@@ -11,39 +11,45 @@ import {
1111 type OpenButtonAction ,
1212 type SleepButtonAction ,
1313 type TemplaterCreateNoteButtonAction ,
14+ type UpdateMetadataButtonAction ,
1415} from './ButtonConfig' ;
1516
16- export const ButtonConfigValidators = schemaForType < CommandButtonAction > ( ) (
17+ export const V_CommandButtonAction = schemaForType < CommandButtonAction > ( ) (
1718 z . object ( {
1819 type : z . literal ( ButtonActionType . COMMAND ) ,
1920 command : z . string ( ) ,
2021 } ) ,
2122) ;
22- export const JSButtonActionValidator = schemaForType < JSButtonAction > ( ) (
23+
24+ export const V_JSButtonAction = schemaForType < JSButtonAction > ( ) (
2325 z . object ( {
2426 type : z . literal ( ButtonActionType . JS ) ,
2527 file : z . string ( ) ,
2628 } ) ,
2729) ;
28- export const OpenButtonActionValidator = schemaForType < OpenButtonAction > ( ) (
30+
31+ export const V_OpenButtonAction = schemaForType < OpenButtonAction > ( ) (
2932 z . object ( {
3033 type : z . literal ( ButtonActionType . OPEN ) ,
3134 link : z . string ( ) ,
3235 } ) ,
3336) ;
34- export const InputButtonActionValidator = schemaForType < InputButtonAction > ( ) (
37+
38+ export const V_InputButtonAction = schemaForType < InputButtonAction > ( ) (
3539 z . object ( {
3640 type : z . literal ( ButtonActionType . INPUT ) ,
3741 str : z . string ( ) ,
3842 } ) ,
3943) ;
40- export const SleepButtonActionValidator = schemaForType < SleepButtonAction > ( ) (
44+
45+ export const V_SleepButtonAction = schemaForType < SleepButtonAction > ( ) (
4146 z . object ( {
4247 type : z . literal ( ButtonActionType . SLEEP ) ,
4348 ms : z . number ( ) ,
4449 } ) ,
4550) ;
46- export const TemplaterCreateNoteButtonActionValidator = schemaForType < TemplaterCreateNoteButtonAction > ( ) (
51+
52+ export const V_TemplaterCreateNoteButtonAction = schemaForType < TemplaterCreateNoteButtonAction > ( ) (
4753 z . object ( {
4854 type : z . literal ( ButtonActionType . TEMPLATER_CREATE_NOTE ) ,
4955 templateFile : z . string ( ) ,
@@ -52,28 +58,40 @@ export const TemplaterCreateNoteButtonActionValidator = schemaForType<TemplaterC
5258 openNote : z . boolean ( ) . optional ( ) ,
5359 } ) ,
5460) ;
55- export const ButtonActionValidator = schemaForType < ButtonAction > ( ) (
61+ export const V_UpdateMetadataButtonAction = schemaForType < UpdateMetadataButtonAction > ( ) (
62+ z . object ( {
63+ type : z . literal ( ButtonActionType . UPDATE_METADATA ) ,
64+ bindTarget : z . coerce . string ( ) ,
65+ evaluate : z . boolean ( ) ,
66+ value : z . coerce . string ( ) ,
67+ } ) ,
68+ ) ;
69+
70+ export const V_ButtonAction = schemaForType < ButtonAction > ( ) (
5671 z . union ( [
57- ButtonConfigValidators ,
58- JSButtonActionValidator ,
59- OpenButtonActionValidator ,
60- InputButtonActionValidator ,
61- SleepButtonActionValidator ,
62- TemplaterCreateNoteButtonActionValidator ,
72+ V_CommandButtonAction ,
73+ V_JSButtonAction ,
74+ V_OpenButtonAction ,
75+ V_InputButtonAction ,
76+ V_SleepButtonAction ,
77+ V_TemplaterCreateNoteButtonAction ,
78+ V_UpdateMetadataButtonAction ,
6379 ] ) ,
6480) ;
65- export const ButtonStyleValidator = z . nativeEnum ( ButtonStyleType ) ;
66- export const ButtonConfigValidator = schemaForType < ButtonConfig > ( ) (
81+
82+ export const V_ButtonStyleType = z . nativeEnum ( ButtonStyleType ) ;
83+
84+ export const V_ButtonConfig = schemaForType < ButtonConfig > ( ) (
6785 z
6886 . object ( {
6987 label : z . string ( ) ,
70- style : ButtonStyleValidator ,
88+ style : V_ButtonStyleType ,
7189 class : z . string ( ) . optional ( ) ,
7290 tooltip : z . string ( ) . optional ( ) ,
7391 id : z . string ( ) . optional ( ) ,
7492 hidden : z . boolean ( ) . optional ( ) ,
75- action : ButtonActionValidator . optional ( ) ,
76- actions : ButtonActionValidator . array ( ) . optional ( ) ,
93+ action : V_ButtonAction . optional ( ) ,
94+ actions : V_ButtonAction . array ( ) . optional ( ) ,
7795 } )
7896 . superRefine ( oneOf ( 'action' , 'actions' ) ) ,
7997) ;
0 commit comments