- 
                Notifications
    You must be signed in to change notification settings 
- Fork 8.5k
[APM] Prevent imports of public in server code #75979
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
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            5 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      780394b
              
                renaming test file
              
              
                cauemarcondes 2a72a16
              
                removing eslint rule
              
              
                cauemarcondes ac50299
              
                restructuring observability types
              
              
                cauemarcondes ce8f502
              
                Merge branch 'master' of github.com:elastic/kibana into apm-fix-imports
              
              
                cauemarcondes 76710b2
              
                refactoring fetchOptions type
              
              
                cauemarcondes File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|  | ||
| import { HttpFetchOptions } from 'kibana/public'; | ||
|  | ||
| export type FetchOptions = Omit<HttpFetchOptions, 'body'> & { | ||
| pathname: string; | ||
| isCachable?: boolean; | ||
| method?: string; | ||
| body?: any; | ||
| }; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
| import { | ||
| ESFilter, | ||
| ESSearchResponse, | ||
| ESSearchRequest, | ||
| } from '../../typings/elasticsearch'; | ||
| import { PromiseReturnType } from '../../typings/common'; | ||
| import { APMConfig } from '..'; | ||
|  | ||
| interface Options { | ||
| mockResponse?: ( | ||
| request: ESSearchRequest | ||
| ) => ESSearchResponse<unknown, ESSearchRequest>; | ||
| } | ||
|  | ||
| interface MockSetup { | ||
| start: number; | ||
| end: number; | ||
| apmEventClient: any; | ||
| internalClient: any; | ||
| config: APMConfig; | ||
| uiFiltersES: ESFilter[]; | ||
| indices: { | ||
| /* eslint-disable @typescript-eslint/naming-convention */ | ||
| 'apm_oss.sourcemapIndices': string; | ||
| 'apm_oss.errorIndices': string; | ||
| 'apm_oss.onboardingIndices': string; | ||
| 'apm_oss.spanIndices': string; | ||
| 'apm_oss.transactionIndices': string; | ||
| 'apm_oss.metricsIndices': string; | ||
| /* eslint-enable @typescript-eslint/naming-convention */ | ||
| apmAgentConfigurationIndex: string; | ||
| apmCustomLinkIndex: string; | ||
| }; | ||
| } | ||
|  | ||
| export async function inspectSearchParams( | ||
| fn: (mockSetup: MockSetup) => Promise<any>, | ||
| options: Options = {} | ||
| ) { | ||
| const spy = jest.fn().mockImplementation(async (request) => { | ||
| return options.mockResponse | ||
| ? options.mockResponse(request) | ||
| : { | ||
| hits: { | ||
| hits: { | ||
| total: { | ||
| value: 0, | ||
| }, | ||
| }, | ||
| }, | ||
| }; | ||
| }); | ||
|  | ||
| let response; | ||
| let error; | ||
|  | ||
| const mockSetup = { | ||
| start: 1528113600000, | ||
| end: 1528977600000, | ||
| apmEventClient: { search: spy } as any, | ||
| internalClient: { search: spy } as any, | ||
| config: new Proxy( | ||
| {}, | ||
| { | ||
| get: (_, key) => { | ||
| switch (key) { | ||
| default: | ||
| return 'myIndex'; | ||
|  | ||
| case 'xpack.apm.metricsInterval': | ||
| return 30; | ||
| } | ||
| }, | ||
| } | ||
| ) as APMConfig, | ||
| uiFiltersES: [{ term: { 'my.custom.ui.filter': 'foo-bar' } }], | ||
| indices: { | ||
| /* eslint-disable @typescript-eslint/naming-convention */ | ||
| 'apm_oss.sourcemapIndices': 'myIndex', | ||
| 'apm_oss.errorIndices': 'myIndex', | ||
| 'apm_oss.onboardingIndices': 'myIndex', | ||
| 'apm_oss.spanIndices': 'myIndex', | ||
| 'apm_oss.transactionIndices': 'myIndex', | ||
| 'apm_oss.metricsIndices': 'myIndex', | ||
| /* eslint-enable @typescript-eslint/naming-convention */ | ||
| apmAgentConfigurationIndex: 'myIndex', | ||
| apmCustomLinkIndex: 'myIndex', | ||
| }, | ||
| dynamicIndexPattern: null as any, | ||
| }; | ||
| try { | ||
| response = await fn(mockSetup); | ||
| } catch (err) { | ||
| error = err; | ||
| // we're only extracting the search params | ||
| } | ||
|  | ||
| return { | ||
| params: spy.mock.calls[0][0], | ||
| response, | ||
| error, | ||
| spy, | ||
| teardown: () => spy.mockClear(), | ||
| }; | ||
| } | ||
|  | ||
| export type SearchParamsMock = PromiseReturnType<typeof inspectSearchParams>; | ||
|  | ||
| export function mockNow(date: string | number | Date) { | ||
| const fakeNow = new Date(date).getTime(); | ||
| return jest.spyOn(Date, 'now').mockReturnValue(fakeNow); | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@elastic/apm-ui We still have a lot of this to remove from the public directory, it might take some time to fix all since most of them are types which is automatically inferred.