@grafana/aws-sdk
Advanced tools
Comparing version 0.0.32 to 0.0.33
@@ -5,3 +5,3 @@ export { ConnectionConfig, ConnectionConfigProps } from './ConnectionConfig'; | ||
export { SQLQuery } from './sql/types'; | ||
export { QueryCodeEditor, FormatSelect, FillValueSelect } from './sql/QueryEditor'; | ||
export { QueryCodeEditor, FormatSelect, FillValueSelect, FillValueOptions } from './sql/QueryEditor'; | ||
export * from './sql/utils'; | ||
@@ -8,0 +8,0 @@ export * from './types'; |
@@ -365,3 +365,2 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
var FillValueOptions; | ||
(function (FillValueOptions) { | ||
@@ -371,15 +370,15 @@ FillValueOptions[FillValueOptions["Previous"] = 0] = "Previous"; | ||
FillValueOptions[FillValueOptions["Value"] = 2] = "Value"; | ||
})(FillValueOptions || (FillValueOptions = {})); | ||
})(exports.FillValueOptions || (exports.FillValueOptions = {})); | ||
var SelectableFillValueOptions = [ | ||
{ | ||
label: 'Previous Value', | ||
value: FillValueOptions.Previous, | ||
value: exports.FillValueOptions.Previous, | ||
}, | ||
{ | ||
label: 'NULL', | ||
value: FillValueOptions.Null, | ||
value: exports.FillValueOptions.Null, | ||
}, | ||
{ | ||
label: 'Value', | ||
value: FillValueOptions.Value, | ||
value: exports.FillValueOptions.Value, | ||
}, | ||
@@ -391,3 +390,3 @@ ]; | ||
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) { | ||
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 : exports.FillValueOptions.Previous, onChange: function (_a) { | ||
var value = _a.value; | ||
@@ -399,7 +398,7 @@ props.onChange(__assign(__assign({}, props.query), { | ||
}, 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 }, | ||
((_c = props.query.fillMode) === null || _c === void 0 ? void 0 : _c.mode) === exports.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, | ||
mode: exports.FillValueOptions.Value, | ||
value: currentTarget.valueAsNumber, | ||
@@ -406,0 +405,0 @@ } })); |
@@ -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"),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),b=v[0],m=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],A=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]),C=s(t.useState(e.default?A:[]),2),I=C[0],x=C[1];t.useEffect((function(){if(f.length){var t=e.default?A:[];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,A,e.default]),t.useEffect((function(){o.isEqual(e.dependencies,b)||(S(!1),h([]),d(null),e.onChange(null),m(e.dependencies))}),[e,b]);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 b=[{label:"Previous Value",value:p.Previous},{label:"NULL",value:p.Null},{label:"Value",value:p.Value}];function m(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,b,m,y,g=s(t.useState((e.standardRegions||d).map(h)),2),w=g[0],E=g[1],D=e.loadRegions,S=e.onOptionsChange,A=e.skipHeader,C=void 0!==A&&A,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,j=null!==(o=F.awsAllowedAuthProviders)&&void 0!==o?o:[exports.AwsAuthType.Default,exports.AwsAuthType.Keys,exports.AwsAuthType.Credentials],O=null===(i=F.awsAssumeRoleEnabled)||void 0===i||i,T=f.find((function(e){return e.value===R.jsonData.authType}));return t.useEffect((function(){!T&&j.length&&S(r(r({},R),{jsonData:r(r({},R.jsonData),{authType:j[0]})}))}),[T,R,S]),t.useEffect((function(){D&&D().then((function(e){return E(e.map(h))}))}),[D]),a.createElement(n.FieldSet,{label:C?"":"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,{"aria-label":"Authentication Provider",className:"width-30",value:T,options:f.filter((function(e){return j.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,{"aria-label":"Credentials Profile Name",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,{"aria-label":"Access Key ID",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,{"aria-label":"Secret Access Key",className:"width-30",value:null!==(m=null===(b=R.secureJsonData)||void 0===b?void 0:b.secretKey)&&void 0!==m?m:"",onChange:l.onUpdateDatasourceSecureJsonDataOption(e,"secretKey")}))),O&&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,{"aria-label":"Assume Role ARN",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,{"aria-label":"External ID",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,{"aria-label":"Endpoint",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,{"aria-label":"Default Region",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:b,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.query,u=o.defaults(e.query,{rawSQL:""}).rawSQL,s=t.useRef([]);return t.useEffect((function(){s.current=l(i)}),[l,i]),a.createElement(n.CodeEditor,r({language:e.language,value:u,onBlur:function(t){var a=r(r({},e.query),{rawSQL:t});e.onChange(a),e.onRunQuery()},showMiniMap:!1,showLineNumbers:!0,getSuggestions:function(){return s.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,m)})},exports.awsAuthProviderOptions=f,exports.filterSQLQuery=function(e){return!!e.rawSQL},exports.standardRegions=d; | ||
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{s(n.next(e))}catch(e){o(e)}}function i(e){try{s(n.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?l(e.value):(t=e.value,t instanceof a?t:new a((function(e){e(t)}))).then(r,i)}s((n=n.apply(e,t||[])).next())}))}function s(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 u(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=u(t.useState(e.value||e.default||null),2),c=r[0],d=r[1],p=u(t.useState(c?[c]:[]),2),f=p[0],h=p[1],v=u(t.useState(e.dependencies),2),b=v[0],m=v[1],y=u(t.useState(!1),2),g=y[0],w=y[1],E=u(t.useState(!1),2),D=E[0],S=E[1],A=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]),x=u(t.useState(e.default?A:[]),2),C=x[0],I=x[1];t.useEffect((function(){if(f.length){var t=e.default?A:[];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))})),I(t)}else I([])}),[f,A,e.default]),t.useEffect((function(){o.isEqual(e.dependencies,b)||(S(!1),h([]),d(null),e.onChange(null),m(e.dependencies))}),[e,b]);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:C,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 s(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 s(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]}}))}))}})))}(p=exports.FillValueOptions||(exports.FillValueOptions={}))[p.Previous=0]="Previous",p[p.Null=1]="Null",p[p.Value=2]="Value";var b=[{label:"Previous Value",value:exports.FillValueOptions.Previous},{label:"NULL",value:exports.FillValueOptions.Null},{label:"Value",value:exports.FillValueOptions.Value}];function m(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,s,c,p,v,b,m,y,g=u(t.useState((e.standardRegions||d).map(h)),2),w=g[0],E=g[1],D=e.loadRegions,S=e.onOptionsChange,A=e.skipHeader,x=void 0!==A&&A,C=e.skipEndpoint,I=void 0!==C&&C,F=e.options,O=F.jsonData.profile;void 0===O&&(O=F.database);var R=window.grafanaBootData.settings,N=null!==(o=R.awsAllowedAuthProviders)&&void 0!==o?o:[exports.AwsAuthType.Default,exports.AwsAuthType.Keys,exports.AwsAuthType.Credentials],V=null===(i=R.awsAssumeRoleEnabled)||void 0===i||i,j=f.find((function(e){return e.value===F.jsonData.authType}));return t.useEffect((function(){!j&&N.length&&S(r(r({},F),{jsonData:r(r({},F.jsonData),{authType:N[0]})}))}),[j,F,S]),t.useEffect((function(){D&&D().then((function(e){return E(e.map(h))}))}),[D]),a.createElement(n.FieldSet,{label:x?"":"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,{"aria-label":"Authentication Provider",className:"width-30",value:j,options:f.filter((function(e){return N.includes(e.value)})),defaultValue:F.jsonData.authType,onChange:function(t){l.onUpdateDatasourceJsonDataOptionSelect(e,"authType")(t)}})),"credentials"===F.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,{"aria-label":"Credentials Profile Name",className:"width-30",placeholder:"default",value:O,onChange:l.onUpdateDatasourceJsonDataOption(e,"profile")})),"keys"===F.jsonData.authType&&a.createElement(a.Fragment,null,a.createElement(n.InlineField,{label:"Access Key ID",labelWidth:28},(null===(s=e.options.secureJsonFields)||void 0===s?void 0:s.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,{"aria-label":"Access Key ID",className:"width-30",value:null!==(p=null===(c=F.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,{"aria-label":"Secret Access Key",className:"width-30",value:null!==(m=null===(b=F.secureJsonData)||void 0===b?void 0:b.secretKey)&&void 0!==m?m:"",onChange:l.onUpdateDatasourceSecureJsonDataOption(e,"secretKey")}))),V&&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,{"aria-label":"Assume Role ARN",className:"width-30",placeholder:"arn:aws:iam:*",value:F.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,{"aria-label":"External ID",className:"width-30",placeholder:"External ID",value:F.jsonData.externalId||"",onChange:l.onUpdateDatasourceJsonDataOption(e,"externalId")}))),!I&&a.createElement(n.InlineField,{label:"Endpoint",labelWidth:28,tooltip:"Optionally, specify a custom endpoint for the service"},a.createElement(n.Input,{"aria-label":"Endpoint",className:"width-30",placeholder:null!==(y=e.defaultEndpoint)&&void 0!==y?y:"https://{service}.{region}.amazonaws.com",value:F.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,{"aria-label":"Default Region",className:"width-30",value:w.find((function(e){return e.value===F.jsonData.defaultRegion})),options:w,defaultValue:F.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:b,value:null!==(l=null===(t=e.query.fillMode)||void 0===t?void 0:t.mode)&&void 0!==l?l:exports.FillValueOptions.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)===exports.FillValueOptions.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:exports.FillValueOptions.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.query,s=o.defaults(e.query,{rawSQL:""}).rawSQL,u=t.useRef([]);return t.useEffect((function(){u.current=l(i)}),[l,i]),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 u.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,m)})},exports.awsAuthProviderOptions=f,exports.filterSQLQuery=function(e){return!!e.rawSQL},exports.standardRegions=d; | ||
//# sourceMappingURL=index.production.js.map |
export { QueryCodeEditor } from './QueryCodeEditor'; | ||
export { FormatSelect } from './FormatSelect'; | ||
export { FillValueSelect } from './FillValueSelect'; | ||
export { FillValueSelect, FillValueOptions } from './FillValueSelect'; |
{ | ||
"name": "@grafana/aws-sdk", | ||
"version": "0.0.32", | ||
"version": "0.0.33", | ||
"description": "Common AWS features for grafana", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
130962