Initial import of verae-zapier-app from zapier monorepo

This commit is contained in:
George Lambert 2026-09-11 12:58:34 -04:00
commit 4a4d64e7cb
16 changed files with 618 additions and 0 deletions

95
test/app.test.js Normal file
View file

@ -0,0 +1,95 @@
/**
* GATE 11 Zapier package shape tests (no live Zapier CLI required)
*/
const { describe, it } = require('node:test');
const assert = require('node:assert/strict');
const App = require('../index');
const authentication = require('../authentication');
const timestampAndWait = require('../creates/timestamp_and_wait');
const createTimestamp = require('../creates/create_timestamp');
const verifyTimestamp = require('../creates/verify_timestamp');
const batchTimestamp = require('../creates/batch_timestamp');
const jobStatus = require('../searches/job_status');
const timestampCompleted = require('../triggers/timestamp_completed');
describe('verae-zapier app definition', () => {
it('exports authentication with api_key field', () => {
assert.equal(authentication.type, 'custom');
assert.ok(authentication.fields.some((f) => f.key === 'api_key'));
});
it('wires creates, searches, triggers', () => {
assert.ok(App.creates.add_numbers);
assert.ok(App.creates.timestamp_and_wait);
assert.ok(App.creates.create_timestamp);
assert.ok(App.creates.verify_timestamp);
assert.ok(App.creates.batch_timestamp);
assert.ok(App.searches.job_status);
assert.ok(App.searches.hash_lookup);
assert.ok(App.searches.tree_lookup);
assert.ok(App.triggers.timestamp_completed);
});
it('create actions target middleware paths', () => {
process.env.MIDDLEWARE_BASE_URL = 'https://mw.example.com';
const urls = [];
const z = {
request: async (opts) => {
urls.push(opts.url);
return { data: { ok: true } };
},
};
const bundle = {
authData: { api_key: 'zmw_test' },
inputData: { data: 'x', certificate: 'c', items: 'a\nb', jobId: 'j1' },
};
return Promise.all([
timestampAndWait.operation.perform(z, bundle),
createTimestamp.operation.perform(z, bundle),
verifyTimestamp.operation.perform(z, bundle),
batchTimestamp.operation.perform(z, bundle),
jobStatus.operation.perform(z, bundle),
]).then(() => {
assert.ok(urls.some((u) => u.endsWith('/zapier/v1/timestamp/wait')));
assert.ok(urls.some((u) => u.endsWith('/zapier/v1/timestamp')));
assert.ok(urls.some((u) => u.endsWith('/zapier/v1/verify')));
assert.ok(urls.some((u) => u.endsWith('/zapier/v1/timestamp/batch')));
assert.ok(urls.some((u) => u.includes('/zapier/v1/status/')));
});
});
it('trigger subscribe/unsubscribe shapes', async () => {
process.env.MIDDLEWARE_BASE_URL = 'https://mw.example.com';
const calls = [];
const z = {
request: async (opts) => {
calls.push(opts);
return { data: { id: 'hook-1' } };
},
};
const id = await timestampCompleted.operation.performSubscribe(z, {
targetUrl: 'https://hooks.zapier.com/x',
authData: { api_key: 'k' },
});
assert.equal(id, 'hook-1');
assert.equal(calls[0].method, 'POST');
assert.match(calls[0].url, /webhooks\/subscribe$/);
assert.equal(calls[0].body.event, 'timestamp.completed');
await timestampCompleted.operation.performUnsubscribe(z, {
subscribeData: 'hook-1',
authData: { api_key: 'k' },
});
assert.equal(calls[1].method, 'DELETE');
assert.match(calls[1].url, /webhooks\/unsubscribe$/);
});
it('beforeRequest adds Authorization bearer', () => {
const req = App.beforeRequest[0]({}, null, { authData: { api_key: 'zmw_abc' } });
assert.equal(req.headers.Authorization, 'Bearer zmw_abc');
});
});