master-zapier-plan-draft/vendor/zapier-platform/example-apps/files/triggers/newFile.js
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

46 lines
1.3 KiB
JavaScript

const hydrators = require('../hydrators');
const perform = (z, bundle) => {
// In reality you're more likely to get file info from a remote server. Here
// we're hard coding some links just to demonstrate.
const fileURLs = [
'https://httpbin.zapier-tooling.com/image/png',
'https://httpbin.zapier-tooling.com/image/jpeg',
'https://httpbin.zapier-tooling.com/xml',
];
return fileURLs.map((fileURL) => {
const fileInfo = {
id: fileURL,
// Make it possible to get the actual file contents if necessary. No need
// to make the request to download files now when the trigger is run.
file: z.dehydrateFile(hydrators.downloadFile, { url: fileURL }),
};
return fileInfo;
});
};
// We recommend writing your triggers separate like this and rolling them into
// the App definition at the end.
module.exports = {
key: 'newFile',
// You'll want to provide some helpful display labels and descriptions
// for users. Zapier will put them into the UX.
noun: 'File',
display: {
label: 'New File',
description: 'Triggers when a new file is added.',
},
// `operation` is where the business logic goes.
operation: {
perform,
sample: {
id: 'https://example.com/file.txt',
file: 'content',
},
},
};