-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
[Components] onlyoffice_docspace: Created new actions and sources for ONLYOFFICE DocSpace #12991
base: master
Are you sure you want to change the base?
[Components] onlyoffice_docspace: Created new actions and sources for ONLYOFFICE DocSpace #12991
Conversation
@jcortes is attempting to deploy a commit to the Pipedreamers Team on Vercel. A member of the Team first needs to authorize it. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
WalkthroughThe changes greatly enhance the OnlyOffice DocSpace integration by introducing functionalities for room creation, user invitation, file uploads, and event emissions for new files, folders, and users. New constants and utility functions improve API interactions and multipart data handling, while polling mechanisms bolster resource management. Overall, these updates elevate the user experience and streamline document and user management within the OnlyOffice environment. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant API
participant App
participant OnlyOffice
User->>App: Create Room Request
App->>OnlyOffice: POST /create-room
OnlyOffice-->>App: Room Created
App-->>User: Room Creation Confirmation
User->>App: Invite User Request
App->>OnlyOffice: POST /invite-user
OnlyOffice-->>App: User Invited
App-->>User: Invitation Confirmation
User->>App: Upload File Request
App->>OnlyOffice: POST /upload-file
OnlyOffice-->>App: File Uploaded
App-->>User: Upload Confirmation
Assessment against linked issues
Poem
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 as PR comments)
Additionally, you can add 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: 5
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
Files selected for processing (11)
- components/onlyoffice_docspace/actions/create-room/create-room.mjs (1 hunks)
- components/onlyoffice_docspace/actions/invite-user/invite-user.mjs (1 hunks)
- components/onlyoffice_docspace/actions/upload-file/upload-file.mjs (1 hunks)
- components/onlyoffice_docspace/common/constants.mjs (1 hunks)
- components/onlyoffice_docspace/common/utils.mjs (1 hunks)
- components/onlyoffice_docspace/onlyoffice_docspace.app.mjs (1 hunks)
- components/onlyoffice_docspace/package.json (2 hunks)
- components/onlyoffice_docspace/sources/common/polling.mjs (1 hunks)
- components/onlyoffice_docspace/sources/new-file/new-file.mjs (1 hunks)
- components/onlyoffice_docspace/sources/new-folder/new-folder.mjs (1 hunks)
- components/onlyoffice_docspace/sources/new-user-added/new-user-added.mjs (1 hunks)
Files skipped from review due to trivial changes (1)
- components/onlyoffice_docspace/common/constants.mjs
Additional context used
Biome
components/onlyoffice_docspace/common/utils.mjs
[error] 32-34: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
Additional comments not posted (44)
components/onlyoffice_docspace/package.json (2)
3-3
: Version update is appropriate.The version has been updated from
0.0.1
to0.1.0
, indicating a feature enhancement. This is consistent with semantic versioning practices.
15-16
: New dependency added.The new dependency on
@pipedream/platform
with version^3.0.0
is added. Ensure that this dependency is necessary and compatible with the existing codebase.Verification successful
New dependency
@pipedream/platform
is necessary.The dependency
@pipedream/platform
is indeed used within thecomponents/onlyoffice_docspace
component, specifically in the following files:
components/onlyoffice_docspace/onlyoffice_docspace.app.mjs
components/onlyoffice_docspace/sources/common/polling.mjs
These usages confirm that the dependency is necessary for the functionality of this component.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of the new dependency in the codebase. # Test: Search for the usage of `@pipedream/platform`. Expect: References to `@pipedream/platform`. rg --type js -w '@pipedream/platform'Length of output: 1157
Script:
#!/bin/bash # Description: Verify the usage of the new dependency in the onlyoffice_docspace component. # Test: Search for the usage of `@pipedream/platform` within the onlyoffice_docspace component directory. rg --type js -w '@pipedream/platform' components/onlyoffice_docspace/Length of output: 69
Script:
#!/bin/bash # Description: Verify any mentions of the new dependency in the onlyoffice_docspace component. # Test: Search for any mentions of `@pipedream/platform` within the onlyoffice_docspace component directory. rg '@pipedream/platform' components/onlyoffice_docspace/Length of output: 328
components/onlyoffice_docspace/sources/new-user-added/new-user-added.mjs (8)
3-4
: Extending common properties.The new source extends common properties and methods from the
common
module. This is a good practice for code reuse.
8-8
: Version is set to 0.0.1.The version for the new source is set to
0.0.1
. This is appropriate for a new feature.
9-10
: Source type and deduplication strategy.The source type is set to
source
and the deduplication strategy is set tounique
. This is appropriate for event sources.
16-23
: Arguments for resource fetching.The
getResourcesFnArgs
method returns the arguments for fetching resources, including activation status. Ensure these arguments are correct and sufficient.
24-30
: Metadata generation.The
generateMeta
method creates metadata for the new user resource. This is necessary for event handling.
5-7
: New source metadata.The key, name, and description for the new source are defined. Ensure the documentation link is correct and provides relevant information.
Verification successful
Documentation link is accessible.
The documentation link provided in the metadata is valid and accessible with an HTTP status code of 200.
- File:
components/onlyoffice_docspace/sources/new-user-added/new-user-added.mjs
- Lines: 5-7
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the documentation link. # Test: Check if the documentation link is accessible. Expect: The link is accessible. curl -o /dev/null -s -w "%{http_code}\n" https://api.onlyoffice.com/docspace/method/people/get/api/2.0/people/simple/filterLength of output: 129
11-14
: Methods for resource fetching.The
getResourcesFn
method returns the function to fetch resources. EnsuresearchUsersByExtendedFilter
is implemented in the app.Verification successful
Verified Implementation of
searchUsersByExtendedFilter
.The
searchUsersByExtendedFilter
method is implemented in thecomponents/onlyoffice_docspace/onlyoffice_docspace.app.mjs
file.
- Location:
components/onlyoffice_docspace/onlyoffice_docspace.app.mjs
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation of `searchUsersByExtendedFilter` in the app. # Test: Search for the `searchUsersByExtendedFilter` method in the app. Expect: The method is implemented. rg 'searchUsersByExtendedFilter' components/onlyoffice_docspace/onlyoffice_docspace.app.mjsLength of output: 136
1-2
: Common module import.The
common
module is imported from../common/polling.mjs
. Ensure this module exists and is correctly implemented.Verification successful
Common module import verification.
The
common
module is correctly imported from../common/polling.mjs
, and the file exists and appears to be correctly implemented.
- The file
components/onlyoffice_docspace/sources/common/polling.mjs
was found and contains a valid implementation.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the existence and correctness of the `common` module. # Test: Check if the `common/polling.mjs` file exists. Expect: The file exists. fd 'polling.mjs' components/onlyoffice_docspace/commonLength of output: 54
Script:
#!/bin/bash # Description: Verify the existence of the `polling.mjs` file in the entire repository. # Test: Check if the `polling.mjs` file exists anywhere in the repository. Expect: The file exists. fd 'polling.mjs'Length of output: 3662
Script:
#!/bin/bash # Description: Display the contents of the `polling.mjs` file to verify its correctness. # Test: Output the contents of the `polling.mjs` file. cat components/onlyoffice_docspace/sources/common/polling.mjsLength of output: 1874
components/onlyoffice_docspace/actions/invite-user/invite-user.mjs (6)
5-8
: Version is set to 0.0.1.The version for the new action is set to
0.0.1
. This is appropriate for a new feature.
9-16
: Action properties.The action properties include the app and email. Ensure the email property is correctly defined and validated.
17-23
: Invite user method.The
inviteUser
method posts data to the/people/invite
endpoint. Ensure the method is correctly implemented and handles errors.
24-44
: Run method.The
run
method executes the invite user action and handles the response. Ensure the method is correctly implemented and handles errors.
3-4
: Action metadata.The key, name, and description for the new action are defined. Ensure the documentation link is correct and provides relevant information.
Verification successful
Documentation link verified.
The documentation link for the action is accessible and correct.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the documentation link. # Test: Check if the documentation link is accessible. Expect: The link is accessible. curl -o /dev/null -s -w "%{http_code}\n" https://api.onlyoffice.com/docspace/method/people/post/api/2.0/people/inviteLength of output: 123
1-2
: App module import.The
app
module is imported from../../onlyoffice_docspace.app.mjs
. Ensure this module exists and is correctly implemented.Verification successful
App module import.
The
app
module is correctly imported fromcomponents/onlyoffice_docspace/onlyoffice_docspace.app.mjs
and is properly implemented.
- The file
components/onlyoffice_docspace/onlyoffice_docspace.app.mjs
exists.- The file exports a default object, confirming its correct implementation.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the existence and correctness of the `app` module. # Test: Check if the `onlyoffice_docspace.app.mjs` file exists. Expect: The file exists. fd 'onlyoffice_docspace.app.mjs' components/onlyoffice_docspaceLength of output: 122
Script:
#!/bin/bash # Description: Inspect the export statements in the `onlyoffice_docspace.app.mjs` file. # Test: Output the export statements. Expect: The file exports necessary components or functionalities. rg 'export' components/onlyoffice_docspace/onlyoffice_docspace.app.mjs -A 5Length of output: 192
components/onlyoffice_docspace/sources/new-file/new-file.mjs (4)
14-16
: LGTM!The sorting function is correctly implemented.
17-19
: LGTM!The method correctly returns the resource name for files.
20-22
: LGTM!The method correctly returns the function to list files and folders.
23-30
: Review thedebug
flag.The
debug
flag is set totrue
. Ensure this is appropriate for the intended environment, as it might not be suitable for production.components/onlyoffice_docspace/sources/new-folder/new-folder.mjs (4)
14-16
: LGTM!The sorting function is correctly implemented.
17-19
: LGTM!The method correctly returns the resource name for folders.
20-22
: LGTM!The method correctly returns the function to list files and folders.
23-30
: Review thedebug
flag.The
debug
flag is set totrue
. Ensure this is appropriate for the intended environment, as it might not be suitable for production.components/onlyoffice_docspace/actions/upload-file/upload-file.mjs (4)
1-3
: LGTM!The import statements are necessary and correctly included.
10-24
: LGTM!The props are correctly defined with appropriate types, labels, descriptions, and propDefinitions.
26-34
: LGTM!The
uploadFile
method is correctly implemented to handle file uploads.
36-54
: Ensure proper error handling.The async run function is correctly implemented, but consider adding error handling to manage potential issues during the file upload process.
+ try { const response = await uploadFile({ $, folderId, headers: constants.MULTIPART_FORM_DATA_HEADERS, data: { File: file, }, }); $.export("$summary", `Successfully uploaded file with ID \`${response.response.id}\`.`); return response; + } catch (error) { + $.export("$summary", `Failed to upload file: ${error.message}`); + throw error; + }components/onlyoffice_docspace/actions/create-room/create-room.mjs (4)
1-2
: LGTM!The import statement is necessary and correctly included.
9-46
: LGTM!The props are correctly defined with appropriate types, labels, descriptions, and options.
48-54
: LGTM!The
createRoom
method is correctly implemented to handle room creation.
56-76
: Ensure proper error handling.The async run function is correctly implemented, but consider adding error handling to manage potential issues during the room creation process.
+ try { const response = await createRoom({ $, data: { Title: title, RoomType: roomType, Notify: notify, SharingMessage: sharingMessage, }, }); $.export("$summary", `Successfully created room with ID \`${response.response.id}\`.`); return response; + } catch (error) { + $.export("$summary", `Failed to create room: ${error.message}`); + throw error; + }components/onlyoffice_docspace/sources/common/polling.mjs (4)
1-6
: LGTM!The import statements are necessary and correctly included.
8-18
: LGTM!The props are correctly defined with appropriate types, labels, descriptions, and default values.
19-55
: Ensure all methods are implemented.Some methods like
generateMeta
,getResourcesFn
, andgetResourcesFnArgs
throwConfigurationError
, indicating they are not yet implemented. Ensure these methods are implemented before using this component.+ generateMeta() { + // Implement the generateMeta method + } + getResourcesFn() { + // Implement the getResourcesFn method + } + getResourcesFnArgs() { + // Implement the getResourcesFnArgs method + }
57-78
: Ensure proper error handling.The async run function is correctly implemented, but consider adding error handling to manage potential issues during the polling process.
+ try { const resourcesName = getResourcesName(); const resourcesFn = getResourcesFn(); const metadata = await resourcesFn(getResourcesFnArgs()); let resources; if (resourcesName) { ({ response: { [resourcesName]: resources } } = metadata); } else { ({ response: resources } = metadata); } processResources(resources); + } catch (error) { + this.$emit("error", `Failed to process resources: ${error.message}`); + throw error; + }components/onlyoffice_docspace/onlyoffice_docspace.app.mjs (8)
36-39
: LGTM!The
getUrl
method constructs a URL based on a base URL and the user's subdomain. The code changes are approved.
41-47
: LGTM!The
getHeaders
method consolidates header management for requests, ensuring the correct content type and authorization are included. The code changes are approved.
78-82
: LGTM!The
post
method uses the_makeRequest
method to make a POST request. The code changes are approved.
84-88
: LGTM!The
listMyFilesAndFolders
method uses the_makeRequest
method to list the user's files and folders. The code changes are approved.
90-94
: LGTM!The
searchUsersByExtendedFilter
method uses the_makeRequest
method to search for users by an extended filter. The code changes are approved.
8-32
: LGTM! But verify thelistMyFilesAndFolders
method.The new property definition for
file
enhances user interaction by providing dynamic options. The code changes are approved.However, ensure that the
listMyFilesAndFolders
method is correctly implemented and returns the expected resources.
49-66
: LGTM! But verify the utility methods.The
getConfig
method handles multipart headers and data preparation, allowing for more flexible request configurations. The code changes are approved.However, ensure that the
utils.hasMultipartHeader
andutils.getFormData
methods are correctly implemented and return the expected results.
68-76
: LGTM! But verify theaxios
import.The
_makeRequest
method centralizes the request logic, utilizing theaxios
library for making HTTP calls with the constructed configuration. The code changes are approved.However, ensure that the
axios
import from@pipedream/platform
is correctly implemented and available.
components/onlyoffice_docspace/sources/new-folder/new-folder.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.
Hi @jcortes , I left some small comments that should be checked but do not impact functionality, so I'll move it forward
@@ -11,5 +11,8 @@ | |||
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)", | |||
"publishConfig": { | |||
"access": "public" | |||
}, | |||
"dependencies": { | |||
"@pipedream/platform": "^3.0.0" |
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.
form-data
needs to be included as a dependency
if (sortFn) { | ||
return Array.from(resources) | ||
.sort(sortFn) | ||
.forEach(processResource); | ||
} | ||
|
||
Array.from(resources) | ||
.forEach(processResource); |
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.
I think the duplication can be avoided here, since .sort
works in-place
if (sortFn) { | |
return Array.from(resources) | |
.sort(sortFn) | |
.forEach(processResource); | |
} | |
Array.from(resources) | |
.forEach(processResource); | |
const arrResources = Array.from(resources); | |
if (sortFn) { | |
arrResources.sort(sortFn); | |
} | |
arrResources.forEach(processResource); |
2652e4d
to
d50b2a9
Compare
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
Files selected for processing (11)
- components/onlyoffice_docspace/actions/create-room/create-room.mjs (1 hunks)
- components/onlyoffice_docspace/actions/invite-user/invite-user.mjs (1 hunks)
- components/onlyoffice_docspace/actions/upload-file/upload-file.mjs (1 hunks)
- components/onlyoffice_docspace/common/constants.mjs (1 hunks)
- components/onlyoffice_docspace/common/utils.mjs (1 hunks)
- components/onlyoffice_docspace/onlyoffice_docspace.app.mjs (1 hunks)
- components/onlyoffice_docspace/package.json (2 hunks)
- components/onlyoffice_docspace/sources/common/polling.mjs (1 hunks)
- components/onlyoffice_docspace/sources/new-file/new-file.mjs (1 hunks)
- components/onlyoffice_docspace/sources/new-folder/new-folder.mjs (1 hunks)
- components/onlyoffice_docspace/sources/new-user-added/new-user-added.mjs (1 hunks)
Files skipped from review due to trivial changes (1)
- components/onlyoffice_docspace/common/constants.mjs
Files skipped from review as they are similar to previous changes (7)
- components/onlyoffice_docspace/actions/create-room/create-room.mjs
- components/onlyoffice_docspace/actions/invite-user/invite-user.mjs
- components/onlyoffice_docspace/actions/upload-file/upload-file.mjs
- components/onlyoffice_docspace/sources/common/polling.mjs
- components/onlyoffice_docspace/sources/new-file/new-file.mjs
- components/onlyoffice_docspace/sources/new-folder/new-folder.mjs
- components/onlyoffice_docspace/sources/new-user-added/new-user-added.mjs
Additional context used
Biome
components/onlyoffice_docspace/common/utils.mjs
[error] 32-34: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
Additional comments not posted (14)
components/onlyoffice_docspace/package.json (2)
3-3
: Version increment is appropriate.The version increment from
0.0.1
to0.1.0
reflects the new features added in this PR.
15-17
: Dependencies added correctly.The new dependencies
@pipedream/platform
andform-data
are added correctly. This aligns with the new functionalities introduced.components/onlyoffice_docspace/common/utils.mjs (3)
5-17
: Optimize condition checking for file properties.The condition checking for file properties can be optimized by using a more efficient method.
- } else if (data && constants.FILE_PROP_NAMES.some((prop) => parentKey.includes(prop))) { + } else if (data && constants.FILE_PROP_NAMES.some((prop) => parentKey.endsWith(prop))) {
20-28
: Improve error handling with a more descriptive error message.The current error handling logs a generic message. Provide a more descriptive error message to help with debugging.
- console.log("FormData Error", error); + console.error("Error building FormData:", error);
32-34
: Simplify header check using optional chaining.Use optional chaining to simplify the check for multipart/form-data content type.
- return headers - && headers[constants.CONTENT_TYPE_KEY_HEADER]?. - includes(constants.MULTIPART_FORM_DATA_VALUE_HEADER); + return headers?.[constants.CONTENT_TYPE_KEY_HEADER]?.includes(constants.MULTIPART_FORM_DATA_VALUE_HEADER);Tools
Biome
[error] 32-34: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
components/onlyoffice_docspace/onlyoffice_docspace.app.mjs (9)
3-3
: Import dependencies correctly.The new dependencies
axios
,constants
, andutils
are imported correctly.
8-33
: New property definition forfile
is well-defined.The new property definition for
file
includes an asynchronous options method that dynamically retrieves and maps available files and folders.
36-39
: URL construction method is correct.The
getUrl
method constructs the URL based on the base URL and the user's subdomain correctly.
41-47
: Header management method is correct.The
getHeaders
method consolidates header management for requests, ensuring that the correct content type and authorization are included.
49-67
: Configuration method handles multipart headers and data preparation effectively.The
getConfig
method handles multipart headers and data preparation, allowing for more flexible request configurations.
68-77
: Request logic is centralized effectively.The
_makeRequest
method centralizes the request logic, utilizing theaxios
library for making HTTP calls with the constructed configuration.
78-83
: Post method leverages centralized request logic.The
post
method leverages the centralized request logic to make POST requests.
84-89
: List files and folders method is well-implemented.The
listMyFilesAndFolders
method utilizes the centralized request logic to list files and folders.
90-94
: Search users method is well-implemented.The
searchUsersByExtendedFilter
method utilizes the centralized request logic to search for users.
WHY
Resolves #12929
Summary by CodeRabbit
New Features
Enhancements
Version Update
@pipedream/platform
.