@looker/extension-utils 0.1.12 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -1
- package/lib/APIErrorDisplay/APIErrorContent.d.ts +3 -0
- package/lib/APIErrorDisplay/APIErrorContent.js +64 -0
- package/lib/APIErrorDisplay/APIErrorContent.js.map +1 -0
- package/lib/APIErrorDisplay/APIErrorDetails.d.ts +7 -0
- package/lib/APIErrorDisplay/APIErrorDetails.js +44 -0
- package/lib/APIErrorDisplay/APIErrorDetails.js.map +1 -0
- package/lib/APIErrorDisplay/APIErrorDialog.d.ts +8 -0
- package/lib/APIErrorDisplay/APIErrorDialog.js +41 -0
- package/lib/APIErrorDisplay/APIErrorDialog.js.map +1 -0
- package/lib/APIErrorDisplay/APIErrorDisplay.d.ts +7 -0
- package/lib/APIErrorDisplay/APIErrorDisplay.js +32 -0
- package/lib/APIErrorDisplay/APIErrorDisplay.js.map +1 -0
- package/lib/APIErrorDisplay/APIErrorDocLink.d.ts +6 -0
- package/lib/APIErrorDisplay/APIErrorDocLink.js +36 -0
- package/lib/APIErrorDisplay/APIErrorDocLink.js.map +1 -0
- package/lib/APIErrorDisplay/index.d.ts +3 -0
- package/lib/APIErrorDisplay/index.js +45 -0
- package/lib/APIErrorDisplay/index.js.map +1 -0
- package/lib/APIErrorDisplay/utils.d.ts +3 -0
- package/lib/APIErrorDisplay/utils.js +37 -0
- package/lib/APIErrorDisplay/utils.js.map +1 -0
- package/lib/ExtMarkdown.d.ts +12 -0
- package/lib/ExtMarkdown.js +40 -0
- package/lib/ExtMarkdown.js.map +1 -0
- package/lib/adaptorUtils.d.ts +4 -0
- package/lib/adaptorUtils.js.map +1 -1
- package/lib/browserAdaptor.d.ts +1 -0
- package/lib/browserAdaptor.js +6 -0
- package/lib/browserAdaptor.js.map +1 -1
- package/lib/esm/APIErrorDisplay/APIErrorContent.js +44 -0
- package/lib/esm/APIErrorDisplay/APIErrorContent.js.map +1 -0
- package/lib/esm/APIErrorDisplay/APIErrorDetails.js +31 -0
- package/lib/esm/APIErrorDisplay/APIErrorDetails.js.map +1 -0
- package/lib/esm/APIErrorDisplay/APIErrorDialog.js +26 -0
- package/lib/esm/APIErrorDisplay/APIErrorDialog.js.map +1 -0
- package/lib/esm/APIErrorDisplay/APIErrorDisplay.js +17 -0
- package/lib/esm/APIErrorDisplay/APIErrorDisplay.js.map +1 -0
- package/lib/esm/APIErrorDisplay/APIErrorDocLink.js +22 -0
- package/lib/esm/APIErrorDisplay/APIErrorDocLink.js.map +1 -0
- package/lib/esm/APIErrorDisplay/index.js +4 -0
- package/lib/esm/APIErrorDisplay/index.js.map +1 -0
- package/lib/esm/APIErrorDisplay/utils.js +25 -0
- package/lib/esm/APIErrorDisplay/utils.js.map +1 -0
- package/lib/esm/ExtMarkdown.js +26 -0
- package/lib/esm/ExtMarkdown.js.map +1 -0
- package/lib/esm/adaptorUtils.js.map +1 -1
- package/lib/esm/browserAdaptor.js +6 -0
- package/lib/esm/browserAdaptor.js.map +1 -1
- package/lib/esm/extensionAdaptor.js +29 -6
- package/lib/esm/extensionAdaptor.js.map +1 -1
- package/lib/esm/index.js +2 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/extensionAdaptor.d.ts +4 -0
- package/lib/extensionAdaptor.js +29 -6
- package/lib/extensionAdaptor.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +26 -0
- package/lib/index.js.map +1 -1
- package/package.json +9 -6
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
2
|
+
|
|
3
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
4
|
+
|
|
5
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
6
|
+
import { ErrorDoc } from '@looker/sdk-rtl';
|
|
7
|
+
import { getEnvAdaptor } from '../adaptorUtils';
|
|
8
|
+
import { ExtMarkdown } from '../ExtMarkdown';
|
|
9
|
+
import { APIErrorDetails } from './APIErrorDetails';
|
|
10
|
+
import { APIErrorDocLink } from './APIErrorDocLink';
|
|
11
|
+
import { apiErrorDisplayFetch } from './utils';
|
|
12
|
+
export var APIErrorContent = _ref => {
|
|
13
|
+
var _error$documentation_;
|
|
14
|
+
|
|
15
|
+
var {
|
|
16
|
+
error,
|
|
17
|
+
showDoc
|
|
18
|
+
} = _ref;
|
|
19
|
+
var [doc, setDoc] = useState('');
|
|
20
|
+
var getDoc = useCallback(function () {
|
|
21
|
+
var _ref2 = _asyncToGenerator(function* (docUrl) {
|
|
22
|
+
var adaptor = getEnvAdaptor();
|
|
23
|
+
var errDoc = new ErrorDoc(adaptor.sdk, apiErrorDisplayFetch);
|
|
24
|
+
setDoc(yield errDoc.content(docUrl));
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return function (_x) {
|
|
28
|
+
return _ref2.apply(this, arguments);
|
|
29
|
+
};
|
|
30
|
+
}(), [error]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (showDoc && error && error.documentation_url) {
|
|
33
|
+
getDoc(error.documentation_url);
|
|
34
|
+
}
|
|
35
|
+
}, [error, showDoc]);
|
|
36
|
+
return React.createElement(React.Fragment, null, React.createElement(APIErrorDetails, {
|
|
37
|
+
error: error
|
|
38
|
+
}), !showDoc && React.createElement(APIErrorDocLink, {
|
|
39
|
+
docUrl: (_error$documentation_ = error.documentation_url) !== null && _error$documentation_ !== void 0 ? _error$documentation_ : ''
|
|
40
|
+
}), showDoc && doc && React.createElement(ExtMarkdown, {
|
|
41
|
+
source: doc
|
|
42
|
+
}));
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=APIErrorContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/APIErrorDisplay/APIErrorContent.tsx"],"names":["React","useCallback","useEffect","useState","ErrorDoc","getEnvAdaptor","ExtMarkdown","APIErrorDetails","APIErrorDocLink","apiErrorDisplayFetch","APIErrorContent","error","showDoc","doc","setDoc","getDoc","docUrl","adaptor","errDoc","sdk","content","documentation_url"],"mappings":";;;;AA0BA,OAAOA,KAAP,IAAgBC,WAAhB,EAA6BC,SAA7B,EAAwCC,QAAxC,QAAwD,OAAxD;AACA,SAASC,QAAT,QAAyB,iBAAzB;AACA,SAASC,aAAT,QAA8B,iBAA9B;AACA,SAASC,WAAT,QAA4B,gBAA5B;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,eAAT,QAAgC,mBAAhC;AAEA,SAASC,oBAAT,QAAqC,SAArC;AAOA,OAAO,IAAMC,eAAe,GAAG,QAA8C;AAAA;;AAAA,MAA7C;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,GAA6C;AAC3E,MAAM,CAACC,GAAD,EAAMC,MAAN,IAAgBX,QAAQ,CAAS,EAAT,CAA9B;AACA,MAAMY,MAAM,GAAGd,WAAW;AAAA,kCACxB,WAAOe,MAAP,EAA0B;AACxB,UAAMC,OAAO,GAAGZ,aAAa,EAA7B;AACA,UAAMa,MAAM,GAAG,IAAId,QAAJ,CAAaa,OAAO,CAACE,GAArB,EAA0BV,oBAA1B,CAAf;AACAK,MAAAA,MAAM,OAAOI,MAAM,CAACE,OAAP,CAAeJ,MAAf,CAAP,CAAN;AACD,KALuB;;AAAA;AAAA;AAAA;AAAA,OAMxB,CAACL,KAAD,CANwB,CAA1B;AASAT,EAAAA,SAAS,CAAC,MAAM;AACd,QAAIU,OAAO,IAAID,KAAX,IAAoBA,KAAK,CAACU,iBAA9B,EAAiD;AAC/CN,MAAAA,MAAM,CAACJ,KAAK,CAACU,iBAAP,CAAN;AACD;AACF,GAJQ,EAIN,CAACV,KAAD,EAAQC,OAAR,CAJM,CAAT;AAMA,SACE,0CACE,oBAAC,eAAD;AAAiB,IAAA,KAAK,EAAED;AAAxB,IADF,EAEG,CAACC,OAAD,IAAY,oBAAC,eAAD;AAAiB,IAAA,MAAM,2BAAED,KAAK,CAACU,iBAAR,yEAA6B;AAApD,IAFf,EAGGT,OAAO,IAAIC,GAAX,IAAkB,oBAAC,WAAD;AAAa,IAAA,MAAM,EAAEA;AAArB,IAHrB,CADF;AAOD,CAxBM","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2022 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport React, { useCallback, useEffect, useState } from 'react'\nimport { ErrorDoc } from '@looker/sdk-rtl'\nimport { getEnvAdaptor } from '../adaptorUtils'\nimport { ExtMarkdown } from '../ExtMarkdown'\nimport { APIErrorDetails } from './APIErrorDetails'\nimport { APIErrorDocLink } from './APIErrorDocLink'\nimport type { APIErrorDisplayProps } from './APIErrorDisplay'\nimport { apiErrorDisplayFetch } from './utils'\n\n/**\n * Shows available content of an API Error response\n * @param error to display\n * @param showDoc true to retrieve the corresponding error markdown\n */\nexport const APIErrorContent = ({ error, showDoc }: APIErrorDisplayProps) => {\n const [doc, setDoc] = useState<string>('')\n const getDoc = useCallback(\n async (docUrl: string) => {\n const adaptor = getEnvAdaptor()\n const errDoc = new ErrorDoc(adaptor.sdk, apiErrorDisplayFetch)\n setDoc(await errDoc.content(docUrl))\n },\n [error]\n )\n\n useEffect(() => {\n if (showDoc && error && error.documentation_url) {\n getDoc(error.documentation_url)\n }\n }, [error, showDoc])\n\n return (\n <>\n <APIErrorDetails error={error} />\n {!showDoc && <APIErrorDocLink docUrl={error.documentation_url ?? ''} />}\n {showDoc && doc && <ExtMarkdown source={doc} />}\n </>\n )\n}\n"],"file":"APIErrorContent.js"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Span, Table, TableBody, TableDataCell, TableHead, TableHeaderCell, TableRow } from '@looker/components';
|
|
3
|
+
export var APIErrorDetails = _ref => {
|
|
4
|
+
var {
|
|
5
|
+
error
|
|
6
|
+
} = _ref;
|
|
7
|
+
if (!(error !== null && error !== void 0 && error.errors)) return React.createElement(React.Fragment, null);
|
|
8
|
+
return React.createElement(Table, null, React.createElement(TableHead, null, React.createElement(TableRow, null, React.createElement(TableHeaderCell, {
|
|
9
|
+
p: "xsmall"
|
|
10
|
+
}, "Field"), React.createElement(TableHeaderCell, {
|
|
11
|
+
p: "xsmall"
|
|
12
|
+
}, "Code"), React.createElement(TableHeaderCell, {
|
|
13
|
+
p: "xsmall"
|
|
14
|
+
}, "Message"))), React.createElement(TableBody, null, error.errors.map((_ref2, index) => {
|
|
15
|
+
var {
|
|
16
|
+
field,
|
|
17
|
+
code,
|
|
18
|
+
message
|
|
19
|
+
} = _ref2;
|
|
20
|
+
return React.createElement(TableRow, {
|
|
21
|
+
key: "".concat(field).concat(index)
|
|
22
|
+
}, React.createElement(TableDataCell, {
|
|
23
|
+
p: "xsmall"
|
|
24
|
+
}, field), React.createElement(TableDataCell, {
|
|
25
|
+
p: "xsmall"
|
|
26
|
+
}, code), React.createElement(TableDataCell, {
|
|
27
|
+
p: "xsmall"
|
|
28
|
+
}, React.createElement(Span, null, message)));
|
|
29
|
+
})));
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=APIErrorDetails.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/APIErrorDisplay/APIErrorDetails.tsx"],"names":["React","Span","Table","TableBody","TableDataCell","TableHead","TableHeaderCell","TableRow","APIErrorDetails","error","errors","map","index","field","code","message"],"mappings":"AA2BA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SACEC,IADF,EAEEC,KAFF,EAGEC,SAHF,EAIEC,aAJF,EAKEC,SALF,EAMEC,eANF,EAOEC,QAPF,QAQO,oBARP;AAsBA,OAAO,IAAMC,eAAe,GAAG,QAAqC;AAAA,MAApC;AAAEC,IAAAA;AAAF,GAAoC;AAClE,MAAI,EAACA,KAAD,aAACA,KAAD,eAACA,KAAK,CAAEC,MAAR,CAAJ,EAAoB,OAAO,yCAAP;AAEpB,SACE,oBAAC,KAAD,QACE,oBAAC,SAAD,QACE,oBAAC,QAAD,QACE,oBAAC,eAAD;AAAiB,IAAA,CAAC,EAAC;AAAnB,aADF,EAEE,oBAAC,eAAD;AAAiB,IAAA,CAAC,EAAC;AAAnB,YAFF,EAGE,oBAAC,eAAD;AAAiB,IAAA,CAAC,EAAC;AAAnB,eAHF,CADF,CADF,EAQE,oBAAC,SAAD,QACGD,KAAK,CAACC,MAAN,CAAaC,GAAb,CAAiB,QAA2BC,KAA3B;AAAA,QAAC;AAAEC,MAAAA,KAAF;AAASC,MAAAA,IAAT;AAAeC,MAAAA;AAAf,KAAD;AAAA,WAChB,oBAAC,QAAD;AAAU,MAAA,GAAG,YAAKF,KAAL,SAAaD,KAAb;AAAb,OACE,oBAAC,aAAD;AAAe,MAAA,CAAC,EAAC;AAAjB,OAA2BC,KAA3B,CADF,EAEE,oBAAC,aAAD;AAAe,MAAA,CAAC,EAAC;AAAjB,OAA2BC,IAA3B,CAFF,EAGE,oBAAC,aAAD;AAAe,MAAA,CAAC,EAAC;AAAjB,OACE,oBAAC,IAAD,QAAOC,OAAP,CADF,CAHF,CADgB;AAAA,GAAjB,CADH,CARF,CADF;AAsBD,CAzBM","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2022 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { LookerSDKError } from '@looker/sdk-rtl'\nimport React from 'react'\nimport {\n Span,\n Table,\n TableBody,\n TableDataCell,\n TableHead,\n TableHeaderCell,\n TableRow,\n} from '@looker/components'\n\ninterface APIErrorDetailsProps {\n error: LookerSDKError\n}\n\n/**\n * Shows the detailed API errors table\n *\n * Because documentation_url is currently identical with the main documentation_url\n * it is not included in the table\n *\n * @param error to display\n */\nexport const APIErrorDetails = ({ error }: APIErrorDetailsProps) => {\n if (!error?.errors) return <></>\n\n return (\n <Table>\n <TableHead>\n <TableRow>\n <TableHeaderCell p=\"xsmall\">Field</TableHeaderCell>\n <TableHeaderCell p=\"xsmall\">Code</TableHeaderCell>\n <TableHeaderCell p=\"xsmall\">Message</TableHeaderCell>\n </TableRow>\n </TableHead>\n <TableBody>\n {error.errors.map(({ field, code, message }, index) => (\n <TableRow key={`${field}${index}`}>\n <TableDataCell p=\"xsmall\">{field}</TableDataCell>\n <TableDataCell p=\"xsmall\">{code}</TableDataCell>\n <TableDataCell p=\"xsmall\">\n <Span>{message}</Span>\n </TableDataCell>\n </TableRow>\n ))}\n </TableBody>\n </Table>\n )\n}\n"],"file":"APIErrorDetails.js"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button, Dialog, DialogLayout } from '@looker/components';
|
|
3
|
+
import { APIErrorContent } from './APIErrorContent';
|
|
4
|
+
import { errorHeading } from './utils';
|
|
5
|
+
export var APIErrorDialog = _ref => {
|
|
6
|
+
var {
|
|
7
|
+
error,
|
|
8
|
+
isOpen,
|
|
9
|
+
setOpen,
|
|
10
|
+
showDoc = false
|
|
11
|
+
} = _ref;
|
|
12
|
+
return React.createElement(Dialog, {
|
|
13
|
+
isOpen: isOpen,
|
|
14
|
+
content: React.createElement(DialogLayout, {
|
|
15
|
+
header: errorHeading(error),
|
|
16
|
+
footer: React.createElement(Button, {
|
|
17
|
+
size: "xsmall",
|
|
18
|
+
onClick: () => setOpen && setOpen(false)
|
|
19
|
+
}, "OK")
|
|
20
|
+
}, React.createElement(APIErrorContent, {
|
|
21
|
+
error: error,
|
|
22
|
+
showDoc: showDoc
|
|
23
|
+
}))
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=APIErrorDialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/APIErrorDisplay/APIErrorDialog.tsx"],"names":["React","Button","Dialog","DialogLayout","APIErrorContent","errorHeading","APIErrorDialog","error","isOpen","setOpen","showDoc"],"mappings":"AA0BA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,MAAT,EAAiBC,MAAjB,EAAyBC,YAAzB,QAA6C,oBAA7C;AAEA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,YAAT,QAA6B,SAA7B;AASA,OAAO,IAAMC,cAAc,GAAG;AAAA,MAAC;AAC7BC,IAAAA,KAD6B;AAE7BC,IAAAA,MAF6B;AAG7BC,IAAAA,OAH6B;AAI7BC,IAAAA,OAAO,GAAG;AAJmB,GAAD;AAAA,SAM5B,oBAAC,MAAD;AACE,IAAA,MAAM,EAAEF,MADV;AAEE,IAAA,OAAO,EACL,oBAAC,YAAD;AACE,MAAA,MAAM,EAAEH,YAAY,CAACE,KAAD,CADtB;AAEE,MAAA,MAAM,EACJ,oBAAC,MAAD;AAAQ,QAAA,IAAI,EAAC,QAAb;AAAsB,QAAA,OAAO,EAAE,MAAME,OAAO,IAAIA,OAAO,CAAC,KAAD;AAAvD;AAHJ,OAQE,oBAAC,eAAD;AAAiB,MAAA,KAAK,EAAEF,KAAxB;AAA+B,MAAA,OAAO,EAAEG;AAAxC,MARF;AAHJ,IAN4B;AAAA,CAAvB","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2022 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport React from 'react'\nimport { Button, Dialog, DialogLayout } from '@looker/components'\nimport type { APIErrorDisplayProps } from './APIErrorDisplay'\nimport { APIErrorContent } from './APIErrorContent'\nimport { errorHeading } from './utils'\n\ninterface APIErrorDialogProps extends APIErrorDisplayProps {\n /** toggle for dialog being open */\n isOpen: boolean\n /** callback for toggling the dialog display */\n setOpen: (open: boolean) => void\n}\n\nexport const APIErrorDialog = ({\n error,\n isOpen,\n setOpen,\n showDoc = false,\n}: APIErrorDialogProps) => (\n <Dialog\n isOpen={isOpen}\n content={\n <DialogLayout\n header={errorHeading(error)}\n footer={\n <Button size=\"xsmall\" onClick={() => setOpen && setOpen(false)}>\n OK\n </Button>\n }\n >\n <APIErrorContent error={error} showDoc={showDoc} />\n </DialogLayout>\n }\n />\n)\n"],"file":"APIErrorDialog.js"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Heading, SpaceVertical } from '@looker/components';
|
|
3
|
+
import { APIErrorContent } from './APIErrorContent';
|
|
4
|
+
import { errorHeading } from './utils';
|
|
5
|
+
export var APIErrorDisplay = _ref => {
|
|
6
|
+
var {
|
|
7
|
+
error,
|
|
8
|
+
showDoc = false
|
|
9
|
+
} = _ref;
|
|
10
|
+
return React.createElement(React.Fragment, null, error && React.createElement(SpaceVertical, null, React.createElement(Heading, {
|
|
11
|
+
type: "h2"
|
|
12
|
+
}, errorHeading(error)), React.createElement(APIErrorContent, {
|
|
13
|
+
error: error,
|
|
14
|
+
showDoc: showDoc
|
|
15
|
+
})));
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=APIErrorDisplay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/APIErrorDisplay/APIErrorDisplay.tsx"],"names":["React","Heading","SpaceVertical","APIErrorContent","errorHeading","APIErrorDisplay","error","showDoc"],"mappings":"AA0BA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,SAASC,OAAT,EAAkBC,aAAlB,QAAuC,oBAAvC;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,YAAT,QAA6B,SAA7B;AAcA,OAAO,IAAMC,eAAe,GAAG,QAGH;AAAA,MAHI;AAC9BC,IAAAA,KAD8B;AAE9BC,IAAAA,OAAO,GAAG;AAFoB,GAGJ;AAC1B,SACE,0CACGD,KAAK,IACJ,oBAAC,aAAD,QACE,oBAAC,OAAD;AAAS,IAAA,IAAI,EAAC;AAAd,KAAoBF,YAAY,CAACE,KAAD,CAAhC,CADF,EAEE,oBAAC,eAAD;AAAiB,IAAA,KAAK,EAAEA,KAAxB;AAA+B,IAAA,OAAO,EAAEC;AAAxC,IAFF,CAFJ,CADF;AAUD,CAdM","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2022 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport React from 'react'\nimport type { LookerSDKError } from '@looker/sdk-rtl'\nimport { Heading, SpaceVertical } from '@looker/components'\nimport { APIErrorContent } from './APIErrorContent'\nimport { errorHeading } from './utils'\n\nexport interface APIErrorDisplayProps {\n /** Populated SDK error information, which may contain detailed errors */\n error: LookerSDKError\n /** true to retrieve the markdown error document from the CDN and display it instead of a link */\n showDoc?: boolean\n}\n\n/**\n * Show API error information in the parent React component\n * @param error to display\n * @param showDoc true to fetch the error document markdown. false for a clickable link\n */\nexport const APIErrorDisplay = ({\n error,\n showDoc = false,\n}: APIErrorDisplayProps) => {\n return (\n <>\n {error && (\n <SpaceVertical>\n <Heading type=\"h2\">{errorHeading(error)}</Heading>\n <APIErrorContent error={error} showDoc={showDoc} />\n </SpaceVertical>\n )}\n </>\n )\n}\n"],"file":"APIErrorDisplay.js"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Link } from '@looker/components';
|
|
3
|
+
import { getEnvAdaptor } from '../adaptorUtils';
|
|
4
|
+
export var APIErrorDocLink = _ref => {
|
|
5
|
+
var {
|
|
6
|
+
docUrl
|
|
7
|
+
} = _ref;
|
|
8
|
+
|
|
9
|
+
var onClick = e => {
|
|
10
|
+
e.preventDefault();
|
|
11
|
+
var adaptor = getEnvAdaptor();
|
|
12
|
+
adaptor.openBrowserWindow(e.currentTarget.href);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
if (!docUrl) return React.createElement(React.Fragment, null);
|
|
16
|
+
return React.createElement(Link, {
|
|
17
|
+
href: docUrl,
|
|
18
|
+
key: docUrl,
|
|
19
|
+
onClick: onClick
|
|
20
|
+
}, "More information");
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=APIErrorDocLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/APIErrorDisplay/APIErrorDocLink.tsx"],"names":["React","Link","getEnvAdaptor","APIErrorDocLink","docUrl","onClick","e","preventDefault","adaptor","openBrowserWindow","currentTarget","href"],"mappings":"AA0BA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,IAAT,QAAqB,oBAArB;AACA,SAASC,aAAT,QAA8B,iBAA9B;AAMA,OAAO,IAAMC,eAAe,GAAG,QAAsC;AAAA,MAArC;AAAEC,IAAAA;AAAF,GAAqC;;AACnE,MAAMC,OAAO,GAAIC,CAAD,IAA4C;AAC1DA,IAAAA,CAAC,CAACC,cAAF;AACA,QAAMC,OAAO,GAAGN,aAAa,EAA7B;AACAM,IAAAA,OAAO,CAACC,iBAAR,CAA0BH,CAAC,CAACI,aAAF,CAAgBC,IAA1C;AACD,GAJD;;AAMA,MAAI,CAACP,MAAL,EAAa,OAAO,yCAAP;AACb,SACE,oBAAC,IAAD;AAAM,IAAA,IAAI,EAAEA,MAAZ;AAAoB,IAAA,GAAG,EAAEA,MAAzB;AAAiC,IAAA,OAAO,EAAEC;AAA1C,wBADF;AAKD,CAbM","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2022 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport React from 'react'\nimport { Link } from '@looker/components'\nimport { getEnvAdaptor } from '../adaptorUtils'\n\ninterface APIErrorDocLinkProps {\n docUrl?: string\n}\n\nexport const APIErrorDocLink = ({ docUrl }: APIErrorDocLinkProps) => {\n const onClick = (e: React.MouseEvent<HTMLAnchorElement>) => {\n e.preventDefault()\n const adaptor = getEnvAdaptor()\n adaptor.openBrowserWindow(e.currentTarget.href)\n }\n\n if (!docUrl) return <></>\n return (\n <Link href={docUrl} key={docUrl} onClick={onClick}>\n More information\n </Link>\n )\n}\n"],"file":"APIErrorDocLink.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/APIErrorDisplay/index.ts"],"names":["apiErrorDisplayFetch"],"mappings":"AA0BA,cAAc,kBAAd;AACA,cAAc,mBAAd;AACA,SAASA,oBAAT,QAAqC,SAArC","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2022 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nexport * from './APIErrorDialog'\nexport * from './APIErrorDisplay'\nexport { apiErrorDisplayFetch } from './utils'\n"],"file":"index.js"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
2
|
+
|
|
3
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
4
|
+
|
|
5
|
+
export var errorHeading = error => error.message || 'Unknown error';
|
|
6
|
+
export var apiErrorDisplayFetch = function () {
|
|
7
|
+
var _ref = _asyncToGenerator(function* (_sdk, url) {
|
|
8
|
+
var fetched = yield fetch(url, {
|
|
9
|
+
mode: 'cors'
|
|
10
|
+
});
|
|
11
|
+
var result = yield fetched.text();
|
|
12
|
+
var stop = result.indexOf('## API Response Type');
|
|
13
|
+
|
|
14
|
+
if (stop > 0) {
|
|
15
|
+
result = result.substring(0, stop - 1).trim();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return result;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return function apiErrorDisplayFetch(_x, _x2) {
|
|
22
|
+
return _ref.apply(this, arguments);
|
|
23
|
+
};
|
|
24
|
+
}();
|
|
25
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/APIErrorDisplay/utils.ts"],"names":["errorHeading","error","message","apiErrorDisplayFetch","_sdk","url","fetched","fetch","mode","result","text","stop","indexOf","substring","trim"],"mappings":";;;;AAgCA,OAAO,IAAMA,YAAY,GAAIC,KAAD,IAC1BA,KAAK,CAACC,OAAN,IAAiB,eADZ;AASP,OAAO,IAAMC,oBAAoB;AAAA,+BAAG,WAAOC,IAAP,EAA0BC,GAA1B,EAA0C;AAC5E,QAAMC,OAAO,SAASC,KAAK,CAACF,GAAD,EAAM;AAAEG,MAAAA,IAAI,EAAE;AAAR,KAAN,CAA3B;AACA,QAAIC,MAAM,SAASH,OAAO,CAACI,IAAR,EAAnB;AACA,QAAMC,IAAI,GAAGF,MAAM,CAACG,OAAP,CAAe,sBAAf,CAAb;;AACA,QAAID,IAAI,GAAG,CAAX,EAAc;AACZF,MAAAA,MAAM,GAAGA,MAAM,CAACI,SAAP,CAAiB,CAAjB,EAAoBF,IAAI,GAAG,CAA3B,EAA8BG,IAA9B,EAAT;AACD;;AACD,WAAOL,MAAP;AACD,GARgC;;AAAA,kBAApBN,oBAAoB;AAAA;AAAA;AAAA,GAA1B","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2022 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { LookerSDKError, IAPIMethods } from '@looker/sdk-rtl'\n\n/**\n * Default the heading to 'Unknown error' if error.message is blank for any reason\n * @param error for heading\n */\nexport const errorHeading = (error: LookerSDKError) =>\n error.message || 'Unknown error'\n\n/**\n * this callback function used by the ErrorDoc constructor gets and truncates\n * API error documents for use within API Explorer\n * @param _sdk required as a parameter, but it's ignored in this function\n * @param url of document (either index.json or md) to fetch\n */\nexport const apiErrorDisplayFetch = async (_sdk: IAPIMethods, url: string) => {\n const fetched = await fetch(url, { mode: 'cors' })\n let result = await fetched.text()\n const stop = result.indexOf('## API Response Type')\n if (stop > 0) {\n result = result.substring(0, stop - 1).trim()\n }\n return result\n}\n"],"file":"utils.js"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Markdown } from '@looker/code-editor';
|
|
3
|
+
import { getEnvAdaptor } from './adaptorUtils';
|
|
4
|
+
export var ExtMarkdown = _ref => {
|
|
5
|
+
var {
|
|
6
|
+
source,
|
|
7
|
+
pattern = '',
|
|
8
|
+
transformLinkUri,
|
|
9
|
+
linkClickHandler,
|
|
10
|
+
paragraphOverride
|
|
11
|
+
} = _ref;
|
|
12
|
+
|
|
13
|
+
var openBrowserWindow = (_pathname, href) => {
|
|
14
|
+
var adaptor = getEnvAdaptor();
|
|
15
|
+
adaptor.openBrowserWindow(href);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
return React.createElement(Markdown, {
|
|
19
|
+
source: source,
|
|
20
|
+
pattern: pattern,
|
|
21
|
+
transformLinkUri: transformLinkUri,
|
|
22
|
+
linkClickHandler: linkClickHandler || openBrowserWindow,
|
|
23
|
+
paragraphOverride: paragraphOverride
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=ExtMarkdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ExtMarkdown.tsx"],"names":["React","Markdown","getEnvAdaptor","ExtMarkdown","source","pattern","transformLinkUri","linkClickHandler","paragraphOverride","openBrowserWindow","_pathname","href","adaptor"],"mappings":"AA2BA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,QAAT,QAAyB,qBAAzB;AACA,SAASC,aAAT,QAA8B,gBAA9B;AAkBA,OAAO,IAAMC,WAAiC,GAAG,QAM3C;AAAA,MAN4C;AAChDC,IAAAA,MADgD;AAEhDC,IAAAA,OAAO,GAAG,EAFsC;AAGhDC,IAAAA,gBAHgD;AAIhDC,IAAAA,gBAJgD;AAKhDC,IAAAA;AALgD,GAM5C;;AACJ,MAAMC,iBAAiB,GAAG,CAACC,SAAD,EAAoBC,IAApB,KAAqC;AAC7D,QAAMC,OAAO,GAAGV,aAAa,EAA7B;AACAU,IAAAA,OAAO,CAACH,iBAAR,CAA0BE,IAA1B;AACD,GAHD;;AAKA,SACE,oBAAC,QAAD;AACE,IAAA,MAAM,EAAEP,MADV;AAEE,IAAA,OAAO,EAAEC,OAFX;AAGE,IAAA,gBAAgB,EAAEC,gBAHpB;AAIE,IAAA,gBAAgB,EAAEC,gBAAgB,IAAIE,iBAJxC;AAKE,IAAA,iBAAiB,EAAED;AALrB,IADF;AASD,CArBM","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { FC, ReactNode } from 'react'\nimport React from 'react'\nimport { Markdown } from '@looker/code-editor'\nimport { getEnvAdaptor } from './adaptorUtils'\n\ninterface ExtMarkdownProps {\n source: string\n pattern?: string\n transformLinkUri?: (url: string) => string\n linkClickHandler?: (pathname: string, href: string) => void\n paragraphOverride?: ({ children }: { children: ReactNode }) => ReactNode\n}\n\n/**\n * Simple wrapper on the standard Markdown component to handle link clicks in an extension\n * @param source markdown to render\n * @param pattern search pattern\n * @param transformLinkUri link pattern transformer override\n * @param linkClickHandler defaults to ExtensionSDK.openBrowserWindow()\n * @param paragraphOverride override paragraph display handling\n */\nexport const ExtMarkdown: FC<ExtMarkdownProps> = ({\n source,\n pattern = '',\n transformLinkUri,\n linkClickHandler,\n paragraphOverride,\n}) => {\n const openBrowserWindow = (_pathname: string, href: string) => {\n const adaptor = getEnvAdaptor()\n adaptor.openBrowserWindow(href)\n }\n\n return (\n <Markdown\n source={source}\n pattern={pattern}\n transformLinkUri={transformLinkUri}\n linkClickHandler={linkClickHandler || openBrowserWindow}\n paragraphOverride={paragraphOverride}\n />\n )\n}\n"],"file":"ExtMarkdown.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/adaptorUtils.ts"],"names":["BrowserAdaptor","hostedInternally","hostname","endsWith","startsWith","getThemeOverrides","internalTheming","loadGoogleFonts","themeCustomizations","fontFamilies","brand","colors","key","extensionAdaptor","registerEnvAdaptor","adaptor","unregisterEnvAdaptor","undefined","getEnvAdaptor","Error","registerTestEnvAdaptor","mockSdk"],"mappings":"AA4BA,SAASA,cAAT,QAA+B,kBAA/B;
|
|
1
|
+
{"version":3,"sources":["../../src/adaptorUtils.ts"],"names":["BrowserAdaptor","hostedInternally","hostname","endsWith","startsWith","getThemeOverrides","internalTheming","loadGoogleFonts","themeCustomizations","fontFamilies","brand","colors","key","extensionAdaptor","registerEnvAdaptor","adaptor","unregisterEnvAdaptor","undefined","getEnvAdaptor","Error","registerTestEnvAdaptor","mockSdk"],"mappings":"AA4BA,SAASA,cAAT,QAA+B,kBAA/B;AAoDA,OAAO,IAAMC,gBAAgB,GAAIC,QAAD,IAC9BA,QAAQ,CAACC,QAAT,CAAkB,aAAlB,KACAD,QAAQ,CAACC,QAAT,CAAkB,aAAlB,CADA,IAEAD,QAAQ,KAAK,WAFb,IAMCA,QAAQ,CAACE,UAAT,CAAoB,yBAApB,KACCF,QAAQ,CAACC,QAAT,CAAkB,UAAlB,CARG;AAcP,OAAO,IAAME,iBAAiB,GAAIC,eAAD,IAC/BA,eAAe,GACX;AACEC,EAAAA,eAAe,EAAE,IADnB;AAEEC,EAAAA,mBAAmB,EAAE;AACnBC,IAAAA,YAAY,EAAE;AAAEC,MAAAA,KAAK,EAAE;AAAT,KADK;AAEnBC,IAAAA,MAAM,EAAE;AAAEC,MAAAA,GAAG,EAAE;AAAP;AAFW;AAFvB,CADW,GAQX;AACEJ,EAAAA,mBAAmB,EAAE;AACnBG,IAAAA,MAAM,EAAE;AAAEC,MAAAA,GAAG,EAAE;AAAP;AADW;AADvB,CATC;AAeP,IAAIC,gBAAJ;AAMA,OAAO,IAAMC,kBAAkB,GAC7BC,OADgC,IAE7B;AACHF,EAAAA,gBAAgB,GAAGE,OAAnB;AACD,CAJM;AASP,OAAO,IAAMC,oBAAoB,GAAG,MAAM;AACxCH,EAAAA,gBAAgB,GAAGI,SAAnB;AACD,CAFM;AAOP,OAAO,IAAMC,aAAa,GAAG,MAAM;AACjC,MAAI,CAACL,gBAAL,EAAuB;AACrB,UAAM,IAAIM,KAAJ,CAAU,sCAAV,CAAN;AACD;;AACD,SAAON,gBAAP;AACD,CALM;AAWP,OAAO,IAAMO,sBAAsB,GACjCL,OADoC,IAEjC;AACH,MAAMM,OAAO,GAAG,EAAhB;AACAP,EAAAA,kBAAkB,CAACC,OAAO,IAAI,IAAIf,cAAJ,CAAmBqB,OAAnB,CAAZ,CAAlB;AACD,CALM","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { ThemeCustomizations } from '@looker/design-tokens'\nimport type { IAPIMethods } from '@looker/sdk-rtl'\nimport { BrowserAdaptor } from './browserAdaptor'\n\nexport interface IAuthAdaptor {\n /** Method for retrieving an instantiated SDK */\n get sdk(): IAPIMethods\n /** Method for authenticating against the API server. Auth mechanism is dependent on the authSession implementation\n * used for the sdk. */\n login(): Promise<boolean>\n}\n\n/**\n * NOTE: This interface should describe all methods that require an adaptor when running in standalone vs extension mode\n * Examples include: local storage operations and various link navigation functions\n */\nexport interface IEnvironmentAdaptor extends IAuthAdaptor {\n /** Copy page URL to clipboard */\n copyToClipboard: (location?: {\n pathname: string\n search: string\n }) => Promise<void>\n /** Method for determining whether running in a browser or extension environment */\n isExtension(): boolean\n /** Method for retrieving a keyed value from local storage */\n localStorageGetItem(key: string): Promise<string | null>\n /** Method for setting a keyed value in local storage */\n localStorageSetItem(key: string, value: string): void\n /** Method for removing a keyed value from local storage */\n localStorageRemoveItem(key: string): void\n /** Theme settings for extension */\n themeOverrides(): ThemeOverrides\n /** Open a new browser window with the given url and target */\n openBrowserWindow: (url: string, target?: string) => void\n /** error logger */\n logError: (error: Error, componentStack: string) => void\n}\n\n/**\n * Theme overrides used to load google fonts in Google environments only.\n * Google fonts should NOT be used when it is not obvious that a Google\n * system is being used (for example an embedded extension).\n */\nexport interface ThemeOverrides {\n /** Should Google-specific fonts be used for the theme? */\n loadGoogleFonts?: boolean\n /** Property bag overrides for Looker component theming */\n themeCustomizations?: ThemeCustomizations\n}\n\n/**\n * Is this an \"internal\" host that will use internal branding?\n * @param hostname to check\n */\nexport const hostedInternally = (hostname: string): boolean =>\n hostname.endsWith('.looker.com') ||\n hostname.endsWith('.google.com') ||\n hostname === 'localhost' ||\n // Include firebase staging dev portal for now. Can be removed\n // when dev portal gets its own APIX project. Also includes\n // PRs.\n (hostname.startsWith('looker-developer-portal') &&\n hostname.endsWith('.web.app'))\n\n/**\n * Return theme overrides that make apply \"internal\" or external theming\n * @param internalTheming true if \"internal\" theme should be used\n */\nexport const getThemeOverrides = (internalTheming: boolean): ThemeOverrides =>\n internalTheming\n ? {\n loadGoogleFonts: true,\n themeCustomizations: {\n fontFamilies: { brand: 'Google Sans' },\n colors: { key: '#1A73E8' },\n },\n }\n : {\n themeCustomizations: {\n colors: { key: '#1A73E8' },\n },\n }\n\nlet extensionAdaptor: IEnvironmentAdaptor | undefined\n\n/**\n * Register the environment adaptor. Used when initializing the application\n * @param adaptor to register\n */\nexport const registerEnvAdaptor = <T extends IEnvironmentAdaptor>(\n adaptor: T\n) => {\n extensionAdaptor = adaptor\n}\n\n/**\n * Unregister the environment adaptor. Extensions should call this when unmounted\n */\nexport const unregisterEnvAdaptor = () => {\n extensionAdaptor = undefined\n}\n\n/**\n * Global access to the environment adaptor. An error will be thrown if accessed prematurely.\n */\nexport const getEnvAdaptor = () => {\n if (!extensionAdaptor) {\n throw new Error('Environment adaptor not initialized.')\n }\n return extensionAdaptor\n}\n\n/**\n * Used by some unit tests\n * @param adaptor to use for testing\n */\nexport const registerTestEnvAdaptor = <T extends IEnvironmentAdaptor>(\n adaptor?: T\n) => {\n const mockSdk = {} as unknown as IAPIMethods\n registerEnvAdaptor(adaptor || new BrowserAdaptor(mockSdk))\n}\n"],"file":"adaptorUtils.js"}
|
|
@@ -38,6 +38,12 @@ export class BrowserAdaptor extends BrowserAuthAdaptor {
|
|
|
38
38
|
this._themeOverrides = getThemeOverrides(hostedInternally(hostname));
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
copyToClipboard() {
|
|
42
|
+
return _asyncToGenerator(function* () {
|
|
43
|
+
yield navigator.clipboard.writeText(location.href);
|
|
44
|
+
})();
|
|
45
|
+
}
|
|
46
|
+
|
|
41
47
|
isExtension() {
|
|
42
48
|
return false;
|
|
43
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/browserAdaptor.ts"],"names":["getThemeOverrides","hostedInternally","BrowserAuthAdaptor","constructor","sdk","login","token","settings","authSession","authIsConfigured","BrowserAdaptor","hostname","location","_themeOverrides","isExtension","localStorageGetItem","key","localStorage","getItem","localStorageSetItem","value","setItem","localStorageRemoveItem","removeItem","themeOverrides","openBrowserWindow","url","target","window","open","logError","_error","_componentStack"],"mappings":";;;;;;AAgCA,SAASA,iBAAT,EAA4BC,gBAA5B,QAAoD,gBAApD;AAGA,OAAO,MAAMC,kBAAN,CAAiD;AACtDC,EAAAA,WAAW,CAAiBC,GAAjB,EAAmC;AAAA,SAAlBA,GAAkB,GAAlBA,GAAkB;AAAE;;AAE1CC,EAAAA,KAAK,GAAG;AAAA;;AAAA;AACZ,UAAIC,KAAJ;AACA,UAAMC,QAAQ,GAAG,KAAI,CAACH,GAAL,CAASI,WAAT,CAAqBD,QAAtC;;AACA,UAAIA,QAAQ,CAACE,gBAAT,EAAJ,EAAiC;AAC/BH,QAAAA,KAAK,SAAS,KAAI,CAACF,GAAL,CAASI,WAAT,CAAqBH,KAArB,EAAd;AACD;;AACD,aAAO,CAAC,CAACC,KAAT;AANY;AAOb;;AAVqD;AAgBxD,OAAO,MAAMI,cAAN,SACGR,kBADH,CAGP;AAGEC,EAAAA,WAAW,CAACC,GAAD,EAAmB;AAC5B,UAAMA,GAAN;;AAD4B;;AAE5B,QAAM;AAAEO,MAAAA;AAAF,QAAeC,QAArB;AACA,SAAKC,eAAL,GAAuBb,iBAAiB,CAACC,gBAAgB,CAACU,QAAD,CAAjB,CAAxC;AACD;;
|
|
1
|
+
{"version":3,"sources":["../../src/browserAdaptor.ts"],"names":["getThemeOverrides","hostedInternally","BrowserAuthAdaptor","constructor","sdk","login","token","settings","authSession","authIsConfigured","BrowserAdaptor","hostname","location","_themeOverrides","copyToClipboard","navigator","clipboard","writeText","href","isExtension","localStorageGetItem","key","localStorage","getItem","localStorageSetItem","value","setItem","localStorageRemoveItem","removeItem","themeOverrides","openBrowserWindow","url","target","window","open","logError","_error","_componentStack"],"mappings":";;;;;;AAgCA,SAASA,iBAAT,EAA4BC,gBAA5B,QAAoD,gBAApD;AAGA,OAAO,MAAMC,kBAAN,CAAiD;AACtDC,EAAAA,WAAW,CAAiBC,GAAjB,EAAmC;AAAA,SAAlBA,GAAkB,GAAlBA,GAAkB;AAAE;;AAE1CC,EAAAA,KAAK,GAAG;AAAA;;AAAA;AACZ,UAAIC,KAAJ;AACA,UAAMC,QAAQ,GAAG,KAAI,CAACH,GAAL,CAASI,WAAT,CAAqBD,QAAtC;;AACA,UAAIA,QAAQ,CAACE,gBAAT,EAAJ,EAAiC;AAC/BH,QAAAA,KAAK,SAAS,KAAI,CAACF,GAAL,CAASI,WAAT,CAAqBH,KAArB,EAAd;AACD;;AACD,aAAO,CAAC,CAACC,KAAT;AANY;AAOb;;AAVqD;AAgBxD,OAAO,MAAMI,cAAN,SACGR,kBADH,CAGP;AAGEC,EAAAA,WAAW,CAACC,GAAD,EAAmB;AAC5B,UAAMA,GAAN;;AAD4B;;AAE5B,QAAM;AAAEO,MAAAA;AAAF,QAAeC,QAArB;AACA,SAAKC,eAAL,GAAuBb,iBAAiB,CAACC,gBAAgB,CAACU,QAAD,CAAjB,CAAxC;AACD;;AAEKG,EAAAA,eAAe,GAAG;AAAA;AACtB,YAAMC,SAAS,CAACC,SAAV,CAAoBC,SAApB,CAA8BL,QAAQ,CAACM,IAAvC,CAAN;AADsB;AAEvB;;AAEDC,EAAAA,WAAW,GAAG;AACZ,WAAO,KAAP;AACD;;AAEKC,EAAAA,mBAAmB,CAACC,GAAD,EAAc;AAAA;AACrC,aAAOC,YAAY,CAACC,OAAb,CAAqBF,GAArB,CAAP;AADqC;AAEtC;;AAEKG,EAAAA,mBAAmB,CAACH,GAAD,EAAcI,KAAd,EAA6B;AAAA;AACpD,YAAMH,YAAY,CAACI,OAAb,CAAqBL,GAArB,EAA0BI,KAA1B,CAAN;AADoD;AAErD;;AAEKE,EAAAA,sBAAsB,CAACN,GAAD,EAAc;AAAA;AACxC,YAAMC,YAAY,CAACM,UAAb,CAAwBP,GAAxB,CAAN;AADwC;AAEzC;;AAEDQ,EAAAA,cAAc,GAAG;AACf,WAAO,KAAKhB,eAAZ;AACD;;AAEDiB,EAAAA,iBAAiB,CAACC,GAAD,EAAcC,MAAd,EAA+B;AAC9CC,IAAAA,MAAM,CAACC,IAAP,CAAYH,GAAZ,EAAiBC,MAAjB;AACD;;AAEDG,EAAAA,QAAQ,CAACC,MAAD,EAAgBC,eAAhB,EAA+C,CAEtD;;AAvCH","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { IAPIMethods } from '@looker/sdk-rtl'\nimport type {\n IAuthAdaptor,\n IEnvironmentAdaptor,\n ThemeOverrides,\n} from './adaptorUtils'\nimport { getThemeOverrides, hostedInternally } from './adaptorUtils'\nimport type { OAuthConfigProvider } from './authUtils'\n\nexport class BrowserAuthAdaptor implements IAuthAdaptor {\n constructor(public readonly sdk: IAPIMethods) {}\n\n async login() {\n let token\n const settings = this.sdk.authSession.settings as OAuthConfigProvider\n if (settings.authIsConfigured()) {\n token = await this.sdk.authSession.login()\n }\n return !!token\n }\n}\n\n/**\n * An adaptor class for interacting with browser APIs when not running in an extension\n */\nexport class BrowserAdaptor\n extends BrowserAuthAdaptor\n implements IEnvironmentAdaptor\n{\n private _themeOverrides: ThemeOverrides\n\n constructor(sdk: IAPIMethods) {\n super(sdk)\n const { hostname } = location\n this._themeOverrides = getThemeOverrides(hostedInternally(hostname))\n }\n\n async copyToClipboard() {\n await navigator.clipboard.writeText(location.href)\n }\n\n isExtension() {\n return false\n }\n\n async localStorageGetItem(key: string) {\n return localStorage.getItem(key)\n }\n\n async localStorageSetItem(key: string, value: string) {\n await localStorage.setItem(key, value)\n }\n\n async localStorageRemoveItem(key: string) {\n await localStorage.removeItem(key)\n }\n\n themeOverrides() {\n return this._themeOverrides\n }\n\n openBrowserWindow(url: string, target?: string) {\n window.open(url, target)\n }\n\n logError(_error: Error, _componentStack: string): void {\n // noop - error logging for standalone applications TBD\n }\n}\n"],"file":"browserAdaptor.js"}
|
|
@@ -29,31 +29,54 @@ export class ExtensionAdaptor extends ExtensionAuthAdaptor {
|
|
|
29
29
|
}).hostType === 'standard');
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
copyToClipboard(location) {
|
|
33
|
+
var _this = this;
|
|
34
|
+
|
|
35
|
+
return _asyncToGenerator(function* () {
|
|
36
|
+
var {
|
|
37
|
+
lookerHostData
|
|
38
|
+
} = _this.extensionSdk;
|
|
39
|
+
|
|
40
|
+
if (lookerHostData && location) {
|
|
41
|
+
var {
|
|
42
|
+
hostOrigin,
|
|
43
|
+
extensionId
|
|
44
|
+
} = lookerHostData;
|
|
45
|
+
var {
|
|
46
|
+
pathname,
|
|
47
|
+
search
|
|
48
|
+
} = location;
|
|
49
|
+
var url = "".concat(hostOrigin, "/extensions/").concat(extensionId).concat(pathname).concat(search);
|
|
50
|
+
yield _this.extensionSdk.clipboardWrite(url);
|
|
51
|
+
}
|
|
52
|
+
})();
|
|
53
|
+
}
|
|
54
|
+
|
|
32
55
|
isExtension() {
|
|
33
56
|
return true;
|
|
34
57
|
}
|
|
35
58
|
|
|
36
59
|
localStorageGetItem(key) {
|
|
37
|
-
var
|
|
60
|
+
var _this2 = this;
|
|
38
61
|
|
|
39
62
|
return _asyncToGenerator(function* () {
|
|
40
|
-
return yield
|
|
63
|
+
return yield _this2.extensionSdk.localStorageGetItem(key);
|
|
41
64
|
})();
|
|
42
65
|
}
|
|
43
66
|
|
|
44
67
|
localStorageSetItem(key, value) {
|
|
45
|
-
var
|
|
68
|
+
var _this3 = this;
|
|
46
69
|
|
|
47
70
|
return _asyncToGenerator(function* () {
|
|
48
|
-
yield
|
|
71
|
+
yield _this3.extensionSdk.localStorageSetItem(key, value);
|
|
49
72
|
})();
|
|
50
73
|
}
|
|
51
74
|
|
|
52
75
|
localStorageRemoveItem(key) {
|
|
53
|
-
var
|
|
76
|
+
var _this4 = this;
|
|
54
77
|
|
|
55
78
|
return _asyncToGenerator(function* () {
|
|
56
|
-
yield
|
|
79
|
+
yield _this4.extensionSdk.localStorageRemoveItem(key);
|
|
57
80
|
})();
|
|
58
81
|
}
|
|
59
82
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/extensionAdaptor.ts"],"names":["getThemeOverrides","ExtensionAuthAdaptor","constructor","sdk","login","ExtensionAdaptor","extensionSdk","_themeOverrides","lookerHostData","hostType","isExtension","localStorageGetItem","key","localStorageSetItem","value","localStorageRemoveItem","themeOverrides","openBrowserWindow","
|
|
1
|
+
{"version":3,"sources":["../../src/extensionAdaptor.ts"],"names":["getThemeOverrides","ExtensionAuthAdaptor","constructor","sdk","login","ExtensionAdaptor","extensionSdk","_themeOverrides","lookerHostData","hostType","copyToClipboard","location","hostOrigin","extensionId","pathname","search","url","clipboardWrite","isExtension","localStorageGetItem","key","localStorageSetItem","value","localStorageRemoveItem","themeOverrides","openBrowserWindow","target","logError","error","componentStack","message"],"mappings":";;;;;;AAiCA,SAASA,iBAAT,QAAkC,gBAAlC;AAEA,OAAO,MAAMC,oBAAN,CAAmD;AACxDC,EAAAA,WAAW,CAAiBC,GAAjB,EAAmC;AAAA,SAAlBA,GAAkB,GAAlBA,GAAkB;AAAE;;AAE1CC,EAAAA,KAAK,GAAG;AAAA;AAEZ,aAAO,IAAP;AAFY;AAGb;;AANuD;AAY1D,OAAO,MAAMC,gBAAN,SACGJ,oBADH,CAGP;AAGEC,EAAAA,WAAW,CAAQI,YAAR,EAAoCH,GAApC,EAAsD;AAC/D,UAAMA,GAAN;AAD+D,SAA9CG,YAA8C,GAA9CA,YAA8C;;AAAA;;AAE/D,SAAKC,eAAL,GAAuBP,iBAAiB,CACtC,CAAC,KAAKM,YAAL,CAAkBE,cAAlB,IAAoC;AAAEC,MAAAA,QAAQ,EAAE;AAAZ,KAArC,EACGA,QADH,KACgB,UAFsB,CAAxC;AAID;;AAEKC,EAAAA,eAAe,CAACC,QAAD,EAAkD;AAAA;;AAAA;AACrE,UAAM;AAAEH,QAAAA;AAAF,UAAqB,KAAI,CAACF,YAAhC;;AACA,UAAIE,cAAc,IAAIG,QAAtB,EAAgC;AAC9B,YAAM;AAAEC,UAAAA,UAAF;AAAcC,UAAAA;AAAd,YAA8BL,cAApC;AACA,YAAM;AAAEM,UAAAA,QAAF;AAAYC,UAAAA;AAAZ,YAAuBJ,QAA7B;AACA,YAAMK,GAAG,aAAMJ,UAAN,yBAA+BC,WAA/B,SAA6CC,QAA7C,SAAwDC,MAAxD,CAAT;AACA,cAAM,KAAI,CAACT,YAAL,CAAkBW,cAAlB,CAAiCD,GAAjC,CAAN;AACD;AAPoE;AAQtE;;AAEDE,EAAAA,WAAW,GAAG;AACZ,WAAO,IAAP;AACD;;AAEKC,EAAAA,mBAAmB,CAACC,GAAD,EAAc;AAAA;;AAAA;AACrC,mBAAa,MAAI,CAACd,YAAL,CAAkBa,mBAAlB,CAAsCC,GAAtC,CAAb;AADqC;AAEtC;;AAEKC,EAAAA,mBAAmB,CAACD,GAAD,EAAcE,KAAd,EAA6B;AAAA;;AAAA;AACpD,YAAM,MAAI,CAAChB,YAAL,CAAkBe,mBAAlB,CAAsCD,GAAtC,EAA2CE,KAA3C,CAAN;AADoD;AAErD;;AAEKC,EAAAA,sBAAsB,CAACH,GAAD,EAAc;AAAA;;AAAA;AACxC,YAAM,MAAI,CAACd,YAAL,CAAkBiB,sBAAlB,CAAyCH,GAAzC,CAAN;AADwC;AAEzC;;AAEDI,EAAAA,cAAc,GAAmB;AAC/B,WAAO,KAAKjB,eAAZ;AACD;;AAEDkB,EAAAA,iBAAiB,CAACT,GAAD,EAAcU,MAAd,EAA+B;AAC9C,SAAKpB,YAAL,CAAkBmB,iBAAlB,CAAoCT,GAApC,EAAyCU,MAAzC;AACD;;AAEDC,EAAAA,QAAQ,CAACC,KAAD,EAAeC,cAAf,EAA6C;AACnD,SAAKvB,YAAL,CAAkBsB,KAAlB,CAAwB;AACtBA,MAAAA,KAAK,EAAEA,KADe;AAEtBE,MAAAA,OAAO,EAAED;AAFa,KAAxB;AAID;;AAlDH","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { ExtensionSDK } from '@looker/extension-sdk'\nimport type { IAPIMethods } from '@looker/sdk-rtl'\nimport type {\n IEnvironmentAdaptor,\n ThemeOverrides,\n IAuthAdaptor,\n} from './adaptorUtils'\nimport { getThemeOverrides } from './adaptorUtils'\n\nexport class ExtensionAuthAdaptor implements IAuthAdaptor {\n constructor(public readonly sdk: IAPIMethods) {}\n\n async login() {\n // Noop for extensions. Authentication is not required in an extension context\n return true\n }\n}\n\n/**\n * An adaptor class for interacting with browser APIs when running as an extension\n */\nexport class ExtensionAdaptor\n extends ExtensionAuthAdaptor\n implements IEnvironmentAdaptor\n{\n _themeOverrides: ThemeOverrides\n\n constructor(public extensionSdk: ExtensionSDK, sdk: IAPIMethods) {\n super(sdk)\n this._themeOverrides = getThemeOverrides(\n (this.extensionSdk.lookerHostData || { hostType: 'standard' })\n .hostType === 'standard'\n )\n }\n\n async copyToClipboard(location?: { pathname: string; search: string }) {\n const { lookerHostData } = this.extensionSdk\n if (lookerHostData && location) {\n const { hostOrigin, extensionId } = lookerHostData\n const { pathname, search } = location\n const url = `${hostOrigin}/extensions/${extensionId}${pathname}${search}`\n await this.extensionSdk.clipboardWrite(url)\n }\n }\n\n isExtension() {\n return true\n }\n\n async localStorageGetItem(key: string) {\n return await this.extensionSdk.localStorageGetItem(key)\n }\n\n async localStorageSetItem(key: string, value: string) {\n await this.extensionSdk.localStorageSetItem(key, value)\n }\n\n async localStorageRemoveItem(key: string) {\n await this.extensionSdk.localStorageRemoveItem(key)\n }\n\n themeOverrides(): ThemeOverrides {\n return this._themeOverrides\n }\n\n openBrowserWindow(url: string, target?: string) {\n this.extensionSdk.openBrowserWindow(url, target)\n }\n\n logError(error: Error, componentStack: string): void {\n this.extensionSdk.error({\n error: error,\n message: componentStack,\n } as ErrorEvent)\n }\n}\n"],"file":"extensionAdaptor.js"}
|
package/lib/esm/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from './adaptorUtils';
|
|
2
|
+
export * from './APIErrorDisplay';
|
|
2
3
|
export * from './browserAdaptor';
|
|
3
4
|
export * from './extensionAdaptor';
|
|
5
|
+
export * from './ExtMarkdown';
|
|
4
6
|
export * from './authUtils';
|
|
5
7
|
export * from './OAuthScene';
|
|
6
8
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":"AA0BA,cAAc,gBAAd;AACA,cAAc,kBAAd;AACA,cAAc,oBAAd;AACA,cAAc,aAAd;AACA,cAAc,cAAd","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nexport * from './adaptorUtils'\nexport * from './browserAdaptor'\nexport * from './extensionAdaptor'\nexport * from './authUtils'\nexport * from './OAuthScene'\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":"AA0BA,cAAc,gBAAd;AACA,cAAc,mBAAd;AACA,cAAc,kBAAd;AACA,cAAc,oBAAd;AACA,cAAc,eAAd;AACA,cAAc,aAAd;AACA,cAAc,cAAd","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nexport * from './adaptorUtils'\nexport * from './APIErrorDisplay'\nexport * from './browserAdaptor'\nexport * from './extensionAdaptor'\nexport * from './ExtMarkdown'\nexport * from './authUtils'\nexport * from './OAuthScene'\n"],"file":"index.js"}
|
|
@@ -10,6 +10,10 @@ export declare class ExtensionAdaptor extends ExtensionAuthAdaptor implements IE
|
|
|
10
10
|
extensionSdk: ExtensionSDK;
|
|
11
11
|
_themeOverrides: ThemeOverrides;
|
|
12
12
|
constructor(extensionSdk: ExtensionSDK, sdk: IAPIMethods);
|
|
13
|
+
copyToClipboard(location?: {
|
|
14
|
+
pathname: string;
|
|
15
|
+
search: string;
|
|
16
|
+
}): Promise<void>;
|
|
13
17
|
isExtension(): boolean;
|
|
14
18
|
localStorageGetItem(key: string): Promise<string | null>;
|
|
15
19
|
localStorageSetItem(key: string, value: string): Promise<void>;
|
package/lib/extensionAdaptor.js
CHANGED
|
@@ -40,31 +40,54 @@ class ExtensionAdaptor extends ExtensionAuthAdaptor {
|
|
|
40
40
|
}).hostType === 'standard');
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
copyToClipboard(location) {
|
|
44
|
+
var _this = this;
|
|
45
|
+
|
|
46
|
+
return _asyncToGenerator(function* () {
|
|
47
|
+
var {
|
|
48
|
+
lookerHostData
|
|
49
|
+
} = _this.extensionSdk;
|
|
50
|
+
|
|
51
|
+
if (lookerHostData && location) {
|
|
52
|
+
var {
|
|
53
|
+
hostOrigin,
|
|
54
|
+
extensionId
|
|
55
|
+
} = lookerHostData;
|
|
56
|
+
var {
|
|
57
|
+
pathname,
|
|
58
|
+
search
|
|
59
|
+
} = location;
|
|
60
|
+
var url = "".concat(hostOrigin, "/extensions/").concat(extensionId).concat(pathname).concat(search);
|
|
61
|
+
yield _this.extensionSdk.clipboardWrite(url);
|
|
62
|
+
}
|
|
63
|
+
})();
|
|
64
|
+
}
|
|
65
|
+
|
|
43
66
|
isExtension() {
|
|
44
67
|
return true;
|
|
45
68
|
}
|
|
46
69
|
|
|
47
70
|
localStorageGetItem(key) {
|
|
48
|
-
var
|
|
71
|
+
var _this2 = this;
|
|
49
72
|
|
|
50
73
|
return _asyncToGenerator(function* () {
|
|
51
|
-
return yield
|
|
74
|
+
return yield _this2.extensionSdk.localStorageGetItem(key);
|
|
52
75
|
})();
|
|
53
76
|
}
|
|
54
77
|
|
|
55
78
|
localStorageSetItem(key, value) {
|
|
56
|
-
var
|
|
79
|
+
var _this3 = this;
|
|
57
80
|
|
|
58
81
|
return _asyncToGenerator(function* () {
|
|
59
|
-
yield
|
|
82
|
+
yield _this3.extensionSdk.localStorageSetItem(key, value);
|
|
60
83
|
})();
|
|
61
84
|
}
|
|
62
85
|
|
|
63
86
|
localStorageRemoveItem(key) {
|
|
64
|
-
var
|
|
87
|
+
var _this4 = this;
|
|
65
88
|
|
|
66
89
|
return _asyncToGenerator(function* () {
|
|
67
|
-
yield
|
|
90
|
+
yield _this4.extensionSdk.localStorageRemoveItem(key);
|
|
68
91
|
})();
|
|
69
92
|
}
|
|
70
93
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/extensionAdaptor.ts"],"names":["ExtensionAuthAdaptor","constructor","sdk","login","ExtensionAdaptor","extensionSdk","_themeOverrides","lookerHostData","hostType","isExtension","localStorageGetItem","key","localStorageSetItem","value","localStorageRemoveItem","themeOverrides","openBrowserWindow","
|
|
1
|
+
{"version":3,"sources":["../src/extensionAdaptor.ts"],"names":["ExtensionAuthAdaptor","constructor","sdk","login","ExtensionAdaptor","extensionSdk","_themeOverrides","lookerHostData","hostType","copyToClipboard","location","hostOrigin","extensionId","pathname","search","url","clipboardWrite","isExtension","localStorageGetItem","key","localStorageSetItem","value","localStorageRemoveItem","themeOverrides","openBrowserWindow","target","logError","error","componentStack","message"],"mappings":";;;;;;;AAiCA;;;;;;;;AAEO,MAAMA,oBAAN,CAAmD;AACxDC,EAAAA,WAAW,CAAiBC,GAAjB,EAAmC;AAAA,SAAlBA,GAAkB,GAAlBA,GAAkB;AAAE;;AAE1CC,EAAAA,KAAK,GAAG;AAAA;AAEZ,aAAO,IAAP;AAFY;AAGb;;AANuD;;;;AAYnD,MAAMC,gBAAN,SACGJ,oBADH,CAGP;AAGEC,EAAAA,WAAW,CAAQI,YAAR,EAAoCH,GAApC,EAAsD;AAC/D,UAAMA,GAAN;AAD+D,SAA9CG,YAA8C,GAA9CA,YAA8C;;AAAA;;AAE/D,SAAKC,eAAL,GAAuB,qCACrB,CAAC,KAAKD,YAAL,CAAkBE,cAAlB,IAAoC;AAAEC,MAAAA,QAAQ,EAAE;AAAZ,KAArC,EACGA,QADH,KACgB,UAFK,CAAvB;AAID;;AAEKC,EAAAA,eAAe,CAACC,QAAD,EAAkD;AAAA;;AAAA;AACrE,UAAM;AAAEH,QAAAA;AAAF,UAAqB,KAAI,CAACF,YAAhC;;AACA,UAAIE,cAAc,IAAIG,QAAtB,EAAgC;AAC9B,YAAM;AAAEC,UAAAA,UAAF;AAAcC,UAAAA;AAAd,YAA8BL,cAApC;AACA,YAAM;AAAEM,UAAAA,QAAF;AAAYC,UAAAA;AAAZ,YAAuBJ,QAA7B;AACA,YAAMK,GAAG,aAAMJ,UAAN,yBAA+BC,WAA/B,SAA6CC,QAA7C,SAAwDC,MAAxD,CAAT;AACA,cAAM,KAAI,CAACT,YAAL,CAAkBW,cAAlB,CAAiCD,GAAjC,CAAN;AACD;AAPoE;AAQtE;;AAEDE,EAAAA,WAAW,GAAG;AACZ,WAAO,IAAP;AACD;;AAEKC,EAAAA,mBAAmB,CAACC,GAAD,EAAc;AAAA;;AAAA;AACrC,mBAAa,MAAI,CAACd,YAAL,CAAkBa,mBAAlB,CAAsCC,GAAtC,CAAb;AADqC;AAEtC;;AAEKC,EAAAA,mBAAmB,CAACD,GAAD,EAAcE,KAAd,EAA6B;AAAA;;AAAA;AACpD,YAAM,MAAI,CAAChB,YAAL,CAAkBe,mBAAlB,CAAsCD,GAAtC,EAA2CE,KAA3C,CAAN;AADoD;AAErD;;AAEKC,EAAAA,sBAAsB,CAACH,GAAD,EAAc;AAAA;;AAAA;AACxC,YAAM,MAAI,CAACd,YAAL,CAAkBiB,sBAAlB,CAAyCH,GAAzC,CAAN;AADwC;AAEzC;;AAEDI,EAAAA,cAAc,GAAmB;AAC/B,WAAO,KAAKjB,eAAZ;AACD;;AAEDkB,EAAAA,iBAAiB,CAACT,GAAD,EAAcU,MAAd,EAA+B;AAC9C,SAAKpB,YAAL,CAAkBmB,iBAAlB,CAAoCT,GAApC,EAAyCU,MAAzC;AACD;;AAEDC,EAAAA,QAAQ,CAACC,KAAD,EAAeC,cAAf,EAA6C;AACnD,SAAKvB,YAAL,CAAkBsB,KAAlB,CAAwB;AACtBA,MAAAA,KAAK,EAAEA,KADe;AAEtBE,MAAAA,OAAO,EAAED;AAFa,KAAxB;AAID;;AAlDH","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { ExtensionSDK } from '@looker/extension-sdk'\nimport type { IAPIMethods } from '@looker/sdk-rtl'\nimport type {\n IEnvironmentAdaptor,\n ThemeOverrides,\n IAuthAdaptor,\n} from './adaptorUtils'\nimport { getThemeOverrides } from './adaptorUtils'\n\nexport class ExtensionAuthAdaptor implements IAuthAdaptor {\n constructor(public readonly sdk: IAPIMethods) {}\n\n async login() {\n // Noop for extensions. Authentication is not required in an extension context\n return true\n }\n}\n\n/**\n * An adaptor class for interacting with browser APIs when running as an extension\n */\nexport class ExtensionAdaptor\n extends ExtensionAuthAdaptor\n implements IEnvironmentAdaptor\n{\n _themeOverrides: ThemeOverrides\n\n constructor(public extensionSdk: ExtensionSDK, sdk: IAPIMethods) {\n super(sdk)\n this._themeOverrides = getThemeOverrides(\n (this.extensionSdk.lookerHostData || { hostType: 'standard' })\n .hostType === 'standard'\n )\n }\n\n async copyToClipboard(location?: { pathname: string; search: string }) {\n const { lookerHostData } = this.extensionSdk\n if (lookerHostData && location) {\n const { hostOrigin, extensionId } = lookerHostData\n const { pathname, search } = location\n const url = `${hostOrigin}/extensions/${extensionId}${pathname}${search}`\n await this.extensionSdk.clipboardWrite(url)\n }\n }\n\n isExtension() {\n return true\n }\n\n async localStorageGetItem(key: string) {\n return await this.extensionSdk.localStorageGetItem(key)\n }\n\n async localStorageSetItem(key: string, value: string) {\n await this.extensionSdk.localStorageSetItem(key, value)\n }\n\n async localStorageRemoveItem(key: string) {\n await this.extensionSdk.localStorageRemoveItem(key)\n }\n\n themeOverrides(): ThemeOverrides {\n return this._themeOverrides\n }\n\n openBrowserWindow(url: string, target?: string) {\n this.extensionSdk.openBrowserWindow(url, target)\n }\n\n logError(error: Error, componentStack: string): void {\n this.extensionSdk.error({\n error: error,\n message: componentStack,\n } as ErrorEvent)\n }\n}\n"],"file":"extensionAdaptor.js"}
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -17,6 +17,19 @@ Object.keys(_adaptorUtils).forEach(function (key) {
|
|
|
17
17
|
});
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
+
var _APIErrorDisplay = require("./APIErrorDisplay");
|
|
21
|
+
|
|
22
|
+
Object.keys(_APIErrorDisplay).forEach(function (key) {
|
|
23
|
+
if (key === "default" || key === "__esModule") return;
|
|
24
|
+
if (key in exports && exports[key] === _APIErrorDisplay[key]) return;
|
|
25
|
+
Object.defineProperty(exports, key, {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function get() {
|
|
28
|
+
return _APIErrorDisplay[key];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
20
33
|
var _browserAdaptor = require("./browserAdaptor");
|
|
21
34
|
|
|
22
35
|
Object.keys(_browserAdaptor).forEach(function (key) {
|
|
@@ -43,6 +56,19 @@ Object.keys(_extensionAdaptor).forEach(function (key) {
|
|
|
43
56
|
});
|
|
44
57
|
});
|
|
45
58
|
|
|
59
|
+
var _ExtMarkdown = require("./ExtMarkdown");
|
|
60
|
+
|
|
61
|
+
Object.keys(_ExtMarkdown).forEach(function (key) {
|
|
62
|
+
if (key === "default" || key === "__esModule") return;
|
|
63
|
+
if (key in exports && exports[key] === _ExtMarkdown[key]) return;
|
|
64
|
+
Object.defineProperty(exports, key, {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function get() {
|
|
67
|
+
return _ExtMarkdown[key];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
46
72
|
var _authUtils = require("./authUtils");
|
|
47
73
|
|
|
48
74
|
Object.keys(_authUtils).forEach(function (key) {
|