@grafana/aws-sdk
Advanced tools
Comparing version 0.0.31 to 0.0.32-pre.1
export { ConnectionConfig, ConnectionConfigProps } from './ConnectionConfig'; | ||
export { ConfigSelect, InlineInput } from './sql/ConfigEditor'; | ||
export { ResourceSelector, ResourceSelectorProps } from './sql/ResourceSelector'; | ||
export { SQLQuery } from './sql/types'; | ||
export { QueryCodeEditor, FormatSelect, FillValueSelect } from './sql/QueryEditor'; | ||
export * from './sql/utils'; | ||
export * from './types'; | ||
export * from './regions'; | ||
export * from './providers'; | ||
export * from './selectors'; |
@@ -9,2 +9,3 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
var data = require('@grafana/data'); | ||
var lodash = require('lodash'); | ||
@@ -37,2 +38,40 @@ /*! ***************************************************************************** | ||
function __awaiter(thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
} | ||
function __generator(thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
} | ||
function __read(o, n) { | ||
@@ -114,16 +153,2 @@ var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
var Components = { | ||
ConfigEditor: { | ||
SecretKey: { | ||
input: 'Config editor secret key input', | ||
}, | ||
AccessKey: { | ||
input: 'Config editor access key input', | ||
}, | ||
}, | ||
}; | ||
var selectors = { | ||
components: Components, | ||
}; | ||
var toOption = function (value) { return ({ value: value, label: value }); }; | ||
@@ -161,3 +186,3 @@ var ConnectionConfig = function (props) { | ||
React__default.createElement(ui.InlineField, { label: "Authentication Provider", labelWidth: 28, tooltip: "Specify which AWS credentials chain to use." }, | ||
React__default.createElement(ui.Select, { className: "width-30 aws-config-authType", value: currentProvider, options: awsAuthProviderOptions.filter(function (opt) { return awsAllowedAuthProviders.includes(opt.value); }), defaultValue: options.jsonData.authType, onChange: function (option) { | ||
React__default.createElement(ui.Select, { className: "width-30", value: currentProvider, options: awsAuthProviderOptions.filter(function (opt) { return awsAllowedAuthProviders.includes(opt.value); }), defaultValue: options.jsonData.authType, onChange: function (option) { | ||
data.onUpdateDatasourceJsonDataOptionSelect(props, 'authType')(option); | ||
@@ -170,6 +195,6 @@ } })), | ||
React__default.createElement(ui.Input, { disabled: true, placeholder: "Configured" }), | ||
React__default.createElement(ui.ToolbarButton, { icon: "edit", tooltip: "Edit Access Key ID", type: "button", onClick: data.onUpdateDatasourceResetOption(props, 'accessKey') }))) : (React__default.createElement(ui.Input, { className: "width-30", value: (_e = (_d = options.secureJsonData) === null || _d === void 0 ? void 0 : _d.accessKey) !== null && _e !== void 0 ? _e : '', onChange: data.onUpdateDatasourceSecureJsonDataOption(props, 'accessKey'), "aria-label": selectors.components.ConfigEditor.AccessKey.input }))), | ||
React__default.createElement(ui.ToolbarButton, { icon: "edit", tooltip: "Edit Access Key ID", type: "button", onClick: data.onUpdateDatasourceResetOption(props, 'accessKey') }))) : (React__default.createElement(ui.Input, { className: "width-30", value: (_e = (_d = options.secureJsonData) === null || _d === void 0 ? void 0 : _d.accessKey) !== null && _e !== void 0 ? _e : '', onChange: data.onUpdateDatasourceSecureJsonDataOption(props, 'accessKey') }))), | ||
React__default.createElement(ui.InlineField, { label: "Secret Access Key", labelWidth: 28 }, ((_f = props.options.secureJsonFields) === null || _f === void 0 ? void 0 : _f.secretKey) ? (React__default.createElement(ui.ButtonGroup, { className: "width-30" }, | ||
React__default.createElement(ui.Input, { disabled: true, placeholder: "Configured" }), | ||
React__default.createElement(ui.ToolbarButton, { icon: "edit", type: "button", tooltip: "Edit Secret Access Key", onClick: data.onUpdateDatasourceResetOption(props, 'secretKey') }))) : (React__default.createElement(ui.Input, { className: "width-30", value: (_h = (_g = options.secureJsonData) === null || _g === void 0 ? void 0 : _g.secretKey) !== null && _h !== void 0 ? _h : '', onChange: data.onUpdateDatasourceSecureJsonDataOption(props, 'secretKey'), "aria-label": selectors.components.ConfigEditor.SecretKey.input }))))), | ||
React__default.createElement(ui.ToolbarButton, { icon: "edit", type: "button", tooltip: "Edit Secret Access Key", onClick: data.onUpdateDatasourceResetOption(props, 'secretKey') }))) : (React__default.createElement(ui.Input, { className: "width-30", value: (_h = (_g = options.secureJsonData) === null || _g === void 0 ? void 0 : _g.secretKey) !== null && _h !== void 0 ? _h : '', onChange: data.onUpdateDatasourceSecureJsonDataOption(props, 'secretKey') }))))), | ||
awsAssumeRoleEnabled && (React__default.createElement(React__default.Fragment, null, | ||
@@ -183,11 +208,257 @@ React__default.createElement(ui.InlineField, { label: "Assume Role ARN", labelWidth: 28, tooltip: "Optionally, specify the ARN of a role to assume. Specifying a role here will ensure that the selected authentication provider is used to assume the specified role rather than using the credentials directly. Leave blank if you don't need to assume a role at all" }, | ||
React__default.createElement(ui.InlineField, { label: "Default Region", labelWidth: 28, tooltip: "Specify the region, such as for US West (Oregon) use ` us-west-2 ` as the region." }, | ||
React__default.createElement(ui.Select, { className: "width-30 aws-config-defaultRegion", value: regions.find(function (region) { return region.value === options.jsonData.defaultRegion; }), options: regions, defaultValue: options.jsonData.defaultRegion, allowCustomValue: true, onChange: data.onUpdateDatasourceJsonDataOptionSelect(props, 'defaultRegion'), formatCreateLabel: function (r) { return "Use region: " + r; } })), | ||
React__default.createElement(ui.Select, { className: "width-30", value: regions.find(function (region) { return region.value === options.jsonData.defaultRegion; }), options: regions, defaultValue: options.jsonData.defaultRegion, allowCustomValue: true, onChange: data.onUpdateDatasourceJsonDataOptionSelect(props, 'defaultRegion'), formatCreateLabel: function (r) { return "Use region: " + r; } })), | ||
props.children)); | ||
}; | ||
exports.Components = Components; | ||
var defaultKey = '__default'; | ||
function ResourceSelector(props) { | ||
var _this = this; | ||
var _a = __read(React.useState(props.value || props.default || null), 2), resource = _a[0], setResource = _a[1]; | ||
var _b = __read(React.useState(resource ? [resource] : []), 2), resources = _b[0], setResources = _b[1]; | ||
var _c = __read(React.useState(props.dependencies), 2), dependencies = _c[0], setDependencies = _c[1]; | ||
var _d = __read(React.useState(false), 2), isLoading = _d[0], setIsLoading = _d[1]; | ||
var _e = __read(React.useState(false), 2), fetched = _e[0], setFetched = _e[1]; | ||
var defaultOpts = React.useMemo(function () { | ||
var opts = [ | ||
{ | ||
label: "default (" + props.default + ")", | ||
value: defaultKey, | ||
description: "Default value set in the data source", | ||
}, | ||
]; | ||
if (props.value && props.value !== defaultKey) { | ||
opts.push({ label: props.value, value: props.value }); | ||
} | ||
return opts; | ||
}, [props.default, props.value]); | ||
var _f = __read(React.useState(props.default ? defaultOpts : []), 2), options = _f[0], setOptions = _f[1]; | ||
React.useEffect(function () { | ||
if (resources.length) { | ||
var newOptions_1 = props.default ? defaultOpts : []; | ||
resources.forEach(function (r) { | ||
var value = typeof r === 'string' ? r : r.value; | ||
if (!newOptions_1.find(function (o) { return o.value === value; })) { | ||
typeof r === 'string' ? newOptions_1.push({ label: r, value: r }) : newOptions_1.push(r); | ||
} | ||
}); | ||
setOptions(newOptions_1); | ||
} | ||
else { | ||
setOptions([]); | ||
} | ||
}, [resources, defaultOpts, props.default]); | ||
React.useEffect(function () { | ||
// A change in the dependencies cause a state clean-up | ||
if (!lodash.isEqual(props.dependencies, dependencies)) { | ||
setFetched(false); | ||
setResources([]); | ||
setResource(null); | ||
props.onChange(null); | ||
setDependencies(props.dependencies); | ||
} | ||
}, [props, dependencies]); | ||
var fetch = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var resources_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (fetched) { | ||
return [2 /*return*/]; | ||
} | ||
if (!props.saveOptions) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, props.saveOptions()]; | ||
case 1: | ||
_a.sent(); | ||
_a.label = 2; | ||
case 2: | ||
_a.trys.push([2, , 4, 5]); | ||
return [4 /*yield*/, props.fetch()]; | ||
case 3: | ||
resources_1 = _a.sent(); | ||
setResources(resources_1); | ||
return [3 /*break*/, 5]; | ||
case 4: | ||
setFetched(true); | ||
return [7 /*endfinally*/]; | ||
case 5: return [2 /*return*/]; | ||
} | ||
}); | ||
}); }; | ||
var onChange = function (e) { | ||
props.onChange(e); | ||
if (e.value) { | ||
setResource(e.value); | ||
} | ||
}; | ||
var onClick = function () { return __awaiter(_this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
setIsLoading(true); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, , 3, 4]); | ||
return [4 /*yield*/, fetch()]; | ||
case 2: | ||
_a.sent(); | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
setIsLoading(false); | ||
return [7 /*endfinally*/]; | ||
case 4: return [2 /*return*/]; | ||
} | ||
}); | ||
}); }; | ||
return (React__default.createElement(ui.InlineField, { label: props.label, labelWidth: props.labelWidth, tooltip: props.tooltip, hidden: props.hidden }, | ||
React__default.createElement("div", { "data-testid": props['data-testid'], title: props.title }, | ||
React__default.createElement(ui.Select, { "aria-label": props.label, options: options, value: props.value, onChange: onChange, isLoading: isLoading, className: props.className || 'min-width-6', disabled: props.disabled, onOpenMenu: onClick })))); | ||
} | ||
function ConfigSelect(props) { | ||
var jsonData = props.options.jsonData; | ||
var commonProps = { | ||
title: jsonData.defaultRegion ? '' : 'select a default region', | ||
disabled: !jsonData.defaultRegion, | ||
labelWidth: 28, | ||
className: 'width-30', | ||
}; | ||
// Any change in the AWS connection details will affect selectors | ||
var dependencies = [ | ||
props.options.jsonData.assumeRoleArn, | ||
props.options.jsonData.authType, | ||
props.options.jsonData.defaultRegion, | ||
props.options.jsonData.endpoint, | ||
props.options.jsonData.externalId, | ||
props.options.jsonData.profile, | ||
].concat(props.dependencies); | ||
return (React__default.createElement(ResourceSelector, __assign({ label: props.label, "data-testid": props['data-testid'], onChange: props.onChange, fetch: props.fetch, value: props.value, saveOptions: props.saveOptions, dependencies: dependencies, hidden: props.hidden, disabled: props.disabled }, commonProps))); | ||
} | ||
function InlineInput(props) { | ||
return (React__default.createElement(ui.InlineField, { label: props.label, labelWidth: 28, tooltip: props.tooltip, hidden: props.hidden, disabled: props.disabled }, | ||
React__default.createElement(ui.Input, { "data-testid": props['data-testid'], className: "width-30", value: props.value, onChange: props.onChange, placeholder: props.placeholder, disabled: props.disabled }))); | ||
} | ||
function QueryCodeEditor(props) { | ||
var getSuggestions = props.getSuggestions, getTemplateSrv = props.getTemplateSrv, query = props.query; | ||
var rawSQL = lodash.defaults(props.query, { rawSQL: '' }).rawSQL; | ||
var onRawSqlChange = function (rawSQL) { | ||
var query = __assign(__assign({}, props.query), { rawSQL: rawSQL }); | ||
props.onChange(query); | ||
props.onRunQuery(); | ||
}; | ||
// Use a reference for suggestions because a bug in CodeEditor getSuggestions | ||
// https://github.com/grafana/grafana/issues/40121 | ||
// It was been fixed in 8.3 but keeping the workaround here to support older | ||
// versions. | ||
var suggestionsRef = React.useRef([]); | ||
React.useEffect(function () { | ||
suggestionsRef.current = getSuggestions(getTemplateSrv(), query); | ||
}, [getSuggestions, getTemplateSrv, query]); | ||
return (React__default.createElement(ui.CodeEditor, __assign({ language: props.language, value: rawSQL, onBlur: onRawSqlChange, showMiniMap: false, showLineNumbers: true, getSuggestions: function () { return suggestionsRef.current; }, height: "240px" }, props.editorProps))); | ||
} | ||
function FormatSelect(props) { | ||
var onChangeFormat = function (e) { | ||
props.onChange(__assign(__assign({}, props.query), { format: e.value || 0 })); | ||
props.onRunQuery(); | ||
}; | ||
return (React__default.createElement(ui.InlineField, { label: "Format as", labelWidth: 11 }, | ||
React__default.createElement(ui.Select, { "aria-label": "Format as", options: props.options, value: props.query.format, onChange: onChangeFormat, className: "width-12" }))); | ||
} | ||
var FillValueOptions; | ||
(function (FillValueOptions) { | ||
FillValueOptions[FillValueOptions["Previous"] = 0] = "Previous"; | ||
FillValueOptions[FillValueOptions["Null"] = 1] = "Null"; | ||
FillValueOptions[FillValueOptions["Value"] = 2] = "Value"; | ||
})(FillValueOptions || (FillValueOptions = {})); | ||
var SelectableFillValueOptions = [ | ||
{ | ||
label: 'Previous Value', | ||
value: FillValueOptions.Previous, | ||
}, | ||
{ | ||
label: 'NULL', | ||
value: FillValueOptions.Null, | ||
}, | ||
{ | ||
label: 'Value', | ||
value: FillValueOptions.Value, | ||
}, | ||
]; | ||
function FillValueSelect(props) { | ||
var _a, _b, _c; | ||
return (React__default.createElement(React__default.Fragment, null, | ||
React__default.createElement(ui.InlineField, { label: "Fill value", tooltip: "value to fill missing points" }, | ||
React__default.createElement(ui.Select, { "aria-label": "Fill value", options: SelectableFillValueOptions, value: (_b = (_a = props.query.fillMode) === null || _a === void 0 ? void 0 : _a.mode) !== null && _b !== void 0 ? _b : FillValueOptions.Previous, onChange: function (_a) { | ||
var value = _a.value; | ||
props.onChange(__assign(__assign({}, props.query), { | ||
// Keep the fillMode.value in case FillValueOptions.Value mode is selected back | ||
fillMode: __assign(__assign({}, props.query.fillMode), { mode: value }) })); | ||
props.onRunQuery(); | ||
}, className: "width-12" })), | ||
((_c = props.query.fillMode) === null || _c === void 0 ? void 0 : _c.mode) === FillValueOptions.Value && (React__default.createElement(ui.InlineField, { label: "Value", labelWidth: 11 }, | ||
React__default.createElement(ui.Input, { type: "number", "aria-label": "Value", value: props.query.fillMode.value, onChange: function (_a) { | ||
var currentTarget = _a.currentTarget; | ||
return props.onChange(__assign(__assign({}, props.query), { fillMode: { | ||
mode: FillValueOptions.Value, | ||
value: currentTarget.valueAsNumber, | ||
} })); | ||
}, onBlur: function () { return props.onRunQuery(); } }))))); | ||
} | ||
/** | ||
* Do not execute queries that do not exist yet | ||
*/ | ||
function filterSQLQuery(query) { | ||
return !!query.rawSQL; | ||
} | ||
function applySQLTemplateVariables(query, scopedVars, getTemplateSrv) { | ||
var templateSrv = getTemplateSrv(); | ||
return __assign(__assign({}, query), { rawSQL: templateSrv.replace(query.rawSQL, scopedVars, interpolateVariable) }); | ||
} | ||
function interpolateVariable(value) { | ||
if (typeof value === 'string') { | ||
return value; | ||
} | ||
var quotedValues = value.map(function (v) { | ||
return quoteLiteral(v); | ||
}); | ||
return quotedValues.join(','); | ||
} | ||
function quoteLiteral(value) { | ||
return "'" + String(value).replace(/'/g, "''") + "'"; | ||
} | ||
var appendTemplateVariablesAsSuggestions = function (getTemplateSrv, sugs) { | ||
var templateSrv = getTemplateSrv(); | ||
var templateSugs = []; | ||
templateSrv.getVariables().forEach(function (variable) { | ||
var label = '$' + variable.name; | ||
var val = templateSrv.replace(label); | ||
if (val === label) { | ||
val = ''; | ||
} | ||
templateSugs.push({ | ||
label: label, | ||
kind: ui.CodeEditorSuggestionItemKind.Text, | ||
detail: "(Template Variable) " + val, | ||
}); | ||
}); | ||
return sugs.concat(templateSugs); | ||
}; | ||
exports.ConfigSelect = ConfigSelect; | ||
exports.ConnectionConfig = ConnectionConfig; | ||
exports.FillValueSelect = FillValueSelect; | ||
exports.FormatSelect = FormatSelect; | ||
exports.InlineInput = InlineInput; | ||
exports.QueryCodeEditor = QueryCodeEditor; | ||
exports.ResourceSelector = ResourceSelector; | ||
exports.appendTemplateVariablesAsSuggestions = appendTemplateVariablesAsSuggestions; | ||
exports.applySQLTemplateVariables = applySQLTemplateVariables; | ||
exports.awsAuthProviderOptions = awsAuthProviderOptions; | ||
exports.selectors = selectors; | ||
exports.filterSQLQuery = filterSQLQuery; | ||
exports.standardRegions = standardRegions; | ||
//# sourceMappingURL=index.development.js.map |
@@ -1,2 +0,2 @@ | ||
Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),a=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,n=require("@grafana/ui"),o=require("@grafana/data"),l=function(){return(l=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++)for(var o in t=arguments[a])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};var s,i=["af-south-1","ap-east-1","ap-northeast-1","ap-northeast-2","ap-northeast-3","ap-south-1","ap-southeast-1","ap-southeast-2","ca-central-1","cn-north-1","cn-northwest-1","eu-central-1","eu-north-1","eu-west-1","eu-west-2","eu-west-3","me-south-1","sa-east-1","us-east-1","us-east-2","us-gov-east-1","us-gov-west-1","us-iso-east-1","us-isob-east-1","us-west-1","us-west-2"];(s=exports.AwsAuthType||(exports.AwsAuthType={})).Keys="keys",s.Credentials="credentials",s.Default="default",s.EC2IAMRole="ec2_iam_role",s.ARN="arn";var r=[{label:"Workspace IAM Role",value:exports.AwsAuthType.EC2IAMRole},{label:"AWS SDK Default",value:exports.AwsAuthType.Default},{label:"Access & secret key",value:exports.AwsAuthType.Keys},{label:"Credentials file",value:exports.AwsAuthType.Credentials}],u={ConfigEditor:{SecretKey:{input:"Config editor secret key input"},AccessKey:{input:"Config editor access key input"}}},c={components:u},d=function(e){return{value:e,label:e}};exports.Components=u,exports.ConnectionConfig=function(e){var s,u,p,h,f,y,m,v,g,D=function(e,t){var a="function"==typeof Symbol&&e[Symbol.iterator];if(!a)return e;var n,o,l=a.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=l.next()).done;)s.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(a=l.return)&&a.call(l)}finally{if(o)throw o.error}}return s}(t.useState((e.standardRegions||i).map(d)),2),w=D[0],b=D[1],A=e.loadRegions,E=e.onOptionsChange,C=e.skipHeader,I=void 0!==C&&C,x=e.skipEndpoint,S=void 0!==x&&x,K=e.options,R=K.jsonData.profile;void 0===R&&(R=K.database);var O=window.grafanaBootData.settings,T=null!==(s=O.awsAllowedAuthProviders)&&void 0!==s?s:[exports.AwsAuthType.Default,exports.AwsAuthType.Keys,exports.AwsAuthType.Credentials],j=null===(u=O.awsAssumeRoleEnabled)||void 0===u||u,N=r.find((function(e){return e.value===K.jsonData.authType}));return t.useEffect((function(){!N&&T.length&&E(l(l({},K),{jsonData:l(l({},K.jsonData),{authType:T[0]})}))}),[N,K,E]),t.useEffect((function(){A&&A().then((function(e){return b(e.map(d))}))}),[A]),a.createElement(n.FieldSet,{label:I?"":"Connection Details","data-testid":"connection-config"},a.createElement(n.InlineField,{label:"Authentication Provider",labelWidth:28,tooltip:"Specify which AWS credentials chain to use."},a.createElement(n.Select,{className:"width-30 aws-config-authType",value:N,options:r.filter((function(e){return T.includes(e.value)})),defaultValue:K.jsonData.authType,onChange:function(t){o.onUpdateDatasourceJsonDataOptionSelect(e,"authType")(t)}})),"credentials"===K.jsonData.authType&&a.createElement(n.InlineField,{label:"Credentials Profile Name",labelWidth:28,tooltip:"Credentials profile name, as specified in ~/.aws/credentials, leave blank for default."},a.createElement(n.Input,{className:"width-30",placeholder:"default",value:R,onChange:o.onUpdateDatasourceJsonDataOption(e,"profile")})),"keys"===K.jsonData.authType&&a.createElement(a.Fragment,null,a.createElement(n.InlineField,{label:"Access Key ID",labelWidth:28},(null===(p=e.options.secureJsonFields)||void 0===p?void 0:p.accessKey)?a.createElement(n.ButtonGroup,{className:"width-30"},a.createElement(n.Input,{disabled:!0,placeholder:"Configured"}),a.createElement(n.ToolbarButton,{icon:"edit",tooltip:"Edit Access Key ID",type:"button",onClick:o.onUpdateDatasourceResetOption(e,"accessKey")})):a.createElement(n.Input,{className:"width-30",value:null!==(f=null===(h=K.secureJsonData)||void 0===h?void 0:h.accessKey)&&void 0!==f?f:"",onChange:o.onUpdateDatasourceSecureJsonDataOption(e,"accessKey"),"aria-label":c.components.ConfigEditor.AccessKey.input})),a.createElement(n.InlineField,{label:"Secret Access Key",labelWidth:28},(null===(y=e.options.secureJsonFields)||void 0===y?void 0:y.secretKey)?a.createElement(n.ButtonGroup,{className:"width-30"},a.createElement(n.Input,{disabled:!0,placeholder:"Configured"}),a.createElement(n.ToolbarButton,{icon:"edit",type:"button",tooltip:"Edit Secret Access Key",onClick:o.onUpdateDatasourceResetOption(e,"secretKey")})):a.createElement(n.Input,{className:"width-30",value:null!==(v=null===(m=K.secureJsonData)||void 0===m?void 0:m.secretKey)&&void 0!==v?v:"",onChange:o.onUpdateDatasourceSecureJsonDataOption(e,"secretKey"),"aria-label":c.components.ConfigEditor.SecretKey.input}))),j&&a.createElement(a.Fragment,null,a.createElement(n.InlineField,{label:"Assume Role ARN",labelWidth:28,tooltip:"Optionally, specify the ARN of a role to assume. Specifying a role here will ensure that the selected authentication provider is used to assume the specified role rather than using the credentials directly. Leave blank if you don't need to assume a role at all"},a.createElement(n.Input,{className:"width-30",placeholder:"arn:aws:iam:*",value:K.jsonData.assumeRoleArn||"",onChange:o.onUpdateDatasourceJsonDataOption(e,"assumeRoleArn")})),a.createElement(n.InlineField,{label:"External ID",labelWidth:28,tooltip:"If you are assuming a role in another account, that has been created with an external ID, specify the external ID here."},a.createElement(n.Input,{className:"width-30",placeholder:"External ID",value:K.jsonData.externalId||"",onChange:o.onUpdateDatasourceJsonDataOption(e,"externalId")}))),!S&&a.createElement(n.InlineField,{label:"Endpoint",labelWidth:28,tooltip:"Optionally, specify a custom endpoint for the service"},a.createElement(n.Input,{className:"width-30",placeholder:null!==(g=e.defaultEndpoint)&&void 0!==g?g:"https://{service}.{region}.amazonaws.com",value:K.jsonData.endpoint||"",onChange:o.onUpdateDatasourceJsonDataOption(e,"endpoint")})),a.createElement(n.InlineField,{label:"Default Region",labelWidth:28,tooltip:"Specify the region, such as for US West (Oregon) use ` us-west-2 ` as the region."},a.createElement(n.Select,{className:"width-30 aws-config-defaultRegion",value:w.find((function(e){return e.value===K.jsonData.defaultRegion})),options:w,defaultValue:K.jsonData.defaultRegion,allowCustomValue:!0,onChange:o.onUpdateDatasourceJsonDataOptionSelect(e,"defaultRegion"),formatCreateLabel:function(e){return"Use region: "+e}})),e.children)},exports.awsAuthProviderOptions=r,exports.selectors=c,exports.standardRegions=i; | ||
Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),a=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,n=require("@grafana/ui"),l=require("@grafana/data"),o=require("lodash"),r=function(){return(r=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++)for(var l in t=arguments[a])Object.prototype.hasOwnProperty.call(t,l)&&(e[l]=t[l]);return e}).apply(this,arguments)};function i(e,t,a,n){return new(a||(a=Promise))((function(l,o){function r(e){try{u(n.next(e))}catch(e){o(e)}}function i(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?l(e.value):(t=e.value,t instanceof a?t:new a((function(e){e(t)}))).then(r,i)}u((n=n.apply(e,t||[])).next())}))}function u(e,t){var a,n,l,o,r={label:0,sent:function(){if(1&l[0])throw l[1];return l[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){return function(o){if(a)throw new TypeError("Generator is already executing.");for(;r;)try{if(a=1,n&&(l=2&o[0]?n.return:o[0]?n.throw||((l=n.return)&&l.call(n),0):n.next)&&!(l=l.call(n,o[1])).done)return l;switch(n=0,l&&(o=[2&o[0],l.value]),o[0]){case 0:case 1:l=o;break;case 4:return r.label++,{value:o[1],done:!1};case 5:r.label++,n=o[1],o=[0];continue;case 7:o=r.ops.pop(),r.trys.pop();continue;default:if(!(l=r.trys,(l=l.length>0&&l[l.length-1])||6!==o[0]&&2!==o[0])){r=0;continue}if(3===o[0]&&(!l||o[1]>l[0]&&o[1]<l[3])){r.label=o[1];break}if(6===o[0]&&r.label<l[1]){r.label=l[1],l=o;break}if(l&&r.label<l[2]){r.label=l[2],r.ops.push(o);break}l[2]&&r.ops.pop(),r.trys.pop();continue}o=t.call(e,r)}catch(e){o=[6,e],n=0}finally{a=l=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,i])}}}function s(e,t){var a="function"==typeof Symbol&&e[Symbol.iterator];if(!a)return e;var n,l,o=a.call(e),r=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)r.push(n.value)}catch(e){l={error:e}}finally{try{n&&!n.done&&(a=o.return)&&a.call(o)}finally{if(l)throw l.error}}return r}var c,d=["af-south-1","ap-east-1","ap-northeast-1","ap-northeast-2","ap-northeast-3","ap-south-1","ap-southeast-1","ap-southeast-2","ca-central-1","cn-north-1","cn-northwest-1","eu-central-1","eu-north-1","eu-west-1","eu-west-2","eu-west-3","me-south-1","sa-east-1","us-east-1","us-east-2","us-gov-east-1","us-gov-west-1","us-iso-east-1","us-isob-east-1","us-west-1","us-west-2"];(c=exports.AwsAuthType||(exports.AwsAuthType={})).Keys="keys",c.Credentials="credentials",c.Default="default",c.EC2IAMRole="ec2_iam_role",c.ARN="arn";var p,f=[{label:"Workspace IAM Role",value:exports.AwsAuthType.EC2IAMRole},{label:"AWS SDK Default",value:exports.AwsAuthType.Default},{label:"Access & secret key",value:exports.AwsAuthType.Keys},{label:"Credentials file",value:exports.AwsAuthType.Credentials}],h=function(e){return{value:e,label:e}};function v(e){var l=this,r=s(t.useState(e.value||e.default||null),2),c=r[0],d=r[1],p=s(t.useState(c?[c]:[]),2),f=p[0],h=p[1],v=s(t.useState(e.dependencies),2),m=v[0],b=v[1],y=s(t.useState(!1),2),g=y[0],w=y[1],E=s(t.useState(!1),2),D=E[0],S=E[1],C=t.useMemo((function(){var t=[{label:"default ("+e.default+")",value:"__default",description:"Default value set in the data source"}];return e.value&&"__default"!==e.value&&t.push({label:e.value,value:e.value}),t}),[e.default,e.value]),A=s(t.useState(e.default?C:[]),2),I=A[0],x=A[1];t.useEffect((function(){if(f.length){var t=e.default?C:[];f.forEach((function(e){var a="string"==typeof e?e:e.value;t.find((function(e){return e.value===a}))||("string"==typeof e?t.push({label:e,value:e}):t.push(e))})),x(t)}else x([])}),[f,C,e.default]),t.useEffect((function(){o.isEqual(e.dependencies,m)||(S(!1),h([]),d(null),e.onChange(null),b(e.dependencies))}),[e,m]);return a.createElement(n.InlineField,{label:e.label,labelWidth:e.labelWidth,tooltip:e.tooltip,hidden:e.hidden},a.createElement("div",{"data-testid":e["data-testid"],title:e.title},a.createElement(n.Select,{"aria-label":e.label,options:I,value:e.value,onChange:function(t){e.onChange(t),t.value&&d(t.value)},isLoading:g,className:e.className||"min-width-6",disabled:e.disabled,onOpenMenu:function(){return i(l,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:w(!0),t.label=1;case 1:return t.trys.push([1,,3,4]),[4,i(l,void 0,void 0,(function(){var t;return u(this,(function(a){switch(a.label){case 0:return D?[2]:e.saveOptions?[4,e.saveOptions()]:[3,2];case 1:a.sent(),a.label=2;case 2:return a.trys.push([2,,4,5]),[4,e.fetch()];case 3:return t=a.sent(),h(t),[3,5];case 4:return S(!0),[7];case 5:return[2]}}))}))];case 2:return t.sent(),[3,4];case 3:return w(!1),[7];case 4:return[2]}}))}))}})))}!function(e){e[e.Previous=0]="Previous",e[e.Null=1]="Null",e[e.Value=2]="Value"}(p||(p={}));var m=[{label:"Previous Value",value:p.Previous},{label:"NULL",value:p.Null},{label:"Value",value:p.Value}];function b(e){return"string"==typeof e?e:e.map((function(e){return function(e){return"'"+String(e).replace(/'/g,"''")+"'"}(e)})).join(",")}exports.ConfigSelect=function(e){var t=e.options.jsonData,n={title:t.defaultRegion?"":"select a default region",disabled:!t.defaultRegion,labelWidth:28,className:"width-30"},l=[e.options.jsonData.assumeRoleArn,e.options.jsonData.authType,e.options.jsonData.defaultRegion,e.options.jsonData.endpoint,e.options.jsonData.externalId,e.options.jsonData.profile].concat(e.dependencies);return a.createElement(v,r({label:e.label,"data-testid":e["data-testid"],onChange:e.onChange,fetch:e.fetch,value:e.value,saveOptions:e.saveOptions,dependencies:l,hidden:e.hidden,disabled:e.disabled},n))},exports.ConnectionConfig=function(e){var o,i,u,c,p,v,m,b,y,g=s(t.useState((e.standardRegions||d).map(h)),2),w=g[0],E=g[1],D=e.loadRegions,S=e.onOptionsChange,C=e.skipHeader,A=void 0!==C&&C,I=e.skipEndpoint,x=void 0!==I&&I,R=e.options,N=R.jsonData.profile;void 0===N&&(N=R.database);var F=window.grafanaBootData.settings,T=null!==(o=F.awsAllowedAuthProviders)&&void 0!==o?o:[exports.AwsAuthType.Default,exports.AwsAuthType.Keys,exports.AwsAuthType.Credentials],j=null===(i=F.awsAssumeRoleEnabled)||void 0===i||i,O=f.find((function(e){return e.value===R.jsonData.authType}));return t.useEffect((function(){!O&&T.length&&S(r(r({},R),{jsonData:r(r({},R.jsonData),{authType:T[0]})}))}),[O,R,S]),t.useEffect((function(){D&&D().then((function(e){return E(e.map(h))}))}),[D]),a.createElement(n.FieldSet,{label:A?"":"Connection Details","data-testid":"connection-config"},a.createElement(n.InlineField,{label:"Authentication Provider",labelWidth:28,tooltip:"Specify which AWS credentials chain to use."},a.createElement(n.Select,{className:"width-30",value:O,options:f.filter((function(e){return T.includes(e.value)})),defaultValue:R.jsonData.authType,onChange:function(t){l.onUpdateDatasourceJsonDataOptionSelect(e,"authType")(t)}})),"credentials"===R.jsonData.authType&&a.createElement(n.InlineField,{label:"Credentials Profile Name",labelWidth:28,tooltip:"Credentials profile name, as specified in ~/.aws/credentials, leave blank for default."},a.createElement(n.Input,{className:"width-30",placeholder:"default",value:N,onChange:l.onUpdateDatasourceJsonDataOption(e,"profile")})),"keys"===R.jsonData.authType&&a.createElement(a.Fragment,null,a.createElement(n.InlineField,{label:"Access Key ID",labelWidth:28},(null===(u=e.options.secureJsonFields)||void 0===u?void 0:u.accessKey)?a.createElement(n.ButtonGroup,{className:"width-30"},a.createElement(n.Input,{disabled:!0,placeholder:"Configured"}),a.createElement(n.ToolbarButton,{icon:"edit",tooltip:"Edit Access Key ID",type:"button",onClick:l.onUpdateDatasourceResetOption(e,"accessKey")})):a.createElement(n.Input,{className:"width-30",value:null!==(p=null===(c=R.secureJsonData)||void 0===c?void 0:c.accessKey)&&void 0!==p?p:"",onChange:l.onUpdateDatasourceSecureJsonDataOption(e,"accessKey")})),a.createElement(n.InlineField,{label:"Secret Access Key",labelWidth:28},(null===(v=e.options.secureJsonFields)||void 0===v?void 0:v.secretKey)?a.createElement(n.ButtonGroup,{className:"width-30"},a.createElement(n.Input,{disabled:!0,placeholder:"Configured"}),a.createElement(n.ToolbarButton,{icon:"edit",type:"button",tooltip:"Edit Secret Access Key",onClick:l.onUpdateDatasourceResetOption(e,"secretKey")})):a.createElement(n.Input,{className:"width-30",value:null!==(b=null===(m=R.secureJsonData)||void 0===m?void 0:m.secretKey)&&void 0!==b?b:"",onChange:l.onUpdateDatasourceSecureJsonDataOption(e,"secretKey")}))),j&&a.createElement(a.Fragment,null,a.createElement(n.InlineField,{label:"Assume Role ARN",labelWidth:28,tooltip:"Optionally, specify the ARN of a role to assume. Specifying a role here will ensure that the selected authentication provider is used to assume the specified role rather than using the credentials directly. Leave blank if you don't need to assume a role at all"},a.createElement(n.Input,{className:"width-30",placeholder:"arn:aws:iam:*",value:R.jsonData.assumeRoleArn||"",onChange:l.onUpdateDatasourceJsonDataOption(e,"assumeRoleArn")})),a.createElement(n.InlineField,{label:"External ID",labelWidth:28,tooltip:"If you are assuming a role in another account, that has been created with an external ID, specify the external ID here."},a.createElement(n.Input,{className:"width-30",placeholder:"External ID",value:R.jsonData.externalId||"",onChange:l.onUpdateDatasourceJsonDataOption(e,"externalId")}))),!x&&a.createElement(n.InlineField,{label:"Endpoint",labelWidth:28,tooltip:"Optionally, specify a custom endpoint for the service"},a.createElement(n.Input,{className:"width-30",placeholder:null!==(y=e.defaultEndpoint)&&void 0!==y?y:"https://{service}.{region}.amazonaws.com",value:R.jsonData.endpoint||"",onChange:l.onUpdateDatasourceJsonDataOption(e,"endpoint")})),a.createElement(n.InlineField,{label:"Default Region",labelWidth:28,tooltip:"Specify the region, such as for US West (Oregon) use ` us-west-2 ` as the region."},a.createElement(n.Select,{className:"width-30",value:w.find((function(e){return e.value===R.jsonData.defaultRegion})),options:w,defaultValue:R.jsonData.defaultRegion,allowCustomValue:!0,onChange:l.onUpdateDatasourceJsonDataOptionSelect(e,"defaultRegion"),formatCreateLabel:function(e){return"Use region: "+e}})),e.children)},exports.FillValueSelect=function(e){var t,l,o;return a.createElement(a.Fragment,null,a.createElement(n.InlineField,{label:"Fill value",tooltip:"value to fill missing points"},a.createElement(n.Select,{"aria-label":"Fill value",options:m,value:null!==(l=null===(t=e.query.fillMode)||void 0===t?void 0:t.mode)&&void 0!==l?l:p.Previous,onChange:function(t){var a=t.value;e.onChange(r(r({},e.query),{fillMode:r(r({},e.query.fillMode),{mode:a})})),e.onRunQuery()},className:"width-12"})),(null===(o=e.query.fillMode)||void 0===o?void 0:o.mode)===p.Value&&a.createElement(n.InlineField,{label:"Value",labelWidth:11},a.createElement(n.Input,{type:"number","aria-label":"Value",value:e.query.fillMode.value,onChange:function(t){var a=t.currentTarget;return e.onChange(r(r({},e.query),{fillMode:{mode:p.Value,value:a.valueAsNumber}}))},onBlur:function(){return e.onRunQuery()}})))},exports.FormatSelect=function(e){return a.createElement(n.InlineField,{label:"Format as",labelWidth:11},a.createElement(n.Select,{"aria-label":"Format as",options:e.options,value:e.query.format,onChange:function(t){e.onChange(r(r({},e.query),{format:t.value||0})),e.onRunQuery()},className:"width-12"}))},exports.InlineInput=function(e){return a.createElement(n.InlineField,{label:e.label,labelWidth:28,tooltip:e.tooltip,hidden:e.hidden,disabled:e.disabled},a.createElement(n.Input,{"data-testid":e["data-testid"],className:"width-30",value:e.value,onChange:e.onChange,placeholder:e.placeholder,disabled:e.disabled}))},exports.QueryCodeEditor=function(e){var l=e.getSuggestions,i=e.getTemplateSrv,u=e.query,s=o.defaults(e.query,{rawSQL:""}).rawSQL,c=t.useRef([]);return t.useEffect((function(){c.current=l(i(),u)}),[l,i,u]),a.createElement(n.CodeEditor,r({language:e.language,value:s,onBlur:function(t){var a=r(r({},e.query),{rawSQL:t});e.onChange(a),e.onRunQuery()},showMiniMap:!1,showLineNumbers:!0,getSuggestions:function(){return c.current},height:"240px"},e.editorProps))},exports.ResourceSelector=v,exports.appendTemplateVariablesAsSuggestions=function(e,t){var a=e(),l=[];return a.getVariables().forEach((function(e){var t="$"+e.name,o=a.replace(t);o===t&&(o=""),l.push({label:t,kind:n.CodeEditorSuggestionItemKind.Text,detail:"(Template Variable) "+o})})),t.concat(l)},exports.applySQLTemplateVariables=function(e,t,a){var n=a();return r(r({},e),{rawSQL:n.replace(e.rawSQL,t,b)})},exports.awsAuthProviderOptions=f,exports.filterSQLQuery=function(e){return!!e.rawSQL},exports.standardRegions=d; | ||
//# sourceMappingURL=index.production.js.map |
@@ -1,2 +0,2 @@ | ||
import { DataSourceJsonData } from '@grafana/data'; | ||
import { DataSourceJsonData, DataSourceSettings } from '@grafana/data'; | ||
export declare enum AwsAuthType { | ||
@@ -23,2 +23,4 @@ Keys = "keys", | ||
secretKey?: string; | ||
sessionToken?: string; | ||
} | ||
export declare type AwsAuthDataSourceSettings = DataSourceSettings<AwsAuthDataSourceJsonData, AwsAuthDataSourceSecureJsonData>; |
{ | ||
"name": "@grafana/aws-sdk", | ||
"version": "0.0.31", | ||
"version": "0.0.32-pre.1", | ||
"description": "Common AWS features for grafana", | ||
@@ -13,3 +13,4 @@ "main": "dist/index.js", | ||
"publish": "npm publish --access=public --scope=grafana", | ||
"test": "jest --notify --watch" | ||
"test": "jest --notify --watch", | ||
"test-ci": "grafana-toolkit plugin:test" | ||
}, | ||
@@ -20,3 +21,3 @@ "files": [ | ||
], | ||
"repository": "github:grafana/grafana-aws-sdk", | ||
"repository": "github:grafana/grafana-aws-sdk-react", | ||
"author": "Grafana Labs <team@grafana.com> (https://grafanap.com)", | ||
@@ -29,7 +30,6 @@ "license": "Apache-2.0", | ||
"@babel/preset-typescript": "^7.13.0", | ||
"@grafana/data": "^7.5.0", | ||
"@grafana/e2e-selectors": "^7.5.4", | ||
"@grafana/toolkit": "^7.5.1", | ||
"@grafana/data": "^8.2.1", | ||
"@grafana/toolkit": "^8.2.1", | ||
"@grafana/tsconfig": "^1.0.0-rc1", | ||
"@grafana/ui": "^7.5.0", | ||
"@grafana/ui": "^8.2.1", | ||
"@rollup/plugin-commonjs": "11.0.2", | ||
@@ -54,2 +54,3 @@ "@rollup/plugin-json": "4.0.3", | ||
"pretty-format": "25.1.0", | ||
"react-select-event": "^5.3.0", | ||
"react-test-renderer": "^17.0.2", | ||
@@ -56,0 +57,0 @@ "rimraf": "^3.0.2", |
@@ -5,11 +5,14 @@ # Grafana AWS SDK | ||
## Frontend configuration | ||
## Backend plugins (go sdk) | ||
see the ./src folder | ||
see the ./pkg folder | ||
| | ||
## Drone configuration | ||
## Frontend configuration | ||
Drone signs the Drone configuration file. This needs to be run everytime the drone.yml file is modified. See https://github.com/grafana/deployment_tools/blob/master/docs/infrastructure/drone/signing.md for more info. | ||
see the ./src folder | ||
To update the drone file run (note that you need to export your `DRONE_TOKEN` before): | ||
``` | ||
drone --server https://drone.grafana.net sign --save grafana/grafana-aws-sdk-react | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
129795
35
681
18
3