Skip to content
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

Language Support: TypeScript #219

Open
dylburger opened this issue Oct 23, 2019 · 6 comments
Open

Language Support: TypeScript #219

dylburger opened this issue Oct 23, 2019 · 6 comments
Labels
enhancement New feature or request New language New language request tracked internally Issue is also tracked in our internal issue tracker triaged For maintainers: This issue has been triaged by a Pipedream employee

Comments

@dylburger
Copy link
Contributor

I'd like to author TypeScript code steps on Pipedream, similar to how I can choose to "Run Node.js code" today.

@dylburger dylburger transferred this issue from PipedreamHQ/roadmap Jun 19, 2020
@dylburger dylburger added enhancement New feature or request New language New language request labels Jun 19, 2020
@hhimanshu
Copy link

Likewise

@jverce
Copy link
Contributor

jverce commented Apr 15, 2021

Bumping 😃

@hhimanshu
Copy link

Hello @todsac, any plans for getting this prioritized?

@dylburger
Copy link
Contributor Author

@hhimanshu this isn't on the immediate roadmap, but we hear you and plan to add support for other languages like TypeScript in the future!

@kangzeroo
Copy link

kangzeroo commented Feb 1, 2022

For anyone looking to get Typescript support - you can get it by compiling your TS into a commonjs module, then uploading that to pipedream via cli. Something like this:

// myAction.ts
export default {
  name: "GBucket - Upload File",
  description: "Uploads a file to a GBucket route",
  key: "myGBucketUploader",
  version: "1.0.0",
  type: "action",
  props: {
    googleCloud: {         // passed in app object https://pipedream.com/docs/apps/all-apps/#apps
      type: "app",
      app: "google_cloud",
    },
    webhookTrigger: {    // passed in param https://pipedream.com/docs/workflows/steps/params/#entering-expressions
      type: "object",      
    },
  },
  async run() {

      // access your passed in variables, which can come from a previous code step
      const { myData } = (this as any).webhookTrigger.object;

     // access your auth passed in from apps
     const { Storage } = require("@google-cloud/storage");
     const key = JSON.parse((this as any).googleCloud.$auth.key_json);
    const storage = new Storage({
      projectId: key.project_id,
      credentials: {
        client_email: key.client_email,
        private_key: key.private_key,
      },
    });
    await storage.upload(myData)

  }
}
// rollup.config.js (or webpack.config.js)
const configAction = {
  input: "src/actions/myAction.ts",
  output: {
    file: "lib/actions/myAction.js",
    format: "cjs",
    sourcemap: true,
    exports: "default",
  },
  plugins: [
    commonjs(), // enable CommonJS modules
    nodePolyfills(), // enable NodeJS polyfills
    resolve({ preferBuiltins: true, browser: true }), // enable importing from node_modules
    typescript(), // enable TypeScript
    json(), // enable JSON
    globals(), // allows globals to be imported (process.env)
    builtins(), // allows builtins to be imported via require/import
  ],
};
echo "Deploying Pipedream..."
yarn build
NODE_ENV=production pd publish ./lib/actions/myAction.js

Which will end up looking like re-useable action this in the Pipedream UI.

image

@dylburger dylburger added tracked internally Issue is also tracked in our internal issue tracker triaged For maintainers: This issue has been triaged by a Pipedream employee labels Jun 7, 2022
@seanparkross
Copy link

Typescript. Yes please.

Powered by Deno and able to define the type that the code block will receive would be 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request New language New language request tracked internally Issue is also tracked in our internal issue tracker triaged For maintainers: This issue has been triaged by a Pipedream employee
Projects
None yet
Development

No branches or pull requests

5 participants