-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Telemetry: Normalize Query URL and Redact PII (#734) * Feature: autocomplete (#480) * Localized GE.jsons HB (#776) * Prevent remote dependency and trace information telemetry types from being captured (#770) * Fix: sample query sample body (#775) * Fix: stop display of options when fetching suggestions (#778) * add aria-label (#780) * chore(release): 4.1.12
- Loading branch information
Showing
59 changed files
with
3,570 additions
and
595 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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,38 @@ | ||
import { suggestions } from '../../../modules/suggestions'; | ||
import { IAction } from '../../../types/action'; | ||
import { | ||
AUTOCOMPLETE_FETCH_ERROR, AUTOCOMPLETE_FETCH_PENDING, | ||
AUTOCOMPLETE_FETCH_SUCCESS | ||
} from '../redux-constants'; | ||
|
||
export function fetchAutocompleteSuccess(response: object): IAction { | ||
return { | ||
type: AUTOCOMPLETE_FETCH_SUCCESS, | ||
response, | ||
}; | ||
} | ||
|
||
export function fetchAutocompleteError(response: object): IAction { | ||
return { | ||
type: AUTOCOMPLETE_FETCH_ERROR, | ||
response, | ||
}; | ||
} | ||
|
||
export function fetchAutocompletePending(): any { | ||
return { | ||
type: AUTOCOMPLETE_FETCH_PENDING | ||
}; | ||
} | ||
|
||
export function fetchAutoCompleteOptions(url: string, version: string): Function { | ||
return async (dispatch: Function, getState: Function) => { | ||
const devxApi = getState().devxApi; | ||
dispatch(fetchAutocompletePending()); | ||
const autoOptions = await suggestions.getSuggestions(url, devxApi, version); | ||
if (autoOptions) { | ||
return dispatch(fetchAutocompleteSuccess(autoOptions)); | ||
} | ||
return dispatch(fetchAutocompleteError({})); | ||
}; | ||
} |
This file contains 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,33 @@ | ||
import { IAction, IApiResponse } from '../../../types/action'; | ||
import { AUTOCOMPLETE_FETCH_ERROR, AUTOCOMPLETE_FETCH_PENDING, AUTOCOMPLETE_FETCH_SUCCESS } from '../redux-constants'; | ||
|
||
const initialState: IApiResponse = { | ||
pending: false, | ||
data: [], | ||
error: null | ||
}; | ||
|
||
export function autoComplete(state = initialState, action: IAction): IApiResponse { | ||
switch (action.type) { | ||
case AUTOCOMPLETE_FETCH_PENDING: | ||
return { | ||
error: null, | ||
data: null, | ||
pending: true | ||
}; | ||
case AUTOCOMPLETE_FETCH_SUCCESS: | ||
return { | ||
pending: false, | ||
data: action.response, | ||
error: null | ||
}; | ||
case AUTOCOMPLETE_FETCH_ERROR: | ||
return { | ||
pending: false, | ||
data: null, | ||
error: action.response | ||
}; | ||
default: | ||
return state; | ||
} | ||
} |
This file contains 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 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 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 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,32 @@ | ||
export function generateGroupsFromList(list: any[], property: string) { | ||
const map = new Map(); | ||
const groups: any[] = []; | ||
|
||
let isCollapsed = false; | ||
let previousCount = 0; | ||
let count = 0; | ||
|
||
if (!list || list.length === 0 || list.some(e => !e[property])) { | ||
return groups; | ||
} | ||
|
||
for (const listItem of list) { | ||
if (!map.has(listItem[property])) { | ||
map.set(listItem[property], true); | ||
count = list.filter(item => item[property] === listItem[property]).length; | ||
if (groups.length > 0) { | ||
isCollapsed = true; | ||
} | ||
groups.push({ | ||
name: listItem[property], | ||
key: listItem[property], | ||
startIndex: previousCount, | ||
isCollapsed, | ||
count, | ||
}); | ||
previousCount += count; | ||
} | ||
} | ||
|
||
return groups; | ||
} |
This file contains 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,15 @@ | ||
export function stringToHash(input: string) { | ||
let hash = 0; | ||
if (input.length === 0) { | ||
return hash; | ||
} | ||
|
||
for (let index = 0; index < input.length; index++) { | ||
const char = input.charCodeAt(index); | ||
// tslint:disable-next-line: no-bitwise | ||
hash = ((hash << 5) - hash) + char; | ||
// tslint:disable-next-line: no-bitwise | ||
hash = hash & hash; | ||
} | ||
return hash; | ||
} |
This file contains 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,55 @@ | ||
import { | ||
IOpenApiParseContent, IParameters, IParameterValue, | ||
IParsedOpenApiResponse, IPathValue, IQueryParameter | ||
} from '../../types/open-api'; | ||
|
||
export function parseOpenApiResponse(params: IOpenApiParseContent): IParsedOpenApiResponse { | ||
const { response: { paths }, url } = params; | ||
|
||
try { | ||
const parameters: IParameters[] = []; | ||
const requestUrl = Object.keys(paths)[0]; | ||
const verbs = Object.keys(paths[`${requestUrl}`]); | ||
const pathValues: any = Object.values(paths)[0]; | ||
|
||
verbs.forEach((verb: string) => { | ||
parameters.push({ | ||
verb, | ||
values: getVerbParameterValues(pathValues[`${verb}`]), | ||
links: getLinkValues(pathValues[`${verb}`]) | ||
}); | ||
}); | ||
|
||
const createdAt = new Date().toISOString(); | ||
return { url, parameters, createdAt }; | ||
} catch (error) { | ||
throw new Error(error); | ||
} | ||
} | ||
|
||
function getVerbParameterValues(values: IPathValue): IParameterValue[] { | ||
const parameterValues: IParameterValue[] = []; | ||
const queryParameters = values.parameters; | ||
if (queryParameters && queryParameters.length > 0) { | ||
queryParameters.forEach((parameter: IQueryParameter) => { | ||
if (parameter.name && parameter.in === 'query') { | ||
parameterValues.push({ | ||
name: parameter.name, | ||
items: (parameter.schema && parameter.schema.items) ? parameter.schema.items.enum : [] | ||
}); | ||
} | ||
}); | ||
} | ||
return parameterValues; | ||
} | ||
|
||
function getLinkValues(values: IPathValue): string[] { | ||
const responses = values.responses; | ||
if (responses) { | ||
const responsesAtIndex200 = responses['200']; | ||
if (responsesAtIndex200 && responsesAtIndex200.links) { | ||
return Object.keys(responsesAtIndex200.links); | ||
} | ||
} | ||
return []; | ||
} |
Oops, something went wrong.