Skip to main content
Question

Use zapier schema as typescript interface type

  • December 10, 2021
  • 0 replies
  • 278 views

asharma

Is there a simple way to use Zapier schema as typescript interface type? Consider trigger definition from typescript zapier template.

import { Bundle, ZObject } from 'zapier-platform-core';

const perform = async (z: ZObject, bundle: Bundle) => {
  const response = await z.request(
    'https://auth-json-server.zapier-staging.com/movies'
  );
  return response.data;
};

const triggerOp = {
  perform,
  sample: {
    id: '1',
    title: 'example',
  },
};

export default {
  key: 'movie',
  noun: 'Movie',

  display: {
    label: 'New Movie',
    description: 'Triggers when a new movie is created.',
  },

  operation: triggerOp,
};

Is there a way to assign type to object “triggerOp” like

const triggerOp: BasicHookOperationSchema = { /*rest hook operation properties */ }

OR

const triggerOp:BasicPollingOperationSchema = { /*polling operation properties */}

 

Did this topic help you find an answer to your question?
This post has been closed for comments. Please create a new post if you need help or have a question about this topic.