@@ -14,13 +14,14 @@ import { withJsonProcessor } from './json-processor';
1414import { Logger } from './logger' ;
1515import { withOmit } from './omit' ;
1616import { withPassword } from './password' ;
17+ import { withEncrypted } from './encrypted' ;
1718import { policyProcessIncludeRelationPayload , withPolicy } from './policy' ;
1819import type { PolicyDef } from './types' ;
1920
2021/**
2122 * All enhancement kinds
2223 */
23- const ALL_ENHANCEMENTS : EnhancementKind [ ] = [ 'password' , 'omit' , 'policy' , 'validation' , 'delegate' ] ;
24+ const ALL_ENHANCEMENTS : EnhancementKind [ ] = [ 'password' , 'omit' , 'policy' , 'validation' , 'delegate' , 'encrypted' ] ;
2425
2526/**
2627 * Options for {@link createEnhancement}
@@ -100,6 +101,7 @@ export function createEnhancement<DbClient extends object>(
100101 }
101102
102103 const hasPassword = allFields . some ( ( field ) => field . attributes ?. some ( ( attr ) => attr . name === '@password' ) ) ;
104+ const hasEncrypted = allFields . some ( ( field ) => field . attributes ?. some ( ( attr ) => attr . name === '@encrypted' ) ) ;
103105 const hasOmit = allFields . some ( ( field ) => field . attributes ?. some ( ( attr ) => attr . name === '@omit' ) ) ;
104106 const hasDefaultAuth = allFields . some ( ( field ) => field . defaultValueProvider ) ;
105107 const hasTypeDefField = allFields . some ( ( field ) => field . isTypeDef ) ;
@@ -120,13 +122,18 @@ export function createEnhancement<DbClient extends object>(
120122 }
121123 }
122124
123- // password enhancement must be applied prior to policy because it changes then length of the field
125+ // password and encrypted enhancement must be applied prior to policy because it changes then length of the field
124126 // and can break validation rules like `@length`
125127 if ( hasPassword && kinds . includes ( 'password' ) ) {
126128 // @password proxy
127129 result = withPassword ( result , options ) ;
128130 }
129131
132+ if ( hasEncrypted && kinds . includes ( 'encrypted' ) ) {
133+ // @encrypted proxy
134+ result = withEncrypted ( result , options ) ;
135+ }
136+
130137 // 'policy' and 'validation' enhancements are both enabled by `withPolicy`
131138 if ( kinds . includes ( 'policy' ) || kinds . includes ( 'validation' ) ) {
132139 result = withPolicy ( result , options , context ) ;
0 commit comments