@@ -238,7 +238,7 @@ export class CubePropContextTranspiler implements TranspilerInterface {
238238 ) {
239239 // Special handling for userAttributes - replace in parameter list with securityContext
240240 const fullPath = this . fullPath ( path ) ;
241- if ( path . node . name === 'userAttributes' && ( fullPath . startsWith ( 'accessPolicy' ) || fullPath . startsWith ( 'access_policy' ) ) ) {
241+ if ( ( path . node . name === 'userAttributes' || path . node . name === 'user_attributes' ) && ( fullPath . startsWith ( 'accessPolicy' ) || fullPath . startsWith ( 'access_policy' ) ) ) {
242242 identifiers . push ( 'securityContext' ) ;
243243 } else {
244244 identifiers . push ( path . node . name ) ;
@@ -249,13 +249,32 @@ export class CubePropContextTranspiler implements TranspilerInterface {
249249 protected static transformUserAttributesMemberExpression ( path : NodePath < t . MemberExpression > ) {
250250 // Check if this is userAttributes.someProperty (object should be identifier named 'userAttributes')
251251 const fullPath = this . fullPath ( path ) ;
252- if ( t . isIdentifier ( path . node . object , { name : 'userAttributes' } ) && ( fullPath . startsWith ( 'accessPolicy' ) || fullPath . startsWith ( 'access_policy' ) ) ) {
252+ if (
253+ ( t . isIdentifier ( path . node . object , { name : 'userAttributes' } ) || t . isIdentifier ( path . node . object , { name : 'user_attributes' } ) ) &&
254+ ( fullPath . startsWith ( 'accessPolicy' ) || fullPath . startsWith ( 'access_policy' ) )
255+ ) {
253256 // Replace userAttributes with securityContext.cubeCloud.userAttributes
254257 const securityContext = t . identifier ( 'securityContext' ) ;
255258 const cubeCloud = t . memberExpression ( securityContext , t . identifier ( 'cubeCloud' ) ) ;
256259 const userAttributes = t . memberExpression ( cubeCloud , t . identifier ( 'userAttributes' ) ) ;
257260 const newMemberExpression = t . memberExpression ( userAttributes , path . node . property , path . node . computed ) ;
258261
262+ path . replaceWith ( newMemberExpression ) ;
263+ } else if (
264+ t . isMemberExpression ( path . node . object ) &&
265+ t . isIdentifier ( path . node . object . property , { name : 'user_attributes' } ) &&
266+ ! path . node . object . computed &&
267+ ( fullPath . startsWith ( 'accessPolicy' ) || fullPath . startsWith ( 'access_policy' ) )
268+ ) {
269+ // Also handle case where user_attributes appears within a MemberExpression chain like
270+ // securityContext.cubeCloud.user_attributes
271+ // We need to convert user_attributes to userAttributes in such chains
272+ const newObject = t . memberExpression (
273+ path . node . object . object ,
274+ t . identifier ( 'userAttributes' ) ,
275+ false
276+ ) ;
277+ const newMemberExpression = t . memberExpression ( newObject , path . node . property , path . node . computed ) ;
259278 path . replaceWith ( newMemberExpression ) ;
260279 }
261280 }
0 commit comments