Milestone 0: import zappier billing, Verae middleware, and Zapier research
Compose-ready workspace: packages/zappier (rate card, portal, Stripe), packages/verae-zapier-middleware (timestamp + NATS), packages/verae-zapier (CLI app), vendor/zapier-platform, and research/zapier vendor corpus. Gate 0 structure checks pass. Product code and research are not yet wired.
This commit is contained in:
commit
b4150c8250
1364 changed files with 6814366 additions and 0 deletions
62
vendor/zapier-platform/packages/cli/scaffold/create.template.js
vendored
Normal file
62
vendor/zapier-platform/packages/cli/scaffold/create.template.js
vendored
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
// create a particular <%= LOWER_NOUN %> by name
|
||||
const perform = async (z, bundle) => {
|
||||
const response = await z.request({
|
||||
method: 'POST',
|
||||
url: 'https://jsonplaceholder.typicode.com/posts',
|
||||
// if `body` is an object, it'll automatically get run through JSON.stringify
|
||||
// if you don't want to send JSON, pass a string in your chosen format here instead
|
||||
body: {
|
||||
name: bundle.inputData.name
|
||||
}
|
||||
});
|
||||
// this should return a single object
|
||||
return response.data;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
// see here for a full list of available properties:
|
||||
// https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#createschema
|
||||
key: '<%= KEY %>',
|
||||
noun: '<%= NOUN %>',
|
||||
|
||||
display: {
|
||||
label: 'Create <%= NOUN %>',
|
||||
description: 'Creates a new <%= LOWER_NOUN %>, probably with input from previous steps.'
|
||||
},
|
||||
|
||||
operation: {
|
||||
perform,
|
||||
|
||||
<%= INCLUDE_INTRO_COMMENTS ? [
|
||||
'// `inputFields` defines the fields a user could provide',
|
||||
'// Zapier will pass them in as `bundle.inputData` later. They\'re optional.',
|
||||
'// End-users will map data into these fields. In general, they should have any fields that the API can accept. Be sure to accurately mark which fields are required!'
|
||||
].join('\n ') : '' %>
|
||||
inputFields: [
|
||||
{key: 'name', required: true},
|
||||
{key: 'fave_meal', label: 'Favorite Meal', required: false}
|
||||
],
|
||||
|
||||
<%= INCLUDE_INTRO_COMMENTS ? [
|
||||
'// In cases where Zapier needs to show an example record to the user, but we are unable to get a live example',
|
||||
'// from the API, Zapier will fallback to this hard-coded sample. It should reflect the data structure of',
|
||||
'// returned records, and have obvious placeholder values that we can show to any user.'
|
||||
].join('\n ') : '' %>
|
||||
sample: {
|
||||
id: 1,
|
||||
name: 'Test'
|
||||
},
|
||||
|
||||
<%= INCLUDE_INTRO_COMMENTS ? [
|
||||
'// If fields are custom to each user (like spreadsheet columns), `outputFields` can create human labels',
|
||||
'// For a more complete example of using dynamic fields see',
|
||||
'// https://github.com/zapier/zapier-platform/tree/main/packages/cli#customdynamic-fields',
|
||||
'// Alternatively, a static field definition can be provided, to specify labels for the fields'
|
||||
].join('\n ') : '' %>
|
||||
outputFields: [
|
||||
// these are placeholders to match the example `perform` above
|
||||
// {key: 'id', label: 'Person ID'},
|
||||
// {key: 'name', label: 'Person Name'}
|
||||
]
|
||||
}
|
||||
};
|
||||
71
vendor/zapier-platform/packages/cli/scaffold/create.template.ts
vendored
Normal file
71
vendor/zapier-platform/packages/cli/scaffold/create.template.ts
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
import {
|
||||
defineInputFields,
|
||||
defineCreate,
|
||||
type CreatePerform,
|
||||
type InferInputData,
|
||||
} from 'zapier-platform-core';
|
||||
|
||||
const inputFields = defineInputFields([
|
||||
{ key: 'name', required: true },
|
||||
{ key: 'fave_meal', label: 'Favorite Meal', required: false },
|
||||
]);
|
||||
|
||||
// create a particular <%= LOWER_NOUN %> by name
|
||||
const perform = (async (z, bundle) => {
|
||||
const response = await z.request({
|
||||
method: 'POST',
|
||||
url: 'https://jsonplaceholder.typicode.com/posts',
|
||||
// if `body` is an object, it'll automatically get run through JSON.stringify
|
||||
// if you don't want to send JSON, pass a string in your chosen format here instead
|
||||
body: {
|
||||
name: bundle.inputData.name,
|
||||
},
|
||||
});
|
||||
// this should return a single object
|
||||
return response.data;
|
||||
}) satisfies CreatePerform<InferInputData<typeof inputFields>>;
|
||||
|
||||
export default defineCreate({
|
||||
// see here for a full list of available properties:
|
||||
// https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#createschema
|
||||
key: '<%= KEY %>',
|
||||
noun: '<%= NOUN %>',
|
||||
|
||||
display: {
|
||||
label: 'Create <%= NOUN %>',
|
||||
description: 'Creates a new <%= LOWER_NOUN %>, probably with input from previous steps.'
|
||||
},
|
||||
|
||||
operation: {
|
||||
perform,
|
||||
|
||||
<%= INCLUDE_INTRO_COMMENTS ? [
|
||||
'// `inputFields` defines the fields a user could provide',
|
||||
'// Zapier will pass them in as `bundle.inputData` later. They\'re optional.',
|
||||
'// End-users will map data into these fields. In general, they should have any fields that the API can accept. Be sure to accurately mark which fields are required!'
|
||||
].join('\n ') : '' %>
|
||||
inputFields,
|
||||
|
||||
<%= INCLUDE_INTRO_COMMENTS ? [
|
||||
'// In cases where Zapier needs to show an example record to the user, but we are unable to get a live example',
|
||||
'// from the API, Zapier will fallback to this hard-coded sample. It should reflect the data structure of',
|
||||
'// returned records, and have obvious placeholder values that we can show to any user.'
|
||||
].join('\n ') : '' %>
|
||||
sample: {
|
||||
id: 1,
|
||||
name: 'Test',
|
||||
},
|
||||
|
||||
<%= INCLUDE_INTRO_COMMENTS ? [
|
||||
'// If fields are custom to each user (like spreadsheet columns), `outputFields` can create human labels',
|
||||
'// For a more complete example of using dynamic fields see',
|
||||
'// https://github.com/zapier/zapier-platform/tree/main/packages/cli#customdynamic-fields',
|
||||
'// Alternatively, a static field definition can be provided, to specify labels for the fields'
|
||||
].join('\n ') : '' %>
|
||||
outputFields: [
|
||||
// these are placeholders to match the example `perform` above
|
||||
// {key: 'id', label: 'Person ID'},
|
||||
// {key: 'name', label: 'Person Name'}
|
||||
],
|
||||
},
|
||||
});
|
||||
121
vendor/zapier-platform/packages/cli/scaffold/resource.template.js
vendored
Normal file
121
vendor/zapier-platform/packages/cli/scaffold/resource.template.js
vendored
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
// get a list of <%= LOWER_NOUN %>s
|
||||
const performList = async (z, bundle) => {
|
||||
const response = await z.request({
|
||||
url: 'https://jsonplaceholder.typicode.com/posts',
|
||||
params: {
|
||||
order_by: 'id desc'
|
||||
}
|
||||
});
|
||||
return response.data
|
||||
};
|
||||
|
||||
// find a particular <%= LOWER_NOUN %> by name (or other search criteria)
|
||||
const performSearch = async (z, bundle) => {
|
||||
const response = await z.request({
|
||||
url: 'https://jsonplaceholder.typicode.com/posts',
|
||||
params: {
|
||||
name: bundle.inputData.name
|
||||
}
|
||||
});
|
||||
return response.data
|
||||
};
|
||||
|
||||
// creates a new <%= LOWER_NOUN %>
|
||||
const performCreate = async (z, bundle) => {
|
||||
const response = await z.request({
|
||||
method: 'POST',
|
||||
url: 'https://jsonplaceholder.typicode.com/posts',
|
||||
body: {
|
||||
name: bundle.inputData.name // json by default
|
||||
}
|
||||
});
|
||||
return response.data
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
// see here for a full list of available properties:
|
||||
// https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#resourceschema
|
||||
key: '<%= KEY %>',
|
||||
noun: '<%= NOUN %>',
|
||||
|
||||
<%= INCLUDE_INTRO_COMMENTS ? [
|
||||
'// If `get` is defined, it will be called after a `search` or `create`'
|
||||
].join('\n ') : '' %>
|
||||
// useful if your `searches` and `creates` return sparse objects
|
||||
// get: {
|
||||
// display: {
|
||||
// label: 'Get <%= NOUN %>',
|
||||
// description: 'Gets a <%= LOWER_NOUN %>.'
|
||||
// },
|
||||
// operation: {
|
||||
// inputFields: [
|
||||
// {key: 'id', required: true}
|
||||
// ],
|
||||
// perform: defineMe
|
||||
// }
|
||||
// },
|
||||
|
||||
list: {
|
||||
display: {
|
||||
label: 'New <%= NOUN %>',
|
||||
description: 'Lists the <%= LOWER_NOUN %>s.'
|
||||
},
|
||||
operation: {
|
||||
perform: performList,
|
||||
<%= INCLUDE_INTRO_COMMENTS ? [
|
||||
'// `inputFields` defines the fields a user could provide',
|
||||
'// Zapier will pass them in as `bundle.inputData` later. They\'re optional on triggers, but required on searches and creates.'
|
||||
].join('\n ') : '' %>
|
||||
inputFields: []
|
||||
}
|
||||
},
|
||||
|
||||
search: {
|
||||
display: {
|
||||
label: 'Find <%= NOUN %>',
|
||||
description: 'Finds a <%= LOWER_NOUN %> give.'
|
||||
},
|
||||
operation: {
|
||||
inputFields: [
|
||||
{key: 'name', required: true}
|
||||
],
|
||||
perform: performSearch
|
||||
},
|
||||
},
|
||||
|
||||
create: {
|
||||
display: {
|
||||
label: 'Create <%= NOUN %>',
|
||||
description: 'Creates a new <%= LOWER_NOUN %>.'
|
||||
},
|
||||
operation: {
|
||||
inputFields: [
|
||||
{key: 'name', required: true}
|
||||
],
|
||||
perform: performCreate
|
||||
},
|
||||
},
|
||||
|
||||
<%= INCLUDE_INTRO_COMMENTS ? [
|
||||
'// In cases where Zapier needs to show an example record to the user, but we are unable to get a live example',
|
||||
'// from the API, Zapier will fallback to this hard-coded sample. It should reflect the data structure of',
|
||||
'// returned records, and have obvious placeholder values that we can show to any user.',
|
||||
'// In this resource, the sample is reused across all methods'
|
||||
].join('\n ') : '' %>
|
||||
sample: {
|
||||
id: 1,
|
||||
name: 'Test'
|
||||
},
|
||||
|
||||
<%= INCLUDE_INTRO_COMMENTS ? [
|
||||
'// If fields are custom to each user (like spreadsheet columns), `outputFields` can create human labels',
|
||||
'// For a more complete example of using dynamic fields see',
|
||||
'// https://github.com/zapier/zapier-platform/tree/main/packages/cli#customdynamic-fields',
|
||||
'// Alternatively, a static field definition can be provided, to specify labels for the fields',
|
||||
'// In this resource, these output fields are reused across all resources'
|
||||
].join('\n ') : '' %>
|
||||
outputFields: [
|
||||
{key: 'id', label: 'ID'},
|
||||
{key: 'name', label: 'Name'}
|
||||
]
|
||||
};
|
||||
140
vendor/zapier-platform/packages/cli/scaffold/resource.template.ts
vendored
Normal file
140
vendor/zapier-platform/packages/cli/scaffold/resource.template.ts
vendored
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
import {
|
||||
defineInputFields,
|
||||
type CreatePerform,
|
||||
type InferInputData,
|
||||
type PollingTriggerPerform,
|
||||
type Resource,
|
||||
type SearchPerform,
|
||||
} from 'zapier-platform-core';
|
||||
|
||||
// get a list of <%= LOWER_NOUN %>s
|
||||
const performList = (async (z, bundle) => {
|
||||
const response = await z.request({
|
||||
url: 'https://jsonplaceholder.typicode.com/posts',
|
||||
params: {
|
||||
order_by: 'id desc',
|
||||
tag: bundle.inputData.tagName,
|
||||
},
|
||||
});
|
||||
return response.data;
|
||||
}) satisfies PollingTriggerPerform;
|
||||
|
||||
const searchInputFields = defineInputFields([
|
||||
{
|
||||
key: 'name',
|
||||
required: true,
|
||||
helpText: 'Find the <%= NOUN %> with this name.',
|
||||
},
|
||||
]);
|
||||
|
||||
// find a particular <%= LOWER_NOUN %> by name (or other search criteria)
|
||||
const performSearch = (async (z, bundle) => {
|
||||
const response = await z.request({
|
||||
url: 'https://jsonplaceholder.typicode.com/posts',
|
||||
params: {
|
||||
name: bundle.inputData.name,
|
||||
},
|
||||
});
|
||||
return response.data;
|
||||
}) satisfies SearchPerform<InferInputData<typeof searchInputFields>>;
|
||||
|
||||
const createInputFields = defineInputFields([
|
||||
{ key: 'name', required: true },
|
||||
{ key: 'fave_meal', label: 'Favorite Meal', required: false },
|
||||
]);
|
||||
|
||||
// creates a new <%= LOWER_NOUN %>
|
||||
const performCreate = (async (z, bundle) => {
|
||||
const response = await z.request({
|
||||
method: 'POST',
|
||||
url: 'https://jsonplaceholder.typicode.com/posts',
|
||||
body: {
|
||||
name: bundle.inputData.name, // json by default
|
||||
},
|
||||
});
|
||||
return response.data;
|
||||
}) satisfies CreatePerform<InferInputData<typeof createInputFields>>;
|
||||
|
||||
export default {
|
||||
// see here for a full list of available properties:
|
||||
// https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#resourceschema
|
||||
key: '<%= KEY %>',
|
||||
noun: '<%= NOUN %>',
|
||||
|
||||
<%= INCLUDE_INTRO_COMMENTS ? [
|
||||
'// If `get` is defined, it will be called after a `search` or `create`'
|
||||
].join('\n ') : '' %>
|
||||
// useful if your `searches` and `creates` return sparse objects
|
||||
// get: {
|
||||
// display: {
|
||||
// label: 'Get <%= NOUN %>',
|
||||
// description: 'Gets a <%= LOWER_NOUN %>.'
|
||||
// },
|
||||
// operation: {
|
||||
// inputFields: [
|
||||
// {key: 'id', required: true}
|
||||
// ],
|
||||
// perform: defineMe
|
||||
// }
|
||||
// },
|
||||
|
||||
list: {
|
||||
display: {
|
||||
label: 'New <%= NOUN %>',
|
||||
description: 'Lists the <%= LOWER_NOUN %>s.',
|
||||
},
|
||||
operation: {
|
||||
perform: performList,
|
||||
<%= INCLUDE_INTRO_COMMENTS ? [
|
||||
'// `inputFields` defines the fields a user could provide',
|
||||
'// Zapier will pass them in as `bundle.inputData` later. They\'re optional on triggers, but required on searches and creates.'
|
||||
].join('\n ') : '' %>
|
||||
inputFields: [],
|
||||
},
|
||||
},
|
||||
|
||||
search: {
|
||||
display: {
|
||||
label: 'Find <%= NOUN %>',
|
||||
description: 'Finds a <%= LOWER_NOUN %> give.',
|
||||
},
|
||||
operation: {
|
||||
inputFields: searchInputFields,
|
||||
perform: performSearch,
|
||||
},
|
||||
},
|
||||
|
||||
create: {
|
||||
display: {
|
||||
label: 'Create <%= NOUN %>',
|
||||
description: 'Creates a new <%= LOWER_NOUN %>.',
|
||||
},
|
||||
operation: {
|
||||
inputFields: createInputFields,
|
||||
perform: performCreate,
|
||||
},
|
||||
},
|
||||
|
||||
<%= INCLUDE_INTRO_COMMENTS ? [
|
||||
'// In cases where Zapier needs to show an example record to the user, but we are unable to get a live example',
|
||||
'// from the API, Zapier will fallback to this hard-coded sample. It should reflect the data structure of',
|
||||
'// returned records, and have obvious placeholder values that we can show to any user.',
|
||||
'// In this resource, the sample is reused across all methods'
|
||||
].join('\n ') : '' %>
|
||||
sample: {
|
||||
id: 1,
|
||||
name: 'Test',
|
||||
},
|
||||
|
||||
<%= INCLUDE_INTRO_COMMENTS ? [
|
||||
'// If fields are custom to each user (like spreadsheet columns), `outputFields` can create human labels',
|
||||
'// For a more complete example of using dynamic fields see',
|
||||
'// https://github.com/zapier/zapier-platform/tree/main/packages/cli#customdynamic-fields',
|
||||
'// Alternatively, a static field definition can be provided, to specify labels for the fields',
|
||||
'// In this resource, these output fields are reused across all resources'
|
||||
].join('\n ') : '' %>
|
||||
outputFields: [
|
||||
{ key: 'id', label: 'ID' },
|
||||
{ key: 'name', label: 'Name' },
|
||||
],
|
||||
} satisfies Resource;
|
||||
57
vendor/zapier-platform/packages/cli/scaffold/search.template.js
vendored
Normal file
57
vendor/zapier-platform/packages/cli/scaffold/search.template.js
vendored
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
// find a particular <%= LOWER_NOUN %> by name
|
||||
const perform = async (z, bundle) => {
|
||||
const response = await z.request({
|
||||
url: 'https://jsonplaceholder.typicode.com/posts',
|
||||
params: {
|
||||
name: bundle.inputData.name
|
||||
}
|
||||
});
|
||||
// this should return an array of objects (but only the first will be used)
|
||||
return response.data
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
// see here for a full list of available properties:
|
||||
// https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#searchschema
|
||||
key: '<%= KEY %>',
|
||||
noun: '<%= NOUN %>',
|
||||
|
||||
display: {
|
||||
label: 'Find <%= NOUN %>',
|
||||
description: 'Finds a <%= LOWER_NOUN %> based on name.'
|
||||
},
|
||||
|
||||
operation: {
|
||||
perform,
|
||||
|
||||
<%= INCLUDE_INTRO_COMMENTS ? [
|
||||
'// `inputFields` defines the fields a user could provide',
|
||||
'// Zapier will pass them in as `bundle.inputData` later. Searches need at least one `inputField`.'
|
||||
].join('\n ') : '' %>
|
||||
inputFields: [
|
||||
{key: 'name', required: true, helpText: 'Find the <%= NOUN %> with this name.'}
|
||||
],
|
||||
|
||||
<%= INCLUDE_INTRO_COMMENTS ? [
|
||||
'// In cases where Zapier needs to show an example record to the user, but we are unable to get a live example',
|
||||
'// from the API, Zapier will fallback to this hard-coded sample. It should reflect the data structure of',
|
||||
'// returned records, and have obvious placeholder values that we can show to any user.'
|
||||
].join('\n ') : '' %>
|
||||
sample: {
|
||||
id: 1,
|
||||
name: 'Test'
|
||||
},
|
||||
|
||||
<%= INCLUDE_INTRO_COMMENTS ? [
|
||||
'// If fields are custom to each user (like spreadsheet columns), `outputFields` can create human labels',
|
||||
'// For a more complete example of using dynamic fields see',
|
||||
'// https://github.com/zapier/zapier-platform/tree/main/packages/cli#customdynamic-fields',
|
||||
'// Alternatively, a static field definition can be provided, to specify labels for the fields'
|
||||
].join('\n ') : '' %>
|
||||
outputFields: [
|
||||
// these are placeholders to match the example `perform` above
|
||||
// {key: 'id', label: 'Person ID'},
|
||||
// {key: 'name', label: 'Person Name'}
|
||||
]
|
||||
}
|
||||
};
|
||||
70
vendor/zapier-platform/packages/cli/scaffold/search.template.ts
vendored
Normal file
70
vendor/zapier-platform/packages/cli/scaffold/search.template.ts
vendored
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
import {
|
||||
defineInputFields,
|
||||
defineSearch,
|
||||
type SearchPerform,
|
||||
type InferInputData,
|
||||
} from 'zapier-platform-core';
|
||||
|
||||
const inputFields = defineInputFields([
|
||||
{
|
||||
key: 'name',
|
||||
required: true,
|
||||
helpText: 'Find the <%= NOUN %> with this name.',
|
||||
},
|
||||
]);
|
||||
|
||||
// find a particular <%= LOWER_NOUN %> by name
|
||||
const perform = (async (z, bundle) => {
|
||||
const response = await z.request({
|
||||
url: 'https://jsonplaceholder.typicode.com/posts',
|
||||
params: {
|
||||
name: bundle.inputData.name,
|
||||
},
|
||||
});
|
||||
// this should return an array of objects (but only the first will be used)
|
||||
return response.data;
|
||||
}) satisfies SearchPerform<InferInputData<typeof inputFields>>;
|
||||
|
||||
export default defineSearch({
|
||||
// see here for a full list of available properties:
|
||||
// https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#searchschema
|
||||
key: '<%= KEY %>',
|
||||
noun: '<%= NOUN %>',
|
||||
|
||||
display: {
|
||||
label: 'Find <%= NOUN %>',
|
||||
description: 'Finds a <%= LOWER_NOUN %> based on name.',
|
||||
},
|
||||
|
||||
operation: {
|
||||
perform,
|
||||
|
||||
<%= INCLUDE_INTRO_COMMENTS ? [
|
||||
'// `inputFields` defines the fields a user could provide',
|
||||
'// Zapier will pass them in as `bundle.inputData` later. Searches need at least one `inputField`.'
|
||||
].join('\n ') : '' %>
|
||||
inputFields,
|
||||
|
||||
<%= INCLUDE_INTRO_COMMENTS ? [
|
||||
'// In cases where Zapier needs to show an example record to the user, but we are unable to get a live example',
|
||||
'// from the API, Zapier will fallback to this hard-coded sample. It should reflect the data structure of',
|
||||
'// returned records, and have obvious placeholder values that we can show to any user.'
|
||||
].join('\n ') : '' %>
|
||||
sample: {
|
||||
id: 1,
|
||||
name: 'Test',
|
||||
},
|
||||
|
||||
<%= INCLUDE_INTRO_COMMENTS ? [
|
||||
'// If fields are custom to each user (like spreadsheet columns), `outputFields` can create human labels',
|
||||
'// For a more complete example of using dynamic fields see',
|
||||
'// https://github.com/zapier/zapier-platform/tree/main/packages/cli#customdynamic-fields',
|
||||
'// Alternatively, a static field definition can be provided, to specify labels for the fields'
|
||||
].join('\n ') : '' %>
|
||||
outputFields: [
|
||||
// these are placeholders to match the example `perform` above
|
||||
// {key: 'id', label: 'Person ID'},
|
||||
// {key: 'name', label: 'Person Name'}
|
||||
],
|
||||
},
|
||||
});
|
||||
17
vendor/zapier-platform/packages/cli/scaffold/test.template.js
vendored
Normal file
17
vendor/zapier-platform/packages/cli/scaffold/test.template.js
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
const zapier = require('zapier-platform-core');
|
||||
|
||||
// Use this to make test calls into your app:
|
||||
const App = require('../../index');
|
||||
const appTester = zapier.createAppTester(App);
|
||||
// read the `.env` file into the environment, if available
|
||||
zapier.tools.env.inject();
|
||||
|
||||
describe('<%= ACTION_PLURAL %>.<%= KEY %>', () => {
|
||||
it('should run', async () => {
|
||||
const bundle = { inputData: {} };
|
||||
|
||||
const results = await appTester(App.<%= ACTION_PLURAL %>['<%= KEY %>'].<%= MAYBE_RESOURCE %>operation.perform, bundle);
|
||||
expect(results).toBeDefined();
|
||||
// TODO: add more assertions
|
||||
});
|
||||
});
|
||||
18
vendor/zapier-platform/packages/cli/scaffold/test.template.ts
vendored
Normal file
18
vendor/zapier-platform/packages/cli/scaffold/test.template.ts
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { describe, expect, it } from 'vitest';
|
||||
import zapier from 'zapier-platform-core';
|
||||
|
||||
import App from '../../index';
|
||||
|
||||
const appTester = zapier.createAppTester(App);
|
||||
// read the `.env` file into the environment, if available
|
||||
zapier.tools.env.inject();
|
||||
|
||||
describe('<%= ACTION_PLURAL %>.<%= KEY %>', () => {
|
||||
it('should run', async () => {
|
||||
const bundle = { inputData: {} };
|
||||
|
||||
const results = await appTester(App.<%= ACTION_PLURAL %>['<%= KEY %>'].<%= MAYBE_RESOURCE %>operation.perform, bundle);
|
||||
expect(results).toBeDefined();
|
||||
// TODO: add more assertions
|
||||
});
|
||||
});
|
||||
55
vendor/zapier-platform/packages/cli/scaffold/trigger.template.js
vendored
Normal file
55
vendor/zapier-platform/packages/cli/scaffold/trigger.template.js
vendored
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
// triggers on a new <%= LOWER_NOUN %> with a certain tag
|
||||
const perform = async (z, bundle) => {
|
||||
const response = await z.request({
|
||||
url: 'https://jsonplaceholder.typicode.com/posts',
|
||||
params: {
|
||||
tag: bundle.inputData.tagName
|
||||
}
|
||||
});
|
||||
// this should return an array of objects
|
||||
return response.data;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
// see here for a full list of available properties:
|
||||
// https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#triggerschema
|
||||
key: '<%= KEY %>',
|
||||
noun: '<%= NOUN %>',
|
||||
|
||||
display: {
|
||||
label: 'New <%= NOUN %>',
|
||||
description: 'Triggers when a new <%= LOWER_NOUN %> is created.'
|
||||
},
|
||||
|
||||
operation: {
|
||||
perform,
|
||||
|
||||
<%= INCLUDE_INTRO_COMMENTS ? [
|
||||
'// `inputFields` defines the fields a user could provide',
|
||||
'// Zapier will pass them in as `bundle.inputData` later. They\'re optional.'
|
||||
].join('\n ') : '' %>
|
||||
inputFields: [],
|
||||
|
||||
<%= INCLUDE_INTRO_COMMENTS ? [
|
||||
'// In cases where Zapier needs to show an example record to the user, but we are unable to get a live example',
|
||||
'// from the API, Zapier will fallback to this hard-coded sample. It should reflect the data structure of',
|
||||
'// returned records, and have obvious placeholder values that we can show to any user.'
|
||||
].join('\n ') : '' %>
|
||||
sample: {
|
||||
id: 1,
|
||||
name: 'Test'
|
||||
},
|
||||
|
||||
<%= INCLUDE_INTRO_COMMENTS ? [
|
||||
'// If fields are custom to each user (like spreadsheet columns), `outputFields` can create human labels',
|
||||
'// For a more complete example of using dynamic fields see',
|
||||
'// https://github.com/zapier/zapier-platform/tree/main/packages/cli#customdynamic-fields',
|
||||
'// Alternatively, a static field definition can be provided, to specify labels for the fields'
|
||||
].join('\n ') : '' %>
|
||||
outputFields: [
|
||||
// these are placeholders to match the example `perform` above
|
||||
// {key: 'id', label: 'Person ID'},
|
||||
// {key: 'name', label: 'Person Name'}
|
||||
]
|
||||
}
|
||||
};
|
||||
61
vendor/zapier-platform/packages/cli/scaffold/trigger.template.ts
vendored
Normal file
61
vendor/zapier-platform/packages/cli/scaffold/trigger.template.ts
vendored
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
import {
|
||||
defineTrigger,
|
||||
type PollingTriggerPerform,
|
||||
} from 'zapier-platform-core';
|
||||
|
||||
// triggers on a new <%= LOWER_NOUN %> with a certain tag
|
||||
const perform = (async (z, bundle) => {
|
||||
const response = await z.request({
|
||||
url: 'https://jsonplaceholder.typicode.com/posts',
|
||||
params: {
|
||||
tag: bundle.inputData.tagName,
|
||||
},
|
||||
});
|
||||
// this should return an array of objects
|
||||
return response.data;
|
||||
}) satisfies PollingTriggerPerform;
|
||||
|
||||
export default defineTrigger({
|
||||
// see here for a full list of available properties:
|
||||
// https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#triggerschema
|
||||
key: '<%= KEY %>' as const,
|
||||
noun: '<%= NOUN %>',
|
||||
|
||||
display: {
|
||||
label: 'New <%= NOUN %>',
|
||||
description: 'Triggers when a new <%= LOWER_NOUN %> is created.',
|
||||
},
|
||||
|
||||
operation: {
|
||||
type: 'polling',
|
||||
perform,
|
||||
|
||||
<%= INCLUDE_INTRO_COMMENTS ? [
|
||||
'// `inputFields` defines the fields a user could provide',
|
||||
'// Zapier will pass them in as `bundle.inputData` later. They\'re optional.'
|
||||
].join('\n ') : '' %>
|
||||
inputFields: [],
|
||||
|
||||
<%= INCLUDE_INTRO_COMMENTS ? [
|
||||
'// In cases where Zapier needs to show an example record to the user, but we are unable to get a live example',
|
||||
'// from the API, Zapier will fallback to this hard-coded sample. It should reflect the data structure of',
|
||||
'// returned records, and have obvious placeholder values that we can show to any user.'
|
||||
].join('\n ') : '' %>
|
||||
sample: {
|
||||
id: 1,
|
||||
name: 'Test',
|
||||
},
|
||||
|
||||
<%= INCLUDE_INTRO_COMMENTS ? [
|
||||
'// If fields are custom to each user (like spreadsheet columns), `outputFields` can create human labels',
|
||||
'// For a more complete example of using dynamic fields see',
|
||||
'// https://github.com/zapier/zapier-platform/tree/main/packages/cli#customdynamic-fields',
|
||||
'// Alternatively, a static field definition can be provided, to specify labels for the fields'
|
||||
].join('\n ') : '' %>
|
||||
outputFields: [
|
||||
// these are placeholders to match the example `perform` above
|
||||
// {key: 'id', label: 'Person ID'},
|
||||
// {key: 'name', label: 'Person Name'}
|
||||
],
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue