Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PermissionKeys is generated but can not be used #5152

Closed
minhhungit opened this issue Aug 11, 2020 · 4 comments
Closed

PermissionKeys is generated but can not be used #5152

minhhungit opened this issue Aug 11, 2020 · 4 comments
Assignees

Comments

@minhhungit
Copy link
Contributor

on typescript code, can not call something like MyProject.PermissionKeys.Module.Abc

this is sample permission keys which is generated by seren

/* ServerTypings/PermissionKeys.ts */

namespace MyProject{
    declare namespace PermissionKeys {

        namespace Project {
            export const View = "Project:View";
            export const Modify = "Project:Modify";
            export const Delete = "Project:Delete";
            export const Lookup = "Project:Lookup";
            export const UserProjectAssignment = "Project:UserProjectAssignment";
        }

        namespace Timelog {
            export const View = "Timelog:View";
            export const Modify = "Timelog:Modify";
            export const Delete = "Timelog:Delete";
            export const Lookup = "Timelog:Lookup";
            export const UpdateStatus = "Timelog:UpdateStatus";
        }
    }
}
@volkanceylan volkanceylan self-assigned this Aug 12, 2020
@RaptorTrap
Copy link
Contributor

To add to this, this happens if there are nested PermissionKey classes with the attribute NestedPermissionKeys.
The ServerTyping of the inner classes are not generated correctly.
This Permissionkey class definition

namespace Proj.PermissionKeys
{
  [NestedPermissionKeys]
  public class OuterClass
  {
    [NestedPermissionKeys]
    public class InnerClass
    {
      public const string Read = "OuterClass:InnerClass:Read";
      public const string Modify = "OuterClass:InnerClass:Modify";
    }
  }
}

is generated to

namespace Proj.PermissionKeys {
  export namespace OuterClass {

    namespace InnerClass {
      export const Read = "OuterClass:InnerClass:Read";
      export const Modify = "OuterClass:InnerClass:Modify";
    }
  }
}

The InnerClass should also get the export keyword: export namespace InnerClass {
Because of this you can't access Proj.PermissionKeys.OuterClass.InnerClass.Read in Typescript.

@volkanceylan
Copy link
Member

@osmanaslancan please also add a test for servertypingsgenerator

@RaptorTrap
Copy link
Contributor

Has this issue been fixed? On the current version NestedPermissionKeys are still not generated correctly.

@volkanceylan
Copy link
Member

Yes, nested permission key classes should also have export

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants