We would like to customize/extend the code that Pipedream already uses to perform actions. The same stuff found on GitHub here: pipedream/copy-file.mjs at master · PipedreamHQ/pipedream · GitHub
But with slight modifications/additions needed for our usecases.
It could be that we’re taking the wrong approach here, hence the broad question in the post title.
That said, here’s a specific example of what we tried, which seemingly worked … until it didn’t.
Example: That Copy File action code linked above is missing option(s) to tell Google Drive:
- In which folder (id) to create the newly copied file.
- What to name the newly copied file.
(Google Drive API allows us to pass in some extra parameters to do these things in a single API call.)
We were able to add those params by simply…
- Creating a GoogleDrive “step” in an existing pipedream workflow, and selecting “Code” (to reuse auth)
- copy/paste the existing action code from GitHub into this new Pipedream action (in the web UI)
- Add our own definitions to the JS under
- pipe the extra parameters’ values into the
It was almost too easy!
The only catch was on the dependencies. We had to change…
import googleDrive from "../../google_drive.app.mjs"; /* to */ import googleDrive from "@pipedream/google_drive"; /* Presumably to force pipedream to install that npm package */
Now, today, we are trying to do a similar thing with a Google Sheets action, but quickly landed in dependency hell.
First, we tried simply copying the action code and updating the
import statement to point to the npm package. But that gave an error about not being able to find the Google Drive package (I see in the code that it’s a dependency, but it’s included with relative path). So then we figured “oh, well let’s force it to
npm install that package too”.
We went through this a few more times, installing things like
But the ultimate result was the same: we keep getting errors about this or that dependency and can’t make sense of what’s happening under the hood.
This got me thinking: We’re surely approaching this the wrong way. After all, even if we made it “work”, some upstream dependency change in the future could break our working code.
All the errors we’re getting are some permutation of these:
Cannot find module '[redacted]/node_modules/@pipedream/google_drive/google_drive.app.mjs' imported from [redacted]/node_modules/@pipedream/google_sheets/google_sheets.app.mjs
Here’s a literal copy/pasted example:
Cannot find module '/tmp/__pdg__/dist/code/02d7a2c4505a8c5723ca8ba705d8e04e5a5f12421db1481851d293602d52cd60/node_modules/.pnpm/@email@example.com/node_modules/@pipedream/google_drive/google_drive.app.mjs' imported from /tmp/__pdg__/dist/code/02d7a2c4505a8c5723ca8ba705d8e04e5a5f12421db1481851d293602d52cd60/node_modules/.pnpm/@firstname.lastname@example.org/node_modules/@pipedream/google_sheets/google_sheets.app.mjs
Is there some better way to extend the code already being used for these actions? We don’t want to re-engineer the whole action; just need to pipe through extra parameters to the API calls.