master-zapier-plan-draft/research/zapier/scratch/veraetime/src/triggers/timestamp_completed.ts
George Lambert b4150c8250 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.
2026-09-09 02:37:36 -04:00

65 lines
1.7 KiB
TypeScript

import type { Bundle, ZObject } from 'zapier-platform-core';
import { zapierV1 } from '../lib/base.js';
const subscribe = async (z: ZObject, bundle: Bundle) => {
const response = await z.request({
url: zapierV1(bundle, '/webhooks/subscribe'),
method: 'POST',
headers: { 'content-type': 'application/json', accept: 'application/json' },
json: {
targetUrl: bundle.targetUrl,
event: 'timestamp.completed',
},
});
return response.data;
};
const unsubscribe = async (z: ZObject, bundle: Bundle) => {
const hookId = bundle.subscribeData?.id;
const response = await z.request({
url: zapierV1(bundle, '/webhooks/unsubscribe'),
method: 'DELETE',
headers: { 'content-type': 'application/json', accept: 'application/json' },
json: { hookId },
});
return response.data;
};
const perform = async (_z: ZObject, bundle: Bundle) => {
const payload = bundle.cleanedRequest;
if (!payload) return [];
return Array.isArray(payload) ? payload : [payload];
};
const performList = async () => [
{
id: 'sample-job',
event: 'timestamp.completed',
jobId: '550e8400-e29b-41d4-a716-446655440000',
status: 'completed',
result: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
},
];
export default {
key: 'timestamp_completed',
noun: 'Timestamp',
display: {
label: 'Timestamp Completed',
description: 'Triggers when the middleware finishes a timestamp job (REST Hook).',
},
operation: {
type: 'hook' as const,
performSubscribe: subscribe,
performUnsubscribe: unsubscribe,
perform,
performList,
sample: {
id: 'sample-job',
event: 'timestamp.completed',
jobId: '550e8400-e29b-41d4-a716-446655440000',
status: 'completed',
},
},
};