3
3
import lombok .RequiredArgsConstructor ;
4
4
import org .jetbrains .annotations .NotNull ;
5
5
import org .lowcoder .api .home .SessionUserService ;
6
+ import org .lowcoder .domain .application .service .ApplicationServiceImpl ;
7
+ import org .lowcoder .domain .organization .service .OrgMemberServiceImpl ;
6
8
import org .lowcoder .domain .organization .service .OrganizationService ;
7
9
import org .lowcoder .infra .constant .NewUrl ;
8
10
import org .lowcoder .infra .js .NodeServerHelper ;
@@ -27,22 +29,24 @@ public class PrivateNpmRegistryController implements PrivateNpmRegistryEndpoint{
27
29
28
30
private static final String NPM_REGISTRY_METADATA = "npm/registry" ;
29
31
private static final String NPM_REGISTRY_ASSET = "npm/package" ;
32
+ private final OrgMemberServiceImpl orgMemberServiceImpl ;
33
+ private final ApplicationServiceImpl applicationServiceImpl ;
30
34
31
35
@ Override
32
- public Mono <ResponseEntity <Resource >> getNpmPackageMeta (String name ) {
33
- return forwardToNodeService (name , NPM_REGISTRY_METADATA );
36
+ public Mono <ResponseEntity <Resource >> getNpmPackageMeta (String applicationId , String name ) {
37
+ return forwardToNodeService (applicationId , name , NPM_REGISTRY_METADATA );
34
38
}
35
39
36
40
@ Override
37
- public Mono <ResponseEntity <Resource >> getNpmPackageAsset (String path ) {
38
- return forwardToNodeService (path , NPM_REGISTRY_ASSET );
41
+ public Mono <ResponseEntity <Resource >> getNpmPackageAsset (String applicationId , String path ) {
42
+ return forwardToNodeService (applicationId , path , NPM_REGISTRY_ASSET );
39
43
}
40
44
41
45
@ NotNull
42
- private Mono <ResponseEntity <Resource >> forwardToNodeService (String path , String prefix ) {
46
+ private Mono <ResponseEntity <Resource >> forwardToNodeService (String applicationId , String path , String prefix ) {
43
47
String withoutLeadingSlash = path .startsWith ("/" ) ? path .substring (1 ) : path ;
44
- return sessionUserService . getVisitorOrgMemberCache ( ).flatMap (orgMember -> organizationService .getOrgCommonSettings (orgMember .getOrgId ()).flatMap (organizationCommonSettings -> {
45
- Map <String , Object > config = Map .of ("npmRegistries" , organizationCommonSettings .get ("npmRegistries" ), "workspaceId" , orgMember .getOrgId ());
48
+ return applicationServiceImpl . findById ( applicationId ).flatMap (application -> organizationService . getById ( application . getOrganizationId ())). flatMap ( orgMember -> organizationService .getOrgCommonSettings (orgMember .getId ()).flatMap (organizationCommonSettings -> {
49
+ Map <String , Object > config = Map .of ("npmRegistries" , organizationCommonSettings .get ("npmRegistries" ), "workspaceId" , orgMember .getId ());
46
50
return WebClientBuildHelper .builder ()
47
51
.systemProxy ()
48
52
.build ()
0 commit comments