-
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
New Components - autodesk #15344
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
|
WalkthroughThis pull request introduces new modules for creating folders and uploading files in Autodesk projects, along with webhook sources for monitoring project and file events. Enhancements to the Autodesk app module include improved property definitions and API interaction methods. Additionally, a polling mechanism for event handling is established, allowing for structured retrieval of project and folder data. Overall, the changes expand the capabilities for managing Autodesk resources programmatically. Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (3)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 15
🧹 Nitpick comments (13)
components/autodesk/sources/new-version-instant/new-version-instant.mjs (2)
9-9: Consider starting with version 0.1.0 instead of 0.0.1Following semantic versioning best practices, initial public releases typically start at 0.1.0 to indicate the first minor version.
- version: "0.0.1", + version: "0.1.0",
17-23: Consider using event timestamp instead of parse timeThe
createdTimeis parsed usingDate.parse(), which might not preserve timezone information. Consider using the native Date object or a robust date handling library likedate-fns.generateMeta(payload) { return { id: payload.source, summary: `New File Version for File: ${payload.name}`, - ts: Date.parse(payload.createdTime), + ts: new Date(payload.createdTime).getTime(), }; },components/autodesk/sources/new-project-created/new-project-created.mjs (1)
9-9: Maintain version consistency across componentsFor consistency with other components, consider using the same version number.
- version: "0.0.1", + version: "0.1.0",components/autodesk/sources/new-folder-instant/test-event.mjs (2)
2-2: Use realistic dates in test eventsThe test event contains future dates (2025). Consider using recent past dates for more realistic test scenarios.
- "modifiedTime": "2025-01-20T21:24:41+0000", + "modifiedTime": "2024-01-20T21:24:41+0000", - "createdTime": "2025-01-20T21:24:41+0000", + "createdTime": "2024-01-20T21:24:41+0000",Also applies to: 15-15
3-3: Use placeholder values for sensitive IDsConsider using obvious placeholder values for user IDs in test data to prevent any confusion with real data.
- "creator": "7QNJ9NNCKNKRJ8ZU", + "creator": "TEST_USER_ID", "user_info": { - "id": "7QNJ9NNCKNKRJ8ZU" + "id": "TEST_USER_ID"Also applies to: 9-10
components/autodesk/sources/common/base-polling.mjs (1)
33-41: Add JSDoc comments for abstract methodsAdd JSDoc comments to clearly document the expected implementation of abstract methods.
+ /** + * @abstract + * @returns {Function} Function to be used for pagination + * @throws {Error} When not implemented by child class + */ getFn() { throw new Error("getFn is not implemented"); }, + /** + * @abstract + * @returns {Object} Arguments to be passed to the pagination function + */ getArgs() { return {}; }, + /** + * @abstract + * @param {Object} data The data to generate metadata from + * @returns {Object} Metadata object with id, summary, and ts + * @throws {Error} When not implemented by child class + */ generateMeta() { throw new Error("generateMeta is not implemented"); },components/autodesk/sources/new-project-created/test-event.mjs (1)
13-13: Consider using environment variables or constants for API URLs.The hardcoded API URLs contain version numbers that could become outdated. Consider extracting these into environment variables or constants for easier maintenance.
Also applies to: 20-20, 31-31, 42-42, 49-49
components/autodesk/sources/new-version-instant/test-event.mjs (1)
3-3: Use a consistent date format with realistic timestamps.The test event uses future dates (2025). Consider using a more recent or relative timestamp to avoid confusion.
Also applies to: 26-26, 29-29, 34-34
components/autodesk/actions/update-file-metadata/update-file-metadata.mjs (1)
48-52: Enhance metadata input validation.Consider adding a custom validation function to ensure the metadata object has the correct structure before processing.
components/autodesk/actions/create-folder/create-folder.mjs (1)
43-53: Improve documentation for extension types.The description could be enhanced with more details about when to use each folder type and their implications.
components/autodesk/actions/upload-file/upload-file.mjs (3)
8-8: Consider starting with version 0.1.0.Following semantic versioning best practices, consider starting with version 0.1.0 for the initial release instead of 0.0.1.
42-46: Enhance filePath documentation.The description could be more specific about:
- Accepted file path formats
- Size limits
- Supported file types
96-103: Add error handling for upload request.Consider adding error handling and progress tracking for large file uploads:
- await this.autodesk._makeRequest({ + try { + await this.autodesk._makeRequest({ $, url: signedUrl, data: fileStream, headers: { "Content-Type": "application/octet-stream", }, - }); + }); + } catch (error) { + throw new Error(`Failed to upload file: ${error.message}`); + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (13)
components/autodesk/actions/create-folder/create-folder.mjs(1 hunks)components/autodesk/actions/update-file-metadata/update-file-metadata.mjs(1 hunks)components/autodesk/actions/upload-file/upload-file.mjs(1 hunks)components/autodesk/autodesk.app.mjs(1 hunks)components/autodesk/package.json(2 hunks)components/autodesk/sources/common/base-polling.mjs(1 hunks)components/autodesk/sources/common/base-webhook.mjs(1 hunks)components/autodesk/sources/new-folder-instant/new-folder-instant.mjs(1 hunks)components/autodesk/sources/new-folder-instant/test-event.mjs(1 hunks)components/autodesk/sources/new-project-created/new-project-created.mjs(1 hunks)components/autodesk/sources/new-project-created/test-event.mjs(1 hunks)components/autodesk/sources/new-version-instant/new-version-instant.mjs(1 hunks)components/autodesk/sources/new-version-instant/test-event.mjs(1 hunks)
🔇 Additional comments (7)
components/autodesk/sources/common/base-webhook.mjs (4)
38-58: Well-structuredactivatemethod with proper error handlingThe
activatemethod effectively creates a webhook and handles potential errors by checking the presence of thelocationheader and throwing an error if it's missing. The extraction and storage ofhookIdis correctly implemented.
59-66: Cleandeactivatemethod that safely handles webhook deletionThe
deactivatemethod appropriately retrieves the storedhookIdand attempts to delete the webhook if it exists. This prevents unnecessary API calls and handles cases where thehookIdmay not be set.
75-80: Abstract methods correctly defined for extensibilityThe
getEventandgenerateMetamethods are intentionally left unimplemented, throwing errors to ensure that any subclass provides the necessary implementations. This is an effective technique for creating an extensible base class.
82-94: Efficient event handling in therunmethodThe
runmethod correctly handles incoming events by responding with a 200 status and emitting the payload with generated metadata. It assumes thatgenerateMetais implemented in derived classes, which aligns with the abstract method design.components/autodesk/sources/new-folder-instant/new-folder-instant.mjs (2)
17-23: Proper implementation ofgenerateMetamethodThe
generateMetamethod correctly constructs metadata for emitted events, including a unique ID, summary, and timestamp. This ensures that each event can be uniquely identified and processed downstream.
13-16: Correct event type specified ingetEventmethodThe
getEventmethod returns the correct event type"dm.folder.added"for detecting when a new folder is created. This aligns with Autodesk's webhook event types and ensures the source functions as intended.components/autodesk/package.json (1)
Line range hint
3-18: LGTM! Version bump and dependency addition look appropriate.The version bump to 0.1.0 aligns with semantic versioning for initial releases, and the @pipedream/platform dependency is correctly specified.
components/autodesk/actions/update-file-metadata/update-file-metadata.mjs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
♻️ Duplicate comments (1)
components/autodesk/autodesk.app.mjs (1)
7-20: 🛠️ Refactor suggestionAdd error handling in the
hubIdoptions method.The async options method should include error handling to prevent unhandled promise rejections.
async options() { - const { data } = await this.listHubs(); - return data?.map(({ - id, attributes, - }) => ({ - label: attributes.name, - value: id, - })) || []; + try { + const { data } = await this.listHubs(); + return data?.map(({ + id, attributes, + }) => ({ + label: attributes.name, + value: id, + })) || []; + } catch (error) { + console.error("Error fetching hubs:", error); + return []; + } },
🧹 Nitpick comments (2)
components/autodesk/autodesk.app.mjs (2)
123-141: Consider adding request timeout and retries in_makeRequest.The base request method could benefit from timeout and retry mechanisms for better reliability.
_makeRequest({ $ = this, path, headers, + timeout = 10000, + maxRetries = 3, ...otherOpts }) { + let retries = 0; + const makeRequestWithRetry = async () => { + try { return axios($, { url: `${this._baseUrl()}${path}`, headers: { "Authorization": `Bearer ${this.$auth.oauth_access_token}`, "Content-Type": "application/json", ...headers, }, + timeout, ...otherOpts, }); + } catch (error) { + if (retries < maxRetries && error.response?.status >= 500) { + retries++; + await new Promise(resolve => setTimeout(resolve, 1000 * retries)); + return makeRequestWithRetry(); + } + throw error; + } + }; + return makeRequestWithRetry(); },
243-268: Verify pagination implementation in thepaginatemethod.The pagination implementation looks correct with the page increment fix, but consider adding error handling.
async *paginate({ fn, args, max, }) { + try { let hasMore = true; let count = 0; args = { ...args, params: { ...args?.params, "page[number]": 0, "page[limit]": 200, }, }; while (hasMore) { + try { const { data } = await fn(args); for (const item of data) { yield item; if (max && ++count >= max) { return; } } hasMore = data?.length === args.params["page[limit]"]; args.params["page[number]"] += 1; + } catch (error) { + console.error("Error during pagination:", error); + break; + } } + } catch (error) { + console.error("Error initializing pagination:", error); + throw error; + } },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
components/autodesk/autodesk.app.mjs(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Verify TypeScript components
- GitHub Check: pnpm publish
- GitHub Check: Publish TypeScript components
🔇 Additional comments (3)
components/autodesk/autodesk.app.mjs (3)
1-6: LGTM! Basic app setup looks good.The import statement and app definition follow the standard pattern for Pipedream components.
21-44: 🛠️ Refactor suggestionAdd error handling and verify pagination in the
projectIdoptions method.The method handles pagination but needs error handling. Also, ensure the page parameter is properly typed.
async options({ hubId, page, }) { + try { if (!hubId) { return []; } const { data } = await this.listProjects({ hubId, params: { - "page[number]": page, + "page[number]": parseInt(page) || 0, }, }); return data?.map(({ id, attributes, }) => ({ label: attributes.name, value: id, })) || []; + } catch (error) { + console.error("Error fetching projects:", error); + return []; + } },Likely invalid or redundant comment.
96-120: 🛠️ Refactor suggestionAdd error handling and consider additional file filtering options.
The file listing implementation needs error handling and could benefit from additional filtering options.
async options({ projectId, folderId, }) { + try { if (!projectId || !folderId) { return []; } const { data } = await this.getFolderContent({ projectId, folderId, params: { "filter[type]": "items", + "filter[extension.type]": "items:autodesk.core:File", }, }); return data?.map(({ id, attributes, }) => ({ label: attributes.displayName, value: id, })) || []; + } catch (error) { + console.error("Error fetching files:", error); + return []; + } },Likely invalid or redundant comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
♻️ Duplicate comments (2)
components/autodesk/autodesk.app.mjs (2)
11-19:⚠️ Potential issueAdd error handling to prevent unhandled promise rejections.
The
optionsmethod needs error handling to gracefully manage API failures.async options() { + try { const { data } = await this.listHubs(); return data?.map(({ id, attributes, }) => ({ label: attributes.name, value: id, })) || []; + } catch (error) { + console.error("Error fetching hubs:", error); + return []; + } },
117-125:⚠️ Potential issueAdd input validation for webhook parameters.
The
createWebhookmethod should validate required parameters before making the request.createWebhook({ system, event, ...opts }) { + if (!system || !event) { + throw new Error("system and event parameters are required"); + } return this._makeRequest({ method: "POST", path: `/webhooks/v1/systems/${system}/events/${event}/hooks`, ...opts, }); },
🧹 Nitpick comments (1)
components/autodesk/autodesk.app.mjs (1)
66-89: Optimize recursive folder fetching with parallel processing.The current implementation fetches folders sequentially. Using
Promise.allwould improve performance.const fetchFoldersRecursively = async (folderId, depth = 0, maxDepth = 10) => { if (depth > maxDepth) { return; } try { const { data } = await this.getFolderContent({ projectId, folderId, params: { "filter[type]": "folders", }, }); const folders = data?.map(({ id, attributes, }) => ({ label: attributes.name, value: id, })) || []; options.push(...folders); - for (const folder of folders) { - await fetchFoldersRecursively(folder.value, depth + 1, maxDepth); - } + await Promise.all( + folders.map(folder => + fetchFoldersRecursively(folder.value, depth + 1, maxDepth) + ) + ); } catch (error) { console.error(`Error fetching subfolders for ${folderId}:`, error); } };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
components/autodesk/actions/upload-file/upload-file.mjs(1 hunks)components/autodesk/autodesk.app.mjs(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- components/autodesk/actions/upload-file/upload-file.mjs
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: pnpm publish
- GitHub Check: Verify TypeScript components
- GitHub Check: Publish TypeScript components
🔇 Additional comments (1)
components/autodesk/autodesk.app.mjs (1)
1-6: LGTM!The basic structure follows Pipedream's app module pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
components/autodesk/autodesk.app.mjs(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: pnpm publish
- GitHub Check: Verify TypeScript components
- GitHub Check: Publish TypeScript components
🔇 Additional comments (8)
components/autodesk/autodesk.app.mjs (8)
1-6: LGTM!The import statement and app definition are correctly implemented.
11-19: Add error handling in the hubId options method.The method should handle API failures gracefully to prevent unhandled promise rejections.
25-43: Add error handling and pagination validation in the projectId options method.The method needs to handle API failures and validate the page parameter.
49-95: Improve folder fetching robustness.While the recursive implementation includes a depth limit, it needs error handling and could benefit from parallel processing improvements.
98-116: LGTM!The base URL and request helper methods are well implemented with proper authorization and content type headers.
117-125: Add input validation for webhook creation.The createWebhook method should validate required parameters before making the request.
148-156: Add error handling for empty response in getProjectTopFolderId.The method assumes the response will always contain data[0].id, which might not be true.
218-243: LGTM! Pagination implementation looks good.The pagination logic is well implemented with:
- Proper initialization of pagination parameters
- Correct page increment logic
- Proper handling of max items limit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
| "folders:autodesk.core:Folder", | ||
| "folders:autodesk.bim360:Folder", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could those have a label? Such as BIM 360 Docs folders and Other folders
|
/approve |
Note to QA: Go to Autodesk Fusion (pipedream.autodesk360.com) to view folders & files.
Resolves #15211.
Summary by CodeRabbit
Summary by CodeRabbit
New Features
Improvements
Version Update