- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.5k
New Components - everhour #14307
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
      
      
    
  
     Merged
                    New Components - everhour #14307
Changes from 5 commits
      Commits
    
    
            Show all changes
          
          
            6 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      cb21348
              
                everhour init
              
              
                luancazarine 362bfea
              
                init
              
              
                luancazarine 190f0b7
              
                pnpm update
              
              
                luancazarine 509f341
              
                [Components] everhour #13219
              
              
                luancazarine 72e7bfa
              
                [Components] everhour #13219
              
              
                luancazarine 66f962a
              
                fix status options
              
              
                luancazarine 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
  
    
      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,84 @@ | ||
| import { STATUS_OPTIONS } from "../../common/constants.mjs"; | ||
| import { parseObject } from "../../common/utils.mjs"; | ||
| import everhour from "../../everhour.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "everhour-create-task", | ||
| name: "Create Task", | ||
| description: "Creates a new task in Everhour. [See the documentation](https://everhour.docs.apiary.io/)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| everhour, | ||
| projectId: { | ||
| propDefinition: [ | ||
| everhour, | ||
| "projectId", | ||
| ], | ||
| }, | ||
| name: { | ||
| type: "string", | ||
| label: "Task Name", | ||
| description: "The name of the task to be created.", | ||
| }, | ||
| sectionId: { | ||
| propDefinition: [ | ||
| everhour, | ||
| "sectionId", | ||
| ({ projectId }) => ({ | ||
| projectId, | ||
| }), | ||
| ], | ||
| }, | ||
| tags: { | ||
| propDefinition: [ | ||
| everhour, | ||
| "tags", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| position: { | ||
| type: "integer", | ||
| label: "Position", | ||
| description: "The position of the task", | ||
| optional: true, | ||
| }, | ||
| description: { | ||
| type: "string", | ||
| label: "Description", | ||
| description: "A description of the task", | ||
| optional: true, | ||
| }, | ||
| dueOn: { | ||
| type: "string", | ||
| label: "Due Date", | ||
| description: "The due date of the task. **Format: YYYY-MM-DD**", | ||
| optional: true, | ||
| }, | ||
| status: { | ||
| type: "string", | ||
| label: "Status", | ||
| description: "The status of the task", | ||
| options: STATUS_OPTIONS, | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.everhour.createTask({ | ||
| $, | ||
| projectId: this.projectId, | ||
| data: { | ||
| name: this.name, | ||
| section: this.sectionId, | ||
| tags: this.tags && parseObject(this.tags), | ||
| position: this.position, | ||
| description: this.description, | ||
| dueOn: this.dueOn, | ||
| status: this.status, | ||
| }, | ||
| }); | ||
|  | ||
| $.export("$summary", `Successfully created task with ID: ${response.id}`); | ||
| return response; | ||
| }, | ||
| }; | 
  
    
      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,52 @@ | ||
| import everhour from "../../everhour.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "everhour-start-timer", | ||
| name: "Start Timer", | ||
| description: "Begins a new timer for a task. [See the documentation](https://everhour.docs.apiary.io/#reference/0/timers/start-timer)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| everhour, | ||
| projectId: { | ||
| propDefinition: [ | ||
| everhour, | ||
| "projectId", | ||
| ], | ||
| }, | ||
| taskId: { | ||
| propDefinition: [ | ||
| everhour, | ||
| "taskId", | ||
| ({ projectId }) => ({ | ||
| projectId, | ||
| }), | ||
| ], | ||
| }, | ||
| userDate: { | ||
| type: "string", | ||
| label: "User Date", | ||
| description: "Date string to associate with the timer. Format as 'YYYY-MM-DD'", | ||
| optional: true, | ||
| }, | ||
| comment: { | ||
| type: "string", | ||
| label: "Comment", | ||
| description: "An optional comment to associate with the timer", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.everhour.startTimer({ | ||
| $, | ||
| data: { | ||
| task: this.taskId, | ||
| userDate: this.userDate, | ||
| comment: this.comment, | ||
| }, | ||
| }); | ||
|  | ||
| $.export("$summary", `Successfully started a timer for task ID: ${this.taskId}`); | ||
| return response; | ||
| }, | ||
| }; | 
  
    
      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,17 @@ | ||
| import everhour from "../../everhour.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "everhour-stop-timer", | ||
| name: "Stop Timer", | ||
| description: "Halts the current running timer. [See the documentation](https://everhour.docs.apiary.io/#reference/timers/stop-timer)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| everhour, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.everhour.stopTimer(); | ||
| $.export("$summary", "Successfully stopped the timer"); | ||
| return response; | ||
| }, | ||
| }; | 
  
    
      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,12 @@ | ||
| export const LIMIT = 100; | ||
|  | ||
| export const STATUS_OPTIONS = [ | ||
| { | ||
| label: "Open", | ||
| value: "open", | ||
| }, | ||
| { | ||
| label: "Close", | ||
| value: "close", | ||
| }, | ||
| ]; | 
  
    
      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,24 @@ | ||
| export const parseObject = (obj) => { | ||
| if (!obj) return undefined; | ||
|  | ||
| if (Array.isArray(obj)) { | ||
| return obj.map((item) => { | ||
| if (typeof item === "string") { | ||
| try { | ||
| return JSON.parse(item); | ||
| } catch (e) { | ||
| return item; | ||
| } | ||
| } | ||
| return item; | ||
| }); | ||
| } | ||
| if (typeof obj === "string") { | ||
| try { | ||
| return JSON.parse(obj); | ||
| } catch (e) { | ||
| return obj; | ||
| } | ||
| } | ||
| return obj; | ||
| }; | 
  
    
      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,176 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
| import { LIMIT } from "./common/constants.mjs"; | ||
|  | ||
| export default { | ||
| type: "app", | ||
| app: "everhour", | ||
| propDefinitions: {}, | ||
| propDefinitions: { | ||
| projectId: { | ||
| type: "string", | ||
| label: "Project ID", | ||
| description: "The ID of the project", | ||
| async options({ page }) { | ||
| const projects = await this.listProjects({ | ||
| params: { | ||
| limit: LIMIT, | ||
| page: page + 1, | ||
| }, | ||
| }); | ||
|  | ||
| return projects.map(({ | ||
| name: label, id: value, | ||
| }) => ({ | ||
| label, | ||
| value, | ||
| })); | ||
| }, | ||
| }, | ||
| sectionId: { | ||
| type: "string", | ||
| label: "Section ID", | ||
| description: "The section id of the task", | ||
| async options({ projectId }) { | ||
| const sections = await this.listSections({ | ||
| projectId, | ||
| }); | ||
|  | ||
| return sections.map(({ | ||
| name: label, id: value, | ||
| }) => ({ | ||
| label, | ||
| value, | ||
| })); | ||
| }, | ||
| }, | ||
| tags: { | ||
| type: "string[]", | ||
| label: "Tag IDs", | ||
| description: "The tag ids of the task", | ||
| async options() { | ||
| const tags = await this.listTags(); | ||
|  | ||
| return tags.map(({ | ||
| name: label, id: value, | ||
| }) => ({ | ||
| label, | ||
| value, | ||
| })); | ||
| }, | ||
| }, | ||
| labels: { | ||
| type: "string[]", | ||
| label: "Tags", | ||
| description: "An array of tags associated with the task", | ||
| async options({ projectId }) { | ||
| const sections = await this.listSections({ | ||
| projectId, | ||
| }); | ||
|  | ||
| return sections.map(({ | ||
| name: label, id: value, | ||
| }) => ({ | ||
| label, | ||
| value, | ||
| })); | ||
| }, | ||
| }, | ||
| taskId: { | ||
| type: "string", | ||
| label: "Task ID", | ||
| description: "The ID of the task", | ||
| async options({ projectId }) { | ||
| const tasks = await this.getProjectTasks({ | ||
| projectId, | ||
| }); | ||
| return tasks.map(({ | ||
| name: label, id: value, | ||
| }) => ({ | ||
| label, | ||
| value, | ||
| })); | ||
| }, | ||
| }, | ||
| }, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| _baseUrl() { | ||
| return "https://api.everhour.com"; | ||
| }, | ||
| _headers() { | ||
| return { | ||
| "X-Api-Key": `${this.$auth.api_token}`, | ||
| }; | ||
| }, | ||
| _makeRequest({ | ||
| $ = this, path, ...opts | ||
| }) { | ||
| return axios($, { | ||
| url: this._baseUrl() + path, | ||
| headers: this._headers(), | ||
| ...opts, | ||
| }); | ||
| }, | ||
| listProjects(opts = {}) { | ||
| return this._makeRequest({ | ||
| path: "/projects", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| listSections({ | ||
| projectId, opts, | ||
| }) { | ||
| return this._makeRequest({ | ||
| path: `/projects/${projectId}/sections`, | ||
| ...opts, | ||
| }); | ||
| }, | ||
|         
                  luancazarine marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| listTags() { | ||
| return this._makeRequest({ | ||
| path: "/tags", | ||
| }); | ||
| }, | ||
| getProjectTasks({ | ||
| projectId, ...opts | ||
| }) { | ||
| return this._makeRequest({ | ||
| path: `/projects/${projectId}/tasks`, | ||
| ...opts, | ||
| }); | ||
| }, | ||
| createTask({ | ||
| projectId, ...opts | ||
| }) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: `/projects/${projectId}/tasks`, | ||
| ...opts, | ||
| }); | ||
| }, | ||
| startTimer(opts = {}) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: "/timers", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| stopTimer(opts = {}) { | ||
| return this._makeRequest({ | ||
| method: "DELETE", | ||
| path: "/timers/current", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| createWebhook(opts = {}) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: "/hooks", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| deleteWebhook(webhookId) { | ||
| return this._makeRequest({ | ||
| method: "DELETE", | ||
| path: `/hooks/${webhookId}`, | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
  
    
      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,18 @@ | ||
| { | ||
| "name": "@pipedream/everhour", | ||
| "version": "0.1.0", | ||
| "description": "Pipedream Everhour Components", | ||
| "main": "everhour.app.mjs", | ||
| "keywords": [ | ||
| "pipedream", | ||
| "everhour" | ||
| ], | ||
| "homepage": "https://pipedream.com/apps/everhour", | ||
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.0.3" | ||
| } | ||
| } | 
      
      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.