- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.5k
[Components] roamresearch #14385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
            jcortes
  merged 1 commit into
  PipedreamHQ:master
from
jcortes:roamresearch-new-components
  
      
      
   
  Oct 28, 2024 
      
    
  
     Merged
                    [Components] roamresearch #14385
Changes from all commits
      Commits
    
    
  File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
        
          
          
            63 changes: 63 additions & 0 deletions
          
          63 
        
  ...ts/roamresearch/actions/add-content-to-daily-note-page/add-content-to-daily-note-page.mjs
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import app from "../../roamresearch.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "roamresearch-add-content-to-daily-note-page", | ||
| name: "Add Content To Daily Note Page", | ||
| description: "Adds content as a child block to a daily note page in Roam Research (access to encrypted and non encrypted graphs). [See the documentation](https://roamresearch.com/#/app/developer-documentation/page/eb8OVhaFC).", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| dailyNoteTitle: { | ||
| type: "string", | ||
| label: "Date For Daily Note", | ||
| description: "The date for the daily note page title, formatted as `MM-DD-YYYY`. Keep in mind the Daily Note page should exist.", | ||
| }, | ||
| content: { | ||
| propDefinition: [ | ||
| app, | ||
| "content", | ||
| ], | ||
| }, | ||
| nestUnder: { | ||
| propDefinition: [ | ||
| app, | ||
| "nestUnder", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| app, | ||
| dailyNoteTitle, | ||
| content, | ||
| nestUnder, | ||
| } = this; | ||
|  | ||
| const response = app.appendBlocks({ | ||
| $, | ||
| data: { | ||
| "location": { | ||
| page: { | ||
| title: { | ||
| "daily-note-page": dailyNoteTitle, | ||
| }, | ||
| }, | ||
| ...(nestUnder && { | ||
| "nest-under": { | ||
| string: nestUnder, | ||
| }, | ||
| }), | ||
| }, | ||
| "append-data": [ | ||
| { | ||
| string: content, | ||
| }, | ||
| ], | ||
| }, | ||
| }); | ||
|         
                  jcortes marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
|  | ||
| $.export("$summary", "Succesfully added content to daily note page."); | ||
| return response; | ||
| }, | ||
| }; | ||
        
          
          
            61 changes: 61 additions & 0 deletions
          
          61 
        
  components/roamresearch/actions/add-content-to-page/add-content-to-page.mjs
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import app from "../../roamresearch.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "roamresearch-add-content-to-page", | ||
| name: "Add Content To Page", | ||
| description: "Add content as a child block to an existing or new page in Roam Research (access to encrypted and non encrypted graphs). [See the documentation](https://roamresearch.com/#/app/developer-documentation/page/eb8OVhaFC).", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| title: { | ||
| type: "string", | ||
| label: "Page Title", | ||
| description: "Title of the page to add content to.", | ||
| }, | ||
| content: { | ||
| propDefinition: [ | ||
| app, | ||
| "content", | ||
| ], | ||
| }, | ||
| nestUnder: { | ||
| propDefinition: [ | ||
| app, | ||
| "nestUnder", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| app, | ||
| title, | ||
| content, | ||
| nestUnder, | ||
| } = this; | ||
|  | ||
| const response = app.appendBlocks({ | ||
| $, | ||
| data: { | ||
| "location": { | ||
| page: { | ||
| title, | ||
| }, | ||
| ...(nestUnder && { | ||
| "nest-under": { | ||
| string: nestUnder, | ||
| }, | ||
| }), | ||
| }, | ||
| "append-data": [ | ||
| { | ||
| string: content, | ||
| }, | ||
| ], | ||
| }, | ||
| }); | ||
|  | ||
| $.export("$summary", "Succesfully added content to page."); | ||
| return response; | ||
| }, | ||
|         
                  jcortes marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| }; | ||
        
          
          
            60 changes: 60 additions & 0 deletions
          
          60 
        
  ...onents/roamresearch/actions/add-content-underneath-block/add-content-underneath-block.mjs
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import app from "../../roamresearch.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "roamresearch-add-content-underneath-block", | ||
| name: "Add Content Underneath Block", | ||
| description: "Add content underneath an existing block in your Roam Research graph (access to encrypted and non encrypted graphs). [See the documentation](https://roamresearch.com/)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| blockUid: { | ||
| type: "string", | ||
| label: "Block UID", | ||
| description: "The block UID in the Roam graph you want to append content to.", | ||
| }, | ||
|         
                  jcortes marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| content: { | ||
| type: "string", | ||
| label: "Content", | ||
| description: "The content of the block to be added.", | ||
| }, | ||
| nestUnder: { | ||
| type: "string", | ||
| label: "Nest Under", | ||
| description: "Title of the block to nest the new block under.", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| app, | ||
| blockUid, | ||
| content, | ||
| nestUnder, | ||
| } = this; | ||
|  | ||
| const response = app.appendBlocks({ | ||
| $, | ||
| data: { | ||
| "location": { | ||
| block: { | ||
| uid: blockUid, | ||
| }, | ||
| ...(nestUnder && { | ||
| "nest-under": { | ||
| string: nestUnder, | ||
| }, | ||
| }), | ||
| }, | ||
| "append-data": [ | ||
| { | ||
| string: content, | ||
| }, | ||
| ], | ||
| }, | ||
| }); | ||
|         
                  jcortes marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
|  | ||
| $.export("$summary", "Succesfully added content underneath block."); | ||
|         
                  jcortes marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| return response; | ||
| }, | ||
| }; | ||
        
          
          
            53 changes: 53 additions & 0 deletions
          
          53 
        
  components/roamresearch/actions/get-page-or-block-data/get-page-or-block-data.mjs
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import app from "../../roamresearch.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "roamresearch-get-page-or-block-data", | ||
| name: "Get Page Or Block Data", | ||
| description: "Get the data for a page or block in Roam Research (access only to non ecrypted graphs). [See the documentation](https://roamresearch.com/#/app/developer-documentation/page/eb8OVhaFC).", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| resourceType: { | ||
| type: "string", | ||
| label: "Resource Type", | ||
| description: "The type of resource to get data for.", | ||
| options: [ | ||
| "page", | ||
| "block", | ||
| ], | ||
| }, | ||
| pageOrBlock: { | ||
| type: "string", | ||
| label: "Page Title Or Block UID", | ||
| description: "The page title of the block uid to get data for. Page title example: `My Page` and Block UID example: `ideWWvTgI`.", | ||
| }, | ||
|         
                  jcortes marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| app, | ||
| resourceType, | ||
| pageOrBlock, | ||
| } = this; | ||
|  | ||
| const attribute = resourceType === "page" | ||
| ? ":node/title" | ||
| : ":block/uid"; | ||
|  | ||
| const response = await app.pull({ | ||
| $, | ||
| data: { | ||
| selector: `[${attribute} :block/string :block/order {:block/children ...}]`, | ||
| eid: `[${attribute} "${pageOrBlock}"]`, | ||
| }, | ||
| }); | ||
|         
                  jcortes marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
|  | ||
| if (!response.result) { | ||
| $.export("$summary", `Failed to get data for ${resourceType}: \`${pageOrBlock}\`.`); | ||
| return response; | ||
| } | ||
|         
                  jcortes marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
|  | ||
| $.export("$summary", `Succesfully got data for ${resourceType}: \`${pageOrBlock}\`.`); | ||
|         
                  jcortes marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| return response; | ||
| }, | ||
| }; | ||
        
          
          
            41 changes: 41 additions & 0 deletions
          
          41 
        
  components/roamresearch/actions/search-title/search-title.mjs
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import app from "../../roamresearch.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "roamresearch-search-title", | ||
| name: "Search Title", | ||
| description: "Search for a title in Roam Research pages (access only to non ecrypted graphs). [See the documentation](https://roamresearch.com/#/app/developer-documentation/page/eb8OVhaFC).", | ||
|         
                  jcortes marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| title: { | ||
| type: "string", | ||
| label: "Search Title", | ||
| description: "The title to search for.", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| app, | ||
| title, | ||
| } = this; | ||
| const response = await app.query({ | ||
| $, | ||
| data: { | ||
| query: `[ | ||
| :find (pull ?b [:block/uid :node/title]) | ||
| :in $ ?search-string | ||
| :where [?b :node/title ?page-title] [ | ||
| (clojure.string/includes? ?page-title ?search-string) | ||
| ] | ||
| ]`, | ||
| args: [ | ||
| title, | ||
| ], | ||
| }, | ||
| }); | ||
|  | ||
| $.export("$summary", `Succesfully searched for title: \`${title}\`.`); | ||
|         
                  jcortes marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| return response; | ||
| }, | ||
|         
                  jcortes marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| }; | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| const SUBDOMAIN_PLACEHOLDER = "{subdomain}"; | ||
| const BASE_URL = `https://${SUBDOMAIN_PLACEHOLDER}.roamresearch.com`; | ||
| const VERSION_PATH = "/api/graph"; | ||
|         
                  jcortes marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
|  | ||
| const API = { | ||
| DEFAULT: "api", | ||
| APPEND: "append-api", | ||
| }; | ||
|  | ||
| export default { | ||
| SUBDOMAIN_PLACEHOLDER, | ||
| BASE_URL, | ||
| VERSION_PATH, | ||
| API, | ||
| }; | ||
|         
                  jcortes marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "name": "@pipedream/roamresearch", | ||
| "version": "0.0.1", | ||
| "version": "0.1.0", | ||
| "description": "Pipedream roamresearch Components", | ||
| "main": "roamresearch.app.mjs", | ||
| "keywords": [ | ||
|  | @@ -11,5 +11,8 @@ | |
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "3.0.3" | ||
| } | ||
| } | ||
| } | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,11 +1,67 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
| import constants from "./common/constants.mjs"; | ||
|  | ||
| export default { | ||
| type: "app", | ||
| app: "roamresearch", | ||
| propDefinitions: {}, | ||
| propDefinitions: { | ||
| content: { | ||
| type: "string", | ||
| label: "Content", | ||
| description: "The content of the block to be added.", | ||
| }, | ||
|         
                  jcortes marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| nestUnder: { | ||
| type: "string", | ||
| label: "Nest Under", | ||
| description: "Title of the block to nest the new block under.", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| getUrl(path, api = constants.API.DEFAULT) { | ||
| const { graph_name: graphName } = this.$auth; | ||
| const baseUrl = constants.BASE_URL.replace(constants.SUBDOMAIN_PLACEHOLDER, api); | ||
| return `${baseUrl}${constants.VERSION_PATH}/${graphName}${path}`; | ||
| }, | ||
| getHeaders(headers) { | ||
| return { | ||
| ...headers, | ||
| "X-Authorization": `Bearer ${this.$auth.api_token}`, | ||
| }; | ||
| }, | ||
| _makeRequest({ | ||
| $ = this, path, headers, api, ...args | ||
| } = {}) { | ||
| return axios($, { | ||
| ...args, | ||
| url: this.getUrl(path, api), | ||
| headers: this.getHeaders(headers), | ||
| }); | ||
| }, | ||
|         
                  jcortes marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| post(args = {}) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| ...args, | ||
| }); | ||
| }, | ||
| appendBlocks(args = {}) { | ||
| return this.post({ | ||
| api: constants.API.APPEND, | ||
| path: "/append-blocks", | ||
| ...args, | ||
| }); | ||
| }, | ||
| query(args = {}) { | ||
| return this.post({ | ||
| path: "/q", | ||
| ...args, | ||
| }); | ||
| }, | ||
| pull(args = {}) { | ||
| return this.post({ | ||
| path: "/pull", | ||
| ...args, | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
| }; | ||
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.