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.
Files changed (333) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +154 -154
  3. package/backend/emailCatch.d.ts +4 -4
  4. package/backend/emailCatch.js +11 -11
  5. package/backend/emailError.d.ts +4 -4
  6. package/backend/emailError.js +56 -56
  7. package/backend/getRoamJSUser.d.ts +11 -11
  8. package/backend/getRoamJSUser.js +30 -30
  9. package/backend/headers.d.ts +5 -5
  10. package/backend/headers.js +7 -7
  11. package/backend/index.d.ts +6 -6
  12. package/backend/index.js +20 -20
  13. package/backend/meterRoamJSUser.d.ts +4 -4
  14. package/backend/meterRoamJSUser.js +14 -14
  15. package/backend/putRoamJSUser.d.ts +10 -10
  16. package/backend/putRoamJSUser.js +25 -25
  17. package/components/BlockErrorBoundary.d.ts +15 -15
  18. package/components/BlockErrorBoundary.js +27 -27
  19. package/components/BlockInput.d.ts +12 -12
  20. package/components/BlockInput.js +53 -53
  21. package/components/ComponentContainer.d.ts +9 -9
  22. package/components/ComponentContainer.js +46 -46
  23. package/components/ConfigPage.d.ts +99 -99
  24. package/components/ConfigPage.js +751 -751
  25. package/components/CursorMenu.d.ts +21 -21
  26. package/components/CursorMenu.js +181 -181
  27. package/components/Description.d.ts +5 -5
  28. package/components/Description.js +16 -16
  29. package/components/ExternalLogin.d.ts +18 -18
  30. package/components/ExternalLogin.js +131 -131
  31. package/components/Filter.d.ts +14 -14
  32. package/components/Filter.js +147 -147
  33. package/components/Loading.d.ts +4 -4
  34. package/components/Loading.js +33 -33
  35. package/components/MenuItemSelect.d.ts +10 -10
  36. package/components/MenuItemSelect.js +13 -13
  37. package/components/OauthSelect.d.ts +5 -5
  38. package/components/OauthSelect.js +25 -25
  39. package/components/PageInput.d.ts +10 -10
  40. package/components/PageInput.js +69 -69
  41. package/components/ServiceComponents.d.ts +49 -49
  42. package/components/ServiceComponents.js +277 -277
  43. package/components/SimpleAlert.d.ts +12 -12
  44. package/components/SimpleAlert.js +38 -38
  45. package/components/Toast.d.ts +10 -10
  46. package/components/Toast.js +41 -41
  47. package/components/TokenDialog.d.ts +11 -11
  48. package/components/TokenDialog.js +100 -100
  49. package/components/index.d.ts +15 -15
  50. package/components/index.js +60 -60
  51. package/date/constants.d.ts +2 -2
  52. package/date/constants.js +5 -5
  53. package/date/index.d.ts +5 -5
  54. package/date/index.js +13 -13
  55. package/date/parseRoamDate.d.ts +2 -2
  56. package/date/parseRoamDate.js +6 -6
  57. package/date/parseRoamDateUid.d.ts +2 -2
  58. package/date/parseRoamDateUid.js +6 -6
  59. package/date/toRoamDate.d.ts +2 -2
  60. package/date/toRoamDate.js +6 -6
  61. package/date/toRoamDateUid.d.ts +2 -2
  62. package/date/toRoamDateUid.js +6 -6
  63. package/dom/addBlockCommand.d.ts +5 -5
  64. package/dom/addBlockCommand.js +53 -53
  65. package/dom/addOldRoamJSDependency.d.ts +2 -2
  66. package/dom/addOldRoamJSDependency.js +10 -10
  67. package/dom/addRoamJSDependency.d.ts +2 -2
  68. package/dom/addRoamJSDependency.js +8 -8
  69. package/dom/addScriptAsDependency.d.ts +6 -6
  70. package/dom/addScriptAsDependency.js +16 -16
  71. package/dom/addStyle.d.ts +2 -2
  72. package/dom/addStyle.js +14 -14
  73. package/dom/constants.d.ts +1 -1
  74. package/dom/constants.js +4 -4
  75. package/dom/createBlockObserver.d.ts +7 -7
  76. package/dom/createBlockObserver.js +43 -43
  77. package/dom/createButtonObserver.d.ts +6 -6
  78. package/dom/createButtonObserver.js +21 -21
  79. package/dom/createDivObserver.d.ts +2 -2
  80. package/dom/createDivObserver.js +8 -8
  81. package/dom/createHTMLObserver.d.ts +8 -8
  82. package/dom/createHTMLObserver.js +24 -24
  83. package/dom/createHashtagObserver.d.ts +5 -5
  84. package/dom/createHashtagObserver.js +16 -16
  85. package/dom/createIconButton.d.ts +2 -2
  86. package/dom/createIconButton.js +12 -12
  87. package/dom/createObserver.d.ts +2 -2
  88. package/dom/createObserver.js +6 -6
  89. package/dom/createOverlayObserver.d.ts +2 -2
  90. package/dom/createOverlayObserver.js +6 -6
  91. package/dom/createPageObserver.d.ts +2 -2
  92. package/dom/createPageObserver.js +34 -34
  93. package/dom/createPageTitleObserver.d.ts +6 -6
  94. package/dom/createPageTitleObserver.js +29 -29
  95. package/dom/genericError.d.ts +4 -4
  96. package/dom/genericError.js +16 -16
  97. package/dom/getActiveUids.d.ts +3 -3
  98. package/dom/getActiveUids.js +6 -6
  99. package/dom/getBlockUidFromTarget.d.ts +2 -2
  100. package/dom/getBlockUidFromTarget.js +33 -33
  101. package/dom/getCurrentPageUid.d.ts +2 -2
  102. package/dom/getCurrentPageUid.js +6 -6
  103. package/dom/getDomRefs.d.ts +2 -2
  104. package/dom/getDomRefs.js +12 -12
  105. package/dom/getDropUidOffset.d.ts +5 -5
  106. package/dom/getDropUidOffset.js +27 -27
  107. package/dom/getMutatedNodes.d.ts +7 -7
  108. package/dom/getMutatedNodes.js +11 -11
  109. package/dom/getPageTitleByHtmlElement.d.ts +2 -2
  110. package/dom/getPageTitleByHtmlElement.js +12 -12
  111. package/dom/getPageTitleValueByHtmlElement.d.ts +2 -2
  112. package/dom/getPageTitleValueByHtmlElement.js +27 -27
  113. package/dom/getReferenceBlockUid.d.ts +2 -2
  114. package/dom/getReferenceBlockUid.js +18 -18
  115. package/dom/getRoamUrl.d.ts +2 -2
  116. package/dom/getRoamUrl.js +4 -4
  117. package/dom/getRoamUrlByPage.d.ts +2 -2
  118. package/dom/getRoamUrlByPage.js +10 -10
  119. package/dom/getUids.d.ts +3 -3
  120. package/dom/getUids.js +8 -8
  121. package/dom/getUidsFromButton.d.ts +3 -3
  122. package/dom/getUidsFromButton.js +9 -9
  123. package/dom/getUidsFromId.d.ts +5 -5
  124. package/dom/getUidsFromId.js +15 -15
  125. package/dom/index.d.ts +31 -31
  126. package/dom/index.js +65 -65
  127. package/dom/openBlock.d.ts +2 -2
  128. package/dom/openBlock.js +6 -6
  129. package/dom/openBlockElement.d.ts +2 -2
  130. package/dom/openBlockElement.js +16 -16
  131. package/dom/parseRoamBlocksToHtml.d.ts +9 -9
  132. package/dom/parseRoamBlocksToHtml.js +75 -75
  133. package/dom/resolveRefs.d.ts +2 -2
  134. package/dom/resolveRefs.js +24 -24
  135. package/events/index.d.ts +1 -1
  136. package/events/index.js +8 -8
  137. package/events/watchOnce.d.ts +3 -3
  138. package/events/watchOnce.js +11 -11
  139. package/hooks/index.d.ts +3 -3
  140. package/hooks/index.js +12 -12
  141. package/hooks/useArrowKeyDown.d.ts +8 -8
  142. package/hooks/useArrowKeyDown.js +31 -31
  143. package/hooks/useRoamJSTokenWarning.d.ts +2 -2
  144. package/hooks/useRoamJSTokenWarning.js +11 -11
  145. package/hooks/useSubTree.d.ts +3 -3
  146. package/hooks/useSubTree.js +11 -11
  147. package/index.d.ts +11 -11
  148. package/index.js +14 -14
  149. package/marked/index.d.ts +14 -14
  150. package/marked/index.js +518 -518
  151. package/package.json +86 -86
  152. package/queries/getAllBlockUids.d.ts +2 -2
  153. package/queries/getAllBlockUids.js +6 -6
  154. package/queries/getAllBlockUidsAndTexts.d.ts +5 -5
  155. package/queries/getAllBlockUidsAndTexts.js +6 -6
  156. package/queries/getAllPageNames.d.ts +2 -2
  157. package/queries/getAllPageNames.js +6 -6
  158. package/queries/getAttributeValueByBlockAndName.d.ts +5 -5
  159. package/queries/getAttributeValueByBlockAndName.js +11 -11
  160. package/queries/getBasicTreeByParentUid.d.ts +3 -3
  161. package/queries/getBasicTreeByParentUid.js +13 -13
  162. package/queries/getBlockUidAndTextIncludingText.d.ts +5 -5
  163. package/queries/getBlockUidAndTextIncludingText.js +6 -6
  164. package/queries/getBlockUidByTextOnPage.d.ts +5 -5
  165. package/queries/getBlockUidByTextOnPage.js +7 -7
  166. package/queries/getBlockUidsAndTextsReferencingPage.d.ts +5 -5
  167. package/queries/getBlockUidsAndTextsReferencingPage.js +11 -11
  168. package/queries/getBlockUidsByPageTitle.d.ts +2 -2
  169. package/queries/getBlockUidsByPageTitle.js +8 -8
  170. package/queries/getBlockUidsReferencingBlock.d.ts +2 -2
  171. package/queries/getBlockUidsReferencingBlock.js +6 -6
  172. package/queries/getBlockUidsReferencingPage.d.ts +2 -2
  173. package/queries/getBlockUidsReferencingPage.js +8 -8
  174. package/queries/getBlockUidsWithParentUid.d.ts +2 -2
  175. package/queries/getBlockUidsWithParentUid.js +6 -6
  176. package/queries/getChildrenLengthByPageUid.d.ts +2 -2
  177. package/queries/getChildrenLengthByPageUid.js +4 -4
  178. package/queries/getCreateTimeByBlockUid.d.ts +2 -2
  179. package/queries/getCreateTimeByBlockUid.js +7 -7
  180. package/queries/getCurrentUser.d.ts +2 -2
  181. package/queries/getCurrentUser.js +11 -11
  182. package/queries/getCurrentUserDisplayName.d.ts +2 -2
  183. package/queries/getCurrentUserDisplayName.js +13 -13
  184. package/queries/getCurrentUserEmail.d.ts +2 -2
  185. package/queries/getCurrentUserEmail.js +13 -13
  186. package/queries/getCurrentUserUid.d.ts +2 -2
  187. package/queries/getCurrentUserUid.js +13 -13
  188. package/queries/getDisplayNameByEmail.d.ts +2 -2
  189. package/queries/getDisplayNameByEmail.js +7 -7
  190. package/queries/getDisplayNameByUid.d.ts +2 -2
  191. package/queries/getDisplayNameByUid.js +7 -7
  192. package/queries/getEditTimeByBlockUid.d.ts +2 -2
  193. package/queries/getEditTimeByBlockUid.js +7 -7
  194. package/queries/getEditedUserEmailByBlockUid.d.ts +2 -2
  195. package/queries/getEditedUserEmailByBlockUid.js +7 -7
  196. package/queries/getFirstChildTextByBlockUid.d.ts +2 -2
  197. package/queries/getFirstChildTextByBlockUid.js +7 -7
  198. package/queries/getFirstChildUidByBlockUid.d.ts +2 -2
  199. package/queries/getFirstChildUidByBlockUid.js +5 -5
  200. package/queries/getFullTreeByParentUid.d.ts +3 -3
  201. package/queries/getFullTreeByParentUid.js +26 -26
  202. package/queries/getLinkedPageTitlesUnderUid.d.ts +2 -2
  203. package/queries/getLinkedPageTitlesUnderUid.js +6 -6
  204. package/queries/getNthChildUidByBlockUid.d.ts +5 -5
  205. package/queries/getNthChildUidByBlockUid.js +7 -7
  206. package/queries/getOrderByBlockUid.d.ts +2 -2
  207. package/queries/getOrderByBlockUid.js +7 -7
  208. package/queries/getPageTitleByBlockUid.d.ts +2 -2
  209. package/queries/getPageTitleByBlockUid.js +7 -7
  210. package/queries/getPageTitleByPageUid.d.ts +2 -2
  211. package/queries/getPageTitleByPageUid.js +9 -9
  212. package/queries/getPageTitleReferencesByPageTitle.d.ts +2 -2
  213. package/queries/getPageTitleReferencesByPageTitle.js +8 -8
  214. package/queries/getPageTitlesAndBlockUidsReferencingPage.d.ts +5 -5
  215. package/queries/getPageTitlesAndBlockUidsReferencingPage.js +8 -8
  216. package/queries/getPageTitlesAndUidsDirectlyReferencingPage.d.ts +5 -5
  217. package/queries/getPageTitlesAndUidsDirectlyReferencingPage.js +8 -8
  218. package/queries/getPageTitlesReferencingBlockUid.d.ts +2 -2
  219. package/queries/getPageTitlesReferencingBlockUid.js +6 -6
  220. package/queries/getPageTitlesStartingWithPrefix.d.ts +2 -2
  221. package/queries/getPageTitlesStartingWithPrefix.js +6 -6
  222. package/queries/getPageUidByPageTitle.d.ts +2 -2
  223. package/queries/getPageUidByPageTitle.js +9 -9
  224. package/queries/getPageViewType.d.ts +3 -3
  225. package/queries/getPageViewType.js +9 -9
  226. package/queries/getParentTextByBlockUid.d.ts +2 -2
  227. package/queries/getParentTextByBlockUid.js +7 -7
  228. package/queries/getParentTextByBlockUidAndTag.d.ts +5 -5
  229. package/queries/getParentTextByBlockUidAndTag.js +7 -7
  230. package/queries/getParentUidByBlockUid.d.ts +2 -2
  231. package/queries/getParentUidByBlockUid.js +7 -7
  232. package/queries/getParentUidsOfBlockUid.d.ts +2 -2
  233. package/queries/getParentUidsOfBlockUid.js +6 -6
  234. package/queries/getSettingsByEmail.d.ts +3 -3
  235. package/queries/getSettingsByEmail.js +7 -7
  236. package/queries/getShallowTreeByParentUid.d.ts +5 -5
  237. package/queries/getShallowTreeByParentUid.js +10 -10
  238. package/queries/getTextByBlockUid.d.ts +2 -2
  239. package/queries/getTextByBlockUid.js +7 -7
  240. package/queries/index.d.ts +45 -45
  241. package/queries/index.js +96 -96
  242. package/queries/isTagOnPage.d.ts +5 -5
  243. package/queries/isTagOnPage.js +9 -9
  244. package/queries/normalizePageTitle.d.ts +2 -2
  245. package/queries/normalizePageTitle.js +4 -4
  246. package/types/index.d.ts +461 -459
  247. package/types/index.js +2 -2
  248. package/types/query-builder.d.ts +16 -16
  249. package/types/query-builder.js +2 -2
  250. package/util/addInputSetting.d.ts +7 -7
  251. package/util/addInputSetting.js +25 -25
  252. package/util/apiDelete.d.ts +2 -2
  253. package/util/apiDelete.js +9 -9
  254. package/util/apiGet.d.ts +2 -2
  255. package/util/apiGet.js +9 -9
  256. package/util/apiPost.d.ts +2 -2
  257. package/util/apiPost.js +9 -9
  258. package/util/apiPut.d.ts +2 -2
  259. package/util/apiPut.js +9 -9
  260. package/util/createOverlayRender.d.ts +6 -6
  261. package/util/createOverlayRender.js +18 -18
  262. package/util/createTagRegex.d.ts +2 -2
  263. package/util/createTagRegex.js +4 -4
  264. package/util/extractRef.d.ts +2 -2
  265. package/util/extractRef.js +8 -8
  266. package/util/extractTag.d.ts +2 -2
  267. package/util/extractTag.js +12 -12
  268. package/util/getAuthorizationHeader.d.ts +2 -2
  269. package/util/getAuthorizationHeader.js +12 -12
  270. package/util/getGraph.d.ts +2 -2
  271. package/util/getGraph.js +8 -8
  272. package/util/getLocalStorageKey.d.ts +2 -2
  273. package/util/getLocalStorageKey.js +6 -6
  274. package/util/getOauth.d.ts +2 -2
  275. package/util/getOauth.js +50 -50
  276. package/util/getOauthAccounts.d.ts +2 -2
  277. package/util/getOauthAccounts.js +21 -21
  278. package/util/getRenderRoot.d.ts +2 -2
  279. package/util/getRenderRoot.js +11 -11
  280. package/util/getSettingIntFromTree.d.ts +7 -7
  281. package/util/getSettingIntFromTree.js +11 -11
  282. package/util/getSettingValueFromTree.d.ts +7 -7
  283. package/util/getSettingValueFromTree.js +13 -13
  284. package/util/getSettingValuesFromTree.d.ts +7 -7
  285. package/util/getSettingValuesFromTree.js +12 -12
  286. package/util/getSubTree.d.ts +8 -8
  287. package/util/getSubTree.js +19 -19
  288. package/util/getToken.d.ts +2 -2
  289. package/util/getToken.js +9 -9
  290. package/util/getTokenFromTree.d.ts +2 -2
  291. package/util/getTokenFromTree.js +5 -5
  292. package/util/idToTitle.d.ts +2 -2
  293. package/util/idToTitle.js +8 -8
  294. package/util/index.d.ts +23 -23
  295. package/util/index.js +52 -52
  296. package/util/isControl.d.ts +2 -2
  297. package/util/isControl.js +6 -6
  298. package/util/localStorageGet.d.ts +2 -2
  299. package/util/localStorageGet.js +8 -8
  300. package/util/localStorageRemove.d.ts +2 -2
  301. package/util/localStorageRemove.js +6 -6
  302. package/util/localStorageSet.d.ts +2 -2
  303. package/util/localStorageSet.js +8 -8
  304. package/util/registerSmartBlocksCommand.d.ts +8 -8
  305. package/util/registerSmartBlocksCommand.js +24 -24
  306. package/util/runExtension.d.ts +4 -4
  307. package/util/runExtension.js +40 -40
  308. package/util/setInputSetting.d.ts +7 -7
  309. package/util/setInputSetting.js +33 -33
  310. package/util/setInputSettings.d.ts +7 -7
  311. package/util/setInputSettings.js +28 -28
  312. package/util/toConfigPageName.d.ts +2 -2
  313. package/util/toConfigPageName.js +4 -4
  314. package/util/toFlexRegex.d.ts +2 -2
  315. package/util/toFlexRegex.js +4 -4
  316. package/writes/clearBlockById.d.ts +2 -2
  317. package/writes/clearBlockById.js +11 -11
  318. package/writes/clearBlockByUid.d.ts +2 -2
  319. package/writes/clearBlockByUid.js +9 -9
  320. package/writes/createBlock.d.ts +9 -9
  321. package/writes/createBlock.js +61 -61
  322. package/writes/createPage.d.ts +7 -7
  323. package/writes/createPage.js +18 -18
  324. package/writes/deleteBlock.d.ts +2 -2
  325. package/writes/deleteBlock.js +6 -6
  326. package/writes/index.d.ts +8 -8
  327. package/writes/index.js +22 -22
  328. package/writes/openBlockInSidebar.d.ts +2 -2
  329. package/writes/openBlockInSidebar.js +13 -13
  330. package/writes/updateActiveBlock.d.ts +2 -2
  331. package/writes/updateActiveBlock.js +11 -11
  332. package/writes/updateBlock.d.ts +5 -5
  333. 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.
@@ -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;
@@ -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
@@ -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;
@@ -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;
@@ -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
@@ -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;
@@ -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