hunk
dict
file
stringlengths
0
11.8M
file_path
stringlengths
2
234
label
int64
0
1
commit_url
stringlengths
74
103
dependency_score
listlengths
5
5
{ "id": 6, "code_window": [ " <label className=\"gf-form--has-input-icon\">\n", " <input\n", " type=\"text\"\n", " className={`gf-form-input width-13 ${!this.hasSearchResults ? 'gf-form-input--invalid' : ''}`}\n", " placeholder=\"\"\n", " onChange={this.onSearchQueryChange}\n", " value={searchQuery}\n", " ref={elem => elem && elem.focus()}\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " className=\"gf-form-input width-13\"\n" ], "file_path": "public/app/features/dashboard/panel_editor/VisualizationTab.tsx", "type": "replace", "edit_start_line_idx": 191 }
package api import ( "time" "github.com/grafana/grafana/pkg/api/dtos" "github.com/grafana/grafana/pkg/bus" m "github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/services/dashboards" "github.com/grafana/grafana/pkg/services/guardian" ) func GetFolderPermissionList(c *m.ReqContext) Response { s := dashboards.NewFolderService(c.OrgId, c.SignedInUser) folder, err := s.GetFolderByUID(c.Params(":uid")) if err != nil { return toFolderError(err) } g := guardian.New(folder.Id, c.OrgId, c.SignedInUser) if canAdmin, err := g.CanAdmin(); err != nil || !canAdmin { return toFolderError(m.ErrFolderAccessDenied) } acl, err := g.GetAcl() if err != nil { return Error(500, "Failed to get folder permissions", err) } for _, perm := range acl { perm.FolderId = folder.Id perm.DashboardId = 0 perm.UserAvatarUrl = dtos.GetGravatarUrl(perm.UserEmail) if perm.TeamId > 0 { perm.TeamAvatarUrl = dtos.GetGravatarUrlWithDefault(perm.TeamEmail, perm.Team) } if perm.Slug != "" { perm.Url = m.GetDashboardFolderUrl(perm.IsFolder, perm.Uid, perm.Slug) } } return JSON(200, acl) } func UpdateFolderPermissions(c *m.ReqContext, apiCmd dtos.UpdateDashboardAclCommand) Response { s := dashboards.NewFolderService(c.OrgId, c.SignedInUser) folder, err := s.GetFolderByUID(c.Params(":uid")) if err != nil { return toFolderError(err) } g := guardian.New(folder.Id, c.OrgId, c.SignedInUser) canAdmin, err := g.CanAdmin() if err != nil { return toFolderError(err) } if !canAdmin { return toFolderError(m.ErrFolderAccessDenied) } cmd := m.UpdateDashboardAclCommand{} cmd.DashboardId = folder.Id for _, item := range apiCmd.Items { cmd.Items = append(cmd.Items, &m.DashboardAcl{ OrgId: c.OrgId, DashboardId: folder.Id, UserId: item.UserId, TeamId: item.TeamId, Role: item.Role, Permission: item.Permission, Created: time.Now(), Updated: time.Now(), }) } if okToUpdate, err := g.CheckPermissionBeforeUpdate(m.PERMISSION_ADMIN, cmd.Items); err != nil || !okToUpdate { if err != nil { if err == guardian.ErrGuardianPermissionExists || err == guardian.ErrGuardianOverride { return Error(400, err.Error(), err) } return Error(500, "Error while checking folder permissions", err) } return Error(403, "Cannot remove own admin permission for a folder", nil) } if err := bus.Dispatch(&cmd); err != nil { if err == m.ErrDashboardAclInfoMissing { err = m.ErrFolderAclInfoMissing } if err == m.ErrDashboardPermissionDashboardEmpty { err = m.ErrFolderPermissionFolderEmpty } if err == m.ErrFolderAclInfoMissing || err == m.ErrFolderPermissionFolderEmpty { return Error(409, err.Error(), err) } return Error(500, "Failed to create permission", err) } return Success("Folder permissions updated") }
pkg/api/folder_permission.go
0
https://github.com/grafana/grafana/commit/44eaa3eaa886e0f193e9b6ae364e0526c858cb00
[ 0.0001717016421025619, 0.0001699248532531783, 0.00016782643797341734, 0.00017008261056616902, 0.000001337442995463789 ]
{ "id": 6, "code_window": [ " <label className=\"gf-form--has-input-icon\">\n", " <input\n", " type=\"text\"\n", " className={`gf-form-input width-13 ${!this.hasSearchResults ? 'gf-form-input--invalid' : ''}`}\n", " placeholder=\"\"\n", " onChange={this.onSearchQueryChange}\n", " value={searchQuery}\n", " ref={elem => elem && elem.focus()}\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " className=\"gf-form-input width-13\"\n" ], "file_path": "public/app/features/dashboard/panel_editor/VisualizationTab.tsx", "type": "replace", "edit_start_line_idx": 191 }
<?xml version="1.0" encoding="utf-8"?> <!-- Generator: Adobe Illustrator 20.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="117.8px" height="64px" viewBox="0 0 117.8 64" style="enable-background:new 0 0 117.8 64;" xml:space="preserve"> <style type="text/css"> .st0{fill:#E3E2E2;} .st1{fill:url(#SVGID_1_);} </style> <g> <path class="st0" d="M15.2,22.7H1.9c-1.1,0-1.9,0.9-1.9,1.9v37.5C0,63.2,0.9,64,1.9,64h13.3c1.1,0,1.9-0.9,1.9-1.9V24.6 C17.1,23.5,16.3,22.7,15.2,22.7z"/> <path class="st0" d="M36.3,10.2H23c-1.1,0-1.9,0.9-1.9,1.9v50c0,1.1,0.9,1.9,1.9,1.9h13.3c1.1,0,1.9-0.9,1.9-1.9v-50 C38.2,11.1,37.3,10.2,36.3,10.2z"/> <path class="st0" d="M57.3,32H44c-1.1,0-1.9,0.9-1.9,1.9v28.1c0,1.1,0.9,1.9,1.9,1.9h13.3c1.1,0,1.9-0.9,1.9-1.9V34 C59.2,32.9,58.4,32,57.3,32z"/> <path class="st0" d="M70.1,38V26.1c0-3.4,2.7-6.1,6.1-6.1h4.1V2c0-1.1-0.9-1.9-1.9-1.9H65.1C64,0,63.1,0.9,63.1,2v60.1 c0,1.1,0.9,1.9,1.9,1.9h13.3c1.1,0,1.9-0.9,1.9-1.9V44.1h-4.1C72.9,44.1,70.1,41.3,70.1,38z"/> <linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="96.4427" y1="83.7013" x2="96.4427" y2="-9.4831"> <stop offset="0" style="stop-color:#FFF23A"/> <stop offset="4.010540e-02" style="stop-color:#FEE62D"/> <stop offset="0.1171" style="stop-color:#FED41A"/> <stop offset="0.1964" style="stop-color:#FDC90F"/> <stop offset="0.2809" style="stop-color:#FDC60B"/> <stop offset="0.6685" style="stop-color:#F28F3F"/> <stop offset="0.8876" style="stop-color:#ED693C"/> <stop offset="1" style="stop-color:#E83E39"/> </linearGradient> <path class="st1" d="M116.7,24.9h-7.2h-0.5h-5.4V11.8c0-0.6-0.5-1.1-1.1-1.1H90.5c-0.6,0-1.1,0.5-1.1,1.1v13.1h-9.1h-4.1 c-0.6,0-1.1,0.5-1.1,1.1V38c0,0.6,0.5,1.1,1.1,1.1h4.1h9.1v4.6v1.9v6.7c0,0.6,0.5,1.1,1.1,1.1h11.9c0.6,0,1.1-0.5,1.1-1.1V39.1 h13.1c0.6,0,1.1-0.5,1.1-1.1V26.1C117.8,25.5,117.3,24.9,116.7,24.9z"/> </g> </svg>
public/img/icons_dark_theme/icon_add_panel.svg
0
https://github.com/grafana/grafana/commit/44eaa3eaa886e0f193e9b6ae364e0526c858cb00
[ 0.00017146082245744765, 0.00016939132183324546, 0.00016556971240788698, 0.00017026736168190837, 0.000002299754896739614 ]
{ "id": 7, "code_window": [ " this.props.onTypeChanged(plugin);\n", " }\n", " };\n", "\n", " setSearchResults = (searchResults: PanelPlugin[]) => {\n", " this.setState({\n", " searchResults: searchResults\n", " });\n", " };\n", "\n", " get hasSearchResults () {\n", " return this.state.searchResults && this.state.searchResults.length > 0;\n", " }\n", "\n", " renderHelp = () => <PluginHelp plugin={this.props.plugin} type=\"help\" />;\n", "\n", " setScrollTop = (event: React.MouseEvent<HTMLElement>) => {\n", " const target = event.target as HTMLElement;\n", " this.setState({ scrollTop: target.scrollTop });\n" ], "labels": [ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [], "file_path": "public/app/features/dashboard/panel_editor/VisualizationTab.tsx", "type": "replace", "edit_start_line_idx": 223 }
import React, { PureComponent } from 'react'; import _ from 'lodash'; import config from 'app/core/config'; import { PanelPlugin } from 'app/types/plugins'; import VizTypePickerPlugin from './VizTypePickerPlugin'; export interface Props { current: PanelPlugin; onTypeChanged: (newType: PanelPlugin) => void; searchQuery: string; onClose: () => void; onPluginListChange: (searchResults: PanelPlugin[]) => void; } export class VizTypePicker extends PureComponent<Props> { searchInput: HTMLElement; pluginList = this.getPanelPlugins(''); constructor(props: Props) { super(props); } get maxSelectedIndex() { const filteredPluginList = this.getFilteredPluginList(); return filteredPluginList.length - 1; } getPanelPlugins(filter): PanelPlugin[] { const panels = _.chain(config.panels) .filter({ hideFromList: false }) .map(item => item) .value(); // add sort by sort property return _.sortBy(panels, 'sort'); } renderVizPlugin = (plugin: PanelPlugin, index: number) => { const { onTypeChanged } = this.props; const isCurrent = plugin.id === this.props.current.id; return ( <VizTypePickerPlugin key={plugin.id} isCurrent={isCurrent} plugin={plugin} onClick={() => onTypeChanged(plugin)} /> ); }; getFilteredPluginList = (): PanelPlugin[] => { const { searchQuery, onPluginListChange } = this.props; const regex = new RegExp(searchQuery, 'i'); const pluginList = this.pluginList; const filtered = pluginList.filter(item => { return regex.test(item.name); }); onPluginListChange(filtered); return filtered; }; render() { const filteredPluginList = this.getFilteredPluginList(); return ( <div className="viz-picker"> <div className="viz-picker-list"> {filteredPluginList.map((plugin, index) => this.renderVizPlugin(plugin, index))} </div> </div> ); } }
public/app/features/dashboard/panel_editor/VizTypePicker.tsx
1
https://github.com/grafana/grafana/commit/44eaa3eaa886e0f193e9b6ae364e0526c858cb00
[ 0.01363974716514349, 0.0031313772778958082, 0.0001656990498304367, 0.0016923043876886368, 0.0042185354977846146 ]
{ "id": 7, "code_window": [ " this.props.onTypeChanged(plugin);\n", " }\n", " };\n", "\n", " setSearchResults = (searchResults: PanelPlugin[]) => {\n", " this.setState({\n", " searchResults: searchResults\n", " });\n", " };\n", "\n", " get hasSearchResults () {\n", " return this.state.searchResults && this.state.searchResults.length > 0;\n", " }\n", "\n", " renderHelp = () => <PluginHelp plugin={this.props.plugin} type=\"help\" />;\n", "\n", " setScrollTop = (event: React.MouseEvent<HTMLElement>) => {\n", " const target = event.target as HTMLElement;\n", " this.setState({ scrollTop: target.scrollTop });\n" ], "labels": [ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [], "file_path": "public/app/features/dashboard/panel_editor/VisualizationTab.tsx", "type": "replace", "edit_start_line_idx": 223 }
// Rotated & Flipped Icons // ------------------------- .#{$fa-css-prefix}-rotate-90 { @include fa-icon-rotate(90deg, 1); } .#{$fa-css-prefix}-rotate-180 { @include fa-icon-rotate(180deg, 2); } .#{$fa-css-prefix}-rotate-270 { @include fa-icon-rotate(270deg, 3); } .#{$fa-css-prefix}-flip-horizontal { @include fa-icon-flip(-1, 1, 0); } .#{$fa-css-prefix}-flip-vertical { @include fa-icon-flip(1, -1, 2); } // Hook for IE8-9 // ------------------------- :root .#{$fa-css-prefix}-rotate-90, :root .#{$fa-css-prefix}-rotate-180, :root .#{$fa-css-prefix}-rotate-270, :root .#{$fa-css-prefix}-flip-horizontal, :root .#{$fa-css-prefix}-flip-vertical { filter: none; }
public/sass/base/font-awesome/_rotated-flipped.scss
0
https://github.com/grafana/grafana/commit/44eaa3eaa886e0f193e9b6ae364e0526c858cb00
[ 0.00017622749146539718, 0.00017316234880127013, 0.00016857896116562188, 0.0001739214640110731, 0.0000029454336072376464 ]
{ "id": 7, "code_window": [ " this.props.onTypeChanged(plugin);\n", " }\n", " };\n", "\n", " setSearchResults = (searchResults: PanelPlugin[]) => {\n", " this.setState({\n", " searchResults: searchResults\n", " });\n", " };\n", "\n", " get hasSearchResults () {\n", " return this.state.searchResults && this.state.searchResults.length > 0;\n", " }\n", "\n", " renderHelp = () => <PluginHelp plugin={this.props.plugin} type=\"help\" />;\n", "\n", " setScrollTop = (event: React.MouseEvent<HTMLElement>) => {\n", " const target = event.target as HTMLElement;\n", " this.setState({ scrollTop: target.scrollTop });\n" ], "labels": [ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [], "file_path": "public/app/features/dashboard/panel_editor/VisualizationTab.tsx", "type": "replace", "edit_start_line_idx": 223 }
// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package websocket implements the WebSocket protocol defined in RFC 6455. // // Overview // // The Conn type represents a WebSocket connection. A server application uses // the Upgrade function from an Upgrader object with a HTTP request handler // to get a pointer to a Conn: // // var upgrader = websocket.Upgrader{ // ReadBufferSize: 1024, // WriteBufferSize: 1024, // } // // func handler(w http.ResponseWriter, r *http.Request) { // conn, err := upgrader.Upgrade(w, r, nil) // if err != nil { // log.Println(err) // return // } // ... Use conn to send and receive messages. // } // // Call the connection's WriteMessage and ReadMessage methods to send and // receive messages as a slice of bytes. This snippet of code shows how to echo // messages using these methods: // // for { // messageType, p, err := conn.ReadMessage() // if err != nil { // return // } // if err = conn.WriteMessage(messageType, p); err != nil { // return err // } // } // // In above snippet of code, p is a []byte and messageType is an int with value // websocket.BinaryMessage or websocket.TextMessage. // // An application can also send and receive messages using the io.WriteCloser // and io.Reader interfaces. To send a message, call the connection NextWriter // method to get an io.WriteCloser, write the message to the writer and close // the writer when done. To receive a message, call the connection NextReader // method to get an io.Reader and read until io.EOF is returned. This snippet // shows how to echo messages using the NextWriter and NextReader methods: // // for { // messageType, r, err := conn.NextReader() // if err != nil { // return // } // w, err := conn.NextWriter(messageType) // if err != nil { // return err // } // if _, err := io.Copy(w, r); err != nil { // return err // } // if err := w.Close(); err != nil { // return err // } // } // // Data Messages // // The WebSocket protocol distinguishes between text and binary data messages. // Text messages are interpreted as UTF-8 encoded text. The interpretation of // binary messages is left to the application. // // This package uses the TextMessage and BinaryMessage integer constants to // identify the two data message types. The ReadMessage and NextReader methods // return the type of the received message. The messageType argument to the // WriteMessage and NextWriter methods specifies the type of a sent message. // // It is the application's responsibility to ensure that text messages are // valid UTF-8 encoded text. // // Control Messages // // The WebSocket protocol defines three types of control messages: close, ping // and pong. Call the connection WriteControl, WriteMessage or NextWriter // methods to send a control message to the peer. // // Connections handle received close messages by sending a close message to the // peer and returning a *CloseError from the the NextReader, ReadMessage or the // message Read method. // // Connections handle received ping and pong messages by invoking callback // functions set with SetPingHandler and SetPongHandler methods. The callback // functions are called from the NextReader, ReadMessage and the message Read // methods. // // The default ping handler sends a pong to the peer. The application's reading // goroutine can block for a short time while the handler writes the pong data // to the connection. // // The application must read the connection to process ping, pong and close // messages sent from the peer. If the application is not otherwise interested // in messages from the peer, then the application should start a goroutine to // read and discard messages from the peer. A simple example is: // // func readLoop(c *websocket.Conn) { // for { // if _, _, err := c.NextReader(); err != nil { // c.Close() // break // } // } // } // // Concurrency // // Connections support one concurrent reader and one concurrent writer. // // Applications are responsible for ensuring that no more than one goroutine // calls the write methods (NextWriter, SetWriteDeadline, WriteMessage, // WriteJSON, EnableWriteCompression, SetCompressionLevel) concurrently and // that no more than one goroutine calls the read methods (NextReader, // SetReadDeadline, ReadMessage, ReadJSON, SetPongHandler, SetPingHandler) // concurrently. // // The Close and WriteControl methods can be called concurrently with all other // methods. // // Origin Considerations // // Web browsers allow Javascript applications to open a WebSocket connection to // any host. It's up to the server to enforce an origin policy using the Origin // request header sent by the browser. // // The Upgrader calls the function specified in the CheckOrigin field to check // the origin. If the CheckOrigin function returns false, then the Upgrade // method fails the WebSocket handshake with HTTP status 403. // // If the CheckOrigin field is nil, then the Upgrader uses a safe default: fail // the handshake if the Origin request header is present and not equal to the // Host request header. // // An application can allow connections from any origin by specifying a // function that always returns true: // // var upgrader = websocket.Upgrader{ // CheckOrigin: func(r *http.Request) bool { return true }, // } // // The deprecated Upgrade function does not enforce an origin policy. It's the // application's responsibility to check the Origin header before calling // Upgrade. // // Compression EXPERIMENTAL // // Per message compression extensions (RFC 7692) are experimentally supported // by this package in a limited capacity. Setting the EnableCompression option // to true in Dialer or Upgrader will attempt to negotiate per message deflate // support. // // var upgrader = websocket.Upgrader{ // EnableCompression: true, // } // // If compression was successfully negotiated with the connection's peer, any // message received in compressed form will be automatically decompressed. // All Read methods will return uncompressed bytes. // // Per message compression of messages written to a connection can be enabled // or disabled by calling the corresponding Conn method: // // conn.EnableWriteCompression(false) // // Currently this package does not support compression with "context takeover". // This means that messages must be compressed and decompressed in isolation, // without retaining sliding window or dictionary state across messages. For // more details refer to RFC 7692. // // Use of compression is experimental and may result in decreased performance. package websocket
vendor/github.com/gorilla/websocket/doc.go
0
https://github.com/grafana/grafana/commit/44eaa3eaa886e0f193e9b6ae364e0526c858cb00
[ 0.00017598133126739413, 0.00016876937297638506, 0.00016100741049740463, 0.00016857896116562188, 0.0000039143874346336816 ]
{ "id": 7, "code_window": [ " this.props.onTypeChanged(plugin);\n", " }\n", " };\n", "\n", " setSearchResults = (searchResults: PanelPlugin[]) => {\n", " this.setState({\n", " searchResults: searchResults\n", " });\n", " };\n", "\n", " get hasSearchResults () {\n", " return this.state.searchResults && this.state.searchResults.length > 0;\n", " }\n", "\n", " renderHelp = () => <PluginHelp plugin={this.props.plugin} type=\"help\" />;\n", "\n", " setScrollTop = (event: React.MouseEvent<HTMLElement>) => {\n", " const target = event.target as HTMLElement;\n", " this.setState({ scrollTop: target.scrollTop });\n" ], "labels": [ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [], "file_path": "public/app/features/dashboard/panel_editor/VisualizationTab.tsx", "type": "replace", "edit_start_line_idx": 223 }
import coreModule from 'app/core/core_module'; import appEvents from 'app/core/app_events'; import { store } from 'app/store/store'; import locationUtil from 'app/core/utils/location_util'; import { updateLocation } from 'app/core/actions'; // Services that handles angular -> redux store sync & other react <-> angular sync export class BridgeSrv { private fullPageReloadRoutes; /** @ngInject */ constructor(private $location, private $timeout, private $window, private $rootScope, private $route) { this.fullPageReloadRoutes = ['/logout']; } init() { this.$rootScope.$on('$routeUpdate', (evt, data) => { const angularUrl = this.$location.url(); const state = store.getState(); if (state.location.url !== angularUrl) { store.dispatch( updateLocation({ path: this.$location.path(), query: this.$location.search(), routeParams: this.$route.current.params, }) ); } }); this.$rootScope.$on('$routeChangeSuccess', (evt, data) => { store.dispatch( updateLocation({ path: this.$location.path(), query: this.$location.search(), routeParams: this.$route.current.params, }) ); }); // Listen for changes in redux location -> update angular location store.subscribe(() => { const state = store.getState(); const angularUrl = this.$location.url(); const url = locationUtil.stripBaseFromUrl(state.location.url); if (angularUrl !== url) { this.$timeout(() => { this.$location.url(url); // some state changes should not trigger new browser history if (state.location.replace) { this.$location.replace(); } }); console.log('store updating angular $location.url', url); } }); appEvents.on('location-change', payload => { const urlWithoutBase = locationUtil.stripBaseFromUrl(payload.href); if (this.fullPageReloadRoutes.indexOf(urlWithoutBase) > -1) { this.$window.location.href = payload.href; return; } this.$timeout(() => { // A hack to use timeout when we're changing things (in this case the url) from outside of Angular. this.$location.url(urlWithoutBase); }); }); } } coreModule.service('bridgeSrv', BridgeSrv);
public/app/core/services/bridge_srv.ts
0
https://github.com/grafana/grafana/commit/44eaa3eaa886e0f193e9b6ae364e0526c858cb00
[ 0.00017565427697263658, 0.00017177191330119967, 0.00016928899276535958, 0.00017181888688355684, 0.000001926761115100817 ]
{ "id": 8, "code_window": [ " onTypeChanged={this.onTypeChanged}\n", " searchQuery={searchQuery}\n", " onClose={this.onCloseVizPicker}\n", " onPluginListChange={this.setSearchResults}\n", " />\n", " </FadeIn>\n", " {this.renderPanelOptions()}\n", " </>\n", " </EditorTabBody>\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [], "file_path": "public/app/features/dashboard/panel_editor/VisualizationTab.tsx", "type": "replace", "edit_start_line_idx": 265 }
// Libraries import React, { PureComponent, ChangeEvent } from 'react'; // Utils & Services import { AngularComponent, getAngularLoader } from 'app/core/services/AngularLoader'; import { connectWithStore } from 'app/core/utils/connectWithReduxStore'; import { StoreState } from 'app/types'; import { updateLocation } from 'app/core/actions'; // Components import { EditorTabBody, EditorToolbarView } from './EditorTabBody'; import { VizTypePicker } from './VizTypePicker'; import { PluginHelp } from 'app/core/components/PluginHelp/PluginHelp'; import { FadeIn } from 'app/core/components/Animations/FadeIn'; // Types import { PanelModel } from '../state/PanelModel'; import { DashboardModel } from '../state/DashboardModel'; import { PanelPlugin } from 'app/types/plugins'; interface Props { panel: PanelModel; dashboard: DashboardModel; plugin: PanelPlugin; angularPanel?: AngularComponent; onTypeChanged: (newType: PanelPlugin) => void; updateLocation: typeof updateLocation; urlOpenVizPicker: boolean; } interface State { isVizPickerOpen: boolean; searchQuery: string; searchResults: PanelPlugin[]; scrollTop: number; } export class VisualizationTab extends PureComponent<Props, State> { element: HTMLElement; angularOptions: AngularComponent; searchInput: HTMLElement; constructor(props: Props) { super(props); this.state = { isVizPickerOpen: this.props.urlOpenVizPicker, searchQuery: '', searchResults: [], scrollTop: 0, }; } getPanelDefaultOptions = () => { const { panel, plugin } = this.props; if (plugin.exports.PanelDefaults) { return panel.getOptions(plugin.exports.PanelDefaults.options); } return panel.getOptions(plugin.exports.PanelDefaults); }; renderPanelOptions() { const { plugin, angularPanel } = this.props; const { PanelOptions } = plugin.exports; if (angularPanel) { return <div ref={element => (this.element = element)} />; } return ( <> {PanelOptions ? ( <PanelOptions options={this.getPanelDefaultOptions()} onChange={this.onPanelOptionsChanged} /> ) : ( <p>Visualization has no options</p> )} </> ); } componentDidMount() { if (this.shouldLoadAngularOptions()) { this.loadAngularOptions(); } } componentDidUpdate(prevProps: Props) { if (this.props.plugin !== prevProps.plugin) { this.cleanUpAngularOptions(); } if (this.shouldLoadAngularOptions()) { this.loadAngularOptions(); } } shouldLoadAngularOptions() { return this.props.angularPanel && this.element && !this.angularOptions; } loadAngularOptions() { const { angularPanel } = this.props; const scope = angularPanel.getScope(); // When full page reloading in edit mode the angular panel has on fully compiled & instantiated yet if (!scope.$$childHead) { setTimeout(() => { this.forceUpdate(); }); return; } const panelCtrl = scope.$$childHead.ctrl; panelCtrl.initEditMode(); let template = ''; for (let i = 0; i < panelCtrl.editorTabs.length; i++) { template += ` <div class="panel-options-group" ng-cloak>` + (i > 0 ? `<div class="panel-options-group__header"> <span class="panel-options-group__title">{{ctrl.editorTabs[${i}].title}} </span> </div>` : '') + `<div class="panel-options-group__body"> <panel-editor-tab editor-tab="ctrl.editorTabs[${i}]" ctrl="ctrl"></panel-editor-tab> </div> </div> `; } const loader = getAngularLoader(); const scopeProps = { ctrl: panelCtrl }; this.angularOptions = loader.load(this.element, scopeProps, template); } componentWillUnmount() { this.cleanUpAngularOptions(); } cleanUpAngularOptions() { if (this.angularOptions) { this.angularOptions.destroy(); this.angularOptions = null; } } clearQuery = () => { this.setState({ searchQuery: '' }); }; onPanelOptionsChanged = (options: any) => { this.props.panel.updateOptions(options); this.forceUpdate(); }; onOpenVizPicker = () => { this.setState({ isVizPickerOpen: true, scrollTop: 0 }); }; onCloseVizPicker = () => { if (this.props.urlOpenVizPicker) { this.props.updateLocation({ query: { openVizPicker: null }, partial: true }); } this.setState({ isVizPickerOpen: false }); }; onSearchQueryChange = (evt: ChangeEvent<HTMLInputElement>) => { const value = evt.target.value; this.setState({ searchQuery: value, }); }; renderToolbar = (): JSX.Element => { const { plugin } = this.props; const { searchQuery } = this.state; if (this.state.isVizPickerOpen) { return ( <> <label className="gf-form--has-input-icon"> <input type="text" className={`gf-form-input width-13 ${!this.hasSearchResults ? 'gf-form-input--invalid' : ''}`} placeholder="" onChange={this.onSearchQueryChange} value={searchQuery} ref={elem => elem && elem.focus()} /> <i className="gf-form-input-icon fa fa-search" /> </label> <button className="btn btn-link toolbar__close" onClick={this.onCloseVizPicker}> <i className="fa fa-chevron-up" /> </button> </> ); } else { return ( <div className="toolbar__main" onClick={this.onOpenVizPicker}> <img className="toolbar__main-image" src={plugin.info.logos.small} /> <div className="toolbar__main-name">{plugin.name}</div> <i className="fa fa-caret-down" /> </div> ); } }; onTypeChanged = (plugin: PanelPlugin) => { if (plugin.id === this.props.plugin.id) { this.setState({ isVizPickerOpen: false }); } else { this.props.onTypeChanged(plugin); } }; setSearchResults = (searchResults: PanelPlugin[]) => { this.setState({ searchResults: searchResults }); }; get hasSearchResults () { return this.state.searchResults && this.state.searchResults.length > 0; } renderHelp = () => <PluginHelp plugin={this.props.plugin} type="help" />; setScrollTop = (event: React.MouseEvent<HTMLElement>) => { const target = event.target as HTMLElement; this.setState({ scrollTop: target.scrollTop }); }; render() { const { plugin } = this.props; const { isVizPickerOpen, searchQuery, scrollTop } = this.state; const pluginHelp: EditorToolbarView = { heading: 'Help', icon: 'fa fa-question', render: this.renderHelp, }; return ( <EditorTabBody heading="Visualization" renderToolbar={this.renderToolbar} toolbarItems={[pluginHelp]} scrollTop={scrollTop} setScrollTop={this.setScrollTop} > <> <FadeIn in={isVizPickerOpen} duration={200} unmountOnExit={true} onExited={this.clearQuery}> <VizTypePicker current={plugin} onTypeChanged={this.onTypeChanged} searchQuery={searchQuery} onClose={this.onCloseVizPicker} onPluginListChange={this.setSearchResults} /> </FadeIn> {this.renderPanelOptions()} </> </EditorTabBody> ); } } const mapStateToProps = (state: StoreState) => ({ urlOpenVizPicker: !!state.location.query.openVizPicker, }); const mapDispatchToProps = { updateLocation, }; export default connectWithStore(VisualizationTab, mapStateToProps, mapDispatchToProps);
public/app/features/dashboard/panel_editor/VisualizationTab.tsx
1
https://github.com/grafana/grafana/commit/44eaa3eaa886e0f193e9b6ae364e0526c858cb00
[ 0.9000750780105591, 0.03403879329562187, 0.0001653231302043423, 0.0010591918835416436, 0.16380825638771057 ]
{ "id": 8, "code_window": [ " onTypeChanged={this.onTypeChanged}\n", " searchQuery={searchQuery}\n", " onClose={this.onCloseVizPicker}\n", " onPluginListChange={this.setSearchResults}\n", " />\n", " </FadeIn>\n", " {this.renderPanelOptions()}\n", " </>\n", " </EditorTabBody>\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [], "file_path": "public/app/features/dashboard/panel_editor/VisualizationTab.tsx", "type": "replace", "edit_start_line_idx": 265 }
// Copyright 2014 com authors // // Licensed under the Apache License, Version 2.0 (the "License"): you may // not use this file except in compliance with the License. You may obtain // a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the // License for the specific language governing permissions and limitations // under the License. package com // PowInt is int type of math.Pow function. func PowInt(x int, y int) int { if y <= 0 { return 1 } else { if y % 2 == 0 { sqrt := PowInt(x, y/2) return sqrt * sqrt } else { return PowInt(x, y-1) * x } } }
vendor/github.com/Unknwon/com/math.go
0
https://github.com/grafana/grafana/commit/44eaa3eaa886e0f193e9b6ae364e0526c858cb00
[ 0.00017767175449989736, 0.00017162349831778556, 0.0001663611183175817, 0.00017083759303204715, 0.000004650867140298942 ]
{ "id": 8, "code_window": [ " onTypeChanged={this.onTypeChanged}\n", " searchQuery={searchQuery}\n", " onClose={this.onCloseVizPicker}\n", " onPluginListChange={this.setSearchResults}\n", " />\n", " </FadeIn>\n", " {this.renderPanelOptions()}\n", " </>\n", " </EditorTabBody>\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [], "file_path": "public/app/features/dashboard/panel_editor/VisualizationTab.tsx", "type": "replace", "edit_start_line_idx": 265 }
// Libraries import classNames from 'classnames'; import React, { PureComponent } from 'react'; // Ignoring because I couldn't get @types/react-select work wih Torkel's fork // @ts-ignore import { default as ReactSelect } from '@torkelo/react-select'; // @ts-ignore import { default as ReactAsyncSelect } from '@torkelo/react-select/lib/Async'; // @ts-ignore import { components } from '@torkelo/react-select'; // Components import { SelectOption, SingleValue } from './SelectOption'; import SelectOptionGroup from './SelectOptionGroup'; import IndicatorsContainer from './IndicatorsContainer'; import NoOptionsMessage from './NoOptionsMessage'; import resetSelectStyles from './resetSelectStyles'; import { CustomScrollbar } from '..'; export interface SelectOptionItem { label?: string; value?: any; imgUrl?: string; description?: string; [key: string]: any; } interface CommonProps { defaultValue?: any; getOptionLabel?: (item: SelectOptionItem) => string; getOptionValue?: (item: SelectOptionItem) => string; onChange: (item: SelectOptionItem) => {} | void; placeholder?: string; width?: number; value?: SelectOptionItem; className?: string; isDisabled?: boolean; isSearchable?: boolean; isClearable?: boolean; autoFocus?: boolean; openMenuOnFocus?: boolean; onBlur?: () => void; maxMenuHeight?: number; isLoading: boolean; noOptionsMessage?: () => string; isMulti?: boolean; backspaceRemovesValue: boolean; } interface SelectProps { options: SelectOptionItem[]; } interface AsyncProps { defaultOptions: boolean; loadOptions: (query: string) => Promise<SelectOptionItem[]>; loadingMessage?: () => string; } export const MenuList = (props: any) => { return ( <components.MenuList {...props}> <CustomScrollbar autoHide={false} autoHeightMax="inherit">{props.children}</CustomScrollbar> </components.MenuList> ); }; export class Select extends PureComponent<CommonProps & SelectProps> { static defaultProps = { width: null, className: '', isDisabled: false, isSearchable: true, isClearable: false, isMulti: false, openMenuOnFocus: false, autoFocus: false, isLoading: false, backspaceRemovesValue: true, maxMenuHeight: 300, }; render() { const { defaultValue, getOptionLabel, getOptionValue, onChange, options, placeholder, width, value, className, isDisabled, isLoading, isSearchable, isClearable, backspaceRemovesValue, isMulti, autoFocus, openMenuOnFocus, onBlur, maxMenuHeight, noOptionsMessage, } = this.props; let widthClass = ''; if (width) { widthClass = 'width-' + width; } const selectClassNames = classNames('gf-form-input', 'gf-form-input--form-dropdown', widthClass, className); return ( <ReactSelect classNamePrefix="gf-form-select-box" className={selectClassNames} components={{ Option: SelectOption, SingleValue, IndicatorsContainer, MenuList, Group: SelectOptionGroup, }} defaultValue={defaultValue} value={value} getOptionLabel={getOptionLabel} getOptionValue={getOptionValue} menuShouldScrollIntoView={false} isSearchable={isSearchable} onChange={onChange} options={options} placeholder={placeholder || 'Choose'} styles={resetSelectStyles()} isDisabled={isDisabled} isLoading={isLoading} isClearable={isClearable} autoFocus={autoFocus} onBlur={onBlur} openMenuOnFocus={openMenuOnFocus} maxMenuHeight={maxMenuHeight} noOptionsMessage={noOptionsMessage} isMulti={isMulti} backspaceRemovesValue={backspaceRemovesValue} /> ); } } export class AsyncSelect extends PureComponent<CommonProps & AsyncProps> { static defaultProps = { width: null, className: '', components: {}, loadingMessage: () => 'Loading...', isDisabled: false, isClearable: false, isMulti: false, isSearchable: true, backspaceRemovesValue: true, autoFocus: false, openMenuOnFocus: false, maxMenuHeight: 300, }; render() { const { defaultValue, getOptionLabel, getOptionValue, onChange, placeholder, width, value, className, loadOptions, defaultOptions, isLoading, loadingMessage, noOptionsMessage, isDisabled, isSearchable, isClearable, backspaceRemovesValue, autoFocus, onBlur, openMenuOnFocus, maxMenuHeight, isMulti, } = this.props; let widthClass = ''; if (width) { widthClass = 'width-' + width; } const selectClassNames = classNames('gf-form-input', 'gf-form-input--form-dropdown', widthClass, className); return ( <ReactAsyncSelect classNamePrefix="gf-form-select-box" className={selectClassNames} components={{ Option: SelectOption, SingleValue, IndicatorsContainer, NoOptionsMessage, }} defaultValue={defaultValue} value={value} getOptionLabel={getOptionLabel} getOptionValue={getOptionValue} menuShouldScrollIntoView={false} onChange={onChange} loadOptions={loadOptions} isLoading={isLoading} defaultOptions={defaultOptions} placeholder={placeholder || 'Choose'} styles={resetSelectStyles()} loadingMessage={loadingMessage} noOptionsMessage={noOptionsMessage} isDisabled={isDisabled} isSearchable={isSearchable} isClearable={isClearable} autoFocus={autoFocus} onBlur={onBlur} openMenuOnFocus={openMenuOnFocus} maxMenuHeight={maxMenuHeight} isMulti={isMulti} backspaceRemovesValue={backspaceRemovesValue} /> ); } } export default Select;
packages/grafana-ui/src/components/Select/Select.tsx
0
https://github.com/grafana/grafana/commit/44eaa3eaa886e0f193e9b6ae364e0526c858cb00
[ 0.00017802482761908323, 0.00016971120203379542, 0.00016296202375087887, 0.00016997211787384003, 0.000003354858563398011 ]
{ "id": 8, "code_window": [ " onTypeChanged={this.onTypeChanged}\n", " searchQuery={searchQuery}\n", " onClose={this.onCloseVizPicker}\n", " onPluginListChange={this.setSearchResults}\n", " />\n", " </FadeIn>\n", " {this.renderPanelOptions()}\n", " </>\n", " </EditorTabBody>\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [], "file_path": "public/app/features/dashboard/panel_editor/VisualizationTab.tsx", "type": "replace", "edit_start_line_idx": 265 }
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package build import ( "fmt" "log" "sort" "strings" "unicode" "golang.org/x/text/internal/colltab" "golang.org/x/text/unicode/norm" ) type logicalAnchor int const ( firstAnchor logicalAnchor = -1 noAnchor = 0 lastAnchor = 1 ) // entry is used to keep track of a single entry in the collation element table // during building. Examples of entries can be found in the Default Unicode // Collation Element Table. // See http://www.unicode.org/Public/UCA/6.0.0/allkeys.txt. type entry struct { str string // same as string(runes) runes []rune elems []rawCE // the collation elements extend string // weights of extend to be appended to elems before bool // weights relative to next instead of previous. lock bool // entry is used in extension and can no longer be moved. // prev, next, and level are used to keep track of tailorings. prev, next *entry level colltab.Level // next differs at this level skipRemove bool // do not unlink when removed decompose bool // can use NFKD decomposition to generate elems exclude bool // do not include in table implicit bool // derived, is not included in the list modified bool // entry was modified in tailoring logical logicalAnchor expansionIndex int // used to store index into expansion table contractionHandle ctHandle contractionIndex int // index into contraction elements } func (e *entry) String() string { return fmt.Sprintf("%X (%q) -> %X (ch:%x; ci:%d, ei:%d)", e.runes, e.str, e.elems, e.contractionHandle, e.contractionIndex, e.expansionIndex) } func (e *entry) skip() bool { return e.contraction() } func (e *entry) expansion() bool { return !e.decompose && len(e.elems) > 1 } func (e *entry) contraction() bool { return len(e.runes) > 1 } func (e *entry) contractionStarter() bool { return e.contractionHandle.n != 0 } // nextIndexed gets the next entry that needs to be stored in the table. // It returns the entry and the collation level at which the next entry differs // from the current entry. // Entries that can be explicitly derived and logical reset positions are // examples of entries that will not be indexed. func (e *entry) nextIndexed() (*entry, colltab.Level) { level := e.level for e = e.next; e != nil && (e.exclude || len(e.elems) == 0); e = e.next { if e.level < level { level = e.level } } return e, level } // remove unlinks entry e from the sorted chain and clears the collation // elements. e may not be at the front or end of the list. This should always // be the case, as the front and end of the list are always logical anchors, // which may not be removed. func (e *entry) remove() { if e.logical != noAnchor { log.Fatalf("may not remove anchor %q", e.str) } // TODO: need to set e.prev.level to e.level if e.level is smaller? e.elems = nil if !e.skipRemove { if e.prev != nil { e.prev.next = e.next } if e.next != nil { e.next.prev = e.prev } } e.skipRemove = false } // insertAfter inserts n after e. func (e *entry) insertAfter(n *entry) { if e == n { panic("e == anchor") } if e == nil { panic("unexpected nil anchor") } n.remove() n.decompose = false // redo decomposition test n.next = e.next n.prev = e if e.next != nil { e.next.prev = n } e.next = n } // insertBefore inserts n before e. func (e *entry) insertBefore(n *entry) { if e == n { panic("e == anchor") } if e == nil { panic("unexpected nil anchor") } n.remove() n.decompose = false // redo decomposition test n.prev = e.prev n.next = e if e.prev != nil { e.prev.next = n } e.prev = n } func (e *entry) encodeBase() (ce uint32, err error) { switch { case e.expansion(): ce, err = makeExpandIndex(e.expansionIndex) default: if e.decompose { log.Fatal("decompose should be handled elsewhere") } ce, err = makeCE(e.elems[0]) } return } func (e *entry) encode() (ce uint32, err error) { if e.skip() { log.Fatal("cannot build colElem for entry that should be skipped") } switch { case e.decompose: t1 := e.elems[0].w[2] t2 := 0 if len(e.elems) > 1 { t2 = e.elems[1].w[2] } ce, err = makeDecompose(t1, t2) case e.contractionStarter(): ce, err = makeContractIndex(e.contractionHandle, e.contractionIndex) default: if len(e.runes) > 1 { log.Fatal("colElem: contractions are handled in contraction trie") } ce, err = e.encodeBase() } return } // entryLess returns true if a sorts before b and false otherwise. func entryLess(a, b *entry) bool { if res, _ := compareWeights(a.elems, b.elems); res != 0 { return res == -1 } if a.logical != noAnchor { return a.logical == firstAnchor } if b.logical != noAnchor { return b.logical == lastAnchor } return a.str < b.str } type sortedEntries []*entry func (s sortedEntries) Len() int { return len(s) } func (s sortedEntries) Swap(i, j int) { s[i], s[j] = s[j], s[i] } func (s sortedEntries) Less(i, j int) bool { return entryLess(s[i], s[j]) } type ordering struct { id string entryMap map[string]*entry ordered []*entry handle *trieHandle } // insert inserts e into both entryMap and ordered. // Note that insert simply appends e to ordered. To reattain a sorted // order, o.sort() should be called. func (o *ordering) insert(e *entry) { if e.logical == noAnchor { o.entryMap[e.str] = e } else { // Use key format as used in UCA rules. o.entryMap[fmt.Sprintf("[%s]", e.str)] = e // Also add index entry for XML format. o.entryMap[fmt.Sprintf("<%s/>", strings.Replace(e.str, " ", "_", -1))] = e } o.ordered = append(o.ordered, e) } // newEntry creates a new entry for the given info and inserts it into // the index. func (o *ordering) newEntry(s string, ces []rawCE) *entry { e := &entry{ runes: []rune(s), elems: ces, str: s, } o.insert(e) return e } // find looks up and returns the entry for the given string. // It returns nil if str is not in the index and if an implicit value // cannot be derived, that is, if str represents more than one rune. func (o *ordering) find(str string) *entry { e := o.entryMap[str] if e == nil { r := []rune(str) if len(r) == 1 { const ( firstHangul = 0xAC00 lastHangul = 0xD7A3 ) if r[0] >= firstHangul && r[0] <= lastHangul { ce := []rawCE{} nfd := norm.NFD.String(str) for _, r := range nfd { ce = append(ce, o.find(string(r)).elems...) } e = o.newEntry(nfd, ce) } else { e = o.newEntry(string(r[0]), []rawCE{ {w: []int{ implicitPrimary(r[0]), defaultSecondary, defaultTertiary, int(r[0]), }, }, }) e.modified = true } e.exclude = true // do not index implicits } } return e } // makeRootOrdering returns a newly initialized ordering value and populates // it with a set of logical reset points that can be used as anchors. // The anchors first_tertiary_ignorable and __END__ will always sort at // the beginning and end, respectively. This means that prev and next are non-nil // for any indexed entry. func makeRootOrdering() ordering { const max = unicode.MaxRune o := ordering{ entryMap: make(map[string]*entry), } insert := func(typ logicalAnchor, s string, ce []int) { e := &entry{ elems: []rawCE{{w: ce}}, str: s, exclude: true, logical: typ, } o.insert(e) } insert(firstAnchor, "first tertiary ignorable", []int{0, 0, 0, 0}) insert(lastAnchor, "last tertiary ignorable", []int{0, 0, 0, max}) insert(lastAnchor, "last primary ignorable", []int{0, defaultSecondary, defaultTertiary, max}) insert(lastAnchor, "last non ignorable", []int{maxPrimary, defaultSecondary, defaultTertiary, max}) insert(lastAnchor, "__END__", []int{1 << maxPrimaryBits, defaultSecondary, defaultTertiary, max}) return o } // patchForInsert eleminates entries from the list with more than one collation element. // The next and prev fields of the eliminated entries still point to appropriate // values in the newly created list. // It requires that sort has been called. func (o *ordering) patchForInsert() { for i := 0; i < len(o.ordered)-1; { e := o.ordered[i] lev := e.level n := e.next for ; n != nil && len(n.elems) > 1; n = n.next { if n.level < lev { lev = n.level } n.skipRemove = true } for ; o.ordered[i] != n; i++ { o.ordered[i].level = lev o.ordered[i].next = n o.ordered[i+1].prev = e } } } // clone copies all ordering of es into a new ordering value. func (o *ordering) clone() *ordering { o.sort() oo := ordering{ entryMap: make(map[string]*entry), } for _, e := range o.ordered { ne := &entry{ runes: e.runes, elems: e.elems, str: e.str, decompose: e.decompose, exclude: e.exclude, logical: e.logical, } oo.insert(ne) } oo.sort() // link all ordering. oo.patchForInsert() return &oo } // front returns the first entry to be indexed. // It assumes that sort() has been called. func (o *ordering) front() *entry { e := o.ordered[0] if e.prev != nil { log.Panicf("unexpected first entry: %v", e) } // The first entry is always a logical position, which should not be indexed. e, _ = e.nextIndexed() return e } // sort sorts all ordering based on their collation elements and initializes // the prev, next, and level fields accordingly. func (o *ordering) sort() { sort.Sort(sortedEntries(o.ordered)) l := o.ordered for i := 1; i < len(l); i++ { k := i - 1 l[k].next = l[i] _, l[k].level = compareWeights(l[k].elems, l[i].elems) l[i].prev = l[k] } } // genColElems generates a collation element array from the runes in str. This // assumes that all collation elements have already been added to the Builder. func (o *ordering) genColElems(str string) []rawCE { elems := []rawCE{} for _, r := range []rune(str) { for _, ce := range o.find(string(r)).elems { if ce.w[0] != 0 || ce.w[1] != 0 || ce.w[2] != 0 { elems = append(elems, ce) } } } return elems }
vendor/golang.org/x/text/collate/build/order.go
0
https://github.com/grafana/grafana/commit/44eaa3eaa886e0f193e9b6ae364e0526c858cb00
[ 0.00017853922327049077, 0.0001715920661808923, 0.00016165920533239841, 0.00017227776697836816, 0.000003915318757208297 ]
{ "id": 9, "code_window": [ "export interface Props {\n", " current: PanelPlugin;\n", " onTypeChanged: (newType: PanelPlugin) => void;\n", " searchQuery: string;\n", " onClose: () => void;\n", " onPluginListChange: (searchResults: PanelPlugin[]) => void;\n", "}\n", "\n", "export class VizTypePicker extends PureComponent<Props> {\n", " searchInput: HTMLElement;\n", " pluginList = this.getPanelPlugins('');\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [], "file_path": "public/app/features/dashboard/panel_editor/VizTypePicker.tsx", "type": "replace", "edit_start_line_idx": 12 }
// Libraries import React, { PureComponent, ChangeEvent } from 'react'; // Utils & Services import { AngularComponent, getAngularLoader } from 'app/core/services/AngularLoader'; import { connectWithStore } from 'app/core/utils/connectWithReduxStore'; import { StoreState } from 'app/types'; import { updateLocation } from 'app/core/actions'; // Components import { EditorTabBody, EditorToolbarView } from './EditorTabBody'; import { VizTypePicker } from './VizTypePicker'; import { PluginHelp } from 'app/core/components/PluginHelp/PluginHelp'; import { FadeIn } from 'app/core/components/Animations/FadeIn'; // Types import { PanelModel } from '../state/PanelModel'; import { DashboardModel } from '../state/DashboardModel'; import { PanelPlugin } from 'app/types/plugins'; interface Props { panel: PanelModel; dashboard: DashboardModel; plugin: PanelPlugin; angularPanel?: AngularComponent; onTypeChanged: (newType: PanelPlugin) => void; updateLocation: typeof updateLocation; urlOpenVizPicker: boolean; } interface State { isVizPickerOpen: boolean; searchQuery: string; searchResults: PanelPlugin[]; scrollTop: number; } export class VisualizationTab extends PureComponent<Props, State> { element: HTMLElement; angularOptions: AngularComponent; searchInput: HTMLElement; constructor(props: Props) { super(props); this.state = { isVizPickerOpen: this.props.urlOpenVizPicker, searchQuery: '', searchResults: [], scrollTop: 0, }; } getPanelDefaultOptions = () => { const { panel, plugin } = this.props; if (plugin.exports.PanelDefaults) { return panel.getOptions(plugin.exports.PanelDefaults.options); } return panel.getOptions(plugin.exports.PanelDefaults); }; renderPanelOptions() { const { plugin, angularPanel } = this.props; const { PanelOptions } = plugin.exports; if (angularPanel) { return <div ref={element => (this.element = element)} />; } return ( <> {PanelOptions ? ( <PanelOptions options={this.getPanelDefaultOptions()} onChange={this.onPanelOptionsChanged} /> ) : ( <p>Visualization has no options</p> )} </> ); } componentDidMount() { if (this.shouldLoadAngularOptions()) { this.loadAngularOptions(); } } componentDidUpdate(prevProps: Props) { if (this.props.plugin !== prevProps.plugin) { this.cleanUpAngularOptions(); } if (this.shouldLoadAngularOptions()) { this.loadAngularOptions(); } } shouldLoadAngularOptions() { return this.props.angularPanel && this.element && !this.angularOptions; } loadAngularOptions() { const { angularPanel } = this.props; const scope = angularPanel.getScope(); // When full page reloading in edit mode the angular panel has on fully compiled & instantiated yet if (!scope.$$childHead) { setTimeout(() => { this.forceUpdate(); }); return; } const panelCtrl = scope.$$childHead.ctrl; panelCtrl.initEditMode(); let template = ''; for (let i = 0; i < panelCtrl.editorTabs.length; i++) { template += ` <div class="panel-options-group" ng-cloak>` + (i > 0 ? `<div class="panel-options-group__header"> <span class="panel-options-group__title">{{ctrl.editorTabs[${i}].title}} </span> </div>` : '') + `<div class="panel-options-group__body"> <panel-editor-tab editor-tab="ctrl.editorTabs[${i}]" ctrl="ctrl"></panel-editor-tab> </div> </div> `; } const loader = getAngularLoader(); const scopeProps = { ctrl: panelCtrl }; this.angularOptions = loader.load(this.element, scopeProps, template); } componentWillUnmount() { this.cleanUpAngularOptions(); } cleanUpAngularOptions() { if (this.angularOptions) { this.angularOptions.destroy(); this.angularOptions = null; } } clearQuery = () => { this.setState({ searchQuery: '' }); }; onPanelOptionsChanged = (options: any) => { this.props.panel.updateOptions(options); this.forceUpdate(); }; onOpenVizPicker = () => { this.setState({ isVizPickerOpen: true, scrollTop: 0 }); }; onCloseVizPicker = () => { if (this.props.urlOpenVizPicker) { this.props.updateLocation({ query: { openVizPicker: null }, partial: true }); } this.setState({ isVizPickerOpen: false }); }; onSearchQueryChange = (evt: ChangeEvent<HTMLInputElement>) => { const value = evt.target.value; this.setState({ searchQuery: value, }); }; renderToolbar = (): JSX.Element => { const { plugin } = this.props; const { searchQuery } = this.state; if (this.state.isVizPickerOpen) { return ( <> <label className="gf-form--has-input-icon"> <input type="text" className={`gf-form-input width-13 ${!this.hasSearchResults ? 'gf-form-input--invalid' : ''}`} placeholder="" onChange={this.onSearchQueryChange} value={searchQuery} ref={elem => elem && elem.focus()} /> <i className="gf-form-input-icon fa fa-search" /> </label> <button className="btn btn-link toolbar__close" onClick={this.onCloseVizPicker}> <i className="fa fa-chevron-up" /> </button> </> ); } else { return ( <div className="toolbar__main" onClick={this.onOpenVizPicker}> <img className="toolbar__main-image" src={plugin.info.logos.small} /> <div className="toolbar__main-name">{plugin.name}</div> <i className="fa fa-caret-down" /> </div> ); } }; onTypeChanged = (plugin: PanelPlugin) => { if (plugin.id === this.props.plugin.id) { this.setState({ isVizPickerOpen: false }); } else { this.props.onTypeChanged(plugin); } }; setSearchResults = (searchResults: PanelPlugin[]) => { this.setState({ searchResults: searchResults }); }; get hasSearchResults () { return this.state.searchResults && this.state.searchResults.length > 0; } renderHelp = () => <PluginHelp plugin={this.props.plugin} type="help" />; setScrollTop = (event: React.MouseEvent<HTMLElement>) => { const target = event.target as HTMLElement; this.setState({ scrollTop: target.scrollTop }); }; render() { const { plugin } = this.props; const { isVizPickerOpen, searchQuery, scrollTop } = this.state; const pluginHelp: EditorToolbarView = { heading: 'Help', icon: 'fa fa-question', render: this.renderHelp, }; return ( <EditorTabBody heading="Visualization" renderToolbar={this.renderToolbar} toolbarItems={[pluginHelp]} scrollTop={scrollTop} setScrollTop={this.setScrollTop} > <> <FadeIn in={isVizPickerOpen} duration={200} unmountOnExit={true} onExited={this.clearQuery}> <VizTypePicker current={plugin} onTypeChanged={this.onTypeChanged} searchQuery={searchQuery} onClose={this.onCloseVizPicker} onPluginListChange={this.setSearchResults} /> </FadeIn> {this.renderPanelOptions()} </> </EditorTabBody> ); } } const mapStateToProps = (state: StoreState) => ({ urlOpenVizPicker: !!state.location.query.openVizPicker, }); const mapDispatchToProps = { updateLocation, }; export default connectWithStore(VisualizationTab, mapStateToProps, mapDispatchToProps);
public/app/features/dashboard/panel_editor/VisualizationTab.tsx
1
https://github.com/grafana/grafana/commit/44eaa3eaa886e0f193e9b6ae364e0526c858cb00
[ 0.998721182346344, 0.44072654843330383, 0.00016485340893268585, 0.031326912343502045, 0.4797872006893158 ]
{ "id": 9, "code_window": [ "export interface Props {\n", " current: PanelPlugin;\n", " onTypeChanged: (newType: PanelPlugin) => void;\n", " searchQuery: string;\n", " onClose: () => void;\n", " onPluginListChange: (searchResults: PanelPlugin[]) => void;\n", "}\n", "\n", "export class VizTypePicker extends PureComponent<Props> {\n", " searchInput: HTMLElement;\n", " pluginList = this.getPanelPlugins('');\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [], "file_path": "public/app/features/dashboard/panel_editor/VizTypePicker.tsx", "type": "replace", "edit_start_line_idx": 12 }
/* * * Copyright 2016 gRPC authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package grpc import ( "golang.org/x/net/context" ) // UnaryInvoker is called by UnaryClientInterceptor to complete RPCs. type UnaryInvoker func(ctx context.Context, method string, req, reply interface{}, cc *ClientConn, opts ...CallOption) error // UnaryClientInterceptor intercepts the execution of a unary RPC on the client. invoker is the handler to complete the RPC // and it is the responsibility of the interceptor to call it. // This is an EXPERIMENTAL API. type UnaryClientInterceptor func(ctx context.Context, method string, req, reply interface{}, cc *ClientConn, invoker UnaryInvoker, opts ...CallOption) error // Streamer is called by StreamClientInterceptor to create a ClientStream. type Streamer func(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, opts ...CallOption) (ClientStream, error) // StreamClientInterceptor intercepts the creation of ClientStream. It may return a custom ClientStream to intercept all I/O // operations. streamer is the handler to create a ClientStream and it is the responsibility of the interceptor to call it. // This is an EXPERIMENTAL API. type StreamClientInterceptor func(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, streamer Streamer, opts ...CallOption) (ClientStream, error) // UnaryServerInfo consists of various information about a unary RPC on // server side. All per-rpc information may be mutated by the interceptor. type UnaryServerInfo struct { // Server is the service implementation the user provides. This is read-only. Server interface{} // FullMethod is the full RPC method string, i.e., /package.service/method. FullMethod string } // UnaryHandler defines the handler invoked by UnaryServerInterceptor to complete the normal // execution of a unary RPC. If a UnaryHandler returns an error, it should be produced by the // status package, or else gRPC will use codes.Unknown as the status code and err.Error() as // the status message of the RPC. type UnaryHandler func(ctx context.Context, req interface{}) (interface{}, error) // UnaryServerInterceptor provides a hook to intercept the execution of a unary RPC on the server. info // contains all the information of this RPC the interceptor can operate on. And handler is the wrapper // of the service method implementation. It is the responsibility of the interceptor to invoke handler // to complete the RPC. type UnaryServerInterceptor func(ctx context.Context, req interface{}, info *UnaryServerInfo, handler UnaryHandler) (resp interface{}, err error) // StreamServerInfo consists of various information about a streaming RPC on // server side. All per-rpc information may be mutated by the interceptor. type StreamServerInfo struct { // FullMethod is the full RPC method string, i.e., /package.service/method. FullMethod string // IsClientStream indicates whether the RPC is a client streaming RPC. IsClientStream bool // IsServerStream indicates whether the RPC is a server streaming RPC. IsServerStream bool } // StreamServerInterceptor provides a hook to intercept the execution of a streaming RPC on the server. // info contains all the information of this RPC the interceptor can operate on. And handler is the // service method implementation. It is the responsibility of the interceptor to invoke handler to // complete the RPC. type StreamServerInterceptor func(srv interface{}, ss ServerStream, info *StreamServerInfo, handler StreamHandler) error
vendor/google.golang.org/grpc/interceptor.go
0
https://github.com/grafana/grafana/commit/44eaa3eaa886e0f193e9b6ae364e0526c858cb00
[ 0.00017800666682887822, 0.0001687337353359908, 0.00016352269449271262, 0.00016582690295763314, 0.000005540477104659658 ]
{ "id": 9, "code_window": [ "export interface Props {\n", " current: PanelPlugin;\n", " onTypeChanged: (newType: PanelPlugin) => void;\n", " searchQuery: string;\n", " onClose: () => void;\n", " onPluginListChange: (searchResults: PanelPlugin[]) => void;\n", "}\n", "\n", "export class VizTypePicker extends PureComponent<Props> {\n", " searchInput: HTMLElement;\n", " pluginList = this.getPanelPlugins('');\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [], "file_path": "public/app/features/dashboard/panel_editor/VizTypePicker.tsx", "type": "replace", "edit_start_line_idx": 12 }
<svg width="44" height="44" viewBox="0 0 44 44" fill="none" xmlns="http://www.w3.org/2000/svg"> <circle cx="22" cy="22" r="20" fill="#09090B" stroke="#8E8E8E" stroke-width="4"/> <ellipse cx="21.9999" cy="26.8889" rx="11.4074" ry="4.88889" fill="#8E8E8E"/> <ellipse cx="21.9999" cy="24.4444" rx="11.4074" ry="4.88889" fill="#09090B"/> <ellipse cx="21.9999" cy="22" rx="11.4074" ry="4.88889" fill="#8E8E8E"/> <ellipse cx="21.9999" cy="19.5555" rx="11.4074" ry="4.88889" fill="#09090B"/> <ellipse cx="21.9999" cy="17.1111" rx="11.4074" ry="4.88889" fill="#8E8E8E"/> </svg>
public/img/panel-tabs/general.svg
0
https://github.com/grafana/grafana/commit/44eaa3eaa886e0f193e9b6ae364e0526c858cb00
[ 0.00017349846893921494, 0.00017349846893921494, 0.00017349846893921494, 0.00017349846893921494, 0 ]
{ "id": 9, "code_window": [ "export interface Props {\n", " current: PanelPlugin;\n", " onTypeChanged: (newType: PanelPlugin) => void;\n", " searchQuery: string;\n", " onClose: () => void;\n", " onPluginListChange: (searchResults: PanelPlugin[]) => void;\n", "}\n", "\n", "export class VizTypePicker extends PureComponent<Props> {\n", " searchInput: HTMLElement;\n", " pluginList = this.getPanelPlugins('');\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [], "file_path": "public/app/features/dashboard/panel_editor/VizTypePicker.tsx", "type": "replace", "edit_start_line_idx": 12 }
<?xml version="1.0" encoding="utf-8"?> <!-- Generator: Adobe Illustrator 20.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="64px" height="64px" viewBox="0 0 64 64" style="enable-background:new 0 0 64 64;" xml:space="preserve"> <style type="text/css"> .st0{fill:#E6E6E6;} .st1{fill:#E3E2E2;} </style> <g> <path class="st0" d="M14.9,46.8c-0.7-1-1.3-2-2-3C13.6,44.9,14.2,45.9,14.9,46.8z"/> <path class="st0" d="M16.2,48.7c-0.4-0.6-0.9-1.2-1.3-1.9C15.4,47.5,15.8,48.1,16.2,48.7z"/> <path class="st0" d="M10.5,39.4c-0.4-0.8-0.8-1.6-1.2-2.4C9.7,37.9,10.1,38.7,10.5,39.4z"/> <path class="st0" d="M19.6,52.9c-0.4-0.5-0.9-1-1.3-1.6C18.7,51.9,19.2,52.4,19.6,52.9z"/> <path class="st0" d="M41.1,56.4c-0.6,0.6-1.3,1.2-1.8,1.8C39.9,57.6,40.5,57,41.1,56.4z"/> <path class="st0" d="M51.1,43.8c-0.6,1-1.3,2-2,3C49.8,45.9,50.4,44.9,51.1,43.8z"/> <path class="st0" d="M24.7,58.2c-0.6-0.6-1.2-1.2-1.8-1.8C23.5,57,24.1,57.6,24.7,58.2z"/> <path class="st0" d="M27,60.2c-0.4-0.3-0.7-0.6-1.1-0.9C26.3,59.6,26.6,59.9,27,60.2z"/> <path class="st0" d="M38.1,59.3c-0.4,0.3-0.7,0.7-1.1,0.9C37.4,59.9,37.7,59.6,38.1,59.3z"/> <path class="st0" d="M3.2,9.1L3.2,9.1c0,0,2.1-1,5.7-2.4C5.3,8.1,3.2,9.1,3.2,9.1z"/> <path class="st0" d="M49.1,46.8c-0.4,0.6-0.9,1.3-1.3,1.9C48.2,48.1,48.6,47.5,49.1,46.8z"/> <path class="st0" d="M32,48.7c1.7-1.7,3.7-3.8,5.6-6.3c5.9-7.7,9.5-16.2,10.8-25.5c-4.3-1.5-10-3.4-16.4-4.8 C32,26.6,32,38.2,32,48.7z"/> <path class="st0" d="M54.7,37.1c-0.4,0.8-0.8,1.6-1.2,2.4C53.9,38.7,54.3,37.9,54.7,37.1z"/> <path class="st0" d="M45.7,51.3c-0.4,0.6-0.9,1.1-1.3,1.6C44.8,52.4,45.3,51.9,45.7,51.3z"/> <path class="st0" d="M60.8,9.1c0,0-2.1-1-5.7-2.4C58.7,8.1,60.8,9.1,60.8,9.1L60.8,9.1z"/> <path class="st0" d="M37.8,1.3C35.9,0.8,34,0.4,32,0c-2,0.4-3.9,0.8-5.8,1.3C28.1,0.8,30,0.4,32,0C34,0.4,35.9,0.8,37.8,1.3z"/> <path class="st1" d="M55.1,6.7C50.9,5.1,44.8,3,37.8,1.3C35.9,0.8,34,0.4,32,0c-2,0.4-3.9,0.8-5.8,1.3C19.2,3,13.1,5.1,8.9,6.7 C5.3,8.1,3.2,9.1,3.2,9.1l0,0c0,2.9,0.2,5.7,0.5,8.4c0.1,0.5,0.1,1.1,0.2,1.6c0.5,3.7,1.4,7.1,2.4,10.3c0.9,2.8,1.9,5.3,3,7.8 c0.4,0.8,0.8,1.6,1.2,2.4c0.8,1.5,1.6,3,2.5,4.4c0.6,1,1.3,2,2,3c0.4,0.6,0.9,1.3,1.3,1.9c0.7,0.9,1.3,1.8,2,2.6 c0.4,0.6,0.9,1.1,1.3,1.6c1.1,1.3,2.2,2.5,3.3,3.5c0.6,0.6,1.3,1.2,1.8,1.8c0.4,0.4,0.8,0.7,1.2,1.1c0.4,0.3,0.7,0.7,1.1,0.9 c3,2.5,5,3.8,5,3.8s2-1.3,5-3.8c0.4-0.3,0.7-0.6,1.1-0.9c0.4-0.3,0.8-0.7,1.2-1.1c0.6-0.6,1.2-1.2,1.8-1.8c1.1-1.1,2.2-2.2,3.3-3.5 c0.4-0.5,0.9-1,1.3-1.6c0.7-0.8,1.4-1.7,2-2.6c0.4-0.6,0.9-1.2,1.3-1.9c0.7-1,1.3-2,2-3c0.9-1.4,1.7-2.9,2.5-4.4 c0.4-0.8,0.8-1.6,1.2-2.4c1.1-2.4,2.2-5,3-7.8c1-3.2,1.8-6.7,2.4-10.3c0.1-0.5,0.1-1.1,0.2-1.6c0.3-2.7,0.5-5.5,0.5-8.4l0,0 C60.8,9.1,58.7,8.1,55.1,6.7z M41.3,45.7c-3.4,4.3-6.8,7.5-9.3,9.6c-2.5-2.1-5.9-5.3-9.3-9.6c-7.4-9.5-11.6-20.3-12.4-32.1 C15,11.8,23,9,32,7.1c9,1.8,17,4.7,21.7,6.5C52.8,25.4,48.6,36.2,41.3,45.7z"/> </g> </svg>
public/img/icons_dark_theme/icon_shield.svg
0
https://github.com/grafana/grafana/commit/44eaa3eaa886e0f193e9b6ae364e0526c858cb00
[ 0.00017453383770771325, 0.00016953730664681643, 0.00016418231825809926, 0.00016971654258668423, 0.0000037064535263198195 ]
{ "id": 10, "code_window": [ " searchInput: HTMLElement;\n", " pluginList = this.getPanelPlugins('');\n", "\n", " constructor(props: Props) {\n", " super(props);\n", " }\n", "\n", " get maxSelectedIndex() {\n", " const filteredPluginList = this.getFilteredPluginList();\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " constructor(props) {\n" ], "file_path": "public/app/features/dashboard/panel_editor/VizTypePicker.tsx", "type": "replace", "edit_start_line_idx": 19 }
// Libraries import React, { PureComponent, ChangeEvent } from 'react'; // Utils & Services import { AngularComponent, getAngularLoader } from 'app/core/services/AngularLoader'; import { connectWithStore } from 'app/core/utils/connectWithReduxStore'; import { StoreState } from 'app/types'; import { updateLocation } from 'app/core/actions'; // Components import { EditorTabBody, EditorToolbarView } from './EditorTabBody'; import { VizTypePicker } from './VizTypePicker'; import { PluginHelp } from 'app/core/components/PluginHelp/PluginHelp'; import { FadeIn } from 'app/core/components/Animations/FadeIn'; // Types import { PanelModel } from '../state/PanelModel'; import { DashboardModel } from '../state/DashboardModel'; import { PanelPlugin } from 'app/types/plugins'; interface Props { panel: PanelModel; dashboard: DashboardModel; plugin: PanelPlugin; angularPanel?: AngularComponent; onTypeChanged: (newType: PanelPlugin) => void; updateLocation: typeof updateLocation; urlOpenVizPicker: boolean; } interface State { isVizPickerOpen: boolean; searchQuery: string; searchResults: PanelPlugin[]; scrollTop: number; } export class VisualizationTab extends PureComponent<Props, State> { element: HTMLElement; angularOptions: AngularComponent; searchInput: HTMLElement; constructor(props: Props) { super(props); this.state = { isVizPickerOpen: this.props.urlOpenVizPicker, searchQuery: '', searchResults: [], scrollTop: 0, }; } getPanelDefaultOptions = () => { const { panel, plugin } = this.props; if (plugin.exports.PanelDefaults) { return panel.getOptions(plugin.exports.PanelDefaults.options); } return panel.getOptions(plugin.exports.PanelDefaults); }; renderPanelOptions() { const { plugin, angularPanel } = this.props; const { PanelOptions } = plugin.exports; if (angularPanel) { return <div ref={element => (this.element = element)} />; } return ( <> {PanelOptions ? ( <PanelOptions options={this.getPanelDefaultOptions()} onChange={this.onPanelOptionsChanged} /> ) : ( <p>Visualization has no options</p> )} </> ); } componentDidMount() { if (this.shouldLoadAngularOptions()) { this.loadAngularOptions(); } } componentDidUpdate(prevProps: Props) { if (this.props.plugin !== prevProps.plugin) { this.cleanUpAngularOptions(); } if (this.shouldLoadAngularOptions()) { this.loadAngularOptions(); } } shouldLoadAngularOptions() { return this.props.angularPanel && this.element && !this.angularOptions; } loadAngularOptions() { const { angularPanel } = this.props; const scope = angularPanel.getScope(); // When full page reloading in edit mode the angular panel has on fully compiled & instantiated yet if (!scope.$$childHead) { setTimeout(() => { this.forceUpdate(); }); return; } const panelCtrl = scope.$$childHead.ctrl; panelCtrl.initEditMode(); let template = ''; for (let i = 0; i < panelCtrl.editorTabs.length; i++) { template += ` <div class="panel-options-group" ng-cloak>` + (i > 0 ? `<div class="panel-options-group__header"> <span class="panel-options-group__title">{{ctrl.editorTabs[${i}].title}} </span> </div>` : '') + `<div class="panel-options-group__body"> <panel-editor-tab editor-tab="ctrl.editorTabs[${i}]" ctrl="ctrl"></panel-editor-tab> </div> </div> `; } const loader = getAngularLoader(); const scopeProps = { ctrl: panelCtrl }; this.angularOptions = loader.load(this.element, scopeProps, template); } componentWillUnmount() { this.cleanUpAngularOptions(); } cleanUpAngularOptions() { if (this.angularOptions) { this.angularOptions.destroy(); this.angularOptions = null; } } clearQuery = () => { this.setState({ searchQuery: '' }); }; onPanelOptionsChanged = (options: any) => { this.props.panel.updateOptions(options); this.forceUpdate(); }; onOpenVizPicker = () => { this.setState({ isVizPickerOpen: true, scrollTop: 0 }); }; onCloseVizPicker = () => { if (this.props.urlOpenVizPicker) { this.props.updateLocation({ query: { openVizPicker: null }, partial: true }); } this.setState({ isVizPickerOpen: false }); }; onSearchQueryChange = (evt: ChangeEvent<HTMLInputElement>) => { const value = evt.target.value; this.setState({ searchQuery: value, }); }; renderToolbar = (): JSX.Element => { const { plugin } = this.props; const { searchQuery } = this.state; if (this.state.isVizPickerOpen) { return ( <> <label className="gf-form--has-input-icon"> <input type="text" className={`gf-form-input width-13 ${!this.hasSearchResults ? 'gf-form-input--invalid' : ''}`} placeholder="" onChange={this.onSearchQueryChange} value={searchQuery} ref={elem => elem && elem.focus()} /> <i className="gf-form-input-icon fa fa-search" /> </label> <button className="btn btn-link toolbar__close" onClick={this.onCloseVizPicker}> <i className="fa fa-chevron-up" /> </button> </> ); } else { return ( <div className="toolbar__main" onClick={this.onOpenVizPicker}> <img className="toolbar__main-image" src={plugin.info.logos.small} /> <div className="toolbar__main-name">{plugin.name}</div> <i className="fa fa-caret-down" /> </div> ); } }; onTypeChanged = (plugin: PanelPlugin) => { if (plugin.id === this.props.plugin.id) { this.setState({ isVizPickerOpen: false }); } else { this.props.onTypeChanged(plugin); } }; setSearchResults = (searchResults: PanelPlugin[]) => { this.setState({ searchResults: searchResults }); }; get hasSearchResults () { return this.state.searchResults && this.state.searchResults.length > 0; } renderHelp = () => <PluginHelp plugin={this.props.plugin} type="help" />; setScrollTop = (event: React.MouseEvent<HTMLElement>) => { const target = event.target as HTMLElement; this.setState({ scrollTop: target.scrollTop }); }; render() { const { plugin } = this.props; const { isVizPickerOpen, searchQuery, scrollTop } = this.state; const pluginHelp: EditorToolbarView = { heading: 'Help', icon: 'fa fa-question', render: this.renderHelp, }; return ( <EditorTabBody heading="Visualization" renderToolbar={this.renderToolbar} toolbarItems={[pluginHelp]} scrollTop={scrollTop} setScrollTop={this.setScrollTop} > <> <FadeIn in={isVizPickerOpen} duration={200} unmountOnExit={true} onExited={this.clearQuery}> <VizTypePicker current={plugin} onTypeChanged={this.onTypeChanged} searchQuery={searchQuery} onClose={this.onCloseVizPicker} onPluginListChange={this.setSearchResults} /> </FadeIn> {this.renderPanelOptions()} </> </EditorTabBody> ); } } const mapStateToProps = (state: StoreState) => ({ urlOpenVizPicker: !!state.location.query.openVizPicker, }); const mapDispatchToProps = { updateLocation, }; export default connectWithStore(VisualizationTab, mapStateToProps, mapDispatchToProps);
public/app/features/dashboard/panel_editor/VisualizationTab.tsx
1
https://github.com/grafana/grafana/commit/44eaa3eaa886e0f193e9b6ae364e0526c858cb00
[ 0.012123926542699337, 0.0018308681901544333, 0.00016602405230514705, 0.0005774504970759153, 0.00295614218339324 ]
{ "id": 10, "code_window": [ " searchInput: HTMLElement;\n", " pluginList = this.getPanelPlugins('');\n", "\n", " constructor(props: Props) {\n", " super(props);\n", " }\n", "\n", " get maxSelectedIndex() {\n", " const filteredPluginList = this.getFilteredPluginList();\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " constructor(props) {\n" ], "file_path": "public/app/features/dashboard/panel_editor/VizTypePicker.tsx", "type": "replace", "edit_start_line_idx": 19 }
import _ from 'lodash'; import React from 'react'; import ReactDOM from 'react-dom'; import { Change, Value } from 'slate'; import { Editor } from 'slate-react'; import Plain from 'slate-plain-serializer'; import classnames from 'classnames'; import { CompletionItem, CompletionItemGroup, TypeaheadOutput } from 'app/types/explore'; import ClearPlugin from './slate-plugins/clear'; import NewlinePlugin from './slate-plugins/newline'; import Typeahead from './Typeahead'; import { makeFragment, makeValue } from './Value'; import PlaceholdersBuffer from './PlaceholdersBuffer'; export const TYPEAHEAD_DEBOUNCE = 100; function getSuggestionByIndex(suggestions: CompletionItemGroup[], index: number): CompletionItem { // Flatten suggestion groups const flattenedSuggestions = suggestions.reduce((acc, g) => acc.concat(g.items), []); const correctedIndex = Math.max(index, 0) % flattenedSuggestions.length; return flattenedSuggestions[correctedIndex]; } function hasSuggestions(suggestions: CompletionItemGroup[]): boolean { return suggestions && suggestions.length > 0; } export interface QueryFieldProps { additionalPlugins?: any[]; cleanText?: (text: string) => string; disabled?: boolean; initialQuery: string | null; onExecuteQuery?: () => void; onQueryChange?: (value: string) => void; onTypeahead?: (typeahead: TypeaheadInput) => TypeaheadOutput; onWillApplySuggestion?: (suggestion: string, state: QueryFieldState) => string; placeholder?: string; portalOrigin?: string; syntax?: string; syntaxLoaded?: boolean; } export interface QueryFieldState { suggestions: CompletionItemGroup[]; typeaheadContext: string | null; typeaheadIndex: number; typeaheadPrefix: string; typeaheadText: string; value: Value; lastExecutedValue: Value; } export interface TypeaheadInput { editorNode: Element; prefix: string; selection?: Selection; text: string; value: Value; wrapperNode: Element; } /** * Renders an editor field. * Pass initial value as initialQuery and listen to changes in props.onValueChanged. * This component can only process strings. Internally it uses Slate Value. * Implement props.onTypeahead to use suggestions, see PromQueryField.tsx as an example. */ export class QueryField extends React.PureComponent<QueryFieldProps, QueryFieldState> { menuEl: HTMLElement | null; placeholdersBuffer: PlaceholdersBuffer; plugins: any[]; resetTimer: any; mounted: boolean; constructor(props: QueryFieldProps, context) { super(props, context); this.placeholdersBuffer = new PlaceholdersBuffer(props.initialQuery || ''); // Base plugins this.plugins = [ClearPlugin(), NewlinePlugin(), ...(props.additionalPlugins || [])].filter(p => p); this.state = { suggestions: [], typeaheadContext: null, typeaheadIndex: 0, typeaheadPrefix: '', typeaheadText: '', value: makeValue(this.placeholdersBuffer.toString(), props.syntax), lastExecutedValue: null, }; } componentDidMount() { this.mounted = true; this.updateMenu(); } componentWillUnmount() { this.mounted = false; clearTimeout(this.resetTimer); } componentDidUpdate(prevProps: QueryFieldProps, prevState: QueryFieldState) { const { initialQuery, syntax } = this.props; const { value, suggestions } = this.state; // if query changed from the outside if (initialQuery !== prevProps.initialQuery) { // and we have a version that differs if (initialQuery !== Plain.serialize(value)) { this.placeholdersBuffer = new PlaceholdersBuffer(initialQuery || ''); this.setState({ value: makeValue(this.placeholdersBuffer.toString(), syntax) }); } } // Only update menu location when suggestion existence or text/selection changed if (value !== prevState.value || hasSuggestions(suggestions) !== hasSuggestions(prevState.suggestions)) { this.updateMenu(); } } componentWillReceiveProps(nextProps: QueryFieldProps) { if (nextProps.syntaxLoaded && !this.props.syntaxLoaded) { // Need a bogus edit to re-render the editor after syntax has fully loaded const change = this.state.value .change() .insertText(' ') .deleteBackward(); if (this.placeholdersBuffer.hasPlaceholders()) { change.move(this.placeholdersBuffer.getNextMoveOffset()).focus(); } this.onChange(change, true); } } onChange = ({ value }, invokeParentOnValueChanged?: boolean) => { const documentChanged = value.document !== this.state.value.document; const prevValue = this.state.value; // Control editor loop, then pass text change up to parent this.setState({ value }, () => { if (documentChanged) { const textChanged = Plain.serialize(prevValue) !== Plain.serialize(value); if (textChanged && invokeParentOnValueChanged) { this.executeOnQueryChangeAndExecuteQueries(); } } }); // Show suggest menu on text input if (documentChanged && value.selection.isCollapsed) { // Need one paint to allow DOM-based typeahead rules to work window.requestAnimationFrame(this.handleTypeahead); } else if (!this.resetTimer) { this.resetTypeahead(); } }; executeOnQueryChangeAndExecuteQueries = () => { // Send text change to parent const { onQueryChange, onExecuteQuery } = this.props; if (onQueryChange) { onQueryChange(Plain.serialize(this.state.value)); } if (onExecuteQuery) { onExecuteQuery(); this.setState({ lastExecutedValue: this.state.value }); } }; handleTypeahead = _.debounce(async () => { const selection = window.getSelection(); const { cleanText, onTypeahead } = this.props; const { value } = this.state; if (onTypeahead && selection.anchorNode) { const wrapperNode = selection.anchorNode.parentElement; const editorNode = wrapperNode.closest('.slate-query-field'); if (!editorNode || this.state.value.isBlurred) { // Not inside this editor return; } const range = selection.getRangeAt(0); const offset = range.startOffset; const text = selection.anchorNode.textContent; let prefix = text.substr(0, offset); // Label values could have valid characters erased if `cleanText()` is // blindly applied, which would undesirably interfere with suggestions const labelValueMatch = prefix.match(/(?:!?=~?"?|")(.*)/); if (labelValueMatch) { prefix = labelValueMatch[1]; } else if (cleanText) { prefix = cleanText(prefix); } const { suggestions, context, refresher } = onTypeahead({ editorNode, prefix, selection, text, value, wrapperNode, }); let filteredSuggestions = suggestions .map(group => { if (group.items) { if (prefix) { // Filter groups based on prefix if (!group.skipFilter) { group.items = group.items.filter(c => (c.filterText || c.label).length >= prefix.length); if (group.prefixMatch) { group.items = group.items.filter(c => (c.filterText || c.label).indexOf(prefix) === 0); } else { group.items = group.items.filter(c => (c.filterText || c.label).indexOf(prefix) > -1); } } // Filter out the already typed value (prefix) unless it inserts custom text group.items = group.items.filter(c => c.insertText || (c.filterText || c.label) !== prefix); } if (!group.skipSort) { group.items = _.sortBy(group.items, item => item.sortText || item.label); } } return group; }) .filter(group => group.items && group.items.length > 0); // Filter out empty groups // Keep same object for equality checking later if (_.isEqual(filteredSuggestions, this.state.suggestions)) { filteredSuggestions = this.state.suggestions; } this.setState( { suggestions: filteredSuggestions, typeaheadPrefix: prefix, typeaheadContext: context, typeaheadText: text, }, () => { if (refresher) { refresher.then(this.handleTypeahead).catch(e => console.error(e)); } } ); } }, TYPEAHEAD_DEBOUNCE); applyTypeahead(change: Change, suggestion: CompletionItem): Change { const { cleanText, onWillApplySuggestion, syntax } = this.props; const { typeaheadPrefix, typeaheadText } = this.state; let suggestionText = suggestion.insertText || suggestion.label; const preserveSuffix = suggestion.kind === 'function'; const move = suggestion.move || 0; if (onWillApplySuggestion) { suggestionText = onWillApplySuggestion(suggestionText, { ...this.state }); } this.resetTypeahead(); // Remove the current, incomplete text and replace it with the selected suggestion const backward = suggestion.deleteBackwards || typeaheadPrefix.length; const text = cleanText ? cleanText(typeaheadText) : typeaheadText; const suffixLength = text.length - typeaheadPrefix.length; const offset = typeaheadText.indexOf(typeaheadPrefix); const midWord = typeaheadPrefix && ((suffixLength > 0 && offset > -1) || suggestionText === typeaheadText); const forward = midWord && !preserveSuffix ? suffixLength + offset : 0; // If new-lines, apply suggestion as block if (suggestionText.match(/\n/)) { const fragment = makeFragment(suggestionText, syntax); return change .deleteBackward(backward) .deleteForward(forward) .insertFragment(fragment) .focus(); } return change .deleteBackward(backward) .deleteForward(forward) .insertText(suggestionText) .move(move) .focus(); } handleEnterAndTabKey = change => { const { typeaheadIndex, suggestions } = this.state; if (this.menuEl) { // Dont blur input event.preventDefault(); if (!suggestions || suggestions.length === 0) { return undefined; } const suggestion = getSuggestionByIndex(suggestions, typeaheadIndex); const nextChange = this.applyTypeahead(change, suggestion); const insertTextOperation = nextChange.operations.find(operation => operation.type === 'insert_text'); if (insertTextOperation) { const suggestionText = insertTextOperation.text; this.placeholdersBuffer.setNextPlaceholderValue(suggestionText); if (this.placeholdersBuffer.hasPlaceholders()) { nextChange.move(this.placeholdersBuffer.getNextMoveOffset()).focus(); } } return true; } else { this.executeOnQueryChangeAndExecuteQueries(); return undefined; } }; onKeyDown = (event, change) => { const { typeaheadIndex } = this.state; switch (event.key) { case 'Escape': { if (this.menuEl) { event.preventDefault(); event.stopPropagation(); this.resetTypeahead(); return true; } break; } case ' ': { if (event.ctrlKey) { event.preventDefault(); this.handleTypeahead(); return true; } break; } case 'Enter': case 'Tab': { return this.handleEnterAndTabKey(change); break; } case 'ArrowDown': { if (this.menuEl) { // Select next suggestion event.preventDefault(); this.setState({ typeaheadIndex: typeaheadIndex + 1 }); } break; } case 'ArrowUp': { if (this.menuEl) { // Select previous suggestion event.preventDefault(); this.setState({ typeaheadIndex: Math.max(0, typeaheadIndex - 1) }); } break; } default: { // console.log('default key', event.key, event.which, event.charCode, event.locale, data.key); break; } } return undefined; }; resetTypeahead = () => { if (this.mounted) { this.setState({ suggestions: [], typeaheadIndex: 0, typeaheadPrefix: '', typeaheadContext: null }); this.resetTimer = null; } }; handleBlur = (event, change) => { const { lastExecutedValue } = this.state; const previousValue = lastExecutedValue ? Plain.serialize(this.state.lastExecutedValue) : null; const currentValue = Plain.serialize(change.value); // If we dont wait here, menu clicks wont work because the menu // will be gone. this.resetTimer = setTimeout(this.resetTypeahead, 100); // Disrupting placeholder entry wipes all remaining placeholders needing input this.placeholdersBuffer.clearPlaceholders(); if (previousValue !== currentValue) { this.executeOnQueryChangeAndExecuteQueries(); } }; handleFocus = () => {}; onClickMenu = (item: CompletionItem) => { // Manually triggering change const change = this.applyTypeahead(this.state.value.change(), item); this.onChange(change, true); }; updateMenu = () => { const { suggestions } = this.state; const menu = this.menuEl; const selection = window.getSelection(); const node = selection.anchorNode; // No menu, nothing to do if (!menu) { return; } // No suggestions or blur, remove menu if (!hasSuggestions(suggestions)) { menu.removeAttribute('style'); return; } // Align menu overlay to editor node if (node) { // Read from DOM const rect = node.parentElement.getBoundingClientRect(); const scrollX = window.scrollX; const scrollY = window.scrollY; // Write DOM requestAnimationFrame(() => { menu.style.opacity = '1'; menu.style.top = `${rect.top + scrollY + rect.height + 4}px`; menu.style.left = `${rect.left + scrollX - 2}px`; }); } }; menuRef = el => { this.menuEl = el; }; renderMenu = () => { const { portalOrigin } = this.props; const { suggestions, typeaheadIndex, typeaheadPrefix } = this.state; if (!hasSuggestions(suggestions)) { return null; } const selectedItem = getSuggestionByIndex(suggestions, typeaheadIndex); // Create typeahead in DOM root so we can later position it absolutely return ( <Portal origin={portalOrigin}> <Typeahead menuRef={this.menuRef} selectedItem={selectedItem} onClickItem={this.onClickMenu} prefix={typeaheadPrefix} groupedItems={suggestions} /> </Portal> ); }; handlePaste = (event: ClipboardEvent, change: Editor) => { const pastedValue = event.clipboardData.getData('Text'); const newValue = change.value.change().insertText(pastedValue); this.onChange(newValue); return true; }; render() { const { disabled } = this.props; const wrapperClassName = classnames('slate-query-field__wrapper', { 'slate-query-field__wrapper--disabled': disabled, }); return ( <div className={wrapperClassName}> <div className="slate-query-field"> {this.renderMenu()} <Editor autoCorrect={false} readOnly={this.props.disabled} onBlur={this.handleBlur} onKeyDown={this.onKeyDown} onChange={this.onChange} onFocus={this.handleFocus} onPaste={this.handlePaste} placeholder={this.props.placeholder} plugins={this.plugins} spellCheck={false} value={this.state.value} /> </div> </div> ); } } class Portal extends React.PureComponent<{ index?: number; origin: string }, {}> { node: HTMLElement; constructor(props) { super(props); const { index = 0, origin = 'query' } = props; this.node = document.createElement('div'); this.node.classList.add(`slate-typeahead`, `slate-typeahead-${origin}-${index}`); document.body.appendChild(this.node); } componentWillUnmount() { document.body.removeChild(this.node); } render() { return ReactDOM.createPortal(this.props.children, this.node); } } export default QueryField;
public/app/features/explore/QueryField.tsx
0
https://github.com/grafana/grafana/commit/44eaa3eaa886e0f193e9b6ae364e0526c858cb00
[ 0.01034143753349781, 0.0005280199111439288, 0.00016632321057841182, 0.0001724596950225532, 0.001541813719086349 ]
{ "id": 10, "code_window": [ " searchInput: HTMLElement;\n", " pluginList = this.getPanelPlugins('');\n", "\n", " constructor(props: Props) {\n", " super(props);\n", " }\n", "\n", " get maxSelectedIndex() {\n", " const filteredPluginList = this.getFilteredPluginList();\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " constructor(props) {\n" ], "file_path": "public/app/features/dashboard/panel_editor/VizTypePicker.tsx", "type": "replace", "edit_start_line_idx": 19 }
default: - 'clean' - 'assemble' - 'replace' - 'uncss' - 'processhtml' - 'premailer'
emails/grunt/aliases.yaml
0
https://github.com/grafana/grafana/commit/44eaa3eaa886e0f193e9b6ae364e0526c858cb00
[ 0.0001747506612446159, 0.0001747506612446159, 0.0001747506612446159, 0.0001747506612446159, 0 ]
{ "id": 10, "code_window": [ " searchInput: HTMLElement;\n", " pluginList = this.getPanelPlugins('');\n", "\n", " constructor(props: Props) {\n", " super(props);\n", " }\n", "\n", " get maxSelectedIndex() {\n", " const filteredPluginList = this.getFilteredPluginList();\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " constructor(props) {\n" ], "file_path": "public/app/features/dashboard/panel_editor/VizTypePicker.tsx", "type": "replace", "edit_start_line_idx": 19 }
Mozilla Public License, version 2.0 1. Definitions 1.1. “Contributor” means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software. 1.2. “Contributor Version” means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributor’s Contribution. 1.3. “Contribution” means Covered Software of a particular Contributor. 1.4. “Covered Software” means Source Code Form to which the initial Contributor has attached the notice in Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source Code Form, in each case including portions thereof. 1.5. “Incompatible With Secondary Licenses” means a. that the initial Contributor has attached the notice described in Exhibit B to the Covered Software; or b. that the Covered Software was made available under the terms of version 1.1 or earlier of the License, but not also under the terms of a Secondary License. 1.6. “Executable Form” means any form of the work other than Source Code Form. 1.7. “Larger Work” means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software. 1.8. “License” means this document. 1.9. “Licensable” means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently, any and all of the rights conveyed by this License. 1.10. “Modifications” means any of the following: a. any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or b. any new file in Source Code Form that contains any Covered Software. 1.11. “Patent Claims” of a Contributor means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the License, by the making, using, selling, offering for sale, having made, import, or transfer of either its Contributions or its Contributor Version. 1.12. “Secondary License” means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses. 1.13. “Source Code Form” means the form of the work preferred for making modifications. 1.14. “You” (or “Your”) means an individual or a legal entity exercising rights under this License. For legal entities, “You” includes any entity that controls, is controlled by, or is under common control with You. For purposes of this definition, “control” means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. 2. License Grants and Conditions 2.1. Grants Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license: a. under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and b. under Patent Claims of such Contributor to make, use, sell, offer for sale, have made, import, and otherwise transfer either its Contributions or its Contributor Version. 2.2. Effective Date The licenses granted in Section 2.1 with respect to any Contribution become effective for each Contribution on the date the Contributor first distributes such Contribution. 2.3. Limitations on Grant Scope The licenses granted in this Section 2 are the only rights granted under this License. No additional rights or licenses will be implied from the distribution or licensing of Covered Software under this License. Notwithstanding Section 2.1(b) above, no patent license is granted by a Contributor: a. for any code that a Contributor has removed from Covered Software; or b. for infringements caused by: (i) Your and any other third party’s modifications of Covered Software, or (ii) the combination of its Contributions with other software (except as part of its Contributor Version); or c. under Patent Claims infringed by Covered Software in the absence of its Contributions. This License does not grant any rights in the trademarks, service marks, or logos of any Contributor (except as may be necessary to comply with the notice requirements in Section 3.4). 2.4. Subsequent Licenses No Contributor makes additional grants as a result of Your choice to distribute the Covered Software under a subsequent version of this License (see Section 10.2) or under the terms of a Secondary License (if permitted under the terms of Section 3.3). 2.5. Representation Each Contributor represents that the Contributor believes its Contributions are its original creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by this License. 2.6. Fair Use This License is not intended to limit any rights You have under applicable copyright doctrines of fair use, fair dealing, or other equivalents. 2.7. Conditions Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1. 3. Responsibilities 3.1. Distribution of Source Form All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients’ rights in the Source Code Form. 3.2. Distribution of Executable Form If You distribute Covered Software in Executable Form then: a. such Covered Software must also be made available in Source Code Form, as described in Section 3.1, and You must inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and b. You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients’ rights in the Source Code Form under this License. 3.3. Distribution of a Larger Work You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for the Covered Software. If the Larger Work is a combination of Covered Software with a work governed by one or more Secondary Licenses, and the Covered Software is not Incompatible With Secondary Licenses, this License permits You to additionally distribute such Covered Software under the terms of such Secondary License(s), so that the recipient of the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s). 3.4. Notices You may not remove or alter the substance of any license notices (including copyright notices, patent notices, disclaimers of warranty, or limitations of liability) contained within the Source Code Form of the Covered Software, except that You may alter any license notices to the extent required to remedy known factual inaccuracies. 3.5. Application of Additional Terms You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, You may do so only on Your own behalf, and not on behalf of any Contributor. You must make it absolutely clear that any such warranty, support, indemnity, or liability obligation is offered by You alone, and You hereby agree to indemnify every Contributor for any liability incurred by such Contributor as a result of warranty, support, indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction. 4. Inability to Comply Due to Statute or Regulation If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. 5. Termination 5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice. 5.2. If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section 2.1 of this License shall terminate. 5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination. 6. Disclaimer of Warranty Covered Software is provided under this License on an “as is” basis, without warranty of any kind, either expressed, implied, or statutory, including, without limitation, warranties that the Covered Software is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire risk as to the quality and performance of the Covered Software is with You. Should any Covered Software prove defective in any respect, You (not any Contributor) assume the cost of any necessary servicing, repair, or correction. This disclaimer of warranty constitutes an essential part of this License. No use of any Covered Software is authorized under this License except under this disclaimer. 7. Limitation of Liability Under no circumstances and under no legal theory, whether tort (including negligence), contract, or otherwise, shall any Contributor, or anyone who distributes Covered Software as permitted above, be liable to You for any direct, indirect, special, incidental, or consequential damages of any character including, without limitation, damages for lost profits, loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses, even if such party shall have been informed of the possibility of such damages. This limitation of liability shall not apply to liability for death or personal injury resulting from such party’s negligence to the extent applicable law prohibits such limitation. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so this exclusion and limitation may not apply to You. 8. Litigation Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a party’s ability to bring cross-claims or counter-claims. 9. Miscellaneous This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor. 10. Versions of the License 10.1. New Versions Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number. 10.2. Effect of New Versions You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward. 10.3. Modified Versions If you create software not governed by this License, and you want to create a new license for such software, you may create and use a modified version of this License if you rename the license and remove any references to the name of the license steward (except to note that such modified license differs from this License). 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached. Exhibit A - Source Code Form License Notice This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice. You may add additional accurate notices of copyright ownership. Exhibit B - “Incompatible With Secondary Licenses” Notice This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozilla Public License, v. 2.0.
vendor/github.com/hashicorp/go-plugin/LICENSE
0
https://github.com/grafana/grafana/commit/44eaa3eaa886e0f193e9b6ae364e0526c858cb00
[ 0.0001787192450137809, 0.00017554816440679133, 0.00017066323198378086, 0.00017595426470506936, 0.0000017699969703244278 ]
{ "id": 11, "code_window": [ " };\n", "\n", " getFilteredPluginList = (): PanelPlugin[] => {\n", " const { searchQuery, onPluginListChange } = this.props;\n", " const regex = new RegExp(searchQuery, 'i');\n", " const pluginList = this.pluginList;\n", "\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep" ], "after_edit": [ " const { searchQuery } = this.props;\n" ], "file_path": "public/app/features/dashboard/panel_editor/VizTypePicker.tsx", "type": "replace", "edit_start_line_idx": 53 }
// Libraries import React, { PureComponent, ChangeEvent } from 'react'; // Utils & Services import { AngularComponent, getAngularLoader } from 'app/core/services/AngularLoader'; import { connectWithStore } from 'app/core/utils/connectWithReduxStore'; import { StoreState } from 'app/types'; import { updateLocation } from 'app/core/actions'; // Components import { EditorTabBody, EditorToolbarView } from './EditorTabBody'; import { VizTypePicker } from './VizTypePicker'; import { PluginHelp } from 'app/core/components/PluginHelp/PluginHelp'; import { FadeIn } from 'app/core/components/Animations/FadeIn'; // Types import { PanelModel } from '../state/PanelModel'; import { DashboardModel } from '../state/DashboardModel'; import { PanelPlugin } from 'app/types/plugins'; interface Props { panel: PanelModel; dashboard: DashboardModel; plugin: PanelPlugin; angularPanel?: AngularComponent; onTypeChanged: (newType: PanelPlugin) => void; updateLocation: typeof updateLocation; urlOpenVizPicker: boolean; } interface State { isVizPickerOpen: boolean; searchQuery: string; searchResults: PanelPlugin[]; scrollTop: number; } export class VisualizationTab extends PureComponent<Props, State> { element: HTMLElement; angularOptions: AngularComponent; searchInput: HTMLElement; constructor(props: Props) { super(props); this.state = { isVizPickerOpen: this.props.urlOpenVizPicker, searchQuery: '', searchResults: [], scrollTop: 0, }; } getPanelDefaultOptions = () => { const { panel, plugin } = this.props; if (plugin.exports.PanelDefaults) { return panel.getOptions(plugin.exports.PanelDefaults.options); } return panel.getOptions(plugin.exports.PanelDefaults); }; renderPanelOptions() { const { plugin, angularPanel } = this.props; const { PanelOptions } = plugin.exports; if (angularPanel) { return <div ref={element => (this.element = element)} />; } return ( <> {PanelOptions ? ( <PanelOptions options={this.getPanelDefaultOptions()} onChange={this.onPanelOptionsChanged} /> ) : ( <p>Visualization has no options</p> )} </> ); } componentDidMount() { if (this.shouldLoadAngularOptions()) { this.loadAngularOptions(); } } componentDidUpdate(prevProps: Props) { if (this.props.plugin !== prevProps.plugin) { this.cleanUpAngularOptions(); } if (this.shouldLoadAngularOptions()) { this.loadAngularOptions(); } } shouldLoadAngularOptions() { return this.props.angularPanel && this.element && !this.angularOptions; } loadAngularOptions() { const { angularPanel } = this.props; const scope = angularPanel.getScope(); // When full page reloading in edit mode the angular panel has on fully compiled & instantiated yet if (!scope.$$childHead) { setTimeout(() => { this.forceUpdate(); }); return; } const panelCtrl = scope.$$childHead.ctrl; panelCtrl.initEditMode(); let template = ''; for (let i = 0; i < panelCtrl.editorTabs.length; i++) { template += ` <div class="panel-options-group" ng-cloak>` + (i > 0 ? `<div class="panel-options-group__header"> <span class="panel-options-group__title">{{ctrl.editorTabs[${i}].title}} </span> </div>` : '') + `<div class="panel-options-group__body"> <panel-editor-tab editor-tab="ctrl.editorTabs[${i}]" ctrl="ctrl"></panel-editor-tab> </div> </div> `; } const loader = getAngularLoader(); const scopeProps = { ctrl: panelCtrl }; this.angularOptions = loader.load(this.element, scopeProps, template); } componentWillUnmount() { this.cleanUpAngularOptions(); } cleanUpAngularOptions() { if (this.angularOptions) { this.angularOptions.destroy(); this.angularOptions = null; } } clearQuery = () => { this.setState({ searchQuery: '' }); }; onPanelOptionsChanged = (options: any) => { this.props.panel.updateOptions(options); this.forceUpdate(); }; onOpenVizPicker = () => { this.setState({ isVizPickerOpen: true, scrollTop: 0 }); }; onCloseVizPicker = () => { if (this.props.urlOpenVizPicker) { this.props.updateLocation({ query: { openVizPicker: null }, partial: true }); } this.setState({ isVizPickerOpen: false }); }; onSearchQueryChange = (evt: ChangeEvent<HTMLInputElement>) => { const value = evt.target.value; this.setState({ searchQuery: value, }); }; renderToolbar = (): JSX.Element => { const { plugin } = this.props; const { searchQuery } = this.state; if (this.state.isVizPickerOpen) { return ( <> <label className="gf-form--has-input-icon"> <input type="text" className={`gf-form-input width-13 ${!this.hasSearchResults ? 'gf-form-input--invalid' : ''}`} placeholder="" onChange={this.onSearchQueryChange} value={searchQuery} ref={elem => elem && elem.focus()} /> <i className="gf-form-input-icon fa fa-search" /> </label> <button className="btn btn-link toolbar__close" onClick={this.onCloseVizPicker}> <i className="fa fa-chevron-up" /> </button> </> ); } else { return ( <div className="toolbar__main" onClick={this.onOpenVizPicker}> <img className="toolbar__main-image" src={plugin.info.logos.small} /> <div className="toolbar__main-name">{plugin.name}</div> <i className="fa fa-caret-down" /> </div> ); } }; onTypeChanged = (plugin: PanelPlugin) => { if (plugin.id === this.props.plugin.id) { this.setState({ isVizPickerOpen: false }); } else { this.props.onTypeChanged(plugin); } }; setSearchResults = (searchResults: PanelPlugin[]) => { this.setState({ searchResults: searchResults }); }; get hasSearchResults () { return this.state.searchResults && this.state.searchResults.length > 0; } renderHelp = () => <PluginHelp plugin={this.props.plugin} type="help" />; setScrollTop = (event: React.MouseEvent<HTMLElement>) => { const target = event.target as HTMLElement; this.setState({ scrollTop: target.scrollTop }); }; render() { const { plugin } = this.props; const { isVizPickerOpen, searchQuery, scrollTop } = this.state; const pluginHelp: EditorToolbarView = { heading: 'Help', icon: 'fa fa-question', render: this.renderHelp, }; return ( <EditorTabBody heading="Visualization" renderToolbar={this.renderToolbar} toolbarItems={[pluginHelp]} scrollTop={scrollTop} setScrollTop={this.setScrollTop} > <> <FadeIn in={isVizPickerOpen} duration={200} unmountOnExit={true} onExited={this.clearQuery}> <VizTypePicker current={plugin} onTypeChanged={this.onTypeChanged} searchQuery={searchQuery} onClose={this.onCloseVizPicker} onPluginListChange={this.setSearchResults} /> </FadeIn> {this.renderPanelOptions()} </> </EditorTabBody> ); } } const mapStateToProps = (state: StoreState) => ({ urlOpenVizPicker: !!state.location.query.openVizPicker, }); const mapDispatchToProps = { updateLocation, }; export default connectWithStore(VisualizationTab, mapStateToProps, mapDispatchToProps);
public/app/features/dashboard/panel_editor/VisualizationTab.tsx
1
https://github.com/grafana/grafana/commit/44eaa3eaa886e0f193e9b6ae364e0526c858cb00
[ 0.9982801675796509, 0.1412515789270401, 0.00016854262503329664, 0.0012835841625928879, 0.3334950804710388 ]
{ "id": 11, "code_window": [ " };\n", "\n", " getFilteredPluginList = (): PanelPlugin[] => {\n", " const { searchQuery, onPluginListChange } = this.props;\n", " const regex = new RegExp(searchQuery, 'i');\n", " const pluginList = this.pluginList;\n", "\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep" ], "after_edit": [ " const { searchQuery } = this.props;\n" ], "file_path": "public/app/features/dashboard/panel_editor/VizTypePicker.tsx", "type": "replace", "edit_start_line_idx": 53 }
The MIT License (MIT) Copyright (c) 2015 Iwasaki Yudai Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ============================================================================ This repository is build with following third party libraries. Thank you! ## go-diff - https://github.com/sergi/go-diff Copyright (c) 2012 Sergi Mansilla <[email protected]> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ## golcs - https://github.com/yudai/golcs The MIT License (MIT) Copyright (c) 2015 Iwasaki Yudai Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ## cli.go - https://github.com/codegangsta/cli Copyright (C) 2013 Jeremy Saenz All Rights Reserved. MIT LICENSE Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ## ginkgo - https://github.com/onsi/ginkgo Copyright (c) 2013-2014 Onsi Fakhouri Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # gomega - https://github.com/onsi/gomega Copyright (c) 2013-2014 Onsi Fakhouri Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
vendor/github.com/yudai/gojsondiff/LICENSE
0
https://github.com/grafana/grafana/commit/44eaa3eaa886e0f193e9b6ae364e0526c858cb00
[ 0.00017881489475257695, 0.00017403227684553713, 0.00016718039114493877, 0.00017354065494146198, 0.0000027172188765689498 ]
{ "id": 11, "code_window": [ " };\n", "\n", " getFilteredPluginList = (): PanelPlugin[] => {\n", " const { searchQuery, onPluginListChange } = this.props;\n", " const regex = new RegExp(searchQuery, 'i');\n", " const pluginList = this.pluginList;\n", "\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep" ], "after_edit": [ " const { searchQuery } = this.props;\n" ], "file_path": "public/app/features/dashboard/panel_editor/VizTypePicker.tsx", "type": "replace", "edit_start_line_idx": 53 }
// Copyright 2015 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build go1.6 package http2 import ( "crypto/tls" "fmt" "net/http" ) func configureTransport(t1 *http.Transport) (*Transport, error) { connPool := new(clientConnPool) t2 := &Transport{ ConnPool: noDialClientConnPool{connPool}, t1: t1, } connPool.t = t2 if err := registerHTTPSProtocol(t1, noDialH2RoundTripper{t2}); err != nil { return nil, err } if t1.TLSClientConfig == nil { t1.TLSClientConfig = new(tls.Config) } if !strSliceContains(t1.TLSClientConfig.NextProtos, "h2") { t1.TLSClientConfig.NextProtos = append([]string{"h2"}, t1.TLSClientConfig.NextProtos...) } if !strSliceContains(t1.TLSClientConfig.NextProtos, "http/1.1") { t1.TLSClientConfig.NextProtos = append(t1.TLSClientConfig.NextProtos, "http/1.1") } upgradeFn := func(authority string, c *tls.Conn) http.RoundTripper { addr := authorityAddr("https", authority) if used, err := connPool.addConnIfNeeded(addr, t2, c); err != nil { go c.Close() return erringRoundTripper{err} } else if !used { // Turns out we don't need this c. // For example, two goroutines made requests to the same host // at the same time, both kicking off TCP dials. (since protocol // was unknown) go c.Close() } return t2 } if m := t1.TLSNextProto; len(m) == 0 { t1.TLSNextProto = map[string]func(string, *tls.Conn) http.RoundTripper{ "h2": upgradeFn, } } else { m["h2"] = upgradeFn } return t2, nil } // registerHTTPSProtocol calls Transport.RegisterProtocol but // converting panics into errors. func registerHTTPSProtocol(t *http.Transport, rt http.RoundTripper) (err error) { defer func() { if e := recover(); e != nil { err = fmt.Errorf("%v", e) } }() t.RegisterProtocol("https", rt) return nil } // noDialH2RoundTripper is a RoundTripper which only tries to complete the request // if there's already has a cached connection to the host. type noDialH2RoundTripper struct{ t *Transport } func (rt noDialH2RoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { res, err := rt.t.RoundTrip(req) if isNoCachedConnError(err) { return nil, http.ErrSkipAltProtocol } return res, err }
vendor/golang.org/x/net/http2/configure_transport.go
0
https://github.com/grafana/grafana/commit/44eaa3eaa886e0f193e9b6ae364e0526c858cb00
[ 0.00019475129374768585, 0.00017551802739035338, 0.00016602278628852218, 0.00017290656978730112, 0.000007903159712441266 ]
{ "id": 11, "code_window": [ " };\n", "\n", " getFilteredPluginList = (): PanelPlugin[] => {\n", " const { searchQuery, onPluginListChange } = this.props;\n", " const regex = new RegExp(searchQuery, 'i');\n", " const pluginList = this.pluginList;\n", "\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep" ], "after_edit": [ " const { searchQuery } = this.props;\n" ], "file_path": "public/app/features/dashboard/panel_editor/VizTypePicker.tsx", "type": "replace", "edit_start_line_idx": 53 }
import $ from 'jquery'; import baron from 'baron'; import coreModule from 'app/core/core_module'; const scrollBarHTML = ` <div class="baron__track"> <div class="baron__bar"></div> </div> `; const scrollRootClass = 'baron baron__root'; const scrollerClass = 'baron__scroller'; export function geminiScrollbar() { return { restrict: 'A', link: (scope, elem, attrs) => { let scrollRoot = elem.parent(); const scroller = elem; console.log('scroll'); if (attrs.grafanaScrollbar && attrs.grafanaScrollbar === 'scrollonroot') { scrollRoot = scroller; } scrollRoot.addClass(scrollRootClass); $(scrollBarHTML).appendTo(scrollRoot); elem.addClass(scrollerClass); const scrollParams = { root: scrollRoot[0], scroller: scroller[0], bar: '.baron__bar', barOnCls: '_scrollbar', scrollingCls: '_scrolling', track: '.baron__track', direction: 'v', }; const scrollbar = baron(scrollParams); scope.$on('$destroy', () => { scrollbar.dispose(); }); }, }; } coreModule.directive('grafanaScrollbar', geminiScrollbar);
public/app/core/components/scroll/scroll.ts
0
https://github.com/grafana/grafana/commit/44eaa3eaa886e0f193e9b6ae364e0526c858cb00
[ 0.00017587566981092095, 0.00017346793902106583, 0.00017179074347950518, 0.0001730899966787547, 0.0000014597231938751065 ]
{ "id": 12, "code_window": [ "\n", " const filtered = pluginList.filter(item => {\n", " return regex.test(item.name);\n", " });\n", "\n", " onPluginListChange(filtered);\n", " return filtered;\n", " };\n", "\n", " render() {\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [], "file_path": "public/app/features/dashboard/panel_editor/VizTypePicker.tsx", "type": "replace", "edit_start_line_idx": 61 }
// Libraries import React, { PureComponent, ChangeEvent } from 'react'; // Utils & Services import { AngularComponent, getAngularLoader } from 'app/core/services/AngularLoader'; import { connectWithStore } from 'app/core/utils/connectWithReduxStore'; import { StoreState } from 'app/types'; import { updateLocation } from 'app/core/actions'; // Components import { EditorTabBody, EditorToolbarView } from './EditorTabBody'; import { VizTypePicker } from './VizTypePicker'; import { PluginHelp } from 'app/core/components/PluginHelp/PluginHelp'; import { FadeIn } from 'app/core/components/Animations/FadeIn'; // Types import { PanelModel } from '../state/PanelModel'; import { DashboardModel } from '../state/DashboardModel'; import { PanelPlugin } from 'app/types/plugins'; interface Props { panel: PanelModel; dashboard: DashboardModel; plugin: PanelPlugin; angularPanel?: AngularComponent; onTypeChanged: (newType: PanelPlugin) => void; updateLocation: typeof updateLocation; urlOpenVizPicker: boolean; } interface State { isVizPickerOpen: boolean; searchQuery: string; searchResults: PanelPlugin[]; scrollTop: number; } export class VisualizationTab extends PureComponent<Props, State> { element: HTMLElement; angularOptions: AngularComponent; searchInput: HTMLElement; constructor(props: Props) { super(props); this.state = { isVizPickerOpen: this.props.urlOpenVizPicker, searchQuery: '', searchResults: [], scrollTop: 0, }; } getPanelDefaultOptions = () => { const { panel, plugin } = this.props; if (plugin.exports.PanelDefaults) { return panel.getOptions(plugin.exports.PanelDefaults.options); } return panel.getOptions(plugin.exports.PanelDefaults); }; renderPanelOptions() { const { plugin, angularPanel } = this.props; const { PanelOptions } = plugin.exports; if (angularPanel) { return <div ref={element => (this.element = element)} />; } return ( <> {PanelOptions ? ( <PanelOptions options={this.getPanelDefaultOptions()} onChange={this.onPanelOptionsChanged} /> ) : ( <p>Visualization has no options</p> )} </> ); } componentDidMount() { if (this.shouldLoadAngularOptions()) { this.loadAngularOptions(); } } componentDidUpdate(prevProps: Props) { if (this.props.plugin !== prevProps.plugin) { this.cleanUpAngularOptions(); } if (this.shouldLoadAngularOptions()) { this.loadAngularOptions(); } } shouldLoadAngularOptions() { return this.props.angularPanel && this.element && !this.angularOptions; } loadAngularOptions() { const { angularPanel } = this.props; const scope = angularPanel.getScope(); // When full page reloading in edit mode the angular panel has on fully compiled & instantiated yet if (!scope.$$childHead) { setTimeout(() => { this.forceUpdate(); }); return; } const panelCtrl = scope.$$childHead.ctrl; panelCtrl.initEditMode(); let template = ''; for (let i = 0; i < panelCtrl.editorTabs.length; i++) { template += ` <div class="panel-options-group" ng-cloak>` + (i > 0 ? `<div class="panel-options-group__header"> <span class="panel-options-group__title">{{ctrl.editorTabs[${i}].title}} </span> </div>` : '') + `<div class="panel-options-group__body"> <panel-editor-tab editor-tab="ctrl.editorTabs[${i}]" ctrl="ctrl"></panel-editor-tab> </div> </div> `; } const loader = getAngularLoader(); const scopeProps = { ctrl: panelCtrl }; this.angularOptions = loader.load(this.element, scopeProps, template); } componentWillUnmount() { this.cleanUpAngularOptions(); } cleanUpAngularOptions() { if (this.angularOptions) { this.angularOptions.destroy(); this.angularOptions = null; } } clearQuery = () => { this.setState({ searchQuery: '' }); }; onPanelOptionsChanged = (options: any) => { this.props.panel.updateOptions(options); this.forceUpdate(); }; onOpenVizPicker = () => { this.setState({ isVizPickerOpen: true, scrollTop: 0 }); }; onCloseVizPicker = () => { if (this.props.urlOpenVizPicker) { this.props.updateLocation({ query: { openVizPicker: null }, partial: true }); } this.setState({ isVizPickerOpen: false }); }; onSearchQueryChange = (evt: ChangeEvent<HTMLInputElement>) => { const value = evt.target.value; this.setState({ searchQuery: value, }); }; renderToolbar = (): JSX.Element => { const { plugin } = this.props; const { searchQuery } = this.state; if (this.state.isVizPickerOpen) { return ( <> <label className="gf-form--has-input-icon"> <input type="text" className={`gf-form-input width-13 ${!this.hasSearchResults ? 'gf-form-input--invalid' : ''}`} placeholder="" onChange={this.onSearchQueryChange} value={searchQuery} ref={elem => elem && elem.focus()} /> <i className="gf-form-input-icon fa fa-search" /> </label> <button className="btn btn-link toolbar__close" onClick={this.onCloseVizPicker}> <i className="fa fa-chevron-up" /> </button> </> ); } else { return ( <div className="toolbar__main" onClick={this.onOpenVizPicker}> <img className="toolbar__main-image" src={plugin.info.logos.small} /> <div className="toolbar__main-name">{plugin.name}</div> <i className="fa fa-caret-down" /> </div> ); } }; onTypeChanged = (plugin: PanelPlugin) => { if (plugin.id === this.props.plugin.id) { this.setState({ isVizPickerOpen: false }); } else { this.props.onTypeChanged(plugin); } }; setSearchResults = (searchResults: PanelPlugin[]) => { this.setState({ searchResults: searchResults }); }; get hasSearchResults () { return this.state.searchResults && this.state.searchResults.length > 0; } renderHelp = () => <PluginHelp plugin={this.props.plugin} type="help" />; setScrollTop = (event: React.MouseEvent<HTMLElement>) => { const target = event.target as HTMLElement; this.setState({ scrollTop: target.scrollTop }); }; render() { const { plugin } = this.props; const { isVizPickerOpen, searchQuery, scrollTop } = this.state; const pluginHelp: EditorToolbarView = { heading: 'Help', icon: 'fa fa-question', render: this.renderHelp, }; return ( <EditorTabBody heading="Visualization" renderToolbar={this.renderToolbar} toolbarItems={[pluginHelp]} scrollTop={scrollTop} setScrollTop={this.setScrollTop} > <> <FadeIn in={isVizPickerOpen} duration={200} unmountOnExit={true} onExited={this.clearQuery}> <VizTypePicker current={plugin} onTypeChanged={this.onTypeChanged} searchQuery={searchQuery} onClose={this.onCloseVizPicker} onPluginListChange={this.setSearchResults} /> </FadeIn> {this.renderPanelOptions()} </> </EditorTabBody> ); } } const mapStateToProps = (state: StoreState) => ({ urlOpenVizPicker: !!state.location.query.openVizPicker, }); const mapDispatchToProps = { updateLocation, }; export default connectWithStore(VisualizationTab, mapStateToProps, mapDispatchToProps);
public/app/features/dashboard/panel_editor/VisualizationTab.tsx
1
https://github.com/grafana/grafana/commit/44eaa3eaa886e0f193e9b6ae364e0526c858cb00
[ 0.01733015663921833, 0.0008326156530529261, 0.00016516305913683027, 0.0001712360099190846, 0.0031355521641671658 ]
{ "id": 12, "code_window": [ "\n", " const filtered = pluginList.filter(item => {\n", " return regex.test(item.name);\n", " });\n", "\n", " onPluginListChange(filtered);\n", " return filtered;\n", " };\n", "\n", " render() {\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [], "file_path": "public/app/features/dashboard/panel_editor/VizTypePicker.tsx", "type": "replace", "edit_start_line_idx": 61 }
import { OrgSwitchCtrl } from '../components/org_switcher'; import q from 'q'; jest.mock('app/core/services/context_srv', () => ({ contextSrv: { user: { orgId: 1 }, }, })); jest.mock('app/core/config', () => { return { appSubUrl: '/subUrl', }; }); describe('OrgSwitcher', () => { describe('when switching org', () => { let expectedHref; let expectedUsingUrl; beforeEach(() => { const backendSrvStub: any = { get: url => { return q.resolve([]); }, post: url => { expectedUsingUrl = url; return q.resolve({}); }, }; const orgSwitcherCtrl = new OrgSwitchCtrl(backendSrvStub); orgSwitcherCtrl.setWindowLocation = href => (expectedHref = href); return orgSwitcherCtrl.setUsingOrg({ orgId: 2 }); }); it('should switch orgId in call to backend', () => { expect(expectedUsingUrl).toBe('/api/user/using/2'); }); it('should switch orgId in url and redirect to home page', () => { expect(expectedHref).toBe('/subUrl/?orgId=2'); }); }); });
public/app/core/specs/org_switcher.test.ts
0
https://github.com/grafana/grafana/commit/44eaa3eaa886e0f193e9b6ae364e0526c858cb00
[ 0.0001750002702465281, 0.00017279479652643204, 0.00016893778229132295, 0.00017323612701147795, 0.000002252547346870415 ]
{ "id": 12, "code_window": [ "\n", " const filtered = pluginList.filter(item => {\n", " return regex.test(item.name);\n", " });\n", "\n", " onPluginListChange(filtered);\n", " return filtered;\n", " };\n", "\n", " render() {\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [], "file_path": "public/app/features/dashboard/panel_editor/VizTypePicker.tsx", "type": "replace", "edit_start_line_idx": 61 }
#!/bin/bash bulkDashboard() { requiresJsonnet COUNTER=0 MAX=400 while [ $COUNTER -lt $MAX ]; do jsonnet -o "bulk-dashboards/dashboard${COUNTER}.json" -e "local bulkDash = import 'bulk-dashboards/bulkdash.jsonnet'; bulkDash + { uid: 'uid-${COUNTER}', title: 'title-${COUNTER}' }" let COUNTER=COUNTER+1 done ln -s -f ../../../devenv/bulk-dashboards/bulk-dashboards.yaml ../conf/provisioning/dashboards/custom.yaml } bulkAlertingDashboard() { requiresJsonnet COUNTER=0 MAX=100 while [ $COUNTER -lt $MAX ]; do jsonnet -o "bulk_alerting_dashboards/alerting_dashboard${COUNTER}.json" -e "local bulkDash = import 'bulk_alerting_dashboards/bulkdash_alerting.jsonnet'; bulkDash + { uid: 'bd-${COUNTER}', title: 'alerting-title-${COUNTER}' }" let COUNTER=COUNTER+1 done ln -s -f ../../../devenv/bulk_alerting_dashboards/bulk_alerting_dashboards.yaml ../conf/provisioning/dashboards/custom.yaml } requiresJsonnet() { if ! type "jsonnet" > /dev/null; then echo "you need you install jsonnet to run this script" echo "follow the instructions on https://github.com/google/jsonnet" exit 1 fi } devDashboards() { echo -e "\xE2\x9C\x94 Setting up all dev dashboards using provisioning" ln -s -f ../../../devenv/dashboards.yaml ../conf/provisioning/dashboards/dev.yaml } devDatasources() { echo -e "\xE2\x9C\x94 Setting up all dev datasources using provisioning" ln -s -f ../../../devenv/datasources.yaml ../conf/provisioning/datasources/dev.yaml } usage() { echo -e "\n" echo "Usage:" echo " bulk-dashboards - create and provisioning 400 dashboards" echo " bulk-alerting-dashboards - create and provisioning 400 dashboards with alerts" echo " no args - provisiong core datasources and dev dashboards" } main() { echo -e "------------------------------------------------------------------" echo -e "This script setups provisioning for dev datasources and dashboards" echo -e "------------------------------------------------------------------" echo -e "\n" local cmd=$1 if [[ $cmd == "bulk-alerting-dashboards" ]]; then bulkAlertingDashboard elif [[ $cmd == "bulk-dashboards" ]]; then bulkDashboard else devDashboards devDatasources fi if [[ -z "$cmd" ]]; then usage fi } main "$@"
devenv/setup.sh
0
https://github.com/grafana/grafana/commit/44eaa3eaa886e0f193e9b6ae364e0526c858cb00
[ 0.0002864351263269782, 0.00018390864715911448, 0.00016528925334569067, 0.00017133922665379941, 0.00003636762630776502 ]
{ "id": 12, "code_window": [ "\n", " const filtered = pluginList.filter(item => {\n", " return regex.test(item.name);\n", " });\n", "\n", " onPluginListChange(filtered);\n", " return filtered;\n", " };\n", "\n", " render() {\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [], "file_path": "public/app/features/dashboard/panel_editor/VizTypePicker.tsx", "type": "replace", "edit_start_line_idx": 61 }
import React, { FC } from 'react'; import _ from 'lodash'; import kbn from 'app/core/utils/kbn'; import { MetricSelect } from 'app/core/components/Select/MetricSelect'; import { alignmentPeriods, alignOptions } from '../constants'; import { TemplateSrv } from 'app/features/templating/template_srv'; export interface Props { onChange: (alignmentPeriod) => void; templateSrv: TemplateSrv; alignmentPeriod: string; perSeriesAligner: string; usedAlignmentPeriod: string; } export const AlignmentPeriods: FC<Props> = ({ alignmentPeriod, templateSrv, onChange, perSeriesAligner, usedAlignmentPeriod, }) => { const alignment = alignOptions.find(ap => ap.value === templateSrv.replace(perSeriesAligner)); const formatAlignmentText = `${kbn.secondsToHms(usedAlignmentPeriod)} interval (${alignment ? alignment.text : ''})`; return ( <> <div className="gf-form-inline"> <div className="gf-form"> <label className="gf-form-label query-keyword width-9">Alignment Period</label> <MetricSelect onChange={onChange} value={alignmentPeriod} variables={templateSrv.variables} options={[ { label: 'Alignment options', expanded: true, options: alignmentPeriods.map(ap => ({ ...ap, label: ap.text, })), }, ]} placeholder="Select Alignment" className="width-15" /> </div> <div className="gf-form gf-form--grow"> {usedAlignmentPeriod && <label className="gf-form-label gf-form-label--grow">{formatAlignmentText}</label>} </div> </div> </> ); };
public/app/plugins/datasource/stackdriver/components/AlignmentPeriods.tsx
0
https://github.com/grafana/grafana/commit/44eaa3eaa886e0f193e9b6ae364e0526c858cb00
[ 0.00017472317267674953, 0.0001714538666419685, 0.0001671362406341359, 0.00017198376008309424, 0.000002390097506577149 ]
{ "id": 0, "code_window": [ "import braintree = require('braintree');\n", "import { BraintreeGateway, Address, AddressCreateRequest,\n", " CreditCard, Customer, PayPalAccount, ApplePayCard, AndroidPayCard,\n", " VisaCheckoutCard, SamsungPayCard, MasterpassCard, PaymentMethod, Transaction\n", "} from 'braintree';\n", "\n", "/**\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep" ], "after_edit": [ " VisaCheckoutCard, SamsungPayCard, MasterpassCard, PaymentMethod,\n", " PaymentMethodNonce, Transaction\n" ], "file_path": "types/braintree/braintree-tests.ts", "type": "replace", "edit_start_line_idx": 3 }
import braintree = require('braintree'); import { BraintreeGateway, Address, AddressCreateRequest, CreditCard, Customer, PayPalAccount, ApplePayCard, AndroidPayCard, VisaCheckoutCard, SamsungPayCard, MasterpassCard, PaymentMethod, Transaction } from 'braintree'; /** * Gateway */ const gateway: BraintreeGateway = new braintree.BraintreeGateway({ environment: 'Sandbox', merchantId: 'abc123', publicKey: 'def456', privateKey: 'xyz789', }); /** * Request / Response */ (async () => { const addressRequest: AddressCreateRequest = { customerId: '123456', streetAddress: '222 Oak Street', }; const response = await gateway.address.create(addressRequest); const { id, customerId }: Address = response.address; })(); (async () => { const creditCardRequest = { cardholderName: 'Johnny Dogood', cvv: '123', }; const response = await gateway.creditCard.update('abcdef', creditCardRequest); const { bin, maskedNumber, last4 }: CreditCard = response.creditCard; })(); (async () => { const response: Customer = await gateway.customer.find('abcdef'); const { id, paymentMethods } = response; })(); (async () => { const paymentMethodRequest = { customerId: '123456', paymentMethodNonce: 'i-am-a-nonce', }; const response = await gateway.paymentMethod.create(paymentMethodRequest); const { token }: PaymentMethod = response.paymentMethod; const applePayCard = <ApplePayCard> response.paymentMethod; const paypalAccount = <PayPalAccount> response.paymentMethod; const androidPayCard = <AndroidPayCard> response.paymentMethod; const creditCard = <CreditCard> response.paymentMethod; const venmoAccount = <braintree.VenmoAccount> response.paymentMethod; const visaCheckoutCard = <VisaCheckoutCard> response.paymentMethod; const samsungPayCard = <SamsungPayCard> response.paymentMethod; const masterpassCard = <MasterpassCard> response.paymentMethod; })(); (async () => { const transactionRequest = { amount: '128.00', }; const response = await gateway.transaction.sale(transactionRequest); const { amount, billing, id }: Transaction = response.transaction; // Cannot assign to var await gateway.transaction.cloneTransaction(id, { amount: '100.00' , options: {submitForSettlement: true }}); const transactions: Transaction[] = await gateway.transaction.search(() => { return; }); })();
types/braintree/braintree-tests.ts
1
https://github.com/DefinitelyTyped/DefinitelyTyped/commit/d0557be9a4101cac9a5d0af47908dd9df52c8906
[ 0.9978298544883728, 0.2363237738609314, 0.00017303520871791989, 0.003255984280258417, 0.4066944718360901 ]
{ "id": 0, "code_window": [ "import braintree = require('braintree');\n", "import { BraintreeGateway, Address, AddressCreateRequest,\n", " CreditCard, Customer, PayPalAccount, ApplePayCard, AndroidPayCard,\n", " VisaCheckoutCard, SamsungPayCard, MasterpassCard, PaymentMethod, Transaction\n", "} from 'braintree';\n", "\n", "/**\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep" ], "after_edit": [ " VisaCheckoutCard, SamsungPayCard, MasterpassCard, PaymentMethod,\n", " PaymentMethodNonce, Transaction\n" ], "file_path": "types/braintree/braintree-tests.ts", "type": "replace", "edit_start_line_idx": 3 }
import * as Globalize from "../globalize"; import "./number"; import "./plural"; declare module "../globalize" { interface UnitFormatterOptions { /** * form: [String] eg. "long", "short" or "narrow". */ form?: "long" | "short" | "narrow"; /** * numberFormatter: [Function] a number formatter function. Defaults to Globalize .numberFormatter() for the current locale using the default options. */ numberFormatter?: NumberFormatterOptions; } interface Shared { /** * Returns a function that formats a unit according to the given unit, options, and the default/instance locale. * The returned function is invoked with one argument: the number value to be formatted. * @param unit String value indicating the unit to be formatted. eg. "day", "week", "month", etc. Could also be a compound unit, eg. "mile-per-hour" or "mile/hour" * @param options form: [String] eg. "long", "short" or "narrow". * @returns {Function} Returns a function that formats a unit according to the given unit, options, and the default/instance locale. */ unitFormatter(unit: string, options?: UnitFormatterOptions): (value: number) => string; /** * Alias for .unitFormatter( unit, options )( value ). * @param {number} value The number to be formatted. * @param {string} unit String value indicating the unit to be formatted. eg. "day", "week", "month", etc. Could also be a compound unit, eg. "mile-per-hour" or "mile/hour" * @param {UnitFormatterOptions} options form: [String] eg. "long", "short" or "narrow". * @returns {string} Returns the unit formatted. */ formatUnit(value: number, unit: string, options?: UnitFormatterOptions): string } } export = Globalize;
types/globalize/dist/globalize/unit.d.ts
0
https://github.com/DefinitelyTyped/DefinitelyTyped/commit/d0557be9a4101cac9a5d0af47908dd9df52c8906
[ 0.00017620196740608662, 0.00017383012163918465, 0.00017110901535488665, 0.00017400475917384028, 0.000002255901790704229 ]
{ "id": 0, "code_window": [ "import braintree = require('braintree');\n", "import { BraintreeGateway, Address, AddressCreateRequest,\n", " CreditCard, Customer, PayPalAccount, ApplePayCard, AndroidPayCard,\n", " VisaCheckoutCard, SamsungPayCard, MasterpassCard, PaymentMethod, Transaction\n", "} from 'braintree';\n", "\n", "/**\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep" ], "after_edit": [ " VisaCheckoutCard, SamsungPayCard, MasterpassCard, PaymentMethod,\n", " PaymentMethodNonce, Transaction\n" ], "file_path": "types/braintree/braintree-tests.ts", "type": "replace", "edit_start_line_idx": 3 }
{ "compilerOptions": { "module": "commonjs", "lib": [ "es6" ], "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" ], "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", "cli-table-tests.ts" ] }
types/cli-table/tsconfig.json
0
https://github.com/DefinitelyTyped/DefinitelyTyped/commit/d0557be9a4101cac9a5d0af47908dd9df52c8906
[ 0.00017439029761590064, 0.00017426021804567426, 0.00017404624668415636, 0.00017434406618122011, 1.5246305906657653e-7 ]
{ "id": 0, "code_window": [ "import braintree = require('braintree');\n", "import { BraintreeGateway, Address, AddressCreateRequest,\n", " CreditCard, Customer, PayPalAccount, ApplePayCard, AndroidPayCard,\n", " VisaCheckoutCard, SamsungPayCard, MasterpassCard, PaymentMethod, Transaction\n", "} from 'braintree';\n", "\n", "/**\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep" ], "after_edit": [ " VisaCheckoutCard, SamsungPayCard, MasterpassCard, PaymentMethod,\n", " PaymentMethodNonce, Transaction\n" ], "file_path": "types/braintree/braintree-tests.ts", "type": "replace", "edit_start_line_idx": 3 }
var ec_ns = (a: number, b: string) => a.toString() == b; //equality comparer on number,string var ec_ss = (a: string, b: string) => a == b; //equality comparer on string,string var ec_nn = (a: number, b: number) => a === b; //equality comparer on number,number var c_nn = (a: number, b: number) => a - b; //comparer on number,number // static Ix.Enumerable.throw(new Error("error")); Ix.Enumerable.throwException(new Error("error")); var ax = Ix.Enumerable.generate(-100, a => a < 100, a=> a + 10, a=> a * 2); Ix.Enumerable.defer(() => ax); Ix.Enumerable.using(() => ax.getEnumerator(), e => Ix.Enumerable.return(e.getCurrent())); Ix.Enumerable.catch(ax, ax, ax); Ix.Enumerable.catchException(ax, ax, ax); Ix.Enumerable.catch<string>(); Ix.Enumerable.catchException<string>(); Ix.Enumerable.onErrorResumeNext(ax, ax, ax); Ix.Enumerable.onErrorResumeNext<string>(); Ix.Enumerable.while(x => x.count() > 0, ax); Ix.Enumerable.whileDo(x => x.count() > 0, ax); Ix.Enumerable.if(() => true, ax, ax); Ix.Enumerable.ifThen(() => true, ax, ax); Ix.Enumerable.if(() => true, ax); Ix.Enumerable.ifThen(() => true, ax); Ix.Enumerable.doWhile(ax, x => x.count() > 0); Ix.Enumerable.case(() => 42, { 42: ax }, ax); Ix.Enumerable.switchCase(() => 42, { 42: ax }, ax); Ix.Enumerable.case(() => 42, { 42: ax }); Ix.Enumerable.switchCase(() => 42, { 42: ax }); Ix.Enumerable.case(() => "42", { "42": ax }, ax); Ix.Enumerable.switchCase(() => "42", { "42": ax }, ax); Ix.Enumerable.case(() => "42", { "42": ax }); Ix.Enumerable.switchCase(() => "42", { "42": ax }); Ix.Enumerable.for(ax, a => ax); Ix.Enumerable.forIn(ax, a => ax); // instance var bx: Ix.Enumerable<string>; ax.isEmpty(); bx.minBy(b => b.length, c_nn); bx.minBy(b => b.length); bx.maxBy(b => b.length, c_nn); bx.maxBy(b => b.length); ax.share(ax => bx); ax.share(); ax.publish(ax => bx); ax.publish(); ax.memoize(); ax.do({ onNext: (a: number) => console.log(a), onError: err => console.log(err), onCompleted: () => console.log("completed") }); ax.do(a => console.log(a), err => console.log(err), () => console.log("completed")); ax.do(a => console.log(a), err => console.log(err)); ax.do((a: number) => console.log(a)); ax.doAction({ onNext: (a: number) => console.log(a), onError: err => console.log(err), onCompleted: () => console.log("completed") }); ax.doAction(a => console.log(a), err => console.log(err), () => console.log("completed")); ax.doAction(a => console.log(a), err => console.log(err)); ax.doAction((a: number) => console.log(a)); ax.bufferWithCount(10, 20); ax.bufferWithCount(10); ax.ignoreElements(); bx.distinctBy(b => b.length, ec_nn); bx.distinctBy(b => b.length); bx.distinctUntilChanged(b => b.length, ec_nn); bx.distinctUntilChanged(b => b.length); bx.distinctUntilChanged(); bx.distinctUntilChanged(false, ec_ss); ax.expand(a => ax); ax.startWith(10, 20); ax.scan(0, (acc, a) => acc + a); ax.scan((acc, a) => acc + a); ax.takeLast(10); ax.skipLast(10); ax.repeat(10); ax.repeat(); ax.catch(ax, ax, ax); ax.catchException(ax, ax, ax); ax.catch(ax); ax.catchException(ax); ax.catch(err => ax); ax.catchException(err => ax); ax.finally(() => { }); ax.finallyDo(() => { }); ax.onErrorResumeNext(ax); ax.retry(10); ax.retry();
types/ix.js/test/index.ts
0
https://github.com/DefinitelyTyped/DefinitelyTyped/commit/d0557be9a4101cac9a5d0af47908dd9df52c8906
[ 0.00018158077728003263, 0.000179159440449439, 0.00017746537923812866, 0.00017888803267851472, 0.0000011137327646792983 ]
{ "id": 1, "code_window": [ " const samsungPayCard = <SamsungPayCard> response.paymentMethod;\n", " const masterpassCard = <MasterpassCard> response.paymentMethod;\n", "})();\n", "\n", "(async () => {\n", " const transactionRequest = {\n", " amount: '128.00',\n" ], "labels": [ "keep", "keep", "keep", "add", "keep", "keep", "keep" ], "after_edit": [ "(async () => {\n", " const response = await gateway.paymentMethodNonce.create('token');\n", " const nonce = response.paymentMethodNonce.nonce;\n", "})();\n", "\n" ], "file_path": "types/braintree/braintree-tests.ts", "type": "add", "edit_start_line_idx": 59 }
import braintree = require('braintree'); import { BraintreeGateway, Address, AddressCreateRequest, CreditCard, Customer, PayPalAccount, ApplePayCard, AndroidPayCard, VisaCheckoutCard, SamsungPayCard, MasterpassCard, PaymentMethod, Transaction } from 'braintree'; /** * Gateway */ const gateway: BraintreeGateway = new braintree.BraintreeGateway({ environment: 'Sandbox', merchantId: 'abc123', publicKey: 'def456', privateKey: 'xyz789', }); /** * Request / Response */ (async () => { const addressRequest: AddressCreateRequest = { customerId: '123456', streetAddress: '222 Oak Street', }; const response = await gateway.address.create(addressRequest); const { id, customerId }: Address = response.address; })(); (async () => { const creditCardRequest = { cardholderName: 'Johnny Dogood', cvv: '123', }; const response = await gateway.creditCard.update('abcdef', creditCardRequest); const { bin, maskedNumber, last4 }: CreditCard = response.creditCard; })(); (async () => { const response: Customer = await gateway.customer.find('abcdef'); const { id, paymentMethods } = response; })(); (async () => { const paymentMethodRequest = { customerId: '123456', paymentMethodNonce: 'i-am-a-nonce', }; const response = await gateway.paymentMethod.create(paymentMethodRequest); const { token }: PaymentMethod = response.paymentMethod; const applePayCard = <ApplePayCard> response.paymentMethod; const paypalAccount = <PayPalAccount> response.paymentMethod; const androidPayCard = <AndroidPayCard> response.paymentMethod; const creditCard = <CreditCard> response.paymentMethod; const venmoAccount = <braintree.VenmoAccount> response.paymentMethod; const visaCheckoutCard = <VisaCheckoutCard> response.paymentMethod; const samsungPayCard = <SamsungPayCard> response.paymentMethod; const masterpassCard = <MasterpassCard> response.paymentMethod; })(); (async () => { const transactionRequest = { amount: '128.00', }; const response = await gateway.transaction.sale(transactionRequest); const { amount, billing, id }: Transaction = response.transaction; // Cannot assign to var await gateway.transaction.cloneTransaction(id, { amount: '100.00' , options: {submitForSettlement: true }}); const transactions: Transaction[] = await gateway.transaction.search(() => { return; }); })();
types/braintree/braintree-tests.ts
1
https://github.com/DefinitelyTyped/DefinitelyTyped/commit/d0557be9a4101cac9a5d0af47908dd9df52c8906
[ 0.9982245564460754, 0.37797823548316956, 0.00016789637447800487, 0.014722716063261032, 0.4802777171134949 ]
{ "id": 1, "code_window": [ " const samsungPayCard = <SamsungPayCard> response.paymentMethod;\n", " const masterpassCard = <MasterpassCard> response.paymentMethod;\n", "})();\n", "\n", "(async () => {\n", " const transactionRequest = {\n", " amount: '128.00',\n" ], "labels": [ "keep", "keep", "keep", "add", "keep", "keep", "keep" ], "after_edit": [ "(async () => {\n", " const response = await gateway.paymentMethodNonce.create('token');\n", " const nonce = response.paymentMethodNonce.nonce;\n", "})();\n", "\n" ], "file_path": "types/braintree/braintree-tests.ts", "type": "add", "edit_start_line_idx": 59 }
{ "extends": "dtslint/dt.json" }
types/clientjs/tslint.json
0
https://github.com/DefinitelyTyped/DefinitelyTyped/commit/d0557be9a4101cac9a5d0af47908dd9df52c8906
[ 0.0001697561383480206, 0.0001697561383480206, 0.0001697561383480206, 0.0001697561383480206, 0 ]
{ "id": 1, "code_window": [ " const samsungPayCard = <SamsungPayCard> response.paymentMethod;\n", " const masterpassCard = <MasterpassCard> response.paymentMethod;\n", "})();\n", "\n", "(async () => {\n", " const transactionRequest = {\n", " amount: '128.00',\n" ], "labels": [ "keep", "keep", "keep", "add", "keep", "keep", "keep" ], "after_edit": [ "(async () => {\n", " const response = await gateway.paymentMethodNonce.create('token');\n", " const nonce = response.paymentMethodNonce.nonce;\n", "})();\n", "\n" ], "file_path": "types/braintree/braintree-tests.ts", "type": "add", "edit_start_line_idx": 59 }
import { RuntimeEvent, BaseEventMap } from './base'; export interface ExternalApplicationEvents extends BaseEventMap { connected: RuntimeEvent<'externalapplication', 'connected'>; disconnected: RuntimeEvent<'externalapplication', 'disconnected'>; }
types/openfin/v39/_v2/api/events/externalApplication.d.ts
0
https://github.com/DefinitelyTyped/DefinitelyTyped/commit/d0557be9a4101cac9a5d0af47908dd9df52c8906
[ 0.00017611798830330372, 0.00017611798830330372, 0.00017611798830330372, 0.00017611798830330372, 0 ]
{ "id": 1, "code_window": [ " const samsungPayCard = <SamsungPayCard> response.paymentMethod;\n", " const masterpassCard = <MasterpassCard> response.paymentMethod;\n", "})();\n", "\n", "(async () => {\n", " const transactionRequest = {\n", " amount: '128.00',\n" ], "labels": [ "keep", "keep", "keep", "add", "keep", "keep", "keep" ], "after_edit": [ "(async () => {\n", " const response = await gateway.paymentMethodNonce.create('token');\n", " const nonce = response.paymentMethodNonce.nonce;\n", "})();\n", "\n" ], "file_path": "types/braintree/braintree-tests.ts", "type": "add", "edit_start_line_idx": 59 }
{ "extends": "dtslint/dt.json" }
types/prosemirror-menu/tslint.json
0
https://github.com/DefinitelyTyped/DefinitelyTyped/commit/d0557be9a4101cac9a5d0af47908dd9df52c8906
[ 0.0001697561383480206, 0.0001697561383480206, 0.0001697561383480206, 0.0001697561383480206, 0 ]
{ "id": 2, "code_window": [ " creditCard: T extends CreditCard ? CreditCard : never;\n", " customer: T extends Customer ? Customer : never;\n", " dispute: T extends Dispute ? Dispute : never;\n", " merchantAccount: T extends MerchantAccount ? MerchantAccount : never;\n", " paymentMethod: T extends PaymentMethod ? PaymentMethod : never;\n", " settlementBatchSumary: T extends SettlementBatchSummary ? SettlementBatchSummary : never;\n", " subscription: T extends Subscription ? Subscription : never;\n", " transaction: T extends Transaction ? Transaction : never;\n", " clientToken: T extends ClientToken ? string : never;\n", " }\n" ], "labels": [ "keep", "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " paymentMethodNonce: T extends PaymentMethodNonce ? PaymentMethodNonce : never;\n" ], "file_path": "types/braintree/index.d.ts", "type": "add", "edit_start_line_idx": 61 }
import braintree = require('braintree'); import { BraintreeGateway, Address, AddressCreateRequest, CreditCard, Customer, PayPalAccount, ApplePayCard, AndroidPayCard, VisaCheckoutCard, SamsungPayCard, MasterpassCard, PaymentMethod, Transaction } from 'braintree'; /** * Gateway */ const gateway: BraintreeGateway = new braintree.BraintreeGateway({ environment: 'Sandbox', merchantId: 'abc123', publicKey: 'def456', privateKey: 'xyz789', }); /** * Request / Response */ (async () => { const addressRequest: AddressCreateRequest = { customerId: '123456', streetAddress: '222 Oak Street', }; const response = await gateway.address.create(addressRequest); const { id, customerId }: Address = response.address; })(); (async () => { const creditCardRequest = { cardholderName: 'Johnny Dogood', cvv: '123', }; const response = await gateway.creditCard.update('abcdef', creditCardRequest); const { bin, maskedNumber, last4 }: CreditCard = response.creditCard; })(); (async () => { const response: Customer = await gateway.customer.find('abcdef'); const { id, paymentMethods } = response; })(); (async () => { const paymentMethodRequest = { customerId: '123456', paymentMethodNonce: 'i-am-a-nonce', }; const response = await gateway.paymentMethod.create(paymentMethodRequest); const { token }: PaymentMethod = response.paymentMethod; const applePayCard = <ApplePayCard> response.paymentMethod; const paypalAccount = <PayPalAccount> response.paymentMethod; const androidPayCard = <AndroidPayCard> response.paymentMethod; const creditCard = <CreditCard> response.paymentMethod; const venmoAccount = <braintree.VenmoAccount> response.paymentMethod; const visaCheckoutCard = <VisaCheckoutCard> response.paymentMethod; const samsungPayCard = <SamsungPayCard> response.paymentMethod; const masterpassCard = <MasterpassCard> response.paymentMethod; })(); (async () => { const transactionRequest = { amount: '128.00', }; const response = await gateway.transaction.sale(transactionRequest); const { amount, billing, id }: Transaction = response.transaction; // Cannot assign to var await gateway.transaction.cloneTransaction(id, { amount: '100.00' , options: {submitForSettlement: true }}); const transactions: Transaction[] = await gateway.transaction.search(() => { return; }); })();
types/braintree/braintree-tests.ts
1
https://github.com/DefinitelyTyped/DefinitelyTyped/commit/d0557be9a4101cac9a5d0af47908dd9df52c8906
[ 0.003031856380403042, 0.0009535736753605306, 0.00017025379929691553, 0.0006120560574345291, 0.0009340663673356175 ]
{ "id": 2, "code_window": [ " creditCard: T extends CreditCard ? CreditCard : never;\n", " customer: T extends Customer ? Customer : never;\n", " dispute: T extends Dispute ? Dispute : never;\n", " merchantAccount: T extends MerchantAccount ? MerchantAccount : never;\n", " paymentMethod: T extends PaymentMethod ? PaymentMethod : never;\n", " settlementBatchSumary: T extends SettlementBatchSummary ? SettlementBatchSummary : never;\n", " subscription: T extends Subscription ? Subscription : never;\n", " transaction: T extends Transaction ? Transaction : never;\n", " clientToken: T extends ClientToken ? string : never;\n", " }\n" ], "labels": [ "keep", "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " paymentMethodNonce: T extends PaymentMethodNonce ? PaymentMethodNonce : never;\n" ], "file_path": "types/braintree/index.d.ts", "type": "add", "edit_start_line_idx": 61 }
{ "compilerOptions": { "module": "commonjs", "lib": [ "es6", "dom" ], "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" ], "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", "backbone-relational-tests.ts" ] }
types/backbone-relational/tsconfig.json
0
https://github.com/DefinitelyTyped/DefinitelyTyped/commit/d0557be9a4101cac9a5d0af47908dd9df52c8906
[ 0.00017604746972210705, 0.00017532655328977853, 0.00017441340605728328, 0.00017551882774569094, 6.808151624682068e-7 ]
{ "id": 2, "code_window": [ " creditCard: T extends CreditCard ? CreditCard : never;\n", " customer: T extends Customer ? Customer : never;\n", " dispute: T extends Dispute ? Dispute : never;\n", " merchantAccount: T extends MerchantAccount ? MerchantAccount : never;\n", " paymentMethod: T extends PaymentMethod ? PaymentMethod : never;\n", " settlementBatchSumary: T extends SettlementBatchSummary ? SettlementBatchSummary : never;\n", " subscription: T extends Subscription ? Subscription : never;\n", " transaction: T extends Transaction ? Transaction : never;\n", " clientToken: T extends ClientToken ? string : never;\n", " }\n" ], "labels": [ "keep", "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " paymentMethodNonce: T extends PaymentMethodNonce ? PaymentMethodNonce : never;\n" ], "file_path": "types/braintree/index.d.ts", "type": "add", "edit_start_line_idx": 61 }
{ "extends": "dtslint/dt.json" }
types/sqlite3/tslint.json
0
https://github.com/DefinitelyTyped/DefinitelyTyped/commit/d0557be9a4101cac9a5d0af47908dd9df52c8906
[ 0.00017202661547344178, 0.00017202661547344178, 0.00017202661547344178, 0.00017202661547344178, 0 ]
{ "id": 2, "code_window": [ " creditCard: T extends CreditCard ? CreditCard : never;\n", " customer: T extends Customer ? Customer : never;\n", " dispute: T extends Dispute ? Dispute : never;\n", " merchantAccount: T extends MerchantAccount ? MerchantAccount : never;\n", " paymentMethod: T extends PaymentMethod ? PaymentMethod : never;\n", " settlementBatchSumary: T extends SettlementBatchSummary ? SettlementBatchSummary : never;\n", " subscription: T extends Subscription ? Subscription : never;\n", " transaction: T extends Transaction ? Transaction : never;\n", " clientToken: T extends ClientToken ? string : never;\n", " }\n" ], "labels": [ "keep", "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " paymentMethodNonce: T extends PaymentMethodNonce ? PaymentMethodNonce : never;\n" ], "file_path": "types/braintree/index.d.ts", "type": "add", "edit_start_line_idx": 61 }
// Type definitions for react-google-login-component 0.9 // Project: https://github.com/kennetpostigo/react-google-login-component // Definitions by: Konstantin Lebedev <https://github.com/koss-lebedev> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 import * as React from "react"; export interface GoogleLoginInfo { getAuthResponse: () => { access_token: string; }; } export interface GoogleLoginProps extends React.ButtonHTMLAttributes<HTMLButtonElement> { socialId: string; scope?: string; fetchBasicProfile?: boolean; buttonText?: string; prompt?: string; responseHandler: (response: GoogleLoginInfo) => void; } export class GoogleLogin extends React.Component<GoogleLoginProps> {}
types/react-google-login-component/index.d.ts
0
https://github.com/DefinitelyTyped/DefinitelyTyped/commit/d0557be9a4101cac9a5d0af47908dd9df52c8906
[ 0.0001747799979057163, 0.00017333909636363387, 0.00017178483540192246, 0.00017345247033517808, 0.00000122539495350793 ]
{ "id": 0, "code_window": [ " body.unshift(t.variableDeclaration(\"var\", paramDecls));\n", " }\n", "\n", " node.body = util.template(\"tail-call-body\", {\n", " THIS_ID: this.thisId,\n", " ARGUMENTS_ID: this.argumentsId,\n", " FUNCTION_ID: this.getFunctionId(),\n", " BLOCK: node.body\n" ], "labels": [ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " body.push(t.returnStatement());\n", "\n" ], "file_path": "lib/babel/transformation/transformers/es6/tail-call.js", "type": "add", "edit_start_line_idx": 114 }
"use strict"; function fact(_x2) { var _arguments = arguments; _function: while (true) { var n = _x2; acc = undefined; var acc = _arguments[1] === undefined ? 1 : _arguments[1]; if (n > 1) { _arguments = [_x2 = n - 1, acc * n]; continue _function; } else { return acc; } } }
test/fixtures/transformation/es6-tail-call/factorial/expected.js
1
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.00016884502838365734, 0.00016881799092516303, 0.0001687909389147535, 0.00016881799092516303, 2.7044736228276633e-8 ]
{ "id": 0, "code_window": [ " body.unshift(t.variableDeclaration(\"var\", paramDecls));\n", " }\n", "\n", " node.body = util.template(\"tail-call-body\", {\n", " THIS_ID: this.thisId,\n", " ARGUMENTS_ID: this.argumentsId,\n", " FUNCTION_ID: this.getFunctionId(),\n", " BLOCK: node.body\n" ], "labels": [ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " body.push(t.returnStatement());\n", "\n" ], "file_path": "lib/babel/transformation/transformers/es6/tail-call.js", "type": "add", "edit_start_line_idx": 114 }
new Foo(); new Foo(); new Foo(bar);
test/fixtures/generation/types/NewExpression/expected.js
0
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.00017126915918197483, 0.00017126915918197483, 0.00017126915918197483, 0.00017126915918197483, 0 ]
{ "id": 0, "code_window": [ " body.unshift(t.variableDeclaration(\"var\", paramDecls));\n", " }\n", "\n", " node.body = util.template(\"tail-call-body\", {\n", " THIS_ID: this.thisId,\n", " ARGUMENTS_ID: this.argumentsId,\n", " FUNCTION_ID: this.getFunctionId(),\n", " BLOCK: node.body\n" ], "labels": [ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " body.push(t.returnStatement());\n", "\n" ], "file_path": "lib/babel/transformation/transformers/es6/tail-call.js", "type": "add", "edit_start_line_idx": 114 }
++i; i++; (foo++).test();
test/fixtures/generation/types/UpdateExpression/actual.js
0
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.0001696574327070266, 0.0001696574327070266, 0.0001696574327070266, 0.0001696574327070266, 0 ]
{ "id": 0, "code_window": [ " body.unshift(t.variableDeclaration(\"var\", paramDecls));\n", " }\n", "\n", " node.body = util.template(\"tail-call-body\", {\n", " THIS_ID: this.thisId,\n", " ARGUMENTS_ID: this.argumentsId,\n", " FUNCTION_ID: this.getFunctionId(),\n", " BLOCK: node.body\n" ], "labels": [ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " body.push(t.returnStatement());\n", "\n" ], "file_path": "lib/babel/transformation/transformers/es6/tail-call.js", "type": "add", "edit_start_line_idx": 114 }
const foo = 1; foo++;
test/fixtures/transformation/es6-constants/update-expression/actual.js
0
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.00016876070003490895, 0.00016876070003490895, 0.00016876070003490895, 0.00016876070003490895, 0 ]
{ "id": 1, "code_window": [ " continue _function;\n", " } else {\n", " _arguments = [_x = n - 1];\n", " continue _function;\n", " }\n", " }\n", "})(1000000) === \"foo\";" ], "labels": [ "keep", "keep", "keep", "keep", "replace", "keep", "keep" ], "after_edit": [ " }return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/call-apply/expected.js", "type": "replace", "edit_start_line_idx": 17 }
"use strict"; function fact(_x2) { var _arguments = arguments; _function: while (true) { var n = _x2; acc = undefined; var acc = _arguments[1] === undefined ? 1 : _arguments[1]; if (n > 1) { _arguments = [_x2 = n - 1, acc * n]; continue _function; } else { return acc; } } }
test/fixtures/transformation/es6-tail-call/factorial/expected.js
1
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.016962148249149323, 0.011045246385037899, 0.0051283445209264755, 0.011045246385037899, 0.0059169018641114235 ]
{ "id": 1, "code_window": [ " continue _function;\n", " } else {\n", " _arguments = [_x = n - 1];\n", " continue _function;\n", " }\n", " }\n", "})(1000000) === \"foo\";" ], "labels": [ "keep", "keep", "keep", "keep", "replace", "keep", "keep" ], "after_edit": [ " }return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/call-apply/expected.js", "type": "replace", "edit_start_line_idx": 17 }
class Foo { } assert.equal(new Foo().constructor, Foo, 'Foo instances should have Foo as constructor'); assert.ok(new Foo() instanceof Foo, 'Foo instances should be `instanceof` Foo');
test/fixtures/esnext/es6-classes/empty-named-class.js
0
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.00034120833151973784, 0.00034120833151973784, 0.00034120833151973784, 0.00034120833151973784, 0 ]
{ "id": 1, "code_window": [ " continue _function;\n", " } else {\n", " _arguments = [_x = n - 1];\n", " continue _function;\n", " }\n", " }\n", "})(1000000) === \"foo\";" ], "labels": [ "keep", "keep", "keep", "keep", "replace", "keep", "keep" ], "after_edit": [ " }return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/call-apply/expected.js", "type": "replace", "edit_start_line_idx": 17 }
System.register(["foo"], function (_export) { "use strict"; var foo, foo2; return { setters: [function (_foo) { foo = _foo["default"]; foo2 = _foo["default"]; }], execute: function () {} }; });
test/fixtures/transformation/es6-modules-system/imports-default/expected.js
0
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.0005777972983196378, 0.00037657376378774643, 0.00017535021470393986, 0.00037657376378774643, 0.00020122353453189135 ]
{ "id": 1, "code_window": [ " continue _function;\n", " } else {\n", " _arguments = [_x = n - 1];\n", " continue _function;\n", " }\n", " }\n", "})(1000000) === \"foo\";" ], "labels": [ "keep", "keep", "keep", "keep", "replace", "keep", "keep" ], "after_edit": [ " }return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/call-apply/expected.js", "type": "replace", "edit_start_line_idx": 17 }
class Test extends Foo { }
test/fixtures/transformation/es6-classes-loose/super-class/actual.js
0
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.00017121771816164255, 0.00017121771816164255, 0.00017121771816164255, 0.00017121771816164255, 0 ]
{ "id": 2, "code_window": [ " _function: while (true) {\n", " if (true) {} else {\n", " continue _function;\n", " }\n", " }\n", "}" ], "labels": [ "keep", "keep", "keep", "add", "keep", "keep" ], "after_edit": [ " return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/expression-consequent/expected.js", "type": "add", "edit_start_line_idx": 7 }
"use strict"; (function f(n) { if (n <= 0) { return "foo"; } try { return f(n - 1); } catch (e) {} })(1000000) === "foo"; (function f(_x) { _function: while (true) { var n = _x; if (n <= 0) { return "foo"; } try { throw new Error(); } catch (e) { _x = n - 1; continue _function; } } })(1000000) === "foo"; (function f(n) { if (n <= 0) { return "foo"; } try { throw new Error(); } catch (e) { return f(n - 1); } finally {} })(1000000) === "foo"; (function f(_x) { _function: while (true) { var n = _x; if (n <= 0) { return "foo"; } try {} finally { _x = n - 1; continue _function; } } })(1000000) === "foo";
test/fixtures/transformation/es6-tail-call/try-catch/expected.js
1
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.9974039196968079, 0.4303533136844635, 0.0001721302978694439, 0.11745844781398773, 0.461535781621933 ]
{ "id": 2, "code_window": [ " _function: while (true) {\n", " if (true) {} else {\n", " continue _function;\n", " }\n", " }\n", "}" ], "labels": [ "keep", "keep", "keep", "add", "keep", "keep" ], "after_edit": [ " return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/expression-consequent/expected.js", "type": "add", "edit_start_line_idx": 7 }
var obj = { ["x" + foo]: "heh", ["y" + bar]: "noo" };
test/fixtures/transformation/es6-properties.computed/multiple/actual.js
0
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.0001735098921926692, 0.0001735098921926692, 0.0001735098921926692, 0.0001735098921926692, 0 ]
{ "id": 2, "code_window": [ " _function: while (true) {\n", " if (true) {} else {\n", " continue _function;\n", " }\n", " }\n", "}" ], "labels": [ "keep", "keep", "keep", "add", "keep", "keep" ], "after_edit": [ " return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/expression-consequent/expected.js", "type": "add", "edit_start_line_idx": 7 }
"use strict"; arr.map(function (i) { return i + 1; });
test/fixtures/transformation/es6-arrow-functions/inside-call/expected.js
0
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.00016776708071120083, 0.00016776708071120083, 0.00016776708071120083, 0.00016776708071120083, 0 ]
{ "id": 2, "code_window": [ " _function: while (true) {\n", " if (true) {} else {\n", " continue _function;\n", " }\n", " }\n", "}" ], "labels": [ "keep", "keep", "keep", "add", "keep", "keep" ], "after_edit": [ " return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/expression-consequent/expected.js", "type": "add", "edit_start_line_idx": 7 }
require("../../../register")({ ignore: false });
test/fixtures/browserify/register.js
0
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.00017520497203804553, 0.00017520497203804553, 0.00017520497203804553, 0.00017520497203804553, 0 ]
{ "id": 3, "code_window": [ " if (_left = getFalseValue()) {\n", " return _left;\n", " }\n", " _x = n - 1;\n", " continue _function;\n", " }\n", " }\n", "})(1000000, true) === \"foo\";" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep" ], "after_edit": [ " }return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/expressions/expected.js", "type": "replace", "edit_start_line_idx": 19 }
"use strict"; var reduceRight = require("lodash/collection/reduceRight"); var messages = require("../../../messages"); var flatten = require("lodash/array/flatten"); var util = require("../../../util"); var map = require("lodash/collection/map"); var t = require("../../../types"); function returnBlock(expr) { return t.blockStatement([t.returnStatement(expr)]); } function TailCallTransformer(node, scope, file) { this.hasTailRecursion = false; this.needsArguments = false; this.setsArguments = false; this.needsThis = false; this.ownerId = node.id; this.vars = []; this.scope = scope; this.file = file; this.node = node; } TailCallTransformer.prototype.getArgumentsId = function () { return this.argumentsId = this.argumentsId || this.scope.generateUidIdentifier("arguments"); }; TailCallTransformer.prototype.getThisId = function () { return this.thisId = this.thisId || this.scope.generateUidIdentifier("this"); }; TailCallTransformer.prototype.getLeftId = function () { return this.leftId = this.leftId || this.scope.generateUidIdentifier("left"); }; TailCallTransformer.prototype.getFunctionId = function () { return this.functionId = this.functionId || this.scope.generateUidIdentifier("function"); }; TailCallTransformer.prototype.getParams = function () { var params = this.params; if (!params) { params = this.node.params; this.paramDecls = []; for (var i = 0; i < params.length; i++) { var param = params[i]; if (!param._isDefaultPlaceholder) { this.paramDecls.push(t.variableDeclarator( param, params[i] = this.scope.generateUidIdentifier("x") )); } } } return this.params = params; }; TailCallTransformer.prototype.hasDeopt = function () { // check if the ownerId has been reassigned, if it has then it's not safe to // perform optimisations var ownerIdInfo = this.scope.getBindingInfo(this.ownerId.name); return ownerIdInfo && ownerIdInfo.reassigned; }; TailCallTransformer.prototype.run = function () { var scope = this.scope; var node = this.node; // only tail recursion can be optimized as for now, so we can skip anonymous // functions entirely var ownerId = this.ownerId; if (!ownerId) return; // traverse the function and look for tail recursion scope.traverse(node, firstPass, this); if (!this.hasTailRecursion) return; if (this.hasDeopt()) { this.file.logDeopt(node, messages.get("tailCallReassignmentDeopt")); return; } // scope.traverse(node, secondPass, this); if (!this.needsThis || !this.needsArguments) { scope.traverse(node, thirdPass, this); } var body = t.ensureBlock(node).body; if (this.vars.length > 0) { var declarations = flatten(map(this.vars, function (decl) { return decl.declarations; }, this)); var statement = reduceRight(declarations, function (expr, decl) { return t.assignmentExpression("=", decl.id, expr); }, t.identifier("undefined")); body.unshift(t.expressionStatement(statement)); } var paramDecls = this.paramDecls; if (paramDecls.length > 0) { body.unshift(t.variableDeclaration("var", paramDecls)); } node.body = util.template("tail-call-body", { THIS_ID: this.thisId, ARGUMENTS_ID: this.argumentsId, FUNCTION_ID: this.getFunctionId(), BLOCK: node.body }); var topVars = []; if (this.needsThis) { topVars.push(t.variableDeclarator(this.getThisId(), t.thisExpression())); } if (this.needsArguments || this.setsArguments) { var decl = t.variableDeclarator(this.getArgumentsId()); if (this.needsArguments) { decl.init = t.identifier("arguments"); } topVars.push(decl); } var leftId = this.leftId; if (leftId) { topVars.push(t.variableDeclarator(leftId)); } if (topVars.length > 0) { node.body.body.unshift(t.variableDeclaration("var", topVars)); } }; TailCallTransformer.prototype.subTransform = function (node) { if (!node) return; var handler = this["subTransform" + node.type]; if (handler) return handler.call(this, node); }; TailCallTransformer.prototype.subTransformConditionalExpression = function (node) { var callConsequent = this.subTransform(node.consequent); var callAlternate = this.subTransform(node.alternate); if (!callConsequent && !callAlternate) { return; } // if ternary operator had tail recursion in value, convert to optimized if-statement node.type = "IfStatement"; node.consequent = callConsequent ? t.toBlock(callConsequent) : returnBlock(node.consequent); if (callAlternate) { node.alternate = t.isIfStatement(callAlternate) ? callAlternate : t.toBlock(callAlternate); } else { node.alternate = returnBlock(node.alternate); } return [node]; }; TailCallTransformer.prototype.subTransformLogicalExpression = function (node) { // only call in right-value of can be optimized var callRight = this.subTransform(node.right); if (!callRight) return; // cache left value as it might have side-effects var leftId = this.getLeftId(); var testExpr = t.assignmentExpression( "=", leftId, node.left ); if (node.operator === "&&") { testExpr = t.unaryExpression("!", testExpr); } return [t.ifStatement(testExpr, returnBlock(leftId))].concat(callRight); }; TailCallTransformer.prototype.subTransformSequenceExpression = function (node) { var seq = node.expressions; // only last element can be optimized var lastCall = this.subTransform(seq[seq.length - 1]); if (!lastCall) { return; } // remove converted expression from sequence // and convert to regular expression if needed if (--seq.length === 1) { node = seq[0]; } return [t.expressionStatement(node)].concat(lastCall); }; TailCallTransformer.prototype.subTransformCallExpression = function (node) { var callee = node.callee, thisBinding, args; if (t.isMemberExpression(callee, { computed: false }) && t.isIdentifier(callee.property)) { switch (callee.property.name) { case "call": args = t.arrayExpression(node.arguments.slice(1)); break; case "apply": args = node.arguments[1] || t.identifier("undefined"); break; default: return; } thisBinding = node.arguments[0]; callee = callee.object; } // only tail recursion can be optimized as for now if (!t.isIdentifier(callee) || !this.scope.bindingIdentifierEquals(callee.name, this.ownerId)) { return; } this.hasTailRecursion = true; if (this.hasDeopt()) return; var body = []; if (!t.isThisExpression(thisBinding)) { body.push(t.expressionStatement(t.assignmentExpression( "=", this.getThisId(), thisBinding || t.identifier("undefined") ))); } if (!args) { args = t.arrayExpression(node.arguments); } var argumentsId = this.getArgumentsId(); var params = this.getParams(); body.push(t.expressionStatement(t.assignmentExpression( "=", argumentsId, args ))); var i, param; if (t.isArrayExpression(args)) { var elems = args.elements; for (i = 0; i < elems.length && i < params.length; i++) { param = params[i]; var elem = elems[i] || (elems[i] = t.identifier("undefined")); if (!param._isDefaultPlaceholder) { elems[i] = t.assignmentExpression("=", param, elem); } } } else { this.setsArguments = true; for (i = 0; i < params.length; i++) { param = params[i]; if (!param._isDefaultPlaceholder) { body.push(t.expressionStatement(t.assignmentExpression( "=", param, t.memberExpression(argumentsId, t.literal(i), true) ))); } } } body.push(t.continueStatement(this.getFunctionId())); return body; }; // looks for and replaces tail recursion calls var firstPass = { enter: function (node, parent, scope, state) { if (t.isIfStatement(node)) { if (t.isReturnStatement(node.alternate)) { t.ensureBlock(node, "alternate"); } if (t.isReturnStatement(node.consequent)) { t.ensureBlock(node, "consequent"); } } else if (t.isReturnStatement(node)) { this.skip(); return state.subTransform(node.argument); } else if (t.isTryStatement(parent)) { if (node === parent.block) { this.skip(); } else if (parent.finalizer && node !== parent.finalizer) { this.skip(); } } else if (t.isFunction(node)) { this.skip(); } else if (t.isVariableDeclaration(node)) { this.skip(); state.vars.push(node); } } }; // hoists up function declarations, replaces `this` and `arguments` and marks // them as needed var secondPass = { enter: function (node, parent, scope, state) { if (t.isThisExpression(node)) { state.needsThis = true; return state.getThisId(); } else if (t.isReferencedIdentifier(node, parent, { name: "arguments" })) { state.needsArguments = true; return state.getArgumentsId(); } else if (t.isFunction(node)) { this.skip(); if (t.isFunctionDeclaration(node)) { node = t.variableDeclaration("var", [ t.variableDeclarator(node.id, t.toExpression(node)) ]); node._blockHoist = 2; return node; } } } }; // optimizes recursion by removing `this` and `arguments` if they aren't used var thirdPass = { enter: function (node, parent, scope, state) { if (!t.isExpressionStatement(node)) return; var expr = node.expression; if (!t.isAssignmentExpression(expr)) return; if (!state.needsThis && expr.left === state.getThisId()) { this.remove(); } else if (!state.needsArguments && expr.left === state.getArgumentsId() && t.isArrayExpression(expr.right)) { return map(expr.right.elements, function (elem) { return t.expressionStatement(elem); }); } } }; exports.Function = function (node, parent, scope, file) { var tailCall = new TailCallTransformer(node, scope, file); tailCall.run(); };
lib/babel/transformation/transformers/es6/tail-call.js
1
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.00020683383627329022, 0.0001715109101496637, 0.00015929709479678422, 0.0001709055359242484, 0.000009119000424107071 ]
{ "id": 3, "code_window": [ " if (_left = getFalseValue()) {\n", " return _left;\n", " }\n", " _x = n - 1;\n", " continue _function;\n", " }\n", " }\n", "})(1000000, true) === \"foo\";" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep" ], "after_edit": [ " }return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/expressions/expected.js", "type": "replace", "edit_start_line_idx": 19 }
"use strict"; var foo; foo === (void 0).foo;
test/fixtures/transformation/spec-undefined-to-void/member-expression/expected.js
0
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.002209549304097891, 0.002209549304097891, 0.002209549304097891, 0.002209549304097891, 0 ]
{ "id": 3, "code_window": [ " if (_left = getFalseValue()) {\n", " return _left;\n", " }\n", " _x = n - 1;\n", " continue _function;\n", " }\n", " }\n", "})(1000000, true) === \"foo\";" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep" ], "after_edit": [ " }return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/expressions/expected.js", "type": "replace", "edit_start_line_idx": 19 }
"use strict"; var react = require("../../helpers/react"); var t = require("../../../types"); require("../../helpers/build-react-transformer")(exports, { pre: function (state) { var tagName = state.tagName; var args = state.args; if (react.isCompatTag(tagName)) { args.push(t.literal(tagName)); } else { args.push(state.tagExpr); } }, post: function (state) { state.callee = t.memberExpression(t.identifier("React"), t.identifier("createElement")); } });
lib/babel/transformation/transformers/other/react.js
0
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.00017334203585051, 0.00017280322208534926, 0.0001721201406326145, 0.00017294746066909283, 5.091578714200296e-7 ]
{ "id": 3, "code_window": [ " if (_left = getFalseValue()) {\n", " return _left;\n", " }\n", " _x = n - 1;\n", " continue _function;\n", " }\n", " }\n", "})(1000000, true) === \"foo\";" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep" ], "after_edit": [ " }return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/expressions/expected.js", "type": "replace", "edit_start_line_idx": 19 }
var x = (React.createElement("div", null, /* A comment at the beginning */ /* A second comment at the beginning */ React.createElement("span", null /* A nested comment */ ), /* A sandwiched comment */ React.createElement("br", null) /* A comment at the end */ /* A second comment at the end */ ));
test/fixtures/transformation/react/.should-properly-handle-comments-adjacent-to-children/expected.js
0
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.0006421406287699938, 0.0004080727812834084, 0.00017400493379682302, 0.0004080727812834084, 0.00023406784748658538 ]
{ "id": 4, "code_window": [ " continue _function;\n", " } else {\n", " return acc;\n", " }\n", " }\n", "}" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep" ], "after_edit": [ " }return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/factorial/expected.js", "type": "replace", "edit_start_line_idx": 13 }
"use strict"; (function f(_x) { var _left; _function: while (true) { var n = _x; if (n <= 0) { return "foo"; } else { doSmth(); if (!(_left = getTrueValue())) { return _left; } if (_left = getFalseValue()) { return _left; } _x = n - 1; continue _function; } } })(1000000, true) === "foo";
test/fixtures/transformation/es6-tail-call/expressions/expected.js
1
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.024192966520786285, 0.010153048671782017, 0.00017345247033517808, 0.006092726718634367, 0.010217596776783466 ]
{ "id": 4, "code_window": [ " continue _function;\n", " } else {\n", " return acc;\n", " }\n", " }\n", "}" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep" ], "after_edit": [ " }return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/factorial/expected.js", "type": "replace", "edit_start_line_idx": 13 }
a; let a = 1;
test/fixtures/transformation/es6-block-scoping-tdz-fail/call.js
0
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.00016850198153406382, 0.00016850198153406382, 0.00016850198153406382, 0.00016850198153406382, 0 ]
{ "id": 4, "code_window": [ " continue _function;\n", " } else {\n", " return acc;\n", " }\n", " }\n", "}" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep" ], "after_edit": [ " }return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/factorial/expected.js", "type": "replace", "edit_start_line_idx": 13 }
var x = React.createElement("div", { attr1: "foo" + "bar", attr2: "foo" + "bar" + "baz" + "bug", attr3: "foo" + "bar" + "baz" + "bug", attr4: "baz" });
test/fixtures/transformation/react/should-insert-commas-after-expressions-before-whitespace/expected.js
0
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.0001701504224911332, 0.0001701504224911332, 0.0001701504224911332, 0.0001701504224911332, 0 ]
{ "id": 4, "code_window": [ " continue _function;\n", " } else {\n", " return acc;\n", " }\n", " }\n", "}" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep" ], "after_edit": [ " }return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/factorial/expected.js", "type": "replace", "edit_start_line_idx": 13 }
var genHelpers = require("./_generator-helpers"); var transform = require("../lib/babel/transformation"); var sourceMap = require("source-map"); var codeFrame = require("../lib/babel/helpers/code-frame"); var Module = require("module"); var helper = require("./_helper"); var assert = require("assert"); var chai = require("chai"); var path = require("path"); var util = require("../lib/babel/util"); var _ = require("lodash"); require("../lib/babel/polyfill"); global.assertNoOwnProperties = function (obj) { assert.equal(Object.getOwnPropertyNames(obj).length, 0); }; global.assertHasOwnProperty = function () { }; global.assertLacksOwnProperty = function () { }; global.assertArrayEquals = assert.deepEqual; global.assert = chai.assert; global.chai = chai; global.genHelpers = genHelpers; // Different Traceur generator message chai.assert._throw = chai.assert.throw; chai.assert.throw = function (fn, msg) { if (msg === '"throw" on executing generator' || msg === '"next" on executing generator') { msg = "Generator is already running"; } else if (msg === "Sent value to newborn generator") { msg = /^attempt to send (.*?) to newborn generator$/; } else if (msg === "super prototype must be an Object or null") { msg = "Object prototype may only be an Object or null"; } return chai.assert._throw(fn, msg); }; var run = function (task, done) { var actual = task.actual; var expect = task.expect; var exec = task.exec; var opts = task.options; var getOpts = function (self) { return _.merge({ filename: self.loc }, opts); }; var execCode = exec.code; var result; var noCheckAst = opts.noCheckAst; delete opts.noCheckAst; var checkAst = function (result, opts) { if (noCheckAst) return; helper.esvalid(result.ast.program, result.code, opts.loc); }; if (execCode) { result = transform(execCode, getOpts(exec)); checkAst(result, exec); execCode = result.code; try { var fakeRequire = function (loc) { if (loc === "../../../src/runtime/polyfills/Number.js") { return Number; } else if (loc === "../../../src/runtime/polyfills/Math.js") { return Math; } else { return require(path.resolve(exec.loc, "..", loc)); } }; var fn = new Function("require", "done", execCode); fn.call(global, fakeRequire, chai.assert, done); } catch (err) { err.message = exec.loc + ": " + err.message; err.message += codeFrame(execCode); throw err; } } var actualCode = actual.code; var expectCode = expect.code; if (!execCode || actualCode) { result = transform(actualCode, getOpts(actual)); checkAst(result, actual); actualCode = result.code; try { chai.expect(actualCode).to.be.equal(expectCode, actual.loc + " !== " + expect.loc); } catch (err) { //require("fs").writeFileSync(expect.loc, actualCode); throw err; } } if (task.sourceMap) { chai.expect(result.map).to.deep.equal(task.sourceMap); } if (task.sourceMappings) { var consumer = new sourceMap.SourceMapConsumer(result.map); _.each(task.sourceMappings, function (mapping, i) { var actual = mapping.original; var expect = consumer.originalPositionFor(mapping.generated); chai.expect({ line: expect.line, column: expect.column }).to.deep.equal(actual); }); } }; module.exports = function (suiteOpts, taskOpts, dynamicOpts) { taskOpts = taskOpts || {}; _.each(helper.get(suiteOpts.name, suiteOpts.loc), function (testSuite) { if (_.contains(suiteOpts.ignoreSuites, testSuite.title)) return; suite(suiteOpts.name + "/" + testSuite.title, function () { setup(function () { require("../register")(taskOpts); }); _.each(testSuite.tests, function (task) { if (_.contains(suiteOpts.ignoreTasks, task.title) || _.contains(suiteOpts.ignoreTasks, testSuite.title + "/" + task.title)) return; var runTest = function (done) { var runTask = function () { run(task, done); }; _.extend(task.options, taskOpts); if (dynamicOpts) dynamicOpts(task.options, task); var throwMsg = task.options.throws; if (throwMsg) { // internal api doesn't have this option but it's best not to pollute // the options object with useless options delete task.options.throws; assert.throws(runTask, function (err) { return throwMsg === true || err.message.indexOf(throwMsg) >= 0; }); } else { runTask(); } }; var callback; if (task.options.asyncExec) { callback = runTest; } else { callback = function () { return runTest(); }; } test(task.title, !task.disabled && callback); }); }); }); };
test/_transformation-helper.js
0
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.0022266197483986616, 0.0002831390593200922, 0.00016155288903973997, 0.0001690625213086605, 0.00047137675574049354 ]
{ "id": 5, "code_window": [ " var local3 = 3;\n", " // `g` should be function here on each pass\n", " g = 123;\n", " _arguments = [_x2 = n - 1];\n", " continue _function;\n", " }\n", "})(1000000, true) === \"foo\";" ], "labels": [ "keep", "keep", "keep", "keep", "add", "keep", "keep" ], "after_edit": [ " return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/recursion/expected.js", "type": "add", "edit_start_line_idx": 22 }
"use strict"; (function f(_x2) { var _arguments = arguments; _function: while (true) { var g = function g() {}; var n = _x2; m = local1 = local2 = local3 = undefined; var m = _arguments[1] === undefined ? getDefaultValue() : _arguments[1]; // `m` should be `getDefaultValue()` after first pass if (n <= 0) { return "foo"; } // `local1`-`local3` should be fresh on each pass var local1; var local2 = undefined; var local3 = 3; // `g` should be function here on each pass g = 123; _arguments = [_x2 = n - 1]; continue _function; } })(1000000, true) === "foo";
test/fixtures/transformation/es6-tail-call/recursion/expected.js
1
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.9981619715690613, 0.6710782051086426, 0.019379349425435066, 0.9956932663917542, 0.4608217775821686 ]
{ "id": 5, "code_window": [ " var local3 = 3;\n", " // `g` should be function here on each pass\n", " g = 123;\n", " _arguments = [_x2 = n - 1];\n", " continue _function;\n", " }\n", "})(1000000, true) === \"foo\";" ], "labels": [ "keep", "keep", "keep", "keep", "add", "keep", "keep" ], "after_edit": [ " return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/recursion/expected.js", "type": "add", "edit_start_line_idx": 22 }
var foo = x => x * x; var foo = (a, b) => a * b; var foo = async x => x * x; var foo = async (a, b) => a * b;
test/fixtures/generation/types/ArrowFunctionExpression/actual.js
0
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.0016239061951637268, 0.0016239061951637268, 0.0016239061951637268, 0.0016239061951637268, 0 ]
{ "id": 5, "code_window": [ " var local3 = 3;\n", " // `g` should be function here on each pass\n", " g = 123;\n", " _arguments = [_x2 = n - 1];\n", " continue _function;\n", " }\n", "})(1000000, true) === \"foo\";" ], "labels": [ "keep", "keep", "keep", "keep", "add", "keep", "keep" ], "after_edit": [ " return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/recursion/expected.js", "type": "add", "edit_start_line_idx": 22 }
"use strict"; arr.map(function (x) { return x * MULTIPLIER; }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNjcmlwdC5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLEdBQUcsQ0FBQyxHQUFHLENBQUMsVUFBQSxDQUFDO1NBQUksQ0FBQyxHQUFHLFVBQVU7Q0FBQSxDQUFDLENBQUMiLCJmaWxlIjoic2NyaXB0Mi5qcyIsInNvdXJjZXNDb250ZW50IjpbImFyci5tYXAoeCA9PiB4ICogTVVMVElQTElFUik7Il19
test/fixtures/bin/babel/filename --out-file --source-maps-inline/out-files/script2.js
0
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.00016677788516972214, 0.00016677788516972214, 0.00016677788516972214, 0.00016677788516972214, 0 ]
{ "id": 5, "code_window": [ " var local3 = 3;\n", " // `g` should be function here on each pass\n", " g = 123;\n", " _arguments = [_x2 = n - 1];\n", " continue _function;\n", " }\n", "})(1000000, true) === \"foo\";" ], "labels": [ "keep", "keep", "keep", "keep", "add", "keep", "keep" ], "after_edit": [ " return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/recursion/expected.js", "type": "add", "edit_start_line_idx": 22 }
import { foo as bar } from "foo"; import { foo as bar } from "bar";
test/fixtures/transformation/es6-modules-common/.disallow-import-remapping-9/actual.js
0
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.00016876166046131402, 0.00016876166046131402, 0.00016876166046131402, 0.00016876166046131402, 0 ]
{ "id": 6, "code_window": [ " } catch (e) {\n", " _x = n - 1;\n", " continue _function;\n", " }\n", " }\n", "})(1000000) === \"foo\";\n", "\n", "(function f(n) {\n" ], "labels": [ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ], "after_edit": [ " return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/try-catch/expected.js", "type": "add", "edit_start_line_idx": 23 }
"use strict"; function fact(_x2) { var _arguments = arguments; _function: while (true) { var n = _x2; acc = undefined; var acc = _arguments[1] === undefined ? 1 : _arguments[1]; if (n > 1) { _arguments = [_x2 = n - 1, acc * n]; continue _function; } else { return acc; } } }
test/fixtures/transformation/es6-tail-call/factorial/expected.js
1
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.0035817334428429604, 0.002464273013174534, 0.0013468124670907855, 0.002464273013174534, 0.0011174604296684265 ]
{ "id": 6, "code_window": [ " } catch (e) {\n", " _x = n - 1;\n", " continue _function;\n", " }\n", " }\n", "})(1000000) === \"foo\";\n", "\n", "(function f(n) {\n" ], "labels": [ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ], "after_edit": [ " return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/try-catch/expected.js", "type": "add", "edit_start_line_idx": 23 }
var x = 'y'; assert.equal({[x]: function() { return 10; }}.y(), 10); assert.equal({[x + 'y']() { return 10; }}.yy(), 10);
test/fixtures/esnext/es6-computed-properties/method.js
0
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.0001736050471663475, 0.0001736050471663475, 0.0001736050471663475, 0.0001736050471663475, 0 ]
{ "id": 6, "code_window": [ " } catch (e) {\n", " _x = n - 1;\n", " continue _function;\n", " }\n", " }\n", "})(1000000) === \"foo\";\n", "\n", "(function f(n) {\n" ], "labels": [ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ], "after_edit": [ " return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/try-catch/expected.js", "type": "add", "edit_start_line_idx": 23 }
var obj = { ["x" + foo]: "heh" };
test/fixtures/transformation/es6-properties.computed/single/actual.js
0
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.0006378735997714102, 0.0006378735997714102, 0.0006378735997714102, 0.0006378735997714102, 0 ]
{ "id": 6, "code_window": [ " } catch (e) {\n", " _x = n - 1;\n", " continue _function;\n", " }\n", " }\n", "})(1000000) === \"foo\";\n", "\n", "(function f(n) {\n" ], "labels": [ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ], "after_edit": [ " return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/try-catch/expected.js", "type": "add", "edit_start_line_idx": 23 }
"use strict"; var _toConsumableArray = function (arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } }; add.apply(undefined, [foo, bar].concat(_toConsumableArray(numbers)));
test/fixtures/transformation/es6-spread/method-call-multiple-args/expected.js
0
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.00019458943279460073, 0.00019458943279460073, 0.00019458943279460073, 0.00019458943279460073, 0 ]
{ "id": 7, "code_window": [ " try {} finally {\n", " _x = n - 1;\n", " continue _function;\n", " }\n", " }\n", "})(1000000) === \"foo\";" ], "labels": [ "keep", "keep", "keep", "add", "keep", "keep" ], "after_edit": [ " return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/try-catch/expected.js", "type": "add", "edit_start_line_idx": 47 }
"use strict"; (function f(n) { if (n <= 0) { return "foo"; } try { return f(n - 1); } catch (e) {} })(1000000) === "foo"; (function f(_x) { _function: while (true) { var n = _x; if (n <= 0) { return "foo"; } try { throw new Error(); } catch (e) { _x = n - 1; continue _function; } } })(1000000) === "foo"; (function f(n) { if (n <= 0) { return "foo"; } try { throw new Error(); } catch (e) { return f(n - 1); } finally {} })(1000000) === "foo"; (function f(_x) { _function: while (true) { var n = _x; if (n <= 0) { return "foo"; } try {} finally { _x = n - 1; continue _function; } } })(1000000) === "foo";
test/fixtures/transformation/es6-tail-call/try-catch/expected.js
1
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.9980419874191284, 0.5973886251449585, 0.005177028011530638, 0.9826635718345642, 0.4831181764602661 ]
{ "id": 7, "code_window": [ " try {} finally {\n", " _x = n - 1;\n", " continue _function;\n", " }\n", " }\n", "})(1000000) === \"foo\";" ], "labels": [ "keep", "keep", "keep", "add", "keep", "keep" ], "after_edit": [ " return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/try-catch/expected.js", "type": "add", "edit_start_line_idx": 47 }
;
test/fixtures/generation/types/EmptyStatement/actual.js
0
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.00017347796529065818, 0.00017347796529065818, 0.00017347796529065818, 0.00017347796529065818, 0 ]
{ "id": 7, "code_window": [ " try {} finally {\n", " _x = n - 1;\n", " continue _function;\n", " }\n", " }\n", "})(1000000) === \"foo\";" ], "labels": [ "keep", "keep", "keep", "add", "keep", "keep" ], "after_edit": [ " return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/try-catch/expected.js", "type": "add", "edit_start_line_idx": 47 }
for (foo.bar of test) { }
test/fixtures/transformation/es6-for-of/illegal-left/actual.js
0
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.00030037196120247245, 0.00030037196120247245, 0.00030037196120247245, 0.00030037196120247245, 0 ]
{ "id": 7, "code_window": [ " try {} finally {\n", " _x = n - 1;\n", " continue _function;\n", " }\n", " }\n", "})(1000000) === \"foo\";" ], "labels": [ "keep", "keep", "keep", "add", "keep", "keep" ], "after_edit": [ " return;\n" ], "file_path": "test/fixtures/transformation/es6-tail-call/try-catch/expected.js", "type": "add", "edit_start_line_idx": 47 }
System.register(["foo"], function (_export) { "use strict"; var foo; return { setters: [function (_foo) { foo = _foo; }], execute: function () {} }; });
test/fixtures/transformation/es6-modules-system/imports-glob/expected.js
0
https://github.com/babel/babel/commit/0874f390ffe3f303f1775983186f542521a41028
[ 0.005428881384432316, 0.002802780829370022, 0.00017668008513282984, 0.002802780829370022, 0.002626100555062294 ]
{ "id": 0, "code_window": [ " const moduleScope = this.reflectScope(metatype);\n", " const isSingleScoped = moduleScope === true;\n", " const opaqueToken = {\n", " module: this.getModuleName(metatype),\n", " dynamic: this.getDynamicMetadataToken(dynamicModuleMetadata),\n", " scope: isSingleScoped ? this.getScopeStack(scope) : moduleScope,\n", " };\n", " return hash(opaqueToken);\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " module: metatype,\n" ], "file_path": "packages/core/injector/module-token-factory.ts", "type": "replace", "edit_start_line_idx": 15 }
import { expect } from 'chai'; import safeStringify from 'fast-safe-stringify'; import * as hash from 'object-hash'; import { SingleScope } from '../../../common'; import { ModuleTokenFactory } from '../../injector/module-token-factory'; describe('ModuleTokenFactory', () => { let factory: ModuleTokenFactory; beforeEach(() => { factory = new ModuleTokenFactory(); }); describe('create', () => { class Module {} it('should force global scope when it is not set', () => { const scope = 'global'; const token = factory.create(Module as any, [Module], undefined); expect(token).to.be.deep.eq( hash({ module: Module.name, dynamic: '', scope, }), ); }); it('should returns expected token', () => { const token = factory.create( SingleScope()(Module) as any, [Module], undefined, ); expect(token).to.be.deep.eq( hash({ module: Module.name, dynamic: '', scope: [Module.name], }), ); }); it('should include dynamic metadata', () => { const token = factory.create(SingleScope()(Module) as any, [Module], { providers: [{}], } as any); expect(token).to.be.deep.eq( hash({ module: Module.name, dynamic: safeStringify({ providers: [{}], }), scope: [Module.name], }), ); }); }); describe('getModuleName', () => { it('should map module metatype to name', () => { const metatype = () => {}; expect(factory.getModuleName(metatype as any)).to.be.eql(metatype.name); }); }); describe('getDynamicMetadataToken', () => { describe('when metadata exists', () => { it('should return hash', () => { const metadata = { providers: ['', {}] }; expect(factory.getDynamicMetadataToken(metadata as any)).to.be.eql( JSON.stringify(metadata), ); }); it('should return hash with class', () => { class Provider {} const metadata = { providers: [Provider], exports: [Provider] }; expect(factory.getDynamicMetadataToken(metadata)).to.be.eql( '{"providers":["Provider"],"exports":["Provider"]}', ); }); }); describe('when metadata does not exist', () => { it('should return empty string', () => { expect(factory.getDynamicMetadataToken(undefined)).to.be.eql(''); }); }); }); describe('getScopeStack', () => { it('should map metatypes to the array with last metatype', () => { const metatype1 = () => {}; const metatype2 = () => {}; expect( factory.getScopeStack([metatype1 as any, metatype2 as any]), ).to.be.eql([metatype2.name]); }); }); });
packages/core/test/injector/module-token-factory.spec.ts
1
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.003763600718230009, 0.0010621764231473207, 0.0001651682541705668, 0.00033338391222059727, 0.0012953957775607705 ]
{ "id": 0, "code_window": [ " const moduleScope = this.reflectScope(metatype);\n", " const isSingleScoped = moduleScope === true;\n", " const opaqueToken = {\n", " module: this.getModuleName(metatype),\n", " dynamic: this.getDynamicMetadataToken(dynamicModuleMetadata),\n", " scope: isSingleScoped ? this.getScopeStack(scope) : moduleScope,\n", " };\n", " return hash(opaqueToken);\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " module: metatype,\n" ], "file_path": "packages/core/injector/module-token-factory.ts", "type": "replace", "edit_start_line_idx": 15 }
import { Body, Controller, Get, Post } from '@nestjs/common'; import { CatsService } from './cats.service'; import { CreateCatDto } from './dto/create-cat.dto'; import { Cat } from './interfaces/cat.interface'; @Controller('cats') export class CatsController { constructor(private readonly catsService: CatsService) {} @Post() async create(@Body() createCatDto: CreateCatDto) { return this.catsService.create(createCatDto); } @Get() async findAll(): Promise<Cat[]> { return this.catsService.findAll(); } }
integration/mongoose/src/cats/cats.controller.ts
0
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.0001769994560163468, 0.00017473837942816317, 0.0001724772882880643, 0.00017473837942816317, 0.0000022610838641412556 ]
{ "id": 0, "code_window": [ " const moduleScope = this.reflectScope(metatype);\n", " const isSingleScoped = moduleScope === true;\n", " const opaqueToken = {\n", " module: this.getModuleName(metatype),\n", " dynamic: this.getDynamicMetadataToken(dynamicModuleMetadata),\n", " scope: isSingleScoped ? this.getScopeStack(scope) : moduleScope,\n", " };\n", " return hash(opaqueToken);\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " module: metatype,\n" ], "file_path": "packages/core/injector/module-token-factory.ts", "type": "replace", "edit_start_line_idx": 15 }
import { Inject, Injectable, Scope } from '@nestjs/common'; @Injectable({ scope: Scope.REQUEST }) export class HelloService { constructor(@Inject('META') private readonly meta) {} greeting(): string { return 'Hello world!'; } }
integration/scopes/src/msvc/hello.service.ts
0
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.00016758193669375032, 0.0001663904549786821, 0.00016519897326361388, 0.0001663904549786821, 0.000001191481715068221 ]
{ "id": 0, "code_window": [ " const moduleScope = this.reflectScope(metatype);\n", " const isSingleScoped = moduleScope === true;\n", " const opaqueToken = {\n", " module: this.getModuleName(metatype),\n", " dynamic: this.getDynamicMetadataToken(dynamicModuleMetadata),\n", " scope: isSingleScoped ? this.getScopeStack(scope) : moduleScope,\n", " };\n", " return hash(opaqueToken);\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " module: metatype,\n" ], "file_path": "packages/core/injector/module-token-factory.ts", "type": "replace", "edit_start_line_idx": 15 }
import { UserEntity } from '../entities/user.entity'; export class BusinessDto { name: string; phone: string; user: UserEntity; }
integration/microservices/src/kafka/dtos/business.dto.ts
0
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.00017520412802696228, 0.00017520412802696228, 0.00017520412802696228, 0.00017520412802696228, 0 ]
{ "id": 1, "code_window": [ " return dynamicModuleMetadata\n", " ? stringify(dynamicModuleMetadata, this.replacer)\n", " : '';\n", " }\n", "\n", " public getModuleName(metatype: Type<any>): string {\n", " return metatype.name;\n", " }\n", "\n", " public getScopeStack(scope: Type<any>[]): string[] {\n", " const reversedScope = scope.reverse();\n", " const firstGlobalIndex = reversedScope.findIndex(\n", " s => this.reflectScope(s) === 'global',\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [], "file_path": "packages/core/injector/module-token-factory.ts", "type": "replace", "edit_start_line_idx": 33 }
import { DynamicModule } from '@nestjs/common'; import { SHARED_MODULE_METADATA } from '@nestjs/common/constants'; import { Type } from '@nestjs/common/interfaces/type.interface'; import stringify from 'fast-safe-stringify'; import * as hash from 'object-hash'; export class ModuleTokenFactory { public create( metatype: Type<any>, scope: Type<any>[], dynamicModuleMetadata?: Partial<DynamicModule> | undefined, ): string { const moduleScope = this.reflectScope(metatype); const isSingleScoped = moduleScope === true; const opaqueToken = { module: this.getModuleName(metatype), dynamic: this.getDynamicMetadataToken(dynamicModuleMetadata), scope: isSingleScoped ? this.getScopeStack(scope) : moduleScope, }; return hash(opaqueToken); } public getDynamicMetadataToken( dynamicModuleMetadata: Partial<DynamicModule> | undefined, ): string { // Uses safeStringify instead of JSON.stringify to support circular dynamic modules // The replacer function is also required in order to obtain real class names // instead of the unified "Function" key return dynamicModuleMetadata ? stringify(dynamicModuleMetadata, this.replacer) : ''; } public getModuleName(metatype: Type<any>): string { return metatype.name; } public getScopeStack(scope: Type<any>[]): string[] { const reversedScope = scope.reverse(); const firstGlobalIndex = reversedScope.findIndex( s => this.reflectScope(s) === 'global', ); scope.reverse(); const stack = firstGlobalIndex >= 0 ? scope.slice(scope.length - firstGlobalIndex - 1) : scope; return stack.map(module => module.name); } private reflectScope(metatype: Type<any>) { const scope = Reflect.getMetadata(SHARED_MODULE_METADATA, metatype); return scope ? scope : 'global'; } private replacer(key: string, value: any) { if (typeof value === 'function') { return value.name; } return value; } }
packages/core/injector/module-token-factory.ts
1
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.9992451667785645, 0.4286341965198517, 0.00017392696463502944, 0.0033710103016346693, 0.4933583736419678 ]
{ "id": 1, "code_window": [ " return dynamicModuleMetadata\n", " ? stringify(dynamicModuleMetadata, this.replacer)\n", " : '';\n", " }\n", "\n", " public getModuleName(metatype: Type<any>): string {\n", " return metatype.name;\n", " }\n", "\n", " public getScopeStack(scope: Type<any>[]): string[] {\n", " const reversedScope = scope.reverse();\n", " const firstGlobalIndex = reversedScope.findIndex(\n", " s => this.reflectScope(s) === 'global',\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [], "file_path": "packages/core/injector/module-token-factory.ts", "type": "replace", "edit_start_line_idx": 33 }
{ "name": "nest-typescript-starter", "version": "1.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { "@nestjs/common": { "version": "6.9.0", "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-6.9.0.tgz", "integrity": "sha512-dIRiKob3SkXA2JoV3/Li3vThmZAh2yEH2znM3DRXxcA+twLzM7sJNxAuVsqaVUNwZ89Piepu66fm2BFcKNlJ6A==", "requires": { "axios": "0.19.0", "cli-color": "2.0.0", "uuid": "3.3.3" } }, "@nestjs/core": { "version": "6.9.0", "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-6.9.0.tgz", "integrity": "sha512-DvzhJQAs8dXzlJ1Ru6YPHQM+7ODQ2Ity5Ad6OU1YHqQp2GJEwa+6uzCVL/37zu7i/FhUfgLCZLcwHhofRPcgkg==", "requires": { "@nuxtjs/opencollective": "0.2.2", "fast-safe-stringify": "2.0.7", "iterare": "1.2.0", "object-hash": "2.0.0", "uuid": "3.3.3" } }, "@nestjs/microservices": { "version": "6.9.0", "resolved": "https://registry.npmjs.org/@nestjs/microservices/-/microservices-6.9.0.tgz", "integrity": "sha512-HxnqnJFkXP0vuywzFrO/hhgAAi73hw0lg3yWQdxBKUsAwlP1my9tMmVxo4hr80ilLiTzgjWnoRuAus//bFytLg==", "requires": { "iterare": "1.2.0", "json-socket": "0.3.0" } }, "@nestjs/testing": { "version": "6.9.0", "resolved": "https://registry.npmjs.org/@nestjs/testing/-/testing-6.9.0.tgz", "integrity": "sha512-vCxUiu5XnPhaQ3RFHQmj04mnQvFHPGAyTEds/2/EpXCPmRbnqPl67NrA1xDTI8GX8sy+yg4DHMPrT7IjQwZfzg==", "requires": { "optional": "0.1.4" } }, "@nestjs/websockets": { "version": "6.9.0", "resolved": "https://registry.npmjs.org/@nestjs/websockets/-/websockets-6.9.0.tgz", "integrity": "sha512-6dsB4V2ovdDFSF80wTDb6C28KJ6gNpbag0q/e4rReFc+uIOPvm1PVFQt6Q2g/0OZfhnwVXjBGRNgtCF0pXDZCQ==", "requires": { "iterare": "1.2.0" } }, "@nuxtjs/opencollective": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/@nuxtjs/opencollective/-/opencollective-0.2.2.tgz", "integrity": "sha512-69gFVDs7mJfNjv9Zs5DFVD+pvBW+k1TaHSOqUWqAyTTfLcKI/EMYQgvEvziRd+zAFtUOoye6MfWh0qvinGISPw==", "requires": { "chalk": "^2.4.1", "consola": "^2.3.0", "node-fetch": "^2.3.0" } }, "@types/node": { "version": "7.10.9", "resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.9.tgz", "integrity": "sha512-usSpgoUsRtO5xNV5YEPU8PPnHisFx8u0rokj1BPVn/hDF7zwUDzVLiuKZM38B7z8V2111Fj6kd4rGtQFUZpNOw==", "dev": true }, "@types/validator": { "version": "10.11.3", "resolved": "https://registry.npmjs.org/@types/validator/-/validator-10.11.3.tgz", "integrity": "sha512-GKF2VnEkMmEeEGvoo03ocrP9ySMuX1ypKazIYMlsjfslfBMhOAtC5dmEWKdJioW4lJN7MZRS88kalTsVClyQ9w==" }, "abstract-logging": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/abstract-logging/-/abstract-logging-1.0.0.tgz", "integrity": "sha1-i33q/TEFWbwo93ck3RuzAXcnjBs=" }, "ajv": { "version": "6.10.2", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", "requires": { "fast-deep-equal": "^2.0.1", "fast-json-stable-stringify": "^2.0.0", "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" } }, "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" }, "ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "requires": { "color-convert": "^1.9.0" } }, "archy": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", "integrity": "sha1-+cjBN1fMHde8N5rHeyxipcKGjEA=" }, "arg": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.1.tgz", "integrity": "sha512-SlmP3fEA88MBv0PypnXZ8ZfJhwmDeIE3SP71j37AiXQBXYosPV0x6uISAaHYSlSVhmHOVkomen0tbGk6Anlebw==", "dev": true }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", "dev": true }, "avvio": { "version": "6.2.2", "resolved": "https://registry.npmjs.org/avvio/-/avvio-6.2.2.tgz", "integrity": "sha512-7+yznbJOMoHQ8Z8VH+1meyRjtxUW8za6gqnHBl8DqlX5qPtaclNIgWrKrTLuIbfn2+1/EGkcr+rQXI8DYVU4RA==", "requires": { "archy": "^1.0.0", "debug": "^4.0.0", "fastq": "^1.6.0" }, "dependencies": { "debug": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", "requires": { "ms": "^2.1.1" } }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" } } }, "axios": { "version": "0.19.0", "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz", "integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==", "requires": { "follow-redirects": "1.5.10", "is-buffer": "^2.0.2" } }, "buffer-from": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", "dev": true }, "chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", "requires": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", "supports-color": "^5.3.0" } }, "class-transformer": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.2.3.tgz", "integrity": "sha512-qsP+0xoavpOlJHuYsQJsN58HXSl8Jvveo+T37rEvCEeRfMWoytAyR0Ua/YsFgpM6AZYZ/og2PJwArwzJl1aXtQ==" }, "class-validator": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/class-validator/-/class-validator-0.11.0.tgz", "integrity": "sha512-niAmmSPFku9xsnpYYrddy8NZRrCX3yyoZ/rgPKOilE5BG0Ma1eVCIxpR4X0LasL/6BzbYzsutG+mSbAXlh4zNw==", "requires": { "@types/validator": "10.11.3", "google-libphonenumber": "^3.1.6", "validator": "12.0.0" } }, "cli-color": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/cli-color/-/cli-color-2.0.0.tgz", "integrity": "sha512-a0VZ8LeraW0jTuCkuAGMNufareGHhyZU9z8OGsW0gXd1hZGi1SRuNRXdbGkraBBKnhyUhyebFWnRbp+dIn0f0A==", "requires": { "ansi-regex": "^2.1.1", "d": "^1.0.1", "es5-ext": "^0.10.51", "es6-iterator": "^2.0.3", "memoizee": "^0.4.14", "timers-ext": "^0.1.7" } }, "color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "requires": { "color-name": "1.1.3" } }, "color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" }, "combined-stream": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", "dev": true, "requires": { "delayed-stream": "~1.0.0" } }, "component-emitter": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", "dev": true }, "consola": { "version": "2.10.1", "resolved": "https://registry.npmjs.org/consola/-/consola-2.10.1.tgz", "integrity": "sha512-4sxpH6SGFYLADfUip4vuY65f/gEogrzJoniVhNUYkJHtng0l8ZjnDCqxxrSVRHOHwKxsy8Vm5ONZh1wOR3/l/w==" }, "cookiejar": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.2.tgz", "integrity": "sha512-Mw+adcfzPxcPeI+0WlvRrr/3lGVO0bD75SxX6811cxSh1Wbxx7xZBGK1eVtDf6si8rg2lhnUjsVLMFMfbRIuwA==", "dev": true }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, "d": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", "requires": { "es5-ext": "^0.10.50", "type": "^1.0.1" } }, "debug": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", "requires": { "ms": "2.0.0" } }, "deepmerge": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.1.1.tgz", "integrity": "sha512-+qO5WbNBKBaZez95TffdUDnGIo4+r5kmsX8aOb7PDHvXsTbghAmleuxjs6ytNaf5Eg4FGBXDS5vqO61TRi6BMg==" }, "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", "dev": true }, "diff": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==", "dev": true }, "es5-ext": { "version": "0.10.52", "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.52.tgz", "integrity": "sha512-bWCbE9fbpYQY4CU6hJbJ1vSz70EClMlDgJ7BmwI+zEJhxrwjesZRPglGJlsZhu0334U3hI+gaspwksH9IGD6ag==", "requires": { "es6-iterator": "~2.0.3", "es6-symbol": "~3.1.2", "next-tick": "~1.0.0" } }, "es6-iterator": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", "requires": { "d": "1", "es5-ext": "^0.10.35", "es6-symbol": "^3.1.1" } }, "es6-symbol": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", "requires": { "d": "^1.0.1", "ext": "^1.1.2" } }, "es6-weak-map": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.3.tgz", "integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==", "requires": { "d": "1", "es5-ext": "^0.10.46", "es6-iterator": "^2.0.3", "es6-symbol": "^3.1.1" } }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" }, "event-emitter": { "version": "0.3.5", "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=", "requires": { "d": "1", "es5-ext": "~0.10.14" } }, "ext": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/ext/-/ext-1.1.2.tgz", "integrity": "sha512-/KLjJdTNyDepCihrk4HQt57nAE1IRCEo5jUt+WgWGCr1oARhibDvmI2DMcSNWood1T9AUWwq+jaV1wvRqaXfnA==", "requires": { "type": "^2.0.0" }, "dependencies": { "type": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/type/-/type-2.0.0.tgz", "integrity": "sha512-KBt58xCHry4Cejnc2ISQAF7QY+ORngsWfxezO68+12hKV6lQY8P/psIkcbjeHWn7MqcgciWJyCCevFMJdIXpow==" } } }, "extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", "dev": true }, "fast-decode-uri-component": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/fast-decode-uri-component/-/fast-decode-uri-component-1.0.1.tgz", "integrity": "sha512-WKgKWg5eUxvRZGwW8FvfbaH7AXSh2cL+3j5fMGzUMCxWBJ3dV3a7Wz8y2f/uQ0e3B6WmodD3oS54jTQ9HVTIIg==" }, "fast-deep-equal": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=" }, "fast-json-stable-stringify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" }, "fast-json-stringify": { "version": "1.15.5", "resolved": "https://registry.npmjs.org/fast-json-stringify/-/fast-json-stringify-1.15.5.tgz", "integrity": "sha512-isOtZqxaBElpIBG5kibeBDIPyMYCGuI271ujJvAiWE+HNMPCFNiJJLVoxfGwer0u6g9wjv6OWbVzSjBPfHAgmg==", "requires": { "ajv": "^6.8.1", "deepmerge": "^4.0.0" } }, "fast-redact": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/fast-redact/-/fast-redact-2.0.0.tgz", "integrity": "sha512-zxpkULI9W9MNTK2sJ3BpPQrTEXFNESd2X6O1tXMFpK/XM0G5c5Rll2EVYZH2TqI3xRGK/VaJ+eEOt7pnENJpeA==" }, "fast-safe-stringify": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz", "integrity": "sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA==" }, "fastify": { "version": "2.10.0", "resolved": "https://registry.npmjs.org/fastify/-/fastify-2.10.0.tgz", "integrity": "sha512-ieWwtPZPpcurQlRBmWer6rSq/2WAKAI3yPkh2oBbQ98U5BnWjhcLXYYgBRTS1TDu2evwbXwnRVdLpILVC2O5XA==", "requires": { "abstract-logging": "^1.0.0", "ajv": "^6.10.2", "avvio": "^6.2.2", "fast-json-stringify": "^1.15.5", "find-my-way": "^2.0.0", "flatstr": "^1.0.12", "light-my-request": "^3.4.1", "middie": "^4.0.1", "pino": "^5.13.2", "proxy-addr": "^2.0.4", "readable-stream": "^3.1.1", "rfdc": "^1.1.2", "secure-json-parse": "^1.0.0", "tiny-lru": "^7.0.0" } }, "fastq": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.6.0.tgz", "integrity": "sha512-jmxqQ3Z/nXoeyDmWAzF9kH1aGZSis6e/SbfPmJpUnyZ0ogr6iscHQaml4wsEepEWSdtmpy+eVXmCRIMpxaXqOA==", "requires": { "reusify": "^1.0.0" } }, "find-my-way": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/find-my-way/-/find-my-way-2.2.1.tgz", "integrity": "sha512-pzZA9/PlhDGG5PRzmd4vH4AbKW7FO68RE7q2I3NzjJHcVPukYbDA7bPdArg7ySKfS6pKki+qhrawFoN6aNZfjA==", "requires": { "fast-decode-uri-component": "^1.0.0", "safe-regex2": "^2.0.0", "semver-store": "^0.3.0" } }, "flatstr": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/flatstr/-/flatstr-1.0.12.tgz", "integrity": "sha512-4zPxDyhCyiN2wIAtSLI6gc82/EjqZc1onI4Mz/l0pWrAlsSfYH/2ZIcU+e3oA2wDwbzIWNKwa23F8rh6+DRWkw==" }, "follow-redirects": { "version": "1.5.10", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz", "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==", "requires": { "debug": "=3.1.0" } }, "form-data": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", "dev": true, "requires": { "asynckit": "^0.4.0", "combined-stream": "^1.0.6", "mime-types": "^2.1.12" } }, "formidable": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.1.tgz", "integrity": "sha512-Fs9VRguL0gqGHkXS5GQiMCr1VhZBxz0JnJs4JmMp/2jL18Fmbzvv7vOFRU+U8TBkHEE/CX1qDXzJplVULgsLeg==", "dev": true }, "forwarded": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" }, "google-libphonenumber": { "version": "3.2.6", "resolved": "https://registry.npmjs.org/google-libphonenumber/-/google-libphonenumber-3.2.6.tgz", "integrity": "sha512-6QCQAaKJlSd/1dUqvdQf7zzfb3uiZHsG8yhCfOdCVRfMuPZ/VDIEB47y5SYwjPQJPs7ebfW5jj6PeobB9JJ4JA==" }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" }, "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, "ipaddr.js": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz", "integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA==" }, "is-buffer": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz", "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==" }, "is-promise": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=" }, "iterare": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/iterare/-/iterare-1.2.0.tgz", "integrity": "sha512-RxMV9p/UzdK0Iplnd8mVgRvNdXlsTOiuDrqMRnDi3wIhbT+JP4xDquAX9ay13R3CH72NBzQ91KWe0+C168QAyQ==" }, "json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" }, "json-socket": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/json-socket/-/json-socket-0.3.0.tgz", "integrity": "sha512-jc8ZbUnYIWdxERFWQKVgwSLkGSe+kyzvmYxwNaRgx/c8NNyuHes4UHnPM3LUrAFXUx1BhNJ94n1h/KCRlbvV0g==" }, "light-my-request": { "version": "3.4.1", "resolved": "https://registry.npmjs.org/light-my-request/-/light-my-request-3.4.1.tgz", "integrity": "sha512-E1zMvRWjqsaCS60dTkD7c//xKV1KOFD2zo92Ru3o3e95lCfQSDCC9aS8MZm1V+zXaA/SeKDwK9gvrfaCseTusg==", "requires": { "ajv": "^6.8.1", "readable-stream": "^3.1.1" } }, "lru-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz", "integrity": "sha1-Jzi9nw089PhEkMVzbEhpmsYyzaM=", "requires": { "es5-ext": "~0.10.2" } }, "make-error": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz", "integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==", "dev": true }, "memoizee": { "version": "0.4.14", "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.14.tgz", "integrity": "sha512-/SWFvWegAIYAO4NQMpcX+gcra0yEZu4OntmUdrBaWrJncxOqAziGFlHxc7yjKVK2uu3lpPW27P27wkR82wA8mg==", "requires": { "d": "1", "es5-ext": "^0.10.45", "es6-weak-map": "^2.0.2", "event-emitter": "^0.3.5", "is-promise": "^2.1", "lru-queue": "0.1", "next-tick": "1", "timers-ext": "^0.1.5" } }, "methods": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=", "dev": true }, "middie": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/middie/-/middie-4.0.1.tgz", "integrity": "sha512-eYK6EEHZiYpQMYPmeCb/vC9ZzJg1HCqi1ot/fQs1sPZKt/XREgXouQ7g6c9J5XvDV5203JjbpovCYNkHcHgTpQ==", "requires": { "path-to-regexp": "^3.0.0", "reusify": "^1.0.2" } }, "mime": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==", "dev": true }, "mime-db": { "version": "1.36.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.36.0.tgz", "integrity": "sha512-L+xvyD9MkoYMXb1jAmzI/lWYAxAMCPvIBSWur0PZ5nOf5euahRLVqH//FKW9mWp2lkqUgYiXPgkzfMUFi4zVDw==", "dev": true }, "mime-types": { "version": "2.1.20", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.20.tgz", "integrity": "sha512-HrkrPaP9vGuWbLK1B1FfgAkbqNjIuy4eHlIYnFi7kamZyLLrGlo2mpcx0bBmNpKqBtYtAfGbodDddIgddSJC2A==", "dev": true, "requires": { "mime-db": "~1.36.0" } }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, "next-tick": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=" }, "node-fetch": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" }, "object-hash": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-2.0.0.tgz", "integrity": "sha512-I7zGBH0rDKwVGeGZpZoFaDhIwvJa3l1CZE+8VchylXbInNiCj7sxxea9P5dTM4ftKR5//nrqxrdeGSTWL2VpBA==" }, "optional": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/optional/-/optional-0.1.4.tgz", "integrity": "sha512-gtvrrCfkE08wKcgXaVwQVgwEQ8vel2dc5DDBn9RLQZ3YtmtkBss6A2HY6BnJH4N/4Ku97Ri/SF8sNWE2225WJw==" }, "path-to-regexp": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-3.1.0.tgz", "integrity": "sha512-PtHLisEvUOepjc+sStXxJ/pDV/s5UBTOKWJY2SOz3e6E/iN/jLknY9WL72kTwRrwXDUbZTEAtSnJbz2fF127DA==" }, "pino": { "version": "5.13.4", "resolved": "https://registry.npmjs.org/pino/-/pino-5.13.4.tgz", "integrity": "sha512-heeg8m8FZY8Nl3nuuD+msJUmhamqoGl7JXoTExh9YpGajzz6LYbVByUqrjbf4sCEMYFsqdcqnTJWiSY660DraQ==", "requires": { "fast-redact": "^2.0.0", "fast-safe-stringify": "^2.0.7", "flatstr": "^1.0.9", "pino-std-serializers": "^2.3.0", "quick-format-unescaped": "^3.0.2", "sonic-boom": "^0.7.5" } }, "pino-std-serializers": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-2.4.2.tgz", "integrity": "sha512-WaL504dO8eGs+vrK+j4BuQQq6GLKeCCcHaMB2ItygzVURcL1CycwNEUHTD/lHFHs/NL5qAz2UKrjYWXKSf4aMQ==" }, "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "proxy-addr": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz", "integrity": "sha512-t/7RxHXPH6cJtP0pRG6smSr9QJidhB+3kXu0KgXnbGYMgzEnUxRQ4/LDdfOwZEMyIh3/xHb8PX3t+lfL9z+YVQ==", "requires": { "forwarded": "~0.1.2", "ipaddr.js": "1.9.0" } }, "punycode": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" }, "qs": { "version": "6.5.2", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", "dev": true }, "quick-format-unescaped": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-3.0.3.tgz", "integrity": "sha512-dy1yjycmn9blucmJLXOfZDx1ikZJUi6E8bBZLnhPG5gBrVhHXx2xVyqqgKBubVNEXmx51dBACMHpoMQK/N/AXQ==" }, "readable-stream": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.4.0.tgz", "integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==", "requires": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", "util-deprecate": "^1.0.1" } }, "reflect-metadata": { "version": "0.1.13", "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz", "integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==" }, "ret": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/ret/-/ret-0.2.2.tgz", "integrity": "sha512-M0b3YWQs7R3Z917WRQy1HHA7Ba7D8hvZg6UE5mLykJxQVE2ju0IXbGlaHPPlkY+WN7wFP+wUMXmBFA0aV6vYGQ==" }, "reusify": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==" }, "rfdc": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.1.4.tgz", "integrity": "sha512-5C9HXdzK8EAqN7JDif30jqsBzavB7wLpaubisuQIGHWf2gUXSpzy6ArX/+Da8RjFpagWsCn+pIgxTMAmKw9Zug==" }, "rxjs": { "version": "6.5.3", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.3.tgz", "integrity": "sha512-wuYsAYYFdWTAnAaPoKGNhfpWwKZbJW+HgAJ+mImp+Epl7BG8oNWBCTyRM8gba9k4lk8BgWdoYm21Mo/RYhhbgA==", "requires": { "tslib": "^1.9.0" } }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "dev": true }, "safe-regex2": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/safe-regex2/-/safe-regex2-2.0.0.tgz", "integrity": "sha512-PaUSFsUaNNuKwkBijoAPHAK6/eM6VirvyPWlZ7BAQy4D+hCvh4B6lIG+nPdhbFfIbP+gTGBcrdsOaUs0F+ZBOQ==", "requires": { "ret": "~0.2.0" } }, "secure-json-parse": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/secure-json-parse/-/secure-json-parse-1.0.0.tgz", "integrity": "sha512-kMg4jXttRQzVyLebIDc+MRxCueJ/zsmHpCn59BRd0mZUCd+V02wNd7/Pds8Nyhv7jfLHo1KkUOzdIF7cRMU4LQ==" }, "semver-store": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/semver-store/-/semver-store-0.3.0.tgz", "integrity": "sha512-TcZvGMMy9vodEFSse30lWinkj+JgOBvPn8wRItpQRSayhc+4ssDs335uklkfvQQJgL/WvmHLVj4Ycv2s7QCQMg==" }, "sonic-boom": { "version": "0.7.6", "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-0.7.6.tgz", "integrity": "sha512-k9E2QQ4zxuVRLDW+ZW6ISzJs3wlEorVdmM7ApDgor7wsGKSDG5YGHsGmgLY4XYh4DMlr/2ap2BWAE7yTFJtWnQ==", "requires": { "flatstr": "^1.0.12" } }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "source-map-support": { "version": "0.5.13", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.13.tgz", "integrity": "sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==", "dev": true, "requires": { "buffer-from": "^1.0.0", "source-map": "^0.6.0" } }, "string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", "requires": { "safe-buffer": "~5.2.0" }, "dependencies": { "safe-buffer": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==" } } }, "superagent": { "version": "3.8.3", "resolved": "https://registry.npmjs.org/superagent/-/superagent-3.8.3.tgz", "integrity": "sha512-GLQtLMCoEIK4eDv6OGtkOoSMt3D+oq0y3dsxMuYuDvaNUvuT8eFBuLmfR0iYYzHC1e8hpzC6ZsxbuP6DIalMFA==", "dev": true, "requires": { "component-emitter": "^1.2.0", "cookiejar": "^2.1.0", "debug": "^3.1.0", "extend": "^3.0.0", "form-data": "^2.3.1", "formidable": "^1.2.0", "methods": "^1.1.1", "mime": "^1.4.1", "qs": "^6.5.1", "readable-stream": "^2.3.5" }, "dependencies": { "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true }, "readable-stream": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "requires": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", "isarray": "~1.0.0", "process-nextick-args": "~2.0.0", "safe-buffer": "~5.1.1", "string_decoder": "~1.1.1", "util-deprecate": "~1.0.1" } }, "string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { "safe-buffer": "~5.1.0" } } } }, "supertest": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/supertest/-/supertest-4.0.2.tgz", "integrity": "sha512-1BAbvrOZsGA3YTCWqbmh14L0YEq0EGICX/nBnfkfVJn7SrxQV1I3pMYjSzG9y/7ZU2V9dWqyqk2POwxlb09duQ==", "dev": true, "requires": { "methods": "^1.1.2", "superagent": "^3.8.3" } }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "requires": { "has-flag": "^3.0.0" } }, "timers-ext": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz", "integrity": "sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==", "requires": { "es5-ext": "~0.10.46", "next-tick": "1" } }, "tiny-lru": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/tiny-lru/-/tiny-lru-7.0.1.tgz", "integrity": "sha512-BImmnAPNkaN7XjrvmOr4JAT2U6ubLmxiD9iDBMMow3/026OZ+yiuWzM1F0TgECLfq1KO2YkXEIJ2h6sPjXv9XA==" }, "ts-node": { "version": "8.4.1", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.4.1.tgz", "integrity": "sha512-5LpRN+mTiCs7lI5EtbXmF/HfMeCjzt7DH9CZwtkr6SywStrNQC723wG+aOWFiLNn7zT3kD/RnFqi3ZUfr4l5Qw==", "dev": true, "requires": { "arg": "^4.1.0", "diff": "^4.0.1", "make-error": "^1.1.1", "source-map-support": "^0.5.6", "yn": "^3.0.0" } }, "tslib": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" }, "type": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" }, "typescript": { "version": "3.7.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.2.tgz", "integrity": "sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==" }, "uri-js": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", "requires": { "punycode": "^2.1.0" } }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, "uuid": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.3.tgz", "integrity": "sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==" }, "validator": { "version": "12.0.0", "resolved": "https://registry.npmjs.org/validator/-/validator-12.0.0.tgz", "integrity": "sha512-r5zA1cQBEOgYlesRmSEwc9LkbfNLTtji+vWyaHzRZUxCTHdsX3bd+sdHfs5tGZ2W6ILGGsxWxCNwT/h3IY/3ng==" }, "yn": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", "dev": true } } }
integration/hello-world/package-lock.json
0
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.00017739312897901982, 0.00017249907250516117, 0.0001676810352364555, 0.00017265616043005139, 0.0000019553817764972337 ]
{ "id": 1, "code_window": [ " return dynamicModuleMetadata\n", " ? stringify(dynamicModuleMetadata, this.replacer)\n", " : '';\n", " }\n", "\n", " public getModuleName(metatype: Type<any>): string {\n", " return metatype.name;\n", " }\n", "\n", " public getScopeStack(scope: Type<any>[]): string[] {\n", " const reversedScope = scope.reverse();\n", " const firstGlobalIndex = reversedScope.findIndex(\n", " s => this.reflectScope(s) === 'global',\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [], "file_path": "packages/core/injector/module-token-factory.ts", "type": "replace", "edit_start_line_idx": 33 }
# dependencies /node_modules # IDE /.idea /.awcache /.vscode # misc npm-debug.log # example /quick-start # tests /test /coverage /.nyc_output # dist /dist
integration/hooks/.gitignore
0
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.00017381887300871313, 0.00017291237600147724, 0.0001722187880659476, 0.00017269945237785578, 6.703575081701274e-7 ]
{ "id": 1, "code_window": [ " return dynamicModuleMetadata\n", " ? stringify(dynamicModuleMetadata, this.replacer)\n", " : '';\n", " }\n", "\n", " public getModuleName(metatype: Type<any>): string {\n", " return metatype.name;\n", " }\n", "\n", " public getScopeStack(scope: Type<any>[]): string[] {\n", " const reversedScope = scope.reverse();\n", " const firstGlobalIndex = reversedScope.findIndex(\n", " s => this.reflectScope(s) === 'global',\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [], "file_path": "packages/core/injector/module-token-factory.ts", "type": "replace", "edit_start_line_idx": 33 }
import { Document } from 'mongoose'; export interface Cat extends Document { readonly name: string; readonly age: number; readonly breed: string; }
sample/06-mongoose/src/cats/interfaces/cat.interface.ts
0
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.00017879903316497803, 0.00017879903316497803, 0.00017879903316497803, 0.00017879903316497803, 0 ]
{ "id": 2, "code_window": [ " const token = factory.create(Module as any, [Module], undefined);\n", " expect(token).to.be.deep.eq(\n", " hash({\n", " module: Module.name,\n", " dynamic: '',\n", " scope,\n", " }),\n", " );\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " module: Module,\n" ], "file_path": "packages/core/test/injector/module-token-factory.spec.ts", "type": "replace", "edit_start_line_idx": 18 }
import { expect } from 'chai'; import safeStringify from 'fast-safe-stringify'; import * as hash from 'object-hash'; import { SingleScope } from '../../../common'; import { ModuleTokenFactory } from '../../injector/module-token-factory'; describe('ModuleTokenFactory', () => { let factory: ModuleTokenFactory; beforeEach(() => { factory = new ModuleTokenFactory(); }); describe('create', () => { class Module {} it('should force global scope when it is not set', () => { const scope = 'global'; const token = factory.create(Module as any, [Module], undefined); expect(token).to.be.deep.eq( hash({ module: Module.name, dynamic: '', scope, }), ); }); it('should returns expected token', () => { const token = factory.create( SingleScope()(Module) as any, [Module], undefined, ); expect(token).to.be.deep.eq( hash({ module: Module.name, dynamic: '', scope: [Module.name], }), ); }); it('should include dynamic metadata', () => { const token = factory.create(SingleScope()(Module) as any, [Module], { providers: [{}], } as any); expect(token).to.be.deep.eq( hash({ module: Module.name, dynamic: safeStringify({ providers: [{}], }), scope: [Module.name], }), ); }); }); describe('getModuleName', () => { it('should map module metatype to name', () => { const metatype = () => {}; expect(factory.getModuleName(metatype as any)).to.be.eql(metatype.name); }); }); describe('getDynamicMetadataToken', () => { describe('when metadata exists', () => { it('should return hash', () => { const metadata = { providers: ['', {}] }; expect(factory.getDynamicMetadataToken(metadata as any)).to.be.eql( JSON.stringify(metadata), ); }); it('should return hash with class', () => { class Provider {} const metadata = { providers: [Provider], exports: [Provider] }; expect(factory.getDynamicMetadataToken(metadata)).to.be.eql( '{"providers":["Provider"],"exports":["Provider"]}', ); }); }); describe('when metadata does not exist', () => { it('should return empty string', () => { expect(factory.getDynamicMetadataToken(undefined)).to.be.eql(''); }); }); }); describe('getScopeStack', () => { it('should map metatypes to the array with last metatype', () => { const metatype1 = () => {}; const metatype2 = () => {}; expect( factory.getScopeStack([metatype1 as any, metatype2 as any]), ).to.be.eql([metatype2.name]); }); }); });
packages/core/test/injector/module-token-factory.spec.ts
1
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.996069073677063, 0.36361268162727356, 0.00016525175306014717, 0.0008001126116141677, 0.4542498290538788 ]
{ "id": 2, "code_window": [ " const token = factory.create(Module as any, [Module], undefined);\n", " expect(token).to.be.deep.eq(\n", " hash({\n", " module: Module.name,\n", " dynamic: '',\n", " scope,\n", " }),\n", " );\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " module: Module,\n" ], "file_path": "packages/core/test/injector/module-token-factory.spec.ts", "type": "replace", "edit_start_line_idx": 18 }
import { Body, Controller, HttpCode, Post, Query } from '@nestjs/common'; import { Client, ClientProxy, EventPattern, MessagePattern, Transport, } from '@nestjs/microservices'; import { from, Observable, of } from 'rxjs'; import { scan } from 'rxjs/operators'; @Controller() export class AppController { static IS_NOTIFIED = false; @Client({ transport: Transport.TCP }) client: ClientProxy; @Post() @HttpCode(200) call(@Query('command') cmd, @Body() data: number[]): Observable<number> { return this.client.send<number>({ cmd }, data); } @Post('stream') @HttpCode(200) stream(@Body() data: number[]): Observable<number> { return this.client .send<number>({ cmd: 'streaming' }, data) .pipe(scan((a, b) => a + b)); } @Post('concurrent') @HttpCode(200) concurrent(@Body() data: number[][]): Promise<boolean> { const send = async (tab: number[]) => { const expected = tab.reduce((a, b) => a + b); const result = await this.client .send<number>({ cmd: 'sum' }, tab) .toPromise(); return result === expected; }; return data .map(async tab => await send(tab)) .reduce(async (a, b) => (await a) && (await b)); } @MessagePattern({ cmd: 'sum' }) sum(data: number[]): number { return (data || []).reduce((a, b) => a + b); } @MessagePattern({ cmd: 'asyncSum' }) async asyncSum(data: number[]): Promise<number> { return (data || []).reduce((a, b) => a + b); } @MessagePattern({ cmd: 'streamSum' }) streamSum(data: number[]): Observable<number> { return of((data || []).reduce((a, b) => a + b)); } @MessagePattern({ cmd: 'streaming' }) streaming(data: number[]): Observable<number> { return from(data); } @Post('notify') async sendNotification(): Promise<any> { return this.client.emit<number>('notification', true); } @EventPattern('notification') eventHandler(data: boolean) { AppController.IS_NOTIFIED = data; } }
integration/microservices/src/app.controller.ts
0
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.00017616031982470304, 0.00017185490287374705, 0.00016762316226959229, 0.00017223240865860134, 0.0000027097885322291404 ]
{ "id": 2, "code_window": [ " const token = factory.create(Module as any, [Module], undefined);\n", " expect(token).to.be.deep.eq(\n", " hash({\n", " module: Module.name,\n", " dynamic: '',\n", " scope,\n", " }),\n", " );\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " module: Module,\n" ], "file_path": "packages/core/test/injector/module-token-factory.spec.ts", "type": "replace", "edit_start_line_idx": 18 }
import { PARAMTYPES_METADATA } from '../../constants'; export function flatten<T extends any[] = any, R extends any[] = any>( arr: T, ): R { const flat = [].concat(...arr); return (flat.some(Array.isArray) ? flatten(flat) : flat) as R; } export const Dependencies = (...dependencies: any[]): ClassDecorator => { const flattenDeps = flatten(dependencies); return (target: object) => { Reflect.defineMetadata(PARAMTYPES_METADATA, flattenDeps, target); }; };
packages/common/decorators/core/dependencies.decorator.ts
0
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.0001701085566310212, 0.00016846446669660509, 0.00016682036221027374, 0.00016846446669660509, 0.0000016440972103737295 ]
{ "id": 2, "code_window": [ " const token = factory.create(Module as any, [Module], undefined);\n", " expect(token).to.be.deep.eq(\n", " hash({\n", " module: Module.name,\n", " dynamic: '',\n", " scope,\n", " }),\n", " );\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " module: Module,\n" ], "file_path": "packages/core/test/injector/module-token-factory.spec.ts", "type": "replace", "edit_start_line_idx": 18 }
import { Module } from '@nestjs/common'; import { GqlModuleOptions, GqlOptionsFactory, GraphQLModule, } from '@nestjs/graphql'; import { join } from 'path'; import { CatsModule } from './cats/cats.module'; class ConfigService implements GqlOptionsFactory { createGqlOptions(): GqlModuleOptions { return { typePaths: [join(__dirname, '**', '*.graphql')], }; } } @Module({ imports: [ CatsModule, GraphQLModule.forRootAsync({ useClass: ConfigService, }), ], }) export class AsyncClassApplicationModule {}
integration/graphql/src/async-options-class.module.ts
0
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.00034377010888420045, 0.0002656487049534917, 0.00018560673925094306, 0.00026756926672533154, 0.00006458420830313116 ]
{ "id": 3, "code_window": [ " scope,\n", " }),\n", " );\n", " });\n", " it('should returns expected token', () => {\n", " const token = factory.create(\n", " SingleScope()(Module) as any,\n", " [Module],\n", " undefined,\n", " );\n", " expect(token).to.be.deep.eq(\n", " hash({\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep" ], "after_edit": [ " const type = SingleScope()(Module) as any;\n", " const token = factory.create(type, [Module], undefined);\n" ], "file_path": "packages/core/test/injector/module-token-factory.spec.ts", "type": "replace", "edit_start_line_idx": 25 }
import { expect } from 'chai'; import safeStringify from 'fast-safe-stringify'; import * as hash from 'object-hash'; import { SingleScope } from '../../../common'; import { ModuleTokenFactory } from '../../injector/module-token-factory'; describe('ModuleTokenFactory', () => { let factory: ModuleTokenFactory; beforeEach(() => { factory = new ModuleTokenFactory(); }); describe('create', () => { class Module {} it('should force global scope when it is not set', () => { const scope = 'global'; const token = factory.create(Module as any, [Module], undefined); expect(token).to.be.deep.eq( hash({ module: Module.name, dynamic: '', scope, }), ); }); it('should returns expected token', () => { const token = factory.create( SingleScope()(Module) as any, [Module], undefined, ); expect(token).to.be.deep.eq( hash({ module: Module.name, dynamic: '', scope: [Module.name], }), ); }); it('should include dynamic metadata', () => { const token = factory.create(SingleScope()(Module) as any, [Module], { providers: [{}], } as any); expect(token).to.be.deep.eq( hash({ module: Module.name, dynamic: safeStringify({ providers: [{}], }), scope: [Module.name], }), ); }); }); describe('getModuleName', () => { it('should map module metatype to name', () => { const metatype = () => {}; expect(factory.getModuleName(metatype as any)).to.be.eql(metatype.name); }); }); describe('getDynamicMetadataToken', () => { describe('when metadata exists', () => { it('should return hash', () => { const metadata = { providers: ['', {}] }; expect(factory.getDynamicMetadataToken(metadata as any)).to.be.eql( JSON.stringify(metadata), ); }); it('should return hash with class', () => { class Provider {} const metadata = { providers: [Provider], exports: [Provider] }; expect(factory.getDynamicMetadataToken(metadata)).to.be.eql( '{"providers":["Provider"],"exports":["Provider"]}', ); }); }); describe('when metadata does not exist', () => { it('should return empty string', () => { expect(factory.getDynamicMetadataToken(undefined)).to.be.eql(''); }); }); }); describe('getScopeStack', () => { it('should map metatypes to the array with last metatype', () => { const metatype1 = () => {}; const metatype2 = () => {}; expect( factory.getScopeStack([metatype1 as any, metatype2 as any]), ).to.be.eql([metatype2.name]); }); }); });
packages/core/test/injector/module-token-factory.spec.ts
1
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.9983370304107666, 0.30068808794021606, 0.00016807128849904984, 0.001017057104036212, 0.4562511742115021 ]
{ "id": 3, "code_window": [ " scope,\n", " }),\n", " );\n", " });\n", " it('should returns expected token', () => {\n", " const token = factory.create(\n", " SingleScope()(Module) as any,\n", " [Module],\n", " undefined,\n", " );\n", " expect(token).to.be.deep.eq(\n", " hash({\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep" ], "after_edit": [ " const type = SingleScope()(Module) as any;\n", " const token = factory.create(type, [Module], undefined);\n" ], "file_path": "packages/core/test/injector/module-token-factory.spec.ts", "type": "replace", "edit_start_line_idx": 25 }
import { Module } from '@nestjs/common'; import { GraphQLModule } from '@nestjs/graphql'; import { CatsModule } from './cats/cats.module'; @Module({ imports: [ CatsModule, GraphQLModule.forRoot({ typePaths: ['./**/*.graphql'], installSubscriptionHandlers: true, }), ], }) export class AppModule {}
sample/12-graphql-apollo/src/app.module.ts
0
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.0013936476316303015, 0.0007822089828550816, 0.0001707703195279464, 0.0007822089828550816, 0.0006114386487752199 ]
{ "id": 3, "code_window": [ " scope,\n", " }),\n", " );\n", " });\n", " it('should returns expected token', () => {\n", " const token = factory.create(\n", " SingleScope()(Module) as any,\n", " [Module],\n", " undefined,\n", " );\n", " expect(token).to.be.deep.eq(\n", " hash({\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep" ], "after_edit": [ " const type = SingleScope()(Module) as any;\n", " const token = factory.create(type, [Module], undefined);\n" ], "file_path": "packages/core/test/injector/module-token-factory.spec.ts", "type": "replace", "edit_start_line_idx": 25 }
import { EXCEPTION_FILTERS_METADATA } from '../../constants'; import { ExceptionFilter } from '../../index'; import { extendArrayMetadata } from '../../utils/extend-metadata.util'; import { isFunction } from '../../utils/shared.utils'; import { validateEach } from '../../utils/validate-each.util'; const defineFiltersMetadata = (...filters: (Function | ExceptionFilter)[]) => { return (target: any, key?: string, descriptor?: any) => { const isFilterValid = <T extends Function | Record<string, any>>( filter: T, ) => filter && (isFunction(filter) || isFunction((filter as Record<string, any>).catch)); if (descriptor) { validateEach( target.constructor, filters, isFilterValid, '@UseFilters', 'filter', ); extendArrayMetadata( EXCEPTION_FILTERS_METADATA, filters, descriptor.value, ); return descriptor; } validateEach(target, filters, isFilterValid, '@UseFilters', 'filter'); extendArrayMetadata(EXCEPTION_FILTERS_METADATA, filters, target); return target; }; }; /** * Decorator that binds exception filters to the scope of the controller or * method, depending on its context. * * When `@UseFilters` is used at the controller level, the filter will be * applied to every handler (method) in the controller. * * When `@UseFilters` is used at the individual handler level, the filter * will apply only to that specific method. * * @param filters exception filter instance or class, or a list of exception * filter instances or classes. * * @see [Exception filters](https://docs.nestjs.com/exception-filters) * * @usageNotes * Exception filters can also be set up globally for all controllers and routes * using `app.useGlobalFilters()`. [See here for details](https://docs.nestjs.com/exception-filters#binding-filters) * * @publicApi */ export const UseFilters = (...filters: (ExceptionFilter | Function)[]) => defineFiltersMetadata(...filters);
packages/common/decorators/core/exception-filters.decorator.ts
0
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.00017506536096334457, 0.00016649688768666238, 0.00016038285684771836, 0.00016615347703918815, 0.000004936659934173804 ]
{ "id": 3, "code_window": [ " scope,\n", " }),\n", " );\n", " });\n", " it('should returns expected token', () => {\n", " const token = factory.create(\n", " SingleScope()(Module) as any,\n", " [Module],\n", " undefined,\n", " );\n", " expect(token).to.be.deep.eq(\n", " hash({\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep" ], "after_edit": [ " const type = SingleScope()(Module) as any;\n", " const token = factory.create(type, [Module], undefined);\n" ], "file_path": "packages/core/test/injector/module-token-factory.spec.ts", "type": "replace", "edit_start_line_idx": 25 }
import { ValidationPipe } from '@nestjs/common'; import { expect } from 'chai'; import { PARAM_ARGS_METADATA } from '../../constants'; import { MessageBody } from '../../decorators'; import { WsParamtype } from '../../enums/ws-paramtype.enum'; class MessagePayloadTest { public test(@MessageBody(ValidationPipe) payload: any) {} } describe('@MessagePayload', () => { it('should enhance class with expected request metadata', () => { const argsMetadata = Reflect.getMetadata( PARAM_ARGS_METADATA, MessagePayloadTest, 'test', ); const expectedMetadata = { [`${WsParamtype.PAYLOAD}:0`]: { data: undefined, index: 0, pipes: [ValidationPipe], }, }; expect(argsMetadata).to.be.eql(expectedMetadata); }); });
packages/websockets/test/decorators/message-body.decorator.spec.ts
0
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.00017556536477059126, 0.00016977202903945, 0.00016299296112265438, 0.00017075777577701956, 0.000005179774689167971 ]
{ "id": 4, "code_window": [ " expect(token).to.be.deep.eq(\n", " hash({\n", " module: Module.name,\n", " dynamic: '',\n", " scope: [Module.name],\n", " }),\n", " );\n" ], "labels": [ "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " module: type,\n" ], "file_path": "packages/core/test/injector/module-token-factory.spec.ts", "type": "replace", "edit_start_line_idx": 32 }
import { expect } from 'chai'; import safeStringify from 'fast-safe-stringify'; import * as hash from 'object-hash'; import { SingleScope } from '../../../common'; import { ModuleTokenFactory } from '../../injector/module-token-factory'; describe('ModuleTokenFactory', () => { let factory: ModuleTokenFactory; beforeEach(() => { factory = new ModuleTokenFactory(); }); describe('create', () => { class Module {} it('should force global scope when it is not set', () => { const scope = 'global'; const token = factory.create(Module as any, [Module], undefined); expect(token).to.be.deep.eq( hash({ module: Module.name, dynamic: '', scope, }), ); }); it('should returns expected token', () => { const token = factory.create( SingleScope()(Module) as any, [Module], undefined, ); expect(token).to.be.deep.eq( hash({ module: Module.name, dynamic: '', scope: [Module.name], }), ); }); it('should include dynamic metadata', () => { const token = factory.create(SingleScope()(Module) as any, [Module], { providers: [{}], } as any); expect(token).to.be.deep.eq( hash({ module: Module.name, dynamic: safeStringify({ providers: [{}], }), scope: [Module.name], }), ); }); }); describe('getModuleName', () => { it('should map module metatype to name', () => { const metatype = () => {}; expect(factory.getModuleName(metatype as any)).to.be.eql(metatype.name); }); }); describe('getDynamicMetadataToken', () => { describe('when metadata exists', () => { it('should return hash', () => { const metadata = { providers: ['', {}] }; expect(factory.getDynamicMetadataToken(metadata as any)).to.be.eql( JSON.stringify(metadata), ); }); it('should return hash with class', () => { class Provider {} const metadata = { providers: [Provider], exports: [Provider] }; expect(factory.getDynamicMetadataToken(metadata)).to.be.eql( '{"providers":["Provider"],"exports":["Provider"]}', ); }); }); describe('when metadata does not exist', () => { it('should return empty string', () => { expect(factory.getDynamicMetadataToken(undefined)).to.be.eql(''); }); }); }); describe('getScopeStack', () => { it('should map metatypes to the array with last metatype', () => { const metatype1 = () => {}; const metatype2 = () => {}; expect( factory.getScopeStack([metatype1 as any, metatype2 as any]), ).to.be.eql([metatype2.name]); }); }); });
packages/core/test/injector/module-token-factory.spec.ts
1
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.24247822165489197, 0.04452388733625412, 0.00016594919725321233, 0.000267172435997054, 0.087918721139431 ]
{ "id": 4, "code_window": [ " expect(token).to.be.deep.eq(\n", " hash({\n", " module: Module.name,\n", " dynamic: '',\n", " scope: [Module.name],\n", " }),\n", " );\n" ], "labels": [ "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " module: type,\n" ], "file_path": "packages/core/test/injector/module-token-factory.spec.ts", "type": "replace", "edit_start_line_idx": 32 }
import { Provider } from '../interfaces'; import { loadPackage } from '../utils/load-package.util'; import { CACHE_MANAGER, CACHE_MODULE_OPTIONS } from './cache.constants'; import { defaultCacheOptions } from './default-options'; import { CacheManagerOptions } from './interfaces/cache-manager.interface'; /** * Creates a CacheManager Provider. * * @publicApi */ export function createCacheManager(): Provider { return { provide: CACHE_MANAGER, useFactory: (options: CacheManagerOptions) => { const cacheManager = loadPackage('cache-manager', 'CacheModule', () => require('cache-manager'), ); const memoryCache = cacheManager.caching({ ...defaultCacheOptions, ...(options || {}), }); return memoryCache; }, inject: [CACHE_MODULE_OPTIONS], }; }
packages/common/cache/cache.providers.ts
0
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.00017041036335285753, 0.00016801024321466684, 0.00016676451195962727, 0.00016685582522768527, 0.00000169755742263078 ]
{ "id": 4, "code_window": [ " expect(token).to.be.deep.eq(\n", " hash({\n", " module: Module.name,\n", " dynamic: '',\n", " scope: [Module.name],\n", " }),\n", " );\n" ], "labels": [ "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " module: type,\n" ], "file_path": "packages/core/test/injector/module-token-factory.spec.ts", "type": "replace", "edit_start_line_idx": 32 }
import { INestApplication } from '@nestjs/common'; import { WsAdapter } from '@nestjs/platform-ws'; import { Test } from '@nestjs/testing'; import { expect } from 'chai'; import * as WebSocket from 'ws'; import { ApplicationGateway } from '../src/app.gateway'; import { CoreGateway } from '../src/core.gateway'; import { ServerGateway } from '../src/server.gateway'; async function createNestApp(...gateways): Promise<INestApplication> { const testingModule = await Test.createTestingModule({ providers: gateways, }).compile(); const app = await testingModule.createNestApplication(); app.useWebSocketAdapter(new WsAdapter(app) as any); return app; } describe('WebSocketGateway (WsAdapter)', () => { let ws, ws2, app; it(`should handle message (2nd port)`, async () => { app = await createNestApp(ApplicationGateway); await app.listenAsync(3000); ws = new WebSocket('ws://localhost:8080'); await new Promise(resolve => ws.on('open', resolve)); ws.send( JSON.stringify({ event: 'push', data: { test: 'test', }, }), ); await new Promise(resolve => ws.on('message', data => { expect(JSON.parse(data).data.test).to.be.eql('test'); resolve(); }), ); }); it(`should handle message (http)`, async () => { app = await createNestApp(ServerGateway); await app.listenAsync(3000); ws = new WebSocket('ws://localhost:3000'); await new Promise(resolve => ws.on('open', resolve)); ws.send( JSON.stringify({ event: 'push', data: { test: 'test', }, }), ); await new Promise(resolve => ws.on('message', data => { expect(JSON.parse(data).data.test).to.be.eql('test'); resolve(); }), ); }); it(`should support 2 different gateways`, async function() { this.retries(10); app = await createNestApp(ApplicationGateway, CoreGateway); await app.listenAsync(3000); // open websockets delay await new Promise(resolve => setTimeout(resolve, 1000)); ws = new WebSocket('ws://localhost:8080'); ws2 = new WebSocket('ws://localhost:8090'); await new Promise(resolve => ws.on('open', () => { ws.on('message', data => { expect(JSON.parse(data).data.test).to.be.eql('test'); resolve(); }); ws.send( JSON.stringify({ event: 'push', data: { test: 'test', }, }), ); }), ); await new Promise(resolve => { ws2.on('message', data => { expect(JSON.parse(data).data.test).to.be.eql('test'); resolve(); }); ws2.send( JSON.stringify({ event: 'push', data: { test: 'test', }, }), ); }); }); afterEach(() => app.close()); });
integration/websockets/e2e/ws-gateway.spec.ts
0
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.00017505601863376796, 0.00017141771968454123, 0.00016842439072206616, 0.00017166018369607627, 0.000001863471766228031 ]
{ "id": 4, "code_window": [ " expect(token).to.be.deep.eq(\n", " hash({\n", " module: Module.name,\n", " dynamic: '',\n", " scope: [Module.name],\n", " }),\n", " );\n" ], "labels": [ "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " module: type,\n" ], "file_path": "packages/core/test/injector/module-token-factory.spec.ts", "type": "replace", "edit_start_line_idx": 32 }
import { expect } from 'chai'; import * as sinon from 'sinon'; import { HttpException } from '../../../common/exceptions/http.exception'; import { ExternalExceptionsHandler } from '../../exceptions/external-exceptions-handler'; import { ExternalErrorProxy } from '../../helpers/external-proxy'; describe('ExternalErrorProxy', () => { let externalErrorProxy: ExternalErrorProxy; let handlerMock: sinon.SinonMock; let handler: ExternalExceptionsHandler; beforeEach(() => { handler = new ExternalExceptionsHandler(); handlerMock = sinon.mock(handler); externalErrorProxy = new ExternalErrorProxy(); }); describe('createProxy', () => { it('should method return thunk', () => { const proxy = externalErrorProxy.createProxy(() => {}, handler); expect(typeof proxy === 'function').to.be.true; }); it('should method encapsulate callback passed as argument', () => { const expectation = handlerMock.expects('next').once(); const proxy = externalErrorProxy.createProxy((req, res, next) => { throw new HttpException('test', 500); }, handler); proxy(null, null, null); expectation.verify(); }); it('should method encapsulate async callback passed as argument', done => { const expectation = handlerMock.expects('next').once(); const proxy = externalErrorProxy.createProxy(async (req, res, next) => { throw new HttpException('test', 500); }, handler); proxy(null, null, null); setTimeout(() => { expectation.verify(); done(); }, 0); }); }); });
packages/core/test/helpers/external-proxy.spec.ts
0
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.00017537747044116259, 0.00017013175238389522, 0.00016541303193662316, 0.00016983725072350353, 0.000004092782546649687 ]
{ "id": 5, "code_window": [ " scope: [Module.name],\n", " }),\n", " );\n", " });\n", " it('should include dynamic metadata', () => {\n", " const token = factory.create(SingleScope()(Module) as any, [Module], {\n", " providers: [{}],\n", " } as any);\n", " expect(token).to.be.deep.eq(\n", " hash({\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " const type = SingleScope()(Module) as any;\n", " const token = factory.create(type as any, [Module], {\n" ], "file_path": "packages/core/test/injector/module-token-factory.spec.ts", "type": "replace", "edit_start_line_idx": 39 }
import { expect } from 'chai'; import safeStringify from 'fast-safe-stringify'; import * as hash from 'object-hash'; import { SingleScope } from '../../../common'; import { ModuleTokenFactory } from '../../injector/module-token-factory'; describe('ModuleTokenFactory', () => { let factory: ModuleTokenFactory; beforeEach(() => { factory = new ModuleTokenFactory(); }); describe('create', () => { class Module {} it('should force global scope when it is not set', () => { const scope = 'global'; const token = factory.create(Module as any, [Module], undefined); expect(token).to.be.deep.eq( hash({ module: Module.name, dynamic: '', scope, }), ); }); it('should returns expected token', () => { const token = factory.create( SingleScope()(Module) as any, [Module], undefined, ); expect(token).to.be.deep.eq( hash({ module: Module.name, dynamic: '', scope: [Module.name], }), ); }); it('should include dynamic metadata', () => { const token = factory.create(SingleScope()(Module) as any, [Module], { providers: [{}], } as any); expect(token).to.be.deep.eq( hash({ module: Module.name, dynamic: safeStringify({ providers: [{}], }), scope: [Module.name], }), ); }); }); describe('getModuleName', () => { it('should map module metatype to name', () => { const metatype = () => {}; expect(factory.getModuleName(metatype as any)).to.be.eql(metatype.name); }); }); describe('getDynamicMetadataToken', () => { describe('when metadata exists', () => { it('should return hash', () => { const metadata = { providers: ['', {}] }; expect(factory.getDynamicMetadataToken(metadata as any)).to.be.eql( JSON.stringify(metadata), ); }); it('should return hash with class', () => { class Provider {} const metadata = { providers: [Provider], exports: [Provider] }; expect(factory.getDynamicMetadataToken(metadata)).to.be.eql( '{"providers":["Provider"],"exports":["Provider"]}', ); }); }); describe('when metadata does not exist', () => { it('should return empty string', () => { expect(factory.getDynamicMetadataToken(undefined)).to.be.eql(''); }); }); }); describe('getScopeStack', () => { it('should map metatypes to the array with last metatype', () => { const metatype1 = () => {}; const metatype2 = () => {}; expect( factory.getScopeStack([metatype1 as any, metatype2 as any]), ).to.be.eql([metatype2.name]); }); }); });
packages/core/test/injector/module-token-factory.spec.ts
1
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.9983980059623718, 0.30450204014778137, 0.0001702518347883597, 0.0035663004964590073, 0.45243194699287415 ]
{ "id": 5, "code_window": [ " scope: [Module.name],\n", " }),\n", " );\n", " });\n", " it('should include dynamic metadata', () => {\n", " const token = factory.create(SingleScope()(Module) as any, [Module], {\n", " providers: [{}],\n", " } as any);\n", " expect(token).to.be.deep.eq(\n", " hash({\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " const type = SingleScope()(Module) as any;\n", " const token = factory.create(type as any, [Module], {\n" ], "file_path": "packages/core/test/injector/module-token-factory.spec.ts", "type": "replace", "edit_start_line_idx": 39 }
import { Module } from '@nestjs/common'; import { HelloController } from './hello.controller'; import { HelloService } from './hello.service'; import { UsersService } from './users/users.service'; @Module({ controllers: [HelloController], providers: [HelloService, UsersService], }) export class HelloModule {}
integration/hello-world/src/hello/hello.module.ts
0
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.00016908573161344975, 0.00016709975898265839, 0.0001651137717999518, 0.00016709975898265839, 0.0000019859799067489803 ]
{ "id": 5, "code_window": [ " scope: [Module.name],\n", " }),\n", " );\n", " });\n", " it('should include dynamic metadata', () => {\n", " const token = factory.create(SingleScope()(Module) as any, [Module], {\n", " providers: [{}],\n", " } as any);\n", " expect(token).to.be.deep.eq(\n", " hash({\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " const type = SingleScope()(Module) as any;\n", " const token = factory.create(type as any, [Module], {\n" ], "file_path": "packages/core/test/injector/module-token-factory.spec.ts", "type": "replace", "edit_start_line_idx": 39 }
import { Controller } from '@nestjs/common/interfaces/controllers/controller.interface'; import { ExceptionsHandler } from '../../exceptions/exceptions-handler'; import { ContextId } from '../../injector/instance-wrapper'; export interface ExceptionsFilter { create( instance: Controller, callback: Function, module: string, contextId?: ContextId, inquirerId?: string, ): ExceptionsHandler; }
packages/core/router/interfaces/exceptions-filter.interface.ts
0
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.00016859341121744365, 0.0001679033157415688, 0.00016721322026569396, 0.0001679033157415688, 6.900954758748412e-7 ]
{ "id": 5, "code_window": [ " scope: [Module.name],\n", " }),\n", " );\n", " });\n", " it('should include dynamic metadata', () => {\n", " const token = factory.create(SingleScope()(Module) as any, [Module], {\n", " providers: [{}],\n", " } as any);\n", " expect(token).to.be.deep.eq(\n", " hash({\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " const type = SingleScope()(Module) as any;\n", " const token = factory.create(type as any, [Module], {\n" ], "file_path": "packages/core/test/injector/module-token-factory.spec.ts", "type": "replace", "edit_start_line_idx": 39 }
export { CACHE_MANAGER } from './cache.constants'; export * from './cache.module'; export * from './decorators'; export * from './interceptors'; export * from './interfaces';
packages/common/cache/index.ts
0
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.000167043341207318, 0.000167043341207318, 0.000167043341207318, 0.000167043341207318, 0 ]
{ "id": 6, "code_window": [ " providers: [{}],\n", " } as any);\n", " expect(token).to.be.deep.eq(\n", " hash({\n", " module: Module.name,\n", " dynamic: safeStringify({\n", " providers: [{}],\n", " }),\n", " scope: [Module.name],\n", " }),\n" ], "labels": [ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " module: type,\n" ], "file_path": "packages/core/test/injector/module-token-factory.spec.ts", "type": "replace", "edit_start_line_idx": 44 }
import { DynamicModule } from '@nestjs/common'; import { SHARED_MODULE_METADATA } from '@nestjs/common/constants'; import { Type } from '@nestjs/common/interfaces/type.interface'; import stringify from 'fast-safe-stringify'; import * as hash from 'object-hash'; export class ModuleTokenFactory { public create( metatype: Type<any>, scope: Type<any>[], dynamicModuleMetadata?: Partial<DynamicModule> | undefined, ): string { const moduleScope = this.reflectScope(metatype); const isSingleScoped = moduleScope === true; const opaqueToken = { module: this.getModuleName(metatype), dynamic: this.getDynamicMetadataToken(dynamicModuleMetadata), scope: isSingleScoped ? this.getScopeStack(scope) : moduleScope, }; return hash(opaqueToken); } public getDynamicMetadataToken( dynamicModuleMetadata: Partial<DynamicModule> | undefined, ): string { // Uses safeStringify instead of JSON.stringify to support circular dynamic modules // The replacer function is also required in order to obtain real class names // instead of the unified "Function" key return dynamicModuleMetadata ? stringify(dynamicModuleMetadata, this.replacer) : ''; } public getModuleName(metatype: Type<any>): string { return metatype.name; } public getScopeStack(scope: Type<any>[]): string[] { const reversedScope = scope.reverse(); const firstGlobalIndex = reversedScope.findIndex( s => this.reflectScope(s) === 'global', ); scope.reverse(); const stack = firstGlobalIndex >= 0 ? scope.slice(scope.length - firstGlobalIndex - 1) : scope; return stack.map(module => module.name); } private reflectScope(metatype: Type<any>) { const scope = Reflect.getMetadata(SHARED_MODULE_METADATA, metatype); return scope ? scope : 'global'; } private replacer(key: string, value: any) { if (typeof value === 'function') { return value.name; } return value; } }
packages/core/injector/module-token-factory.ts
1
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.0027585404459387064, 0.0007372326799668372, 0.00016887641686480492, 0.00036376380012370646, 0.0008663804037496448 ]
{ "id": 6, "code_window": [ " providers: [{}],\n", " } as any);\n", " expect(token).to.be.deep.eq(\n", " hash({\n", " module: Module.name,\n", " dynamic: safeStringify({\n", " providers: [{}],\n", " }),\n", " scope: [Module.name],\n", " }),\n" ], "labels": [ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " module: type,\n" ], "file_path": "packages/core/test/injector/module-token-factory.spec.ts", "type": "replace", "edit_start_line_idx": 44 }
import { Controller, UseGuards, UseInterceptors } from '@nestjs/common'; import { MessagePattern } from '@nestjs/microservices'; import { Guard } from './guards/request-scoped.guard'; import { HelloService } from './hello.service'; import { Interceptor } from './interceptors/logging.interceptor'; import { UsersService } from './users/users.service'; @Controller() export class HelloController { static COUNTER = 0; constructor( private readonly helloService: HelloService, private readonly usersService: UsersService, ) { HelloController.COUNTER++; } @UseGuards(Guard) @UseInterceptors(Interceptor) @MessagePattern('test') greeting(): string { return this.helloService.greeting(); } }
integration/scopes/src/msvc/hello.controller.ts
0
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.00017308571841567755, 0.00017078280507121235, 0.00016829131345730275, 0.00017097136878874153, 0.000001961844191100681 ]
{ "id": 6, "code_window": [ " providers: [{}],\n", " } as any);\n", " expect(token).to.be.deep.eq(\n", " hash({\n", " module: Module.name,\n", " dynamic: safeStringify({\n", " providers: [{}],\n", " }),\n", " scope: [Module.name],\n", " }),\n" ], "labels": [ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " module: type,\n" ], "file_path": "packages/core/test/injector/module-token-factory.spec.ts", "type": "replace", "edit_start_line_idx": 44 }
import { Exclude, Expose, Transform } from 'class-transformer'; import { RoleEntity } from './role.entity'; export class UserEntity { id: number; firstName: string; lastName: string; @Exclude() password: string; @Expose() get fullName(): string { return `${this.firstName} ${this.lastName}`; } @Transform(role => role.name) role: RoleEntity; constructor(partial: Partial<UserEntity>) { Object.assign(this, partial); } }
sample/21-serializer/src/entities/user.entity.ts
0
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.0001741055166348815, 0.00017214725085068494, 0.00016997057537082583, 0.0001723656605463475, 0.0000016951325960690156 ]
{ "id": 6, "code_window": [ " providers: [{}],\n", " } as any);\n", " expect(token).to.be.deep.eq(\n", " hash({\n", " module: Module.name,\n", " dynamic: safeStringify({\n", " providers: [{}],\n", " }),\n", " scope: [Module.name],\n", " }),\n" ], "labels": [ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " module: type,\n" ], "file_path": "packages/core/test/injector/module-token-factory.spec.ts", "type": "replace", "edit_start_line_idx": 44 }
import { ValidationPipe } from '@nestjs/common'; import { expect } from 'chai'; import { PARAM_ARGS_METADATA } from '../../constants'; import { MessageBody } from '../../decorators'; import { WsParamtype } from '../../enums/ws-paramtype.enum'; class MessagePayloadTest { public test(@MessageBody(ValidationPipe) payload: any) {} } describe('@MessagePayload', () => { it('should enhance class with expected request metadata', () => { const argsMetadata = Reflect.getMetadata( PARAM_ARGS_METADATA, MessagePayloadTest, 'test', ); const expectedMetadata = { [`${WsParamtype.PAYLOAD}:0`]: { data: undefined, index: 0, pipes: [ValidationPipe], }, }; expect(argsMetadata).to.be.eql(expectedMetadata); }); });
packages/websockets/test/decorators/message-body.decorator.spec.ts
0
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.00017331047274637967, 0.00017010133888106793, 0.00016774132382124662, 0.00016925219097174704, 0.0000023515428893006174 ]
{ "id": 7, "code_window": [ " }),\n", " );\n", " });\n", " });\n", " describe('getModuleName', () => {\n", " it('should map module metatype to name', () => {\n", " const metatype = () => {};\n", " expect(factory.getModuleName(metatype as any)).to.be.eql(metatype.name);\n", " });\n", " });\n", " describe('getDynamicMetadataToken', () => {\n", " describe('when metadata exists', () => {\n", " it('should return hash', () => {\n", " const metadata = { providers: ['', {}] };\n" ], "labels": [ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [], "file_path": "packages/core/test/injector/module-token-factory.spec.ts", "type": "replace", "edit_start_line_idx": 53 }
import { expect } from 'chai'; import safeStringify from 'fast-safe-stringify'; import * as hash from 'object-hash'; import { SingleScope } from '../../../common'; import { ModuleTokenFactory } from '../../injector/module-token-factory'; describe('ModuleTokenFactory', () => { let factory: ModuleTokenFactory; beforeEach(() => { factory = new ModuleTokenFactory(); }); describe('create', () => { class Module {} it('should force global scope when it is not set', () => { const scope = 'global'; const token = factory.create(Module as any, [Module], undefined); expect(token).to.be.deep.eq( hash({ module: Module.name, dynamic: '', scope, }), ); }); it('should returns expected token', () => { const token = factory.create( SingleScope()(Module) as any, [Module], undefined, ); expect(token).to.be.deep.eq( hash({ module: Module.name, dynamic: '', scope: [Module.name], }), ); }); it('should include dynamic metadata', () => { const token = factory.create(SingleScope()(Module) as any, [Module], { providers: [{}], } as any); expect(token).to.be.deep.eq( hash({ module: Module.name, dynamic: safeStringify({ providers: [{}], }), scope: [Module.name], }), ); }); }); describe('getModuleName', () => { it('should map module metatype to name', () => { const metatype = () => {}; expect(factory.getModuleName(metatype as any)).to.be.eql(metatype.name); }); }); describe('getDynamicMetadataToken', () => { describe('when metadata exists', () => { it('should return hash', () => { const metadata = { providers: ['', {}] }; expect(factory.getDynamicMetadataToken(metadata as any)).to.be.eql( JSON.stringify(metadata), ); }); it('should return hash with class', () => { class Provider {} const metadata = { providers: [Provider], exports: [Provider] }; expect(factory.getDynamicMetadataToken(metadata)).to.be.eql( '{"providers":["Provider"],"exports":["Provider"]}', ); }); }); describe('when metadata does not exist', () => { it('should return empty string', () => { expect(factory.getDynamicMetadataToken(undefined)).to.be.eql(''); }); }); }); describe('getScopeStack', () => { it('should map metatypes to the array with last metatype', () => { const metatype1 = () => {}; const metatype2 = () => {}; expect( factory.getScopeStack([metatype1 as any, metatype2 as any]), ).to.be.eql([metatype2.name]); }); }); });
packages/core/test/injector/module-token-factory.spec.ts
1
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.9982446432113647, 0.29804423451423645, 0.00016530595894437283, 0.0017119341064244509, 0.4475286602973938 ]
{ "id": 7, "code_window": [ " }),\n", " );\n", " });\n", " });\n", " describe('getModuleName', () => {\n", " it('should map module metatype to name', () => {\n", " const metatype = () => {};\n", " expect(factory.getModuleName(metatype as any)).to.be.eql(metatype.name);\n", " });\n", " });\n", " describe('getDynamicMetadataToken', () => {\n", " describe('when metadata exists', () => {\n", " it('should return hash', () => {\n", " const metadata = { providers: ['', {}] };\n" ], "labels": [ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [], "file_path": "packages/core/test/injector/module-token-factory.spec.ts", "type": "replace", "edit_start_line_idx": 53 }
import { ExceptionFilter } from './exception-filter.interface'; import { Type } from '../type.interface'; export interface ExceptionFilterMetadata { func: ExceptionFilter['catch']; exceptionMetatypes: Type<any>[]; }
packages/common/interfaces/exceptions/exception-filter-metadata.interface.ts
0
https://github.com/nestjs/nest/commit/ed3da85252fef246c73b5bc120fb218018a5abf9
[ 0.00016743004380259663, 0.00016743004380259663, 0.00016743004380259663, 0.00016743004380259663, 0 ]