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:
George Lambert 2026-09-09 02:37:36 -04:00
commit b4150c8250
1364 changed files with 6814366 additions and 0 deletions

View file

@ -0,0 +1,6 @@
build
docs
node_modules
*.log
.environment
.env

View file

@ -0,0 +1,7 @@
language: node_js
node_js:
- 8.10.0
before_script: 'npm install -g zapier-platform-cli'
script: 'zapier test'
notifications:
email: false

View file

@ -0,0 +1,7 @@
# "REST Hooks" Trigger Example App For Zapier Platform
[![Build Status](https://travis-ci.org/zapier/zapier-platform-example-app-rest-hooks.svg?branch=master)](https://travis-ci.org/zapier/zapier-platform-example-app-rest-hooks)
A barebones app that has a [REST Hook](https://resthooks.org) trigger defined.
> We recommend using the zapier-platform-cli and `zapier-platform init .`  to create an app - youll be presented with a list of currently available templates to start with.

View file

@ -0,0 +1,29 @@
const recipe = require('./triggers/recipe');
// Now we can roll up all our behaviors in an App.
const App = {
// This is just shorthand to reference the installed dependencies you have. Zapier will
// need to know these before we can upload
version: require('./package.json').version,
platformVersion: require('zapier-platform-core').version,
beforeRequest: [],
afterResponse: [],
resources: {},
// If you want your trigger to show up, you better include it here!
triggers: {
[recipe.key]: recipe,
},
// If you want your searches to show up, you better include it here!
searches: {},
// If you want your creates to show up, you better include it here!
creates: {},
};
// Finally, export the app.
module.exports = App;

View file

@ -0,0 +1,25 @@
{
"name": "zapier-platform-example-app-rest-hooks",
"version": "1.0.0",
"description": "An example app for the Zapier platform.",
"repository": "zapier/zapier-platform-example-app-rest-hooks",
"homepage": "https://zapier.com/",
"author": "Bryan Helmig <bryan@zapier.com>",
"license": "BSD-3-Clause",
"main": "index.js",
"scripts": {
"test": "mocha --recursive"
},
"engines": {
"node": ">=8.10.0",
"npm": ">=5.6.0"
},
"dependencies": {
"zapier-platform-core": "19.1.0"
},
"devDependencies": {
"mocha": "^5.2.0",
"should": "^13.2.0"
},
"private": true
}

View file

@ -0,0 +1,60 @@
/* globals describe, it */
require('should');
const zapier = require('zapier-platform-core');
const App = require('../index');
const appTester = zapier.createAppTester(App);
describe('triggers', () => {
describe('new recipe trigger', () => {
it('should load recipe from fake hook', (done) => {
const bundle = {
inputData: {
style: 'mediterranean',
},
cleanedRequest: {
id: 1,
name: 'name 1',
directions: 'directions 1',
},
};
appTester(App.triggers.recipe.operation.perform, bundle)
.then((results) => {
results.length.should.eql(1);
const firstRecipe = results[0];
firstRecipe.name.should.eql('name 1');
firstRecipe.directions.should.eql('directions 1');
done();
})
.catch(done);
});
it('should load recipe from list', (done) => {
const bundle = {
inputData: {
style: 'mediterranean',
},
meta: {
frontend: true,
},
};
appTester(App.triggers.recipe.operation.performList, bundle)
.then((results) => {
results.length.should.be.greaterThan(1);
const firstRecipe = results[0];
firstRecipe.name.should.eql('name 1');
firstRecipe.directions.should.eql('directions 1');
done();
})
.catch(done);
});
});
});

View file

@ -0,0 +1,128 @@
const subscribeHook = (z, bundle) => {
// `z.console.log()` is similar to `console.log()`.
z.console.log('console says hello world!');
// bundle.targetUrl has the Hook URL this app should call when a recipe is created.
// https://platform.zapier.com/build/bundle#targeturl
const data = {
url: bundle.targetUrl,
style: bundle.inputData.style,
};
// You can build requests and our client will helpfully inject all the variables
// you need to complete. You can also register middleware to control this.
const options = {
url: 'https://57b20fb546b57d1100a3c405.mockapi.io/api/hooks',
method: 'POST',
body: data,
};
// You may return a promise or a normal data structure from any perform method.
// If your webhook subscriptions expire, make sure the subscribe endpoint returns an `expiration_date` property containing an ISO8601 date.
// The platform will automatically attempt to resubscribe after the expiration date. More details here: https://platform.zapier.com/build/cli-hook-trigger#prerequisites
return z.request(options).then((response) => response.data);
};
const unsubscribeHook = (z, bundle) => {
// bundle.subscribeData contains the parsed response JSON from the subscribe request.
const hookId = bundle.subscribeData.id;
// You can build requests and our client will helpfully inject all the variables
// you need to complete. You can also register middleware to control this.
const options = {
url: `https://57b20fb546b57d1100a3c405.mockapi.io/api/hooks/${hookId}`,
method: 'DELETE',
};
// You may return a promise or a normal data structure from any perform method.
return z.request(options).then((response) => response.data);
};
const getRecipe = (z, bundle) => {
// bundle.cleanedRequest will include the parsed JSON object (if it's not a
// test poll) and also a .querystring property with the URL's query string.
const recipe = {
id: bundle.cleanedRequest.id,
name: bundle.cleanedRequest.name,
directions: bundle.cleanedRequest.directions,
style: bundle.cleanedRequest.style,
authorId: bundle.cleanedRequest.authorId,
createdAt: bundle.cleanedRequest.createdAt,
};
return [recipe];
};
const getFallbackRealRecipe = (z, bundle) => {
// For the test poll, you should get some real data, to aid the setup process.
const options = {
url: 'https://57b20fb546b57d1100a3c405.mockapi.io/api/recipes/',
params: {
style: bundle.inputData.style,
},
};
return z.request(options).then((response) => response.data);
};
// We recommend writing your triggers separate like this and rolling them
// into the App definition at the end.
module.exports = {
key: 'recipe',
// You'll want to provide some helpful display labels and descriptions
// for users. Zapier will put them into the UI.
noun: 'Recipe',
display: {
label: 'New Recipe',
description: 'Trigger when a new recipe is added.',
},
// `operation` is where the business logic goes.
operation: {
// `inputFields` can define the fields a user could provide,
// we'll pass them in as `bundle.inputData` later.
inputFields: [
{
key: 'style',
type: 'string',
helpText: 'Which styles of cuisine this should trigger on.',
},
],
type: 'hook',
performSubscribe: subscribeHook,
performUnsubscribe: unsubscribeHook,
perform: getRecipe,
performList: getFallbackRealRecipe,
// 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 obviously dummy values that we can show to any user.
sample: {
id: 1,
createdAt: 1472069465,
name: 'Best Spaghetti Ever',
authorId: 1,
directions: '1. Boil Noodles\n2.Serve with sauce',
style: 'italian',
},
// If the resource can have fields that are custom on a per-user basis, define a function to fetch the custom
// field definitions. The result will be used to augment the sample.
// outputFields: () => { return []; }
// Alternatively, a static field definition should be provided, to specify labels for the fields
outputFields: [
{ key: 'id', label: 'ID' },
{ key: 'createdAt', label: 'Created At' },
{ key: 'name', label: 'Name' },
{ key: 'directions', label: 'Directions' },
{ key: 'authorId', label: 'Author ID' },
{ key: 'style', label: 'Style' },
],
},
};