PipedreamHQ / pipedream

Connect APIs, remarkably fast. Free for developers.
https://pipedream.com
Other
9.01k stars 5.28k forks source link

Language Support: TypeScript #219

Open dylburger opened 5 years ago

dylburger commented 5 years ago

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

hhimanshu commented 4 years ago

Likewise

jverce commented 3 years ago

Bumping 😃

hhimanshu commented 3 years ago

Hello @todsac, any plans for getting this prioritized?

dylburger commented 3 years ago

@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 commented 2 years ago

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

seanparkross commented 1 year ago

Typescript. Yes please.

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

joscha commented 6 months ago

Is there any news on this? It's been almost a year and the only other resource I can find is https://pipedream.com/docs/components/typescript which is a start but there's not a lot of movement: https://github.com/PipedreamHQ/pipedream/commits/master/types/src/index.ts ?

joscha commented 6 months ago

For anyone interested in using Parcel for their build, here is a sample configuration: https://gist.github.com/joscha/bd630f90adaa0cb1ce2f9c4714ba3d7a