roamjs-components 0.53.2 → 0.53.5
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/LICENSE +21 -21
- package/README.md +154 -154
- package/backend/emailCatch.d.ts +4 -4
- package/backend/emailCatch.js +11 -11
- package/backend/emailError.d.ts +4 -4
- package/backend/emailError.js +56 -56
- package/backend/getRoamJSUser.d.ts +11 -11
- package/backend/getRoamJSUser.js +30 -30
- package/backend/headers.d.ts +5 -5
- package/backend/headers.js +7 -7
- package/backend/index.d.ts +6 -6
- package/backend/index.js +20 -20
- package/backend/meterRoamJSUser.d.ts +4 -4
- package/backend/meterRoamJSUser.js +14 -14
- package/backend/putRoamJSUser.d.ts +10 -10
- package/backend/putRoamJSUser.js +25 -25
- package/components/BlockErrorBoundary.d.ts +15 -15
- package/components/BlockErrorBoundary.js +27 -27
- package/components/BlockInput.d.ts +12 -12
- package/components/BlockInput.js +53 -53
- package/components/ComponentContainer.d.ts +9 -9
- package/components/ComponentContainer.js +46 -46
- package/components/ConfigPage.d.ts +99 -99
- package/components/ConfigPage.js +751 -751
- package/components/CursorMenu.d.ts +21 -21
- package/components/CursorMenu.js +181 -181
- package/components/Description.d.ts +5 -5
- package/components/Description.js +16 -16
- package/components/ExternalLogin.d.ts +18 -18
- package/components/ExternalLogin.js +131 -131
- package/components/Filter.d.ts +14 -14
- package/components/Filter.js +147 -147
- package/components/Loading.d.ts +4 -4
- package/components/Loading.js +33 -33
- package/components/MenuItemSelect.d.ts +10 -10
- package/components/MenuItemSelect.js +13 -13
- package/components/OauthSelect.d.ts +5 -5
- package/components/OauthSelect.js +25 -25
- package/components/PageInput.d.ts +10 -10
- package/components/PageInput.js +69 -69
- package/components/ServiceComponents.d.ts +49 -49
- package/components/ServiceComponents.js +277 -277
- package/components/SimpleAlert.d.ts +12 -12
- package/components/SimpleAlert.js +38 -38
- package/components/Toast.d.ts +10 -10
- package/components/Toast.js +41 -41
- package/components/TokenDialog.d.ts +11 -11
- package/components/TokenDialog.js +100 -100
- package/components/index.d.ts +15 -15
- package/components/index.js +60 -60
- package/date/constants.d.ts +2 -2
- package/date/constants.js +5 -5
- package/date/index.d.ts +5 -5
- package/date/index.js +13 -13
- package/date/parseRoamDate.d.ts +2 -2
- package/date/parseRoamDate.js +6 -6
- package/date/parseRoamDateUid.d.ts +2 -2
- package/date/parseRoamDateUid.js +6 -6
- package/date/toRoamDate.d.ts +2 -2
- package/date/toRoamDate.js +6 -6
- package/date/toRoamDateUid.d.ts +2 -2
- package/date/toRoamDateUid.js +6 -6
- package/dom/addBlockCommand.d.ts +5 -5
- package/dom/addBlockCommand.js +53 -53
- package/dom/addOldRoamJSDependency.d.ts +2 -2
- package/dom/addOldRoamJSDependency.js +10 -10
- package/dom/addRoamJSDependency.d.ts +2 -2
- package/dom/addRoamJSDependency.js +8 -8
- package/dom/addScriptAsDependency.d.ts +6 -6
- package/dom/addScriptAsDependency.js +16 -16
- package/dom/addStyle.d.ts +2 -2
- package/dom/addStyle.js +14 -14
- package/dom/constants.d.ts +1 -1
- package/dom/constants.js +4 -4
- package/dom/createBlockObserver.d.ts +7 -7
- package/dom/createBlockObserver.js +43 -43
- package/dom/createButtonObserver.d.ts +6 -6
- package/dom/createButtonObserver.js +21 -21
- package/dom/createDivObserver.d.ts +2 -2
- package/dom/createDivObserver.js +8 -8
- package/dom/createHTMLObserver.d.ts +8 -8
- package/dom/createHTMLObserver.js +24 -24
- package/dom/createHashtagObserver.d.ts +5 -5
- package/dom/createHashtagObserver.js +16 -16
- package/dom/createIconButton.d.ts +2 -2
- package/dom/createIconButton.js +12 -12
- package/dom/createObserver.d.ts +2 -2
- package/dom/createObserver.js +6 -6
- package/dom/createOverlayObserver.d.ts +2 -2
- package/dom/createOverlayObserver.js +6 -6
- package/dom/createPageObserver.d.ts +2 -2
- package/dom/createPageObserver.js +34 -34
- package/dom/createPageTitleObserver.d.ts +6 -6
- package/dom/createPageTitleObserver.js +29 -29
- package/dom/genericError.d.ts +4 -4
- package/dom/genericError.js +16 -16
- package/dom/getActiveUids.d.ts +3 -3
- package/dom/getActiveUids.js +6 -6
- package/dom/getBlockUidFromTarget.d.ts +2 -2
- package/dom/getBlockUidFromTarget.js +33 -33
- package/dom/getCurrentPageUid.d.ts +2 -2
- package/dom/getCurrentPageUid.js +6 -6
- package/dom/getDomRefs.d.ts +2 -2
- package/dom/getDomRefs.js +12 -12
- package/dom/getDropUidOffset.d.ts +5 -5
- package/dom/getDropUidOffset.js +27 -27
- package/dom/getMutatedNodes.d.ts +7 -7
- package/dom/getMutatedNodes.js +11 -11
- package/dom/getPageTitleByHtmlElement.d.ts +2 -2
- package/dom/getPageTitleByHtmlElement.js +12 -12
- package/dom/getPageTitleValueByHtmlElement.d.ts +2 -2
- package/dom/getPageTitleValueByHtmlElement.js +27 -27
- package/dom/getReferenceBlockUid.d.ts +2 -2
- package/dom/getReferenceBlockUid.js +18 -18
- package/dom/getRoamUrl.d.ts +2 -2
- package/dom/getRoamUrl.js +4 -4
- package/dom/getRoamUrlByPage.d.ts +2 -2
- package/dom/getRoamUrlByPage.js +10 -10
- package/dom/getUids.d.ts +3 -3
- package/dom/getUids.js +8 -8
- package/dom/getUidsFromButton.d.ts +3 -3
- package/dom/getUidsFromButton.js +9 -9
- package/dom/getUidsFromId.d.ts +5 -5
- package/dom/getUidsFromId.js +15 -15
- package/dom/index.d.ts +31 -31
- package/dom/index.js +65 -65
- package/dom/openBlock.d.ts +2 -2
- package/dom/openBlock.js +6 -6
- package/dom/openBlockElement.d.ts +2 -2
- package/dom/openBlockElement.js +16 -16
- package/dom/parseRoamBlocksToHtml.d.ts +9 -9
- package/dom/parseRoamBlocksToHtml.js +75 -75
- package/dom/resolveRefs.d.ts +2 -2
- package/dom/resolveRefs.js +24 -24
- package/events/index.d.ts +1 -1
- package/events/index.js +8 -8
- package/events/watchOnce.d.ts +3 -3
- package/events/watchOnce.js +11 -11
- package/hooks/index.d.ts +3 -3
- package/hooks/index.js +12 -12
- package/hooks/useArrowKeyDown.d.ts +8 -8
- package/hooks/useArrowKeyDown.js +31 -31
- package/hooks/useRoamJSTokenWarning.d.ts +2 -2
- package/hooks/useRoamJSTokenWarning.js +11 -11
- package/hooks/useSubTree.d.ts +3 -3
- package/hooks/useSubTree.js +11 -11
- package/index.d.ts +11 -11
- package/index.js +14 -14
- package/marked/index.d.ts +14 -14
- package/marked/index.js +518 -518
- package/package.json +86 -86
- package/queries/getAllBlockUids.d.ts +2 -2
- package/queries/getAllBlockUids.js +6 -6
- package/queries/getAllBlockUidsAndTexts.d.ts +5 -5
- package/queries/getAllBlockUidsAndTexts.js +6 -6
- package/queries/getAllPageNames.d.ts +2 -2
- package/queries/getAllPageNames.js +6 -6
- package/queries/getAttributeValueByBlockAndName.d.ts +5 -5
- package/queries/getAttributeValueByBlockAndName.js +11 -11
- package/queries/getBasicTreeByParentUid.d.ts +3 -3
- package/queries/getBasicTreeByParentUid.js +13 -13
- package/queries/getBlockUidAndTextIncludingText.d.ts +5 -5
- package/queries/getBlockUidAndTextIncludingText.js +6 -6
- package/queries/getBlockUidByTextOnPage.d.ts +5 -5
- package/queries/getBlockUidByTextOnPage.js +7 -7
- package/queries/getBlockUidsAndTextsReferencingPage.d.ts +5 -5
- package/queries/getBlockUidsAndTextsReferencingPage.js +11 -11
- package/queries/getBlockUidsByPageTitle.d.ts +2 -2
- package/queries/getBlockUidsByPageTitle.js +8 -8
- package/queries/getBlockUidsReferencingBlock.d.ts +2 -2
- package/queries/getBlockUidsReferencingBlock.js +6 -6
- package/queries/getBlockUidsReferencingPage.d.ts +2 -2
- package/queries/getBlockUidsReferencingPage.js +8 -8
- package/queries/getBlockUidsWithParentUid.d.ts +2 -2
- package/queries/getBlockUidsWithParentUid.js +6 -6
- package/queries/getChildrenLengthByPageUid.d.ts +2 -2
- package/queries/getChildrenLengthByPageUid.js +4 -4
- package/queries/getCreateTimeByBlockUid.d.ts +2 -2
- package/queries/getCreateTimeByBlockUid.js +7 -7
- package/queries/getCurrentUser.d.ts +2 -2
- package/queries/getCurrentUser.js +11 -11
- package/queries/getCurrentUserDisplayName.d.ts +2 -2
- package/queries/getCurrentUserDisplayName.js +13 -13
- package/queries/getCurrentUserEmail.d.ts +2 -2
- package/queries/getCurrentUserEmail.js +13 -13
- package/queries/getCurrentUserUid.d.ts +2 -2
- package/queries/getCurrentUserUid.js +13 -13
- package/queries/getDisplayNameByEmail.d.ts +2 -2
- package/queries/getDisplayNameByEmail.js +7 -7
- package/queries/getDisplayNameByUid.d.ts +2 -2
- package/queries/getDisplayNameByUid.js +7 -7
- package/queries/getEditTimeByBlockUid.d.ts +2 -2
- package/queries/getEditTimeByBlockUid.js +7 -7
- package/queries/getEditedUserEmailByBlockUid.d.ts +2 -2
- package/queries/getEditedUserEmailByBlockUid.js +7 -7
- package/queries/getFirstChildTextByBlockUid.d.ts +2 -2
- package/queries/getFirstChildTextByBlockUid.js +7 -7
- package/queries/getFirstChildUidByBlockUid.d.ts +2 -2
- package/queries/getFirstChildUidByBlockUid.js +5 -5
- package/queries/getFullTreeByParentUid.d.ts +3 -3
- package/queries/getFullTreeByParentUid.js +26 -26
- package/queries/getLinkedPageTitlesUnderUid.d.ts +2 -2
- package/queries/getLinkedPageTitlesUnderUid.js +6 -6
- package/queries/getNthChildUidByBlockUid.d.ts +5 -5
- package/queries/getNthChildUidByBlockUid.js +7 -7
- package/queries/getOrderByBlockUid.d.ts +2 -2
- package/queries/getOrderByBlockUid.js +7 -7
- package/queries/getPageTitleByBlockUid.d.ts +2 -2
- package/queries/getPageTitleByBlockUid.js +7 -7
- package/queries/getPageTitleByPageUid.d.ts +2 -2
- package/queries/getPageTitleByPageUid.js +9 -9
- package/queries/getPageTitleReferencesByPageTitle.d.ts +2 -2
- package/queries/getPageTitleReferencesByPageTitle.js +8 -8
- package/queries/getPageTitlesAndBlockUidsReferencingPage.d.ts +5 -5
- package/queries/getPageTitlesAndBlockUidsReferencingPage.js +8 -8
- package/queries/getPageTitlesAndUidsDirectlyReferencingPage.d.ts +5 -5
- package/queries/getPageTitlesAndUidsDirectlyReferencingPage.js +8 -8
- package/queries/getPageTitlesReferencingBlockUid.d.ts +2 -2
- package/queries/getPageTitlesReferencingBlockUid.js +6 -6
- package/queries/getPageTitlesStartingWithPrefix.d.ts +2 -2
- package/queries/getPageTitlesStartingWithPrefix.js +6 -6
- package/queries/getPageUidByPageTitle.d.ts +2 -2
- package/queries/getPageUidByPageTitle.js +9 -9
- package/queries/getPageViewType.d.ts +3 -3
- package/queries/getPageViewType.js +9 -9
- package/queries/getParentTextByBlockUid.d.ts +2 -2
- package/queries/getParentTextByBlockUid.js +7 -7
- package/queries/getParentTextByBlockUidAndTag.d.ts +5 -5
- package/queries/getParentTextByBlockUidAndTag.js +7 -7
- package/queries/getParentUidByBlockUid.d.ts +2 -2
- package/queries/getParentUidByBlockUid.js +7 -7
- package/queries/getParentUidsOfBlockUid.d.ts +2 -2
- package/queries/getParentUidsOfBlockUid.js +6 -6
- package/queries/getSettingsByEmail.d.ts +3 -3
- package/queries/getSettingsByEmail.js +7 -7
- package/queries/getShallowTreeByParentUid.d.ts +5 -5
- package/queries/getShallowTreeByParentUid.js +10 -10
- package/queries/getTextByBlockUid.d.ts +2 -2
- package/queries/getTextByBlockUid.js +7 -7
- package/queries/index.d.ts +45 -45
- package/queries/index.js +96 -96
- package/queries/isTagOnPage.d.ts +5 -5
- package/queries/isTagOnPage.js +9 -9
- package/queries/normalizePageTitle.d.ts +2 -2
- package/queries/normalizePageTitle.js +4 -4
- package/types/index.d.ts +461 -459
- package/types/index.js +2 -2
- package/types/query-builder.d.ts +16 -16
- package/types/query-builder.js +2 -2
- package/util/addInputSetting.d.ts +7 -7
- package/util/addInputSetting.js +25 -25
- package/util/apiDelete.d.ts +2 -2
- package/util/apiDelete.js +9 -9
- package/util/apiGet.d.ts +2 -2
- package/util/apiGet.js +9 -9
- package/util/apiPost.d.ts +2 -2
- package/util/apiPost.js +9 -9
- package/util/apiPut.d.ts +2 -2
- package/util/apiPut.js +9 -9
- package/util/createOverlayRender.d.ts +6 -6
- package/util/createOverlayRender.js +18 -18
- package/util/createTagRegex.d.ts +2 -2
- package/util/createTagRegex.js +4 -4
- package/util/extractRef.d.ts +2 -2
- package/util/extractRef.js +8 -8
- package/util/extractTag.d.ts +2 -2
- package/util/extractTag.js +12 -12
- package/util/getAuthorizationHeader.d.ts +2 -2
- package/util/getAuthorizationHeader.js +12 -12
- package/util/getGraph.d.ts +2 -2
- package/util/getGraph.js +8 -8
- package/util/getLocalStorageKey.d.ts +2 -2
- package/util/getLocalStorageKey.js +6 -6
- package/util/getOauth.d.ts +2 -2
- package/util/getOauth.js +50 -50
- package/util/getOauthAccounts.d.ts +2 -2
- package/util/getOauthAccounts.js +21 -21
- package/util/getRenderRoot.d.ts +2 -2
- package/util/getRenderRoot.js +11 -11
- package/util/getSettingIntFromTree.d.ts +7 -7
- package/util/getSettingIntFromTree.js +11 -11
- package/util/getSettingValueFromTree.d.ts +7 -7
- package/util/getSettingValueFromTree.js +13 -13
- package/util/getSettingValuesFromTree.d.ts +7 -7
- package/util/getSettingValuesFromTree.js +12 -12
- package/util/getSubTree.d.ts +8 -8
- package/util/getSubTree.js +19 -19
- package/util/getToken.d.ts +2 -2
- package/util/getToken.js +9 -9
- package/util/getTokenFromTree.d.ts +2 -2
- package/util/getTokenFromTree.js +5 -5
- package/util/idToTitle.d.ts +2 -2
- package/util/idToTitle.js +8 -8
- package/util/index.d.ts +23 -23
- package/util/index.js +52 -52
- package/util/isControl.d.ts +2 -2
- package/util/isControl.js +6 -6
- package/util/localStorageGet.d.ts +2 -2
- package/util/localStorageGet.js +8 -8
- package/util/localStorageRemove.d.ts +2 -2
- package/util/localStorageRemove.js +6 -6
- package/util/localStorageSet.d.ts +2 -2
- package/util/localStorageSet.js +8 -8
- package/util/registerSmartBlocksCommand.d.ts +8 -8
- package/util/registerSmartBlocksCommand.js +24 -24
- package/util/runExtension.d.ts +4 -4
- package/util/runExtension.js +40 -40
- package/util/setInputSetting.d.ts +7 -7
- package/util/setInputSetting.js +33 -33
- package/util/setInputSettings.d.ts +7 -7
- package/util/setInputSettings.js +28 -28
- package/util/toConfigPageName.d.ts +2 -2
- package/util/toConfigPageName.js +4 -4
- package/util/toFlexRegex.d.ts +2 -2
- package/util/toFlexRegex.js +4 -4
- package/writes/clearBlockById.d.ts +2 -2
- package/writes/clearBlockById.js +11 -11
- package/writes/clearBlockByUid.d.ts +2 -2
- package/writes/clearBlockByUid.js +9 -9
- package/writes/createBlock.d.ts +9 -9
- package/writes/createBlock.js +61 -61
- package/writes/createPage.d.ts +7 -7
- package/writes/createPage.js +18 -18
- package/writes/deleteBlock.d.ts +2 -2
- package/writes/deleteBlock.js +6 -6
- package/writes/index.d.ts +8 -8
- package/writes/index.js +22 -22
- package/writes/openBlockInSidebar.d.ts +2 -2
- package/writes/openBlockInSidebar.js +13 -13
- package/writes/updateActiveBlock.d.ts +2 -2
- package/writes/updateActiveBlock.js +11 -11
- package/writes/updateBlock.d.ts +5 -5
- package/writes/updateBlock.js +17 -17
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021 David Vargas
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 David Vargas
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,154 +1,154 @@
|
|
|
1
|
-
# roamjs-components
|
|
2
|
-
|
|
3
|
-
This is a collection of common UI components used by RoamJS extensions and services made available to make development easier for other Roam developers.
|
|
4
|
-
|
|
5
|
-
## Organization
|
|
6
|
-
|
|
7
|
-
This package takes a modular approach - each function exposed in its own file in an effort to limit the bundle sizes of consumers. It has the following directories:
|
|
8
|
-
- `components` - React components used in Roam
|
|
9
|
-
- `date` - Utilities made to make interacting with Roam dates easier
|
|
10
|
-
- `dom` - Utilities that interact with Roam's DOM structure
|
|
11
|
-
- `events` - Utilities that interact with Roam's event system
|
|
12
|
-
- `hooks` - React hooks commonly used in Roam extensions
|
|
13
|
-
- `marked` - RoamJS' official Roam-flavored markdown to HTML processor
|
|
14
|
-
- `queries` - Helpers that abstract datalog into common, easy-to-invoke, typed queries
|
|
15
|
-
- `types` - Common typescript types used when interacting with these methods
|
|
16
|
-
- `util` - All other utilities not found in the other directories
|
|
17
|
-
- `writes` - Helpers that abstract Roam's write API into common, easy-to-invoke, typed actions
|
|
18
|
-
|
|
19
|
-
We recommend using modular imports for using any methods found in these libraries. For example,
|
|
20
|
-
|
|
21
|
-
```typescript
|
|
22
|
-
import getTextByBlockUid from "roam-client/queries/getTextByBlockUid";
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
instead of
|
|
26
|
-
|
|
27
|
-
```typescript
|
|
28
|
-
import { getTextByBlockUid } from "roam-client/queries";
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
though, the latter is still available for convenience.
|
|
32
|
-
|
|
33
|
-
The rest of this README is not exhaustive, and will soon live in https://roamjs.com/extensions/developer.
|
|
34
|
-
|
|
35
|
-
## Util
|
|
36
|
-
|
|
37
|
-
The following are a list of methods used to help interface with the RoamJS Components found in this library.
|
|
38
|
-
|
|
39
|
-
### createConfigObserver({title, config})
|
|
40
|
-
|
|
41
|
-
This is an observer that will render the `ConfigPage` UI on the page of your choosing.
|
|
42
|
-
|
|
43
|
-
* `title: string` Name of the page to render the Configuration page ui. If this page doesn't already exist in the user's Roam database, one will be created with specified default values filled in.
|
|
44
|
-
* `config: object` The metadata specifying which fields your configuration supports
|
|
45
|
-
* `tabs: object[]` The first level tabs grouping your fields. They map to first level blocks on the Roam Page.
|
|
46
|
-
* `id: string` The name of the tab to use in both the Roam UI and in the tab label. The `home` id inserts blocks at the top level of Roam.
|
|
47
|
-
* `toggleable: boolean` Whether this tab should be able to turn on and off. Turning a tab off disables the rest of the nested fields.
|
|
48
|
-
* `fields: object[]` The set of field metadata grouped in this tab. If fields is empty, it will be assumed that this tab is a state container for the extension not meant to be interacted with by the user.
|
|
49
|
-
* `title: string` The name of the field, displayed on the nested tag and in the Roam block.
|
|
50
|
-
* `description: string` The description of the field with renders next to each field label as a tooltip.
|
|
51
|
-
* `type: string` The field type, with only the following valid values:
|
|
52
|
-
* `text` Renders a text input.
|
|
53
|
-
* `number` Renders a number input.
|
|
54
|
-
* `flag` Renders a boolean checkbox.
|
|
55
|
-
* `multitext` Renders a text input that could have multiple child values. Used for an array of string values.
|
|
56
|
-
* `pages` Similar to multitext, but all values are Roam pages.
|
|
57
|
-
* `oauth` Renders a login button based on the service provider
|
|
58
|
-
* `select` Renders a dropdown with the configured options
|
|
59
|
-
* `defaultValue` The default value filled in on page creation. Field is optional and type based on type above
|
|
60
|
-
* `options` An extra object of options for configuring a field, based on the type above.
|
|
61
|
-
* `text` None
|
|
62
|
-
* `number` None
|
|
63
|
-
* `flag` None
|
|
64
|
-
* `multitext` None
|
|
65
|
-
* `pages` None
|
|
66
|
-
* `oauth`
|
|
67
|
-
* `service: string` The name of the service provider, used on the login button
|
|
68
|
-
* `getPopoutUrl: () => Promise<string>` A getter retrieving the url needed to begin the oauth process
|
|
69
|
-
* `getAuthData: (d: string) => Promise<Record<string, string>>` A getter that takes in a stringified JSON object from the oauth popout window and retrieves the auth related data.
|
|
70
|
-
* `ServiceIcon: React.FunctionComponent<React.SVGAttributes<SVGElement>>` The SVG Icon to render next to the login button.
|
|
71
|
-
* `select`
|
|
72
|
-
* `items: string[]` The set of valid options for this dopdown
|
|
73
|
-
|
|
74
|
-
### createComponentRender(FC, className)
|
|
75
|
-
|
|
76
|
-
Creates a render function for the component `FC` rendered inside of a `ComponentContainer` component. A `ComponentContainer` simulates standard Roam `{{components}}` in that they are meant to be rendered in a block with an edit pencil icon to edit the block if necessary.
|
|
77
|
-
* `FC: ReactElement` The component rendered with a `blockUid` prop that references the block the component is rendered in.
|
|
78
|
-
* `className` An optional class name to pass to the surrounding `ComponentContainer`.
|
|
79
|
-
|
|
80
|
-
### createOverlayRender(id, Overlay)
|
|
81
|
-
|
|
82
|
-
Creates a render function for the component `Overlay` mounted on a parent from the id passed to [getRenderRoot](#getRenderRoot(id)), unmounting when the overlay closes.
|
|
83
|
-
* `id: string` The id passed to the parent element rendering the Overlay, interpolated inside of `roamjs-${id}-root`.
|
|
84
|
-
* `Overlay: ({onClose: () => void}) => ReactElement` The React component rendered with a `onClose` prop to handle unmounting.
|
|
85
|
-
|
|
86
|
-
### getRenderRoot(id)
|
|
87
|
-
|
|
88
|
-
This creates a `div` appended to Roam's natural react root, most commonly used as its own root element for overlay components.
|
|
89
|
-
* `id: string` The id of the parent element, interpolated inside of `roamjs-${id}-root`.
|
|
90
|
-
|
|
91
|
-
### getSettingIntFromTree({tree, key, defaultValue})
|
|
92
|
-
|
|
93
|
-
This is a utility method for grabbing the integer value of a node from a tree by a given key.
|
|
94
|
-
* `tree: TextNode[]` The array of `TextNode` to search through.
|
|
95
|
-
* `key: string` The key used to find the desired node
|
|
96
|
-
* `defaultValue?: number` The default value the getter should have if there are no nodes with the specified key, defaulted to 0.
|
|
97
|
-
|
|
98
|
-
### getSettingValueFromTree
|
|
99
|
-
|
|
100
|
-
This is a utility method for grabbing the string value of a node from a tree by a given key.
|
|
101
|
-
* `tree: TextNode[]` The array of `TextNode` to search through.
|
|
102
|
-
* `key: string` The key used to find the desired node
|
|
103
|
-
* `defaultValue?: number` The default value the getter should have if there are no nodes with the specified key, defaulted to an empty string.
|
|
104
|
-
|
|
105
|
-
### getSettingValuesFromTree
|
|
106
|
-
|
|
107
|
-
This is a utility method for grabbing the string value of a node from a tree by a given key.
|
|
108
|
-
* `tree: TextNode[]` The array of `TextNode` to search through.
|
|
109
|
-
* `key: string` The key used to find the desired node
|
|
110
|
-
* `defaultValue?: number` The default value the getter should have if there are no nodes with the specified key, defaulted to an empty string.
|
|
111
|
-
|
|
112
|
-
### addInputSetting
|
|
113
|
-
|
|
114
|
-
This is a utility method for adding a value as part of multiple to a key by making it a descendant of node in the tree.
|
|
115
|
-
* `blockUid: string` The uid of the root block housing all of settings.
|
|
116
|
-
* `value: string` The value to add to the setting
|
|
117
|
-
* `key: string` The setting name
|
|
118
|
-
* `index?: number` The index where the setting should be created if new, defaulted to 0
|
|
119
|
-
|
|
120
|
-
### setInputSetting
|
|
121
|
-
|
|
122
|
-
This is a utility method for setting a value to a key by making it a descendant of node in the tree.
|
|
123
|
-
* `blockUid: string` The uid of the root block housing all of settings.
|
|
124
|
-
* `value: string` The value to assign to the setting
|
|
125
|
-
* `key: string` The setting name
|
|
126
|
-
* `index?: number` The index where the setting should be created if new, defaulted to 0
|
|
127
|
-
|
|
128
|
-
### setInputSettings
|
|
129
|
-
|
|
130
|
-
This is a utility method for setting multiple values to a key by making it a descendant of node in the tree.
|
|
131
|
-
* `blockUid: string` The uid of the root block housing all of settings.
|
|
132
|
-
* `values: string` The set of values to assign to the setting
|
|
133
|
-
* `key: string` The setting name
|
|
134
|
-
* `index?: number` The index where the setting should be created if new, defaulted to 0
|
|
135
|
-
|
|
136
|
-
## Components
|
|
137
|
-
|
|
138
|
-
The following are a list of React components commonly used across RoamJS extensions.
|
|
139
|
-
|
|
140
|
-
### BlockErrorBoundary
|
|
141
|
-
|
|
142
|
-
An Error Boundary to wrap around components meant to live within blocks to catch any React Errors. The error message will interpolate inside of a `{ERROR}` placeholder within the `message` prop and output as a child block.
|
|
143
|
-
|
|
144
|
-
### Description
|
|
145
|
-
|
|
146
|
-
An info icon with a tooltip, used to give help text to UI components.
|
|
147
|
-
|
|
148
|
-
### MenuItemSelect
|
|
149
|
-
|
|
150
|
-
A standard Select using blueprint's MenuItem component as the item rendered.
|
|
151
|
-
|
|
152
|
-
### WarningToast
|
|
153
|
-
|
|
154
|
-
Renders a yellow warning message, then unmounts itself upon dismissing.
|
|
1
|
+
# roamjs-components
|
|
2
|
+
|
|
3
|
+
This is a collection of common UI components used by RoamJS extensions and services made available to make development easier for other Roam developers.
|
|
4
|
+
|
|
5
|
+
## Organization
|
|
6
|
+
|
|
7
|
+
This package takes a modular approach - each function exposed in its own file in an effort to limit the bundle sizes of consumers. It has the following directories:
|
|
8
|
+
- `components` - React components used in Roam
|
|
9
|
+
- `date` - Utilities made to make interacting with Roam dates easier
|
|
10
|
+
- `dom` - Utilities that interact with Roam's DOM structure
|
|
11
|
+
- `events` - Utilities that interact with Roam's event system
|
|
12
|
+
- `hooks` - React hooks commonly used in Roam extensions
|
|
13
|
+
- `marked` - RoamJS' official Roam-flavored markdown to HTML processor
|
|
14
|
+
- `queries` - Helpers that abstract datalog into common, easy-to-invoke, typed queries
|
|
15
|
+
- `types` - Common typescript types used when interacting with these methods
|
|
16
|
+
- `util` - All other utilities not found in the other directories
|
|
17
|
+
- `writes` - Helpers that abstract Roam's write API into common, easy-to-invoke, typed actions
|
|
18
|
+
|
|
19
|
+
We recommend using modular imports for using any methods found in these libraries. For example,
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import getTextByBlockUid from "roam-client/queries/getTextByBlockUid";
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
instead of
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { getTextByBlockUid } from "roam-client/queries";
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
though, the latter is still available for convenience.
|
|
32
|
+
|
|
33
|
+
The rest of this README is not exhaustive, and will soon live in https://roamjs.com/extensions/developer.
|
|
34
|
+
|
|
35
|
+
## Util
|
|
36
|
+
|
|
37
|
+
The following are a list of methods used to help interface with the RoamJS Components found in this library.
|
|
38
|
+
|
|
39
|
+
### createConfigObserver({title, config})
|
|
40
|
+
|
|
41
|
+
This is an observer that will render the `ConfigPage` UI on the page of your choosing.
|
|
42
|
+
|
|
43
|
+
* `title: string` Name of the page to render the Configuration page ui. If this page doesn't already exist in the user's Roam database, one will be created with specified default values filled in.
|
|
44
|
+
* `config: object` The metadata specifying which fields your configuration supports
|
|
45
|
+
* `tabs: object[]` The first level tabs grouping your fields. They map to first level blocks on the Roam Page.
|
|
46
|
+
* `id: string` The name of the tab to use in both the Roam UI and in the tab label. The `home` id inserts blocks at the top level of Roam.
|
|
47
|
+
* `toggleable: boolean` Whether this tab should be able to turn on and off. Turning a tab off disables the rest of the nested fields.
|
|
48
|
+
* `fields: object[]` The set of field metadata grouped in this tab. If fields is empty, it will be assumed that this tab is a state container for the extension not meant to be interacted with by the user.
|
|
49
|
+
* `title: string` The name of the field, displayed on the nested tag and in the Roam block.
|
|
50
|
+
* `description: string` The description of the field with renders next to each field label as a tooltip.
|
|
51
|
+
* `type: string` The field type, with only the following valid values:
|
|
52
|
+
* `text` Renders a text input.
|
|
53
|
+
* `number` Renders a number input.
|
|
54
|
+
* `flag` Renders a boolean checkbox.
|
|
55
|
+
* `multitext` Renders a text input that could have multiple child values. Used for an array of string values.
|
|
56
|
+
* `pages` Similar to multitext, but all values are Roam pages.
|
|
57
|
+
* `oauth` Renders a login button based on the service provider
|
|
58
|
+
* `select` Renders a dropdown with the configured options
|
|
59
|
+
* `defaultValue` The default value filled in on page creation. Field is optional and type based on type above
|
|
60
|
+
* `options` An extra object of options for configuring a field, based on the type above.
|
|
61
|
+
* `text` None
|
|
62
|
+
* `number` None
|
|
63
|
+
* `flag` None
|
|
64
|
+
* `multitext` None
|
|
65
|
+
* `pages` None
|
|
66
|
+
* `oauth`
|
|
67
|
+
* `service: string` The name of the service provider, used on the login button
|
|
68
|
+
* `getPopoutUrl: () => Promise<string>` A getter retrieving the url needed to begin the oauth process
|
|
69
|
+
* `getAuthData: (d: string) => Promise<Record<string, string>>` A getter that takes in a stringified JSON object from the oauth popout window and retrieves the auth related data.
|
|
70
|
+
* `ServiceIcon: React.FunctionComponent<React.SVGAttributes<SVGElement>>` The SVG Icon to render next to the login button.
|
|
71
|
+
* `select`
|
|
72
|
+
* `items: string[]` The set of valid options for this dopdown
|
|
73
|
+
|
|
74
|
+
### createComponentRender(FC, className)
|
|
75
|
+
|
|
76
|
+
Creates a render function for the component `FC` rendered inside of a `ComponentContainer` component. A `ComponentContainer` simulates standard Roam `{{components}}` in that they are meant to be rendered in a block with an edit pencil icon to edit the block if necessary.
|
|
77
|
+
* `FC: ReactElement` The component rendered with a `blockUid` prop that references the block the component is rendered in.
|
|
78
|
+
* `className` An optional class name to pass to the surrounding `ComponentContainer`.
|
|
79
|
+
|
|
80
|
+
### createOverlayRender(id, Overlay)
|
|
81
|
+
|
|
82
|
+
Creates a render function for the component `Overlay` mounted on a parent from the id passed to [getRenderRoot](#getRenderRoot(id)), unmounting when the overlay closes.
|
|
83
|
+
* `id: string` The id passed to the parent element rendering the Overlay, interpolated inside of `roamjs-${id}-root`.
|
|
84
|
+
* `Overlay: ({onClose: () => void}) => ReactElement` The React component rendered with a `onClose` prop to handle unmounting.
|
|
85
|
+
|
|
86
|
+
### getRenderRoot(id)
|
|
87
|
+
|
|
88
|
+
This creates a `div` appended to Roam's natural react root, most commonly used as its own root element for overlay components.
|
|
89
|
+
* `id: string` The id of the parent element, interpolated inside of `roamjs-${id}-root`.
|
|
90
|
+
|
|
91
|
+
### getSettingIntFromTree({tree, key, defaultValue})
|
|
92
|
+
|
|
93
|
+
This is a utility method for grabbing the integer value of a node from a tree by a given key.
|
|
94
|
+
* `tree: TextNode[]` The array of `TextNode` to search through.
|
|
95
|
+
* `key: string` The key used to find the desired node
|
|
96
|
+
* `defaultValue?: number` The default value the getter should have if there are no nodes with the specified key, defaulted to 0.
|
|
97
|
+
|
|
98
|
+
### getSettingValueFromTree
|
|
99
|
+
|
|
100
|
+
This is a utility method for grabbing the string value of a node from a tree by a given key.
|
|
101
|
+
* `tree: TextNode[]` The array of `TextNode` to search through.
|
|
102
|
+
* `key: string` The key used to find the desired node
|
|
103
|
+
* `defaultValue?: number` The default value the getter should have if there are no nodes with the specified key, defaulted to an empty string.
|
|
104
|
+
|
|
105
|
+
### getSettingValuesFromTree
|
|
106
|
+
|
|
107
|
+
This is a utility method for grabbing the string value of a node from a tree by a given key.
|
|
108
|
+
* `tree: TextNode[]` The array of `TextNode` to search through.
|
|
109
|
+
* `key: string` The key used to find the desired node
|
|
110
|
+
* `defaultValue?: number` The default value the getter should have if there are no nodes with the specified key, defaulted to an empty string.
|
|
111
|
+
|
|
112
|
+
### addInputSetting
|
|
113
|
+
|
|
114
|
+
This is a utility method for adding a value as part of multiple to a key by making it a descendant of node in the tree.
|
|
115
|
+
* `blockUid: string` The uid of the root block housing all of settings.
|
|
116
|
+
* `value: string` The value to add to the setting
|
|
117
|
+
* `key: string` The setting name
|
|
118
|
+
* `index?: number` The index where the setting should be created if new, defaulted to 0
|
|
119
|
+
|
|
120
|
+
### setInputSetting
|
|
121
|
+
|
|
122
|
+
This is a utility method for setting a value to a key by making it a descendant of node in the tree.
|
|
123
|
+
* `blockUid: string` The uid of the root block housing all of settings.
|
|
124
|
+
* `value: string` The value to assign to the setting
|
|
125
|
+
* `key: string` The setting name
|
|
126
|
+
* `index?: number` The index where the setting should be created if new, defaulted to 0
|
|
127
|
+
|
|
128
|
+
### setInputSettings
|
|
129
|
+
|
|
130
|
+
This is a utility method for setting multiple values to a key by making it a descendant of node in the tree.
|
|
131
|
+
* `blockUid: string` The uid of the root block housing all of settings.
|
|
132
|
+
* `values: string` The set of values to assign to the setting
|
|
133
|
+
* `key: string` The setting name
|
|
134
|
+
* `index?: number` The index where the setting should be created if new, defaulted to 0
|
|
135
|
+
|
|
136
|
+
## Components
|
|
137
|
+
|
|
138
|
+
The following are a list of React components commonly used across RoamJS extensions.
|
|
139
|
+
|
|
140
|
+
### BlockErrorBoundary
|
|
141
|
+
|
|
142
|
+
An Error Boundary to wrap around components meant to live within blocks to catch any React Errors. The error message will interpolate inside of a `{ERROR}` placeholder within the `message` prop and output as a child block.
|
|
143
|
+
|
|
144
|
+
### Description
|
|
145
|
+
|
|
146
|
+
An info icon with a tooltip, used to give help text to UI components.
|
|
147
|
+
|
|
148
|
+
### MenuItemSelect
|
|
149
|
+
|
|
150
|
+
A standard Select using blueprint's MenuItem component as the item rendered.
|
|
151
|
+
|
|
152
|
+
### WarningToast
|
|
153
|
+
|
|
154
|
+
Renders a yellow warning message, then unmounts itself upon dismissing.
|
package/backend/emailCatch.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { APIGatewayProxyResult } from "aws-lambda";
|
|
2
|
-
import type { AxiosError } from "axios";
|
|
3
|
-
declare const emailCatch: (subject: string) => (e: AxiosError) => Promise<APIGatewayProxyResult>;
|
|
4
|
-
export default emailCatch;
|
|
1
|
+
import type { APIGatewayProxyResult } from "aws-lambda";
|
|
2
|
+
import type { AxiosError } from "axios";
|
|
3
|
+
declare const emailCatch: (subject: string) => (e: AxiosError) => Promise<APIGatewayProxyResult>;
|
|
4
|
+
export default emailCatch;
|
package/backend/emailCatch.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const emailError_1 = (0, tslib_1.__importDefault)(require("./emailError"));
|
|
5
|
-
const headers_1 = (0, tslib_1.__importDefault)(require("./headers"));
|
|
6
|
-
const emailCatch = (subject) => (e) => (0, emailError_1.default)(subject, e).then((id) => ({
|
|
7
|
-
statusCode: 500,
|
|
8
|
-
body: `Unknown error - Message Id ${id}`,
|
|
9
|
-
headers: headers_1.default,
|
|
10
|
-
}));
|
|
11
|
-
exports.default = emailCatch;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const emailError_1 = (0, tslib_1.__importDefault)(require("./emailError"));
|
|
5
|
+
const headers_1 = (0, tslib_1.__importDefault)(require("./headers"));
|
|
6
|
+
const emailCatch = (subject) => (e) => (0, emailError_1.default)(subject, e).then((id) => ({
|
|
7
|
+
statusCode: 500,
|
|
8
|
+
body: `Unknown error - Message Id ${id}`,
|
|
9
|
+
headers: headers_1.default,
|
|
10
|
+
}));
|
|
11
|
+
exports.default = emailCatch;
|
|
12
12
|
//# sourceMappingURL=emailCatch.js.map
|
package/backend/emailError.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AxiosError } from "axios";
|
|
2
|
-
import React from "react";
|
|
3
|
-
declare const emailError: (subject: string, e: AxiosError, moreBody?: React.ReactNode) => Promise<string>;
|
|
4
|
-
export default emailError;
|
|
1
|
+
import type { AxiosError } from "axios";
|
|
2
|
+
import React from "react";
|
|
3
|
+
declare const emailError: (subject: string, e: AxiosError, moreBody?: React.ReactNode) => Promise<string>;
|
|
4
|
+
export default emailError;
|
package/backend/emailError.js
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const sendEmail_1 = (0, tslib_1.__importDefault)(require("aws-sdk-plus/dist/sendEmail"));
|
|
5
|
-
const react_1 = (0, tslib_1.__importDefault)(require("react"));
|
|
6
|
-
const emailError = (subject, e, moreBody) => {
|
|
7
|
-
var _a, _b;
|
|
8
|
-
return (0, sendEmail_1.default)({
|
|
9
|
-
to: process.env.ROAMJS_EMAIL,
|
|
10
|
-
from: "support@roamjs.com",
|
|
11
|
-
subject: `RoamJS Error: ${subject}`,
|
|
12
|
-
body: react_1.default.createElement("div", {
|
|
13
|
-
style: {
|
|
14
|
-
margin: "0 auto",
|
|
15
|
-
maxWidth: 600,
|
|
16
|
-
fontFamily: `"Proxima Nova","proxima-nova",Helvetica,Arial sans-serif`,
|
|
17
|
-
padding: `20px 0`,
|
|
18
|
-
},
|
|
19
|
-
}, react_1.default.createElement("div", {
|
|
20
|
-
style: {
|
|
21
|
-
width: "80%",
|
|
22
|
-
margin: "0 auto",
|
|
23
|
-
paddingBottom: 20,
|
|
24
|
-
borderBottom: "1px dashed #dadada",
|
|
25
|
-
textAlign: "center",
|
|
26
|
-
},
|
|
27
|
-
}, react_1.default.createElement("img", {
|
|
28
|
-
src: "https://roamjs.com/images/logo-low-res.png",
|
|
29
|
-
width: 128,
|
|
30
|
-
})), react_1.default.createElement("div", {
|
|
31
|
-
style: {
|
|
32
|
-
width: "80%",
|
|
33
|
-
margin: "30px auto",
|
|
34
|
-
fontSize: 16,
|
|
35
|
-
},
|
|
36
|
-
}, react_1.default.createElement("h3", {}, `An error was thrown in a RoamJS Lambda`), react_1.default.createElement("p", {}, `${e.name}: ${typeof ((_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === "object"
|
|
37
|
-
? e.response.data.message || JSON.stringify(e.response.data)
|
|
38
|
-
: ((_b = e.response) === null || _b === void 0 ? void 0 : _b.data) || e.message}`), react_1.default.createElement("p", {}, e.stack), ...(moreBody ? [react_1.default.createElement("div", {}, moreBody)] : [])), react_1.default.createElement("div", {
|
|
39
|
-
style: {
|
|
40
|
-
width: "80%",
|
|
41
|
-
margin: "30px auto",
|
|
42
|
-
borderTop: "1px dashed #dadada",
|
|
43
|
-
display: "flex",
|
|
44
|
-
color: "#a8a8a8",
|
|
45
|
-
paddingTop: 15,
|
|
46
|
-
},
|
|
47
|
-
}, react_1.default.createElement("div", { style: { width: "50%" } }, "Sent From ", react_1.default.createElement("a", {
|
|
48
|
-
href: "https://roamjs.com",
|
|
49
|
-
style: { color: "#3ba4dc", textDecoration: "none" },
|
|
50
|
-
}, "RoamJS")), react_1.default.createElement("div", { style: { width: "50%", textAlign: "right" } }, react_1.default.createElement("a", {
|
|
51
|
-
href: "mailto:support@roamjs.com",
|
|
52
|
-
style: { color: "#3ba4dc", textDecoration: "none" },
|
|
53
|
-
}, "Contact Support")))),
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
exports.default = emailError;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const sendEmail_1 = (0, tslib_1.__importDefault)(require("aws-sdk-plus/dist/sendEmail"));
|
|
5
|
+
const react_1 = (0, tslib_1.__importDefault)(require("react"));
|
|
6
|
+
const emailError = (subject, e, moreBody) => {
|
|
7
|
+
var _a, _b;
|
|
8
|
+
return (0, sendEmail_1.default)({
|
|
9
|
+
to: process.env.ROAMJS_EMAIL,
|
|
10
|
+
from: "support@roamjs.com",
|
|
11
|
+
subject: `RoamJS Error: ${subject}`,
|
|
12
|
+
body: react_1.default.createElement("div", {
|
|
13
|
+
style: {
|
|
14
|
+
margin: "0 auto",
|
|
15
|
+
maxWidth: 600,
|
|
16
|
+
fontFamily: `"Proxima Nova","proxima-nova",Helvetica,Arial sans-serif`,
|
|
17
|
+
padding: `20px 0`,
|
|
18
|
+
},
|
|
19
|
+
}, react_1.default.createElement("div", {
|
|
20
|
+
style: {
|
|
21
|
+
width: "80%",
|
|
22
|
+
margin: "0 auto",
|
|
23
|
+
paddingBottom: 20,
|
|
24
|
+
borderBottom: "1px dashed #dadada",
|
|
25
|
+
textAlign: "center",
|
|
26
|
+
},
|
|
27
|
+
}, react_1.default.createElement("img", {
|
|
28
|
+
src: "https://roamjs.com/images/logo-low-res.png",
|
|
29
|
+
width: 128,
|
|
30
|
+
})), react_1.default.createElement("div", {
|
|
31
|
+
style: {
|
|
32
|
+
width: "80%",
|
|
33
|
+
margin: "30px auto",
|
|
34
|
+
fontSize: 16,
|
|
35
|
+
},
|
|
36
|
+
}, react_1.default.createElement("h3", {}, `An error was thrown in a RoamJS Lambda`), react_1.default.createElement("p", {}, `${e.name}: ${typeof ((_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === "object"
|
|
37
|
+
? e.response.data.message || JSON.stringify(e.response.data)
|
|
38
|
+
: ((_b = e.response) === null || _b === void 0 ? void 0 : _b.data) || e.message}`), react_1.default.createElement("p", {}, e.stack), ...(moreBody ? [react_1.default.createElement("div", {}, moreBody)] : [])), react_1.default.createElement("div", {
|
|
39
|
+
style: {
|
|
40
|
+
width: "80%",
|
|
41
|
+
margin: "30px auto",
|
|
42
|
+
borderTop: "1px dashed #dadada",
|
|
43
|
+
display: "flex",
|
|
44
|
+
color: "#a8a8a8",
|
|
45
|
+
paddingTop: 15,
|
|
46
|
+
},
|
|
47
|
+
}, react_1.default.createElement("div", { style: { width: "50%" } }, "Sent From ", react_1.default.createElement("a", {
|
|
48
|
+
href: "https://roamjs.com",
|
|
49
|
+
style: { color: "#3ba4dc", textDecoration: "none" },
|
|
50
|
+
}, "RoamJS")), react_1.default.createElement("div", { style: { width: "50%", textAlign: "right" } }, react_1.default.createElement("a", {
|
|
51
|
+
href: "mailto:support@roamjs.com",
|
|
52
|
+
style: { color: "#3ba4dc", textDecoration: "none" },
|
|
53
|
+
}, "Contact Support")))),
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
exports.default = emailError;
|
|
57
57
|
//# sourceMappingURL=emailError.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { APIGatewayProxyResult, APIGatewayProxyHandler } from "aws-lambda";
|
|
2
|
-
declare type RoamJSUser = {
|
|
3
|
-
email: string;
|
|
4
|
-
id: string;
|
|
5
|
-
[k: string]: unknown;
|
|
6
|
-
};
|
|
7
|
-
declare const getRoamJSUser: (token: string, extensionId?: string, email?: string | undefined, dev?: boolean) => Promise<RoamJSUser>;
|
|
8
|
-
export declare const awsGetRoamJSUser: <T = Record<string, unknown>>(handler: (u: RoamJSUser & {
|
|
9
|
-
token: string;
|
|
10
|
-
}, body: T) => Promise<APIGatewayProxyResult>) => APIGatewayProxyHandler;
|
|
11
|
-
export default getRoamJSUser;
|
|
1
|
+
import { APIGatewayProxyResult, APIGatewayProxyHandler } from "aws-lambda";
|
|
2
|
+
declare type RoamJSUser = {
|
|
3
|
+
email: string;
|
|
4
|
+
id: string;
|
|
5
|
+
[k: string]: unknown;
|
|
6
|
+
};
|
|
7
|
+
declare const getRoamJSUser: (token: string, extensionId?: string, email?: string | undefined, dev?: boolean) => Promise<RoamJSUser>;
|
|
8
|
+
export declare const awsGetRoamJSUser: <T = Record<string, unknown>>(handler: (u: RoamJSUser & {
|
|
9
|
+
token: string;
|
|
10
|
+
}, body: T) => Promise<APIGatewayProxyResult>) => APIGatewayProxyHandler;
|
|
11
|
+
export default getRoamJSUser;
|
package/backend/getRoamJSUser.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.awsGetRoamJSUser = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const axios_1 = (0, tslib_1.__importDefault)(require("axios"));
|
|
6
|
-
const headers_1 = (0, tslib_1.__importDefault)(require("./headers"));
|
|
7
|
-
const getRoamJSUser = (token, extensionId = process.env.ROAMJS_EXTENSION_ID || "", email = process.env.ROAMJS_EMAIL, dev = process.env.NODE_ENV === "development") => axios_1.default
|
|
8
|
-
.get(`https://lambda.roamjs.com/user`, {
|
|
9
|
-
headers: Object.assign({ Authorization: `Bearer ${Buffer.from(`${email}:${process.env.ROAMJS_DEVELOPER_TOKEN}`).toString("base64")}`, "x-roamjs-token": token, "x-roamjs-extension": extensionId }, (dev
|
|
10
|
-
? {
|
|
11
|
-
"x-roamjs-dev": "true",
|
|
12
|
-
}
|
|
13
|
-
: {})),
|
|
14
|
-
})
|
|
15
|
-
.then((r) => r.data);
|
|
16
|
-
const awsGetRoamJSUser = (handler) => (event) => {
|
|
17
|
-
const token = event.headers.Authorization || event.headers.authorization || "";
|
|
18
|
-
return getRoamJSUser(token)
|
|
19
|
-
.then((u) => handler(Object.assign(Object.assign({}, u), { token }), Object.assign(Object.assign({}, event.queryStringParameters), JSON.parse(event.body || "{}"))))
|
|
20
|
-
.catch((e) => {
|
|
21
|
-
var _a;
|
|
22
|
-
return ({
|
|
23
|
-
statusCode: 401,
|
|
24
|
-
body: (_a = e.response) === null || _a === void 0 ? void 0 : _a.data,
|
|
25
|
-
headers: headers_1.default,
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
exports.awsGetRoamJSUser = awsGetRoamJSUser;
|
|
30
|
-
exports.default = getRoamJSUser;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.awsGetRoamJSUser = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const axios_1 = (0, tslib_1.__importDefault)(require("axios"));
|
|
6
|
+
const headers_1 = (0, tslib_1.__importDefault)(require("./headers"));
|
|
7
|
+
const getRoamJSUser = (token, extensionId = process.env.ROAMJS_EXTENSION_ID || "", email = process.env.ROAMJS_EMAIL, dev = process.env.NODE_ENV === "development") => axios_1.default
|
|
8
|
+
.get(`https://lambda.roamjs.com/user`, {
|
|
9
|
+
headers: Object.assign({ Authorization: `Bearer ${Buffer.from(`${email}:${process.env.ROAMJS_DEVELOPER_TOKEN}`).toString("base64")}`, "x-roamjs-token": token, "x-roamjs-extension": extensionId }, (dev
|
|
10
|
+
? {
|
|
11
|
+
"x-roamjs-dev": "true",
|
|
12
|
+
}
|
|
13
|
+
: {})),
|
|
14
|
+
})
|
|
15
|
+
.then((r) => r.data);
|
|
16
|
+
const awsGetRoamJSUser = (handler) => (event) => {
|
|
17
|
+
const token = event.headers.Authorization || event.headers.authorization || "";
|
|
18
|
+
return getRoamJSUser(token)
|
|
19
|
+
.then((u) => handler(Object.assign(Object.assign({}, u), { token }), Object.assign(Object.assign({}, event.queryStringParameters), JSON.parse(event.body || "{}"))))
|
|
20
|
+
.catch((e) => {
|
|
21
|
+
var _a;
|
|
22
|
+
return ({
|
|
23
|
+
statusCode: 401,
|
|
24
|
+
body: (_a = e.response) === null || _a === void 0 ? void 0 : _a.data,
|
|
25
|
+
headers: headers_1.default,
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
exports.awsGetRoamJSUser = awsGetRoamJSUser;
|
|
30
|
+
exports.default = getRoamJSUser;
|
|
31
31
|
//# sourceMappingURL=getRoamJSUser.js.map
|
package/backend/headers.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
declare const headers: {
|
|
2
|
-
"Access-Control-Allow-Origin": string;
|
|
3
|
-
"Access-Control-Allow-Methods": string;
|
|
4
|
-
};
|
|
5
|
-
export default headers;
|
|
1
|
+
declare const headers: {
|
|
2
|
+
"Access-Control-Allow-Origin": string;
|
|
3
|
+
"Access-Control-Allow-Methods": string;
|
|
4
|
+
};
|
|
5
|
+
export default headers;
|
package/backend/headers.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const headers = {
|
|
4
|
-
"Access-Control-Allow-Origin": "https://roamresearch.com",
|
|
5
|
-
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE",
|
|
6
|
-
};
|
|
7
|
-
exports.default = headers;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const headers = {
|
|
4
|
+
"Access-Control-Allow-Origin": "https://roamresearch.com",
|
|
5
|
+
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE",
|
|
6
|
+
};
|
|
7
|
+
exports.default = headers;
|
|
8
8
|
//# sourceMappingURL=headers.js.map
|