-
Notifications
You must be signed in to change notification settings - Fork 5.5k
13382 components remote #19418
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
13382 components remote #19418
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
48593f1
Update Remote component to version 0.1.0 and add new actions
luancazarine ded2fe9
pnpm update
luancazarine dabd201
Update test events for employment onboarding and custom field value u…
luancazarine a11fc13
Refactor pagination and update data handling in remote components
luancazarine a98307b
Update ID formatting in remote sources to include timestamps
luancazarine 9d17fc6
minor updates
michelle0927 9e22ada
Merge remote-tracking branch 'origin/master' into 13382-components-re…
michelle0927 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
138 changes: 138 additions & 0 deletions
138
components/remote/actions/create-expense/create-expense.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,138 @@ | ||
| import { getFileStreamAndMetadata } from "@pipedream/platform"; | ||
| import remote from "../../remote.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "remote-create-expense", | ||
| name: "Create Expense", | ||
| description: "Create an expense in Remote. [See the documentation](https://developer.remote.com/reference/post_create_expense)", | ||
| version: "0.0.1", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: false, | ||
| }, | ||
| type: "action", | ||
| props: { | ||
| remote, | ||
| amount: { | ||
| type: "integer", | ||
| label: "Amount", | ||
| description: "The amount of the expense", | ||
| }, | ||
| currency: { | ||
| type: "string", | ||
| label: "Currency", | ||
| description: "The currency of the expense", | ||
| options: [ | ||
| "USD", | ||
| "EUR", | ||
| "CAD", | ||
| ], | ||
| }, | ||
| employmentId: { | ||
| propDefinition: [ | ||
| remote, | ||
| "employmentId", | ||
| ], | ||
| }, | ||
| expenseCategorySlug: { | ||
| propDefinition: [ | ||
| remote, | ||
| "expenseCategorySlug", | ||
| ({ employmentId }) => ({ | ||
| employmentId, | ||
| }), | ||
| ], | ||
| }, | ||
| expenseDate: { | ||
| type: "string", | ||
| label: "Expense Date", | ||
| description: "Date of the purchase, which must be in the past. **Format: YYYY-MM-DD**", | ||
| }, | ||
| receiptContentFilePath: { | ||
| type: "string", | ||
| label: "Receipt Content File Path", | ||
| description: "The file of the receipt. Provide either a file URL or a path to a file in the `/tmp` directory (for example, `/tmp/myFile.pdf`)", | ||
| }, | ||
| receiptFileName: { | ||
| type: "string", | ||
| label: "Receipt File Name", | ||
| description: "The file name", | ||
| }, | ||
| reviewedAt: { | ||
| type: "string", | ||
| label: "Reviewed At", | ||
| description: "The date and time that the expense was reviewed in ISO8601 format. If not provided, it defaults to the current datetime. **Format: YYYY-MM-DDTHH:MM:SS**", | ||
| }, | ||
| taxAmount: { | ||
| type: "integer", | ||
| label: "Tax Amount", | ||
| description: "The tax amount of the expense", | ||
| optional: true, | ||
| }, | ||
| timezone: { | ||
| type: "string", | ||
| label: "Timezone", | ||
| description: "The timezone of the expense. [TZ identifier](https://www.iana.org/time-zones)", | ||
| optional: true, | ||
| }, | ||
| title: { | ||
| type: "string", | ||
| label: "Title", | ||
| description: "The title of the expense", | ||
| }, | ||
| syncDir: { | ||
| type: "dir", | ||
| accessMode: "read", | ||
| sync: true, | ||
| }, | ||
| }, | ||
| methods: { | ||
| async streamToBase64(stream) { | ||
| return new Promise((resolve, reject) => { | ||
| const chunks = []; | ||
|
|
||
| stream.on("data", (chunk) => { | ||
| chunks.push(chunk); | ||
| }); | ||
|
|
||
| stream.on("end", () => { | ||
| const buffer = Buffer.concat(chunks); | ||
| resolve(buffer.toString("base64")); | ||
| }); | ||
|
|
||
| stream.on("error", (err) => { | ||
| reject(err); | ||
| }); | ||
| }); | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| stream, metadata, | ||
| } = await getFileStreamAndMetadata(this.receiptContentFilePath); | ||
| const base64String = await this.streamToBase64(stream); | ||
|
|
||
| const response = await this.remote.createExpense({ | ||
| $, | ||
| data: { | ||
| amount: this.amount, | ||
| currency: this.currency, | ||
| employment_id: this.employmentId, | ||
| expense_date: this.expenseDate, | ||
| title: this.title, | ||
| receipt: { | ||
| content: `data:${metadata.contentType};base64,${base64String}`, | ||
| name: this.receiptFileName, | ||
| }, | ||
| expense_category_slug: this.expenseCategorySlug, | ||
| reviewed_at: this.reviewedAt, | ||
| tax_amount: this.taxAmount, | ||
| timezone: this.timezone, | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully created expense with ID: ${response?.data?.expense?.id}`); | ||
| return response; | ||
| }, | ||
| }; | ||
72 changes: 72 additions & 0 deletions
72
components/remote/actions/list-employments/list-employments.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,72 @@ | ||
| import remote from "../../remote.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "remote-list-employments", | ||
| name: "List Employments", | ||
| description: "List employments in Remote. [See the documentation](https://developer.remote.com/reference/get_index_employment)", | ||
| version: "0.0.1", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| type: "action", | ||
| props: { | ||
| remote, | ||
| email: { | ||
| type: "string", | ||
| label: "Email", | ||
| description: "Filters the results by employments whose login email matches the value", | ||
| optional: true, | ||
| }, | ||
| employmentType: { | ||
| type: "string", | ||
| label: "Employment Type", | ||
| description: "Filters the results by employments whose employment product type matches the value", | ||
| optional: true, | ||
| options: [ | ||
| "contractor", | ||
| "direct_employee", | ||
| "employee", | ||
| ], | ||
| }, | ||
| employmentModel: { | ||
| type: "string", | ||
| label: "Employment Model", | ||
| description: "Filters the results by employments whose employment model matches the value", | ||
| optional: true, | ||
| options: [ | ||
| "global_payroll", | ||
| "peo", | ||
| "eor", | ||
| ], | ||
| }, | ||
| maxResults: { | ||
| type: "integer", | ||
| label: "Max Results", | ||
| description: "The maximum number of results to return", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = this.remote.paginate({ | ||
| $, | ||
| dataKey: "employments", | ||
| fn: this.remote.listEmployments, | ||
| params: { | ||
| email: this.email, | ||
| employment_type: this.employmentType, | ||
| employment_model: this.employmentModel, | ||
| }, | ||
| maxResults: this.maxResults, | ||
| }); | ||
|
|
||
| const responseArray = []; | ||
| for await (const employment of response) { | ||
| responseArray.push(employment); | ||
| } | ||
|
|
||
| $.export("$summary", `Successfully listed ${responseArray.length} employments`); | ||
| return responseArray; | ||
| }, | ||
| }; |
32 changes: 32 additions & 0 deletions
32
components/remote/actions/show-timeoff-balance/show-timeoff-balance.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,32 @@ | ||
| import remote from "../../remote.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "remote-show-timeoff-balance", | ||
| name: "Show Time Off Balance", | ||
| description: "Show the time off balance for an employment in Remote. [See the documentation](https://developer.remote.com/reference/get_show_timeoff_balance)", | ||
| version: "0.0.1", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| type: "action", | ||
| props: { | ||
| remote, | ||
| employmentId: { | ||
| propDefinition: [ | ||
| remote, | ||
| "employmentId", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.remote.showTimeoffBalance({ | ||
| $, | ||
| employmentId: this.employmentId, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully retrieved time off balance for employment with ID: ${this.employmentId}`); | ||
| 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 |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "name": "@pipedream/remote", | ||
| "version": "0.0.2", | ||
| "version": "0.1.0", | ||
| "description": "Pipedream Remote Components", | ||
| "main": "remote.app.mjs", | ||
| "keywords": [ | ||
|
|
@@ -11,5 +11,8 @@ | |
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.1.1" | ||
| } | ||
| } | ||
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.