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,13 @@
{
"presets": [
[
"env",
{
"targets": {
"node": 6
}
}
]
],
"plugins": ["transform-regenerator", "add-module-exports"]
}

View file

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

View file

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

View file

@ -0,0 +1,16 @@
# "Babel" Example App For Zapier Platform
[![Build Status](https://travis-ci.org/zapier/zapier-platform-example-app-babel.svg?branch=main)](https://travis-ci.org/zapier/zapier-platform-example-app-babel)
A barebones app that has a resource defined. This is mainly a proof-of-concept for using features not yet available in node v12.x.
Run this:
```bash
npm run zapier-dev # compiles live
zapier-platform test
```
`zapier-platform build` works as a non-watch command that calls the `npm run _zapier-build` hook, and `zapier-platform push` will make a fresh build using that hook as well.
> 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,3 @@
global._babelPolyfill || require('babel-polyfill');
module.exports = require('./lib');

View file

@ -0,0 +1,37 @@
{
"name": "zapier-platform-example-app-babel",
"version": "1.0.0",
"description": "An example app for the Zapier platform.",
"repository": "zapier/zapier-platform-example-app-babel",
"homepage": "https://zapier.com/",
"author": "Bryan Helmig <bryan@zapier.com>",
"license": "BSD-3-Clause",
"main": "index.js",
"scripts": {
"zapier-build": "rm -rf lib && babel src --out-dir lib",
"zapier-dev": "rm -rf lib && babel src --out-dir lib --watch",
"prepare": "npm run zapier-build",
"pretest": "npm run zapier-build",
"test": "mocha --recursive lib/test --require babel-polyfill",
"_zapier-build": "npm run zapier-build"
},
"engines": {
"node": ">=8.10.0",
"npm": ">=5.6.0"
},
"dependencies": {
"babel-polyfill": "6.26.0",
"zapier-platform-core": "19.1.0"
},
"devDependencies": {
"babel-cli": "6.26.0",
"babel-core": "6.26.0",
"babel-eslint": "8.2.3",
"babel-plugin-add-module-exports": "0.2.1",
"babel-plugin-transform-regenerator": "6.26.0",
"babel-preset-env": "1.6.1",
"mocha": "^5.2.0",
"should": "^13.2.1"
},
"private": true
}

View file

@ -0,0 +1,21 @@
const test = async (z /*, bundle */) => {
// Normally you want to make a request to an endpoint that is either specifically designed to test auth, or one that
// every user will have access to, such as an account or profile endpoint like /me.
// In this example, we'll hit httpbin, which validates the Authorization Header against the arguments passed in the URL path
const response = await z.request({
url: 'https://auth-json-server.zapier-staging.com/me',
});
return response;
};
const Authentication = {
type: 'basic',
// The test method allows Zapier to verify that the credentials a user provides are valid. We'll execute this
// method whenever a user connects their account for the first time.
test,
// assuming "username" is a key returned from the test
connectionLabel: '{{username}}',
};
export default Authentication;

View file

@ -0,0 +1,27 @@
import Authentication from './authentication';
import Recipe from './resources/recipe';
import { version } from '../package.json';
import { version as platformVersion } from 'zapier-platform-core';
const App = {
version,
platformVersion,
authentication: Authentication,
beforeRequest: [],
afterResponse: [],
resources: {
[Recipe.key]: Recipe,
},
triggers: {},
searches: {},
creates: {},
};
export default App;

View file

@ -0,0 +1,168 @@
const _sharedBaseUrl = 'https://auth-json-server.zapier-staging.com';
const getRecipe = async (z, bundle) => {
const response = await z.request({
url: `${_sharedBaseUrl}/recipes/${bundle.inputData.id}`,
});
return response.data;
};
const listRecipes = async (z, bundle) => {
const response = await z.request({
url: _sharedBaseUrl + '/recipes',
params: {
style: bundle.inputData.style,
},
});
return response.data;
};
const createRecipe = async (z, bundle) => {
const response = await z.request({
url: _sharedBaseUrl + '/recipes',
method: 'POST',
body: {
name: bundle.inputData.name,
directions: bundle.inputData.directions,
authorId: bundle.inputData.authorId,
},
headers: {
'content-type': 'application/json',
},
});
return response.data;
};
const searchRecipe = async (z, bundle) => {
const response = await z.request({
url: _sharedBaseUrl + '/recipes',
params: {
nameSearch: bundle.inputData.name,
},
});
const matchingRecipes = response.data;
// Only return the first matching recipe
if (matchingRecipes && matchingRecipes.length) {
return matchingRecipes[0];
}
return [];
};
const sample = {
id: 1,
createdAt: 1472069465,
name: 'Best Spagetti Ever',
authorId: 1,
directions: '1. Boil Noodles\n2.Serve with sauce',
style: 'italian',
};
// This file exports a Recipe resource. The definition below contains all of the keys available,
// and implements the list and create methods.
const Recipe = {
key: 'recipe',
noun: 'Recipe',
// The get method is used by Zapier to fetch a complete representation of a record. This is helpful when the HTTP
// response from a create call only return an ID, or a search that only returns a minimuml representation of the
// record. Zapier will follow these up with the get() to retrieve the entire object.
get: {
display: {
label: 'Get Recipe',
description: 'Gets a recipe.',
},
operation: {
inputFields: [{ key: 'id', required: true }],
perform: getRecipe,
sample,
},
},
// The list method on this resource becomes a Trigger on the app. Zapier will use polling to watch for new records
list: {
display: {
label: 'New Recipe',
description: 'Trigger when a new recipe is added.',
},
operation: {
inputFields: [
{
key: 'style',
type: 'string',
helpText: 'Explain what style of cuisine this is.',
},
],
perform: listRecipes,
sample,
},
},
// If your app supports webhooks, you can define a hook method instead of a list method.
// Zapier will turn this into a webhook Trigger on the app.
// hook: {
//
// },
create: {
display: {
label: 'Create Recipe',
description: 'Creates a new recipe.',
},
operation: {
inputFields: [
{ key: 'name', required: true, type: 'string' },
{
key: 'directions',
required: true,
type: 'text',
helpText: 'Explain how should one make the recipe, step by step.',
},
{
key: 'authorId',
required: true,
type: 'integer',
label: 'Author ID',
},
{
key: 'style',
required: false,
type: 'string',
helpText: 'Explain what style of cuisine this is.',
},
],
perform: createRecipe,
sample,
},
},
search: {
display: {
label: 'Find Recipe',
description: 'Finds an existing recipe by name.',
},
operation: {
inputFields: [{ key: 'name', required: true, type: 'string' }],
perform: searchRecipe,
sample,
},
},
// 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,
// 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' },
],
};
export default Recipe;

View file

@ -0,0 +1,33 @@
/* globals describe, it */
import should from 'should';
import zapier from 'zapier-platform-core';
import App from '../index';
const appTester = zapier.createAppTester(App);
describe('My Test', () => {
it('should test the auth succeeds', async () => {
const bundle = {
authData: {
username: 'user',
password: 'secret',
},
};
const response = await appTester(App.authentication.test, bundle);
should(response.status).eql(200);
response.request.headers.Authorization.should.eql('Basic dXNlcjpzZWNyZXQ=');
});
it('should test the auth fails', () => {
const bundle = {
authData: {
username: 'user',
password: 'boom',
},
};
return appTester(App.authentication.test, bundle).should.be.rejected();
});
});