-
Couldn't load subscription status.
- Fork 5.5k
New Components - autodesk #15344
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 - autodesk #15344
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d1df610
autodesk init
michelle0927 9e15875
new components
michelle0927 f83ba4b
pnpm-lock.yaml
michelle0927 c2256f3
updates
michelle0927 4a774d6
wip
michelle0927 fc0edd0
updates
michelle0927 1e074b5
fix pagination
michelle0927 611c97e
update type prop
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
There are no files selected for viewing
92 changes: 92 additions & 0 deletions
92
components/autodesk/actions/create-folder/create-folder.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,92 @@ | ||
| import autodesk from "../../autodesk.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "autodesk-create-folder", | ||
| name: "Create Folder", | ||
| description: "Creates a new folder in a project in Autodesk. [See the documentation](https://aps.autodesk.com/en/docs/data/v2/reference/http/projects-project_id-folders-POST/)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| autodesk, | ||
| hubId: { | ||
| propDefinition: [ | ||
| autodesk, | ||
| "hubId", | ||
| ], | ||
| }, | ||
| projectId: { | ||
| propDefinition: [ | ||
| autodesk, | ||
| "projectId", | ||
| (c) => ({ | ||
| hubId: c.hubId, | ||
| }), | ||
| ], | ||
| }, | ||
| name: { | ||
| type: "string", | ||
| label: "Name", | ||
| description: "The name of the new folder", | ||
| }, | ||
| parent: { | ||
| propDefinition: [ | ||
| autodesk, | ||
| "folderId", | ||
| (c) => ({ | ||
| hubId: c.hubId, | ||
| projectId: c.projectId, | ||
| }), | ||
| ], | ||
| label: "Parent Folder ID", | ||
| description: "The identifier of the parent folder", | ||
| }, | ||
| type: { | ||
| type: "string", | ||
| label: "Extension Type", | ||
| description: "The type of folder extension. For BIM 360 Docs folders, use `folders:autodesk.bim360:Folder`. For all other services, use `folders:autodesk.core:Folder`.", | ||
| options: [ | ||
| { | ||
| label: "BIM 360 Docs folders", | ||
| value: "folders:autodesk.core:Folder", | ||
| }, | ||
| { | ||
| label: "Other folders", | ||
| value: "folders:autodesk.bim360:Folder", | ||
| }, | ||
| ], | ||
| default: "folders:autodesk.core:Folder", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.autodesk.createFolder({ | ||
| $, | ||
| projectId: this.projectId, | ||
| data: { | ||
| jsonapi: { | ||
| version: "1.0", | ||
| }, | ||
| data: { | ||
| type: "folders", | ||
| attributes: { | ||
| name: this.name, | ||
| extension: { | ||
| type: this.type, | ||
| version: "1.0", | ||
| }, | ||
| }, | ||
| relationships: { | ||
| parent: { | ||
| data: { | ||
| type: "folders", | ||
| id: this.parent, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Successfully created new folder: ${this.name}`); | ||
| return response; | ||
| }, | ||
| }; | ||
197 changes: 197 additions & 0 deletions
197
components/autodesk/actions/upload-file/upload-file.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,197 @@ | ||
| import autodesk from "../../autodesk.app.mjs"; | ||
| import { axios } from "@pipedream/platform"; | ||
| import fs from "fs"; | ||
|
|
||
| export default { | ||
| key: "autodesk-upload-file", | ||
| name: "Upload File", | ||
| description: "Uploads a new file to a specified folder in Autodesk. [See the documentation](https://aps.autodesk.com/en/docs/data/v2/tutorials/upload-file/).", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| autodesk, | ||
| hubId: { | ||
| propDefinition: [ | ||
| autodesk, | ||
| "hubId", | ||
| ], | ||
| }, | ||
| projectId: { | ||
| propDefinition: [ | ||
| autodesk, | ||
| "projectId", | ||
| (c) => ({ | ||
| hubId: c.hubId, | ||
| }), | ||
| ], | ||
| }, | ||
| folderId: { | ||
| propDefinition: [ | ||
| autodesk, | ||
| "folderId", | ||
| (c) => ({ | ||
| hubId: c.hubId, | ||
| projectId: c.projectId, | ||
| }), | ||
| ], | ||
| }, | ||
| fileName: { | ||
| type: "string", | ||
| label: "File Name", | ||
| description: "The name of the file to upload", | ||
| }, | ||
| filePath: { | ||
| type: "string", | ||
| label: "File Path", | ||
| description: "The path to a file in the `/tmp` directory. [See the documentation on working with files](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp)", | ||
| }, | ||
| type: { | ||
| type: "string", | ||
| label: "Extension Type", | ||
| description: "The type of file extension. For BIM 360 Docs files, use `items:autodesk.bim360:File`. For all other services, use `items:autodesk.core:File`.", | ||
| options: [ | ||
| { | ||
| label: "BIM 360 Docs files", | ||
| value: "items:autodesk.core:File", | ||
| }, | ||
| { | ||
| label: "Other files", | ||
| value: "items:autodesk.bim360:File", | ||
| }, | ||
| ], | ||
| default: "items:autodesk.core:File", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| // Create storage location | ||
| const { data } = await this.autodesk.createStorageLocation({ | ||
| $, | ||
| projectId: this.projectId, | ||
| data: { | ||
| jsonapi: { | ||
| version: "1.0", | ||
| }, | ||
| data: { | ||
| type: "objects", | ||
| attributes: { | ||
| name: this.fileName, | ||
| }, | ||
| relationships: { | ||
| target: { | ||
| data: { | ||
| type: "folders", | ||
| id: this.folderId, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| const objectId = data.id; | ||
| const [ | ||
| bucketKey, | ||
| objectKey, | ||
| ] = objectId.split("os.object:")[1]?.split("/") || []; | ||
|
|
||
| // Generate signed URL | ||
| const { | ||
| urls, uploadKey, | ||
| } = await this.autodesk.generateSignedUrl({ | ||
| $, | ||
| bucketKey, | ||
| objectKey, | ||
| }); | ||
|
|
||
| const signedUrl = urls[0]; | ||
|
|
||
| // Upload to signed URL | ||
| const filePath = this.filePath.includes("tmp/") | ||
| ? this.filePath | ||
| : `/tmp/${this.filePath}`; | ||
| const fileStream = fs.createReadStream(filePath); | ||
| const fileSize = fs.statSync(filePath).size; | ||
|
|
||
| await axios($, { | ||
| url: signedUrl, | ||
| data: fileStream, | ||
| method: "PUT", | ||
| headers: { | ||
| "Content-Type": "application/octet-stream", | ||
| "Content-Length": fileSize, | ||
| }, | ||
| maxContentLength: Infinity, | ||
| maxBodyLength: Infinity, | ||
| }); | ||
|
|
||
| // Complete the upload | ||
| await this.autodesk.completeUpload({ | ||
| $, | ||
| bucketKey, | ||
| objectKey, | ||
| data: { | ||
| uploadKey, | ||
| }, | ||
| }); | ||
|
|
||
| // Create version 1.0 of uploaded file | ||
| const response = await this.autodesk.createFirstVersionOfFile({ | ||
| $, | ||
| projectId: this.projectId, | ||
| data: { | ||
| jsonapi: { | ||
| version: "1.0", | ||
| }, | ||
| data: { | ||
| type: "items", | ||
| attributes: { | ||
| displayName: this.fileName, | ||
| extension: { | ||
| type: this.type, | ||
| version: "1.0", | ||
| }, | ||
| }, | ||
| relationships: { | ||
| tip: { | ||
| data: { | ||
| type: "versions", | ||
| id: "1", | ||
| }, | ||
| }, | ||
| parent: { | ||
| data: { | ||
| type: "folders", | ||
| id: this.folderId, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| included: [ | ||
| { | ||
| type: "versions", | ||
| id: "1", | ||
| attributes: { | ||
| name: this.fileName, | ||
| extension: { | ||
| type: this.type.replace("items", "versions"), | ||
| version: "1.0", | ||
| }, | ||
| }, | ||
| relationships: { | ||
| storage: { | ||
| data: { | ||
| type: "objects", | ||
| id: objectId, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully uploaded file ${this.fileName}`); | ||
| return response; | ||
| }, | ||
| }; |
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.