-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add example esm app, copy dir to fix broken import
- Loading branch information
Showing
8 changed files
with
170 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/ | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Typescript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# environment variables file | ||
.env | ||
.environment | ||
|
||
# next.js build output | ||
.next |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import fs from 'fs'; | ||
import zapier from 'zapier-platform-core'; | ||
|
||
import recipeTrigger from './triggers/recipe.js'; | ||
|
||
const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8')); | ||
|
||
export default { | ||
// This is just shorthand to reference the installed dependencies you have. | ||
// Zapier will need to know these before we can upload. | ||
version: packageJson.version, | ||
platformVersion: zapier.version, | ||
|
||
triggers: { | ||
[recipeTrigger.key]: recipeTrigger, | ||
}, | ||
creates: {}, | ||
searches: {}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "esmodule-app", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "jest --testTimeout 10000" | ||
}, | ||
"dependencies": { | ||
"openapi-fetch": "^0.10.5", | ||
"zapier-platform-core": "16.1.0" | ||
}, | ||
"devDependencies": { | ||
"jest": "^29.7.0" | ||
}, | ||
"type": "module" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* globals describe, it, expect */ | ||
|
||
describe('addition ', () => { | ||
it('should work', () => { | ||
expect(1 + 1).toEqual(2); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* globals describe, expect, test */ | ||
|
||
import zapier from 'zapier-platform-core'; | ||
|
||
import App from '../../index.js'; | ||
|
||
const appTester = zapier.createAppTester(App); | ||
zapier.tools.env.inject(); | ||
|
||
describe('trigger recipe', () => { | ||
test('basic case', async () => { | ||
const bundle = {}; | ||
const results = await appTester( | ||
App.triggers.recipe.operation.perform, | ||
bundle, | ||
); | ||
|
||
expect(results.length).toBe(2); | ||
|
||
expect(results[0].id).toBe(1); | ||
expect(results[0].url).toBe('https://httpbin.zapier-tooling.com/get'); | ||
|
||
expect(results[1].id).toBe(2); | ||
expect(results[1].slideshow.author).toBe('Yours Truly'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import createClient from 'openapi-fetch'; | ||
|
||
const client = createClient({ baseUrl: 'https://httpbin.zapier-tooling.com' }); | ||
|
||
const perform = async (z, bundle) => { | ||
const response1 = await z.request('https://httpbin.zapier-tooling.com/get'); | ||
const data1 = await response1.json(); | ||
data1.id = 1; // just to pass the check | ||
|
||
const response2 = await client.GET('/json'); | ||
const data2 = response2.data; | ||
data2.id = 2; | ||
|
||
return [data1, data2]; | ||
}; | ||
|
||
export default { | ||
key: 'recipe', | ||
noun: 'Recipe', | ||
display: { | ||
label: 'New Recipe', | ||
description: 'Triggers when a new recipe is created.', | ||
}, | ||
operation: { | ||
perform, | ||
inputFields: [], | ||
sample: { | ||
id: 1, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters