zapier-platform-cli 15.18.1 → 16.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/oclif.manifest.json +2316 -1
- package/package.json +43 -33
- package/scaffold/create.template.ts +64 -0
- package/scaffold/resource.template.ts +119 -0
- package/scaffold/search.template.ts +63 -0
- package/scaffold/test.template.ts +18 -0
- package/scaffold/trigger.template.ts +58 -0
- package/src/bin/run +4 -4
- package/src/bin/run.cmd +0 -3
- package/src/generators/index.js +11 -11
- package/src/index.js +1 -1
- package/src/oclif/ZapierBaseCommand.js +51 -44
- package/src/oclif/buildFlags.js +14 -16
- package/src/oclif/commands/analytics.js +6 -6
- package/src/oclif/commands/build.js +6 -6
- package/src/oclif/commands/cache/clear.js +13 -13
- package/src/oclif/commands/canary/create.js +27 -20
- package/src/oclif/commands/canary/delete.js +26 -16
- package/src/oclif/commands/canary/list.js +5 -7
- package/src/oclif/commands/convert.js +16 -16
- package/src/oclif/commands/delete/version.js +6 -6
- package/src/oclif/commands/deprecate.js +10 -11
- package/src/oclif/commands/describe.js +5 -5
- package/src/oclif/commands/env/get.js +5 -5
- package/src/oclif/commands/env/set.js +11 -12
- package/src/oclif/commands/env/unset.js +9 -10
- package/src/oclif/commands/init.js +12 -13
- package/src/oclif/commands/invoke.js +67 -69
- package/src/oclif/commands/jobs.js +1 -1
- package/src/oclif/commands/link.js +2 -2
- package/src/oclif/commands/login.js +15 -15
- package/src/oclif/commands/logout.js +1 -1
- package/src/oclif/commands/logs.js +9 -9
- package/src/oclif/commands/migrate.js +19 -22
- package/src/oclif/commands/promote.js +25 -27
- package/src/oclif/commands/push.js +2 -2
- package/src/oclif/commands/register.js +31 -32
- package/src/oclif/commands/scaffold.js +112 -106
- package/src/oclif/commands/team/add.js +12 -15
- package/src/oclif/commands/team/get.js +2 -2
- package/src/oclif/commands/team/remove.js +6 -6
- package/src/oclif/commands/test.js +8 -8
- package/src/oclif/commands/upload.js +1 -1
- package/src/oclif/commands/users/add.js +9 -11
- package/src/oclif/commands/users/get.js +7 -7
- package/src/oclif/commands/users/links.js +4 -4
- package/src/oclif/commands/users/remove.js +8 -9
- package/src/oclif/commands/validate.js +29 -21
- package/src/oclif/commands/versions.js +26 -1
- package/src/oclif/hooks/checkValidNodeVersion.js +1 -1
- package/src/oclif/hooks/deprecated.js +1 -1
- package/src/oclif/hooks/getAppRegistrationFieldChoices.js +4 -4
- package/src/oclif/hooks/renderMarkdownHelp.js +1 -2
- package/src/oclif/hooks/versionInfo.js +2 -2
- package/src/utils/analytics.js +4 -4
- package/src/utils/api.js +26 -29
- package/src/utils/ast.js +112 -11
- package/src/utils/auth-files-codegen.js +102 -99
- package/src/utils/build.js +27 -28
- package/src/utils/changelog.js +1 -1
- package/src/utils/check-missing-app-info.js +2 -2
- package/src/utils/convert.js +26 -20
- package/src/utils/credentials.js +1 -1
- package/src/utils/display.js +31 -8
- package/src/utils/files.js +3 -3
- package/src/utils/ignore.js +2 -2
- package/src/utils/local.js +1 -1
- package/src/utils/metadata.js +1 -1
- package/src/utils/misc.js +21 -22
- package/src/utils/promisify.js +1 -1
- package/src/utils/scaffold.js +293 -40
- package/src/utils/team.js +3 -3
- package/src/utils/xdg.js +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zapier-platform-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "16.0.0",
|
|
4
4
|
"description": "The CLI for managing integrations in Zapier Developer Platform.",
|
|
5
5
|
"repository": "zapier/zapier-platform",
|
|
6
6
|
"homepage": "https://platform.zapier.com/",
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"/oclif.manifest.json"
|
|
20
20
|
],
|
|
21
21
|
"engines": {
|
|
22
|
-
"node": ">=
|
|
22
|
+
"node": ">=18.18"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"docs": "ZAPIER_BASE_ENDPOINT='' node scripts/docs.js",
|
|
26
26
|
"preversion": "git pull && yarn validate",
|
|
27
|
-
"prepack": "oclif
|
|
27
|
+
"prepack": "oclif manifest",
|
|
28
28
|
"postpack": "rm -f oclif.manifest.json",
|
|
29
29
|
"precommit": "yarn docs && git add docs",
|
|
30
30
|
"version": "yarn docs && git add docs/*",
|
|
@@ -40,54 +40,56 @@
|
|
|
40
40
|
"validate": "yarn test && yarn smoke-test && yarn lint"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@oclif/
|
|
44
|
-
"@oclif/
|
|
45
|
-
"@oclif/plugin-
|
|
46
|
-
"@oclif/plugin-
|
|
47
|
-
"@oclif/plugin-
|
|
48
|
-
"adm-zip": "0.5.
|
|
49
|
-
"archiver": "
|
|
50
|
-
"browserify": "17.0.
|
|
43
|
+
"@oclif/core": "4.0.34",
|
|
44
|
+
"@oclif/plugin-autocomplete": "3.2.11",
|
|
45
|
+
"@oclif/plugin-help": "6.2.18",
|
|
46
|
+
"@oclif/plugin-not-found": "3.2.29",
|
|
47
|
+
"@oclif/plugin-version": "2.2.16",
|
|
48
|
+
"adm-zip": "0.5.16",
|
|
49
|
+
"archiver": "7.0.1",
|
|
50
|
+
"browserify": "17.0.1",
|
|
51
51
|
"chrono-node": "2.7.7",
|
|
52
|
-
"cli-table3": "0.6.
|
|
52
|
+
"cli-table3": "0.6.5",
|
|
53
53
|
"colors": "1.4.0",
|
|
54
|
-
"debug": "4.3.
|
|
55
|
-
"dotenv": "16.4.
|
|
56
|
-
"fs-extra": "11.
|
|
54
|
+
"debug": "4.3.7",
|
|
55
|
+
"dotenv": "16.4.6",
|
|
56
|
+
"fs-extra": "11.2.0",
|
|
57
57
|
"gulp-filter": "7.0.0",
|
|
58
58
|
"gulp-prettier": "4.0.0",
|
|
59
59
|
"ignore": "5.2.4",
|
|
60
60
|
"inquirer": "8.2.5",
|
|
61
|
-
"jscodeshift": "0.
|
|
61
|
+
"jscodeshift": "^17.0.0",
|
|
62
62
|
"klaw": "4.1.0",
|
|
63
63
|
"lodash": "4.17.21",
|
|
64
64
|
"luxon": "3.5.0",
|
|
65
|
-
"marked": "
|
|
66
|
-
"marked-terminal": "
|
|
65
|
+
"marked": "14.1.4",
|
|
66
|
+
"marked-terminal": "7.2.1",
|
|
67
67
|
"minimatch": "9.0.3",
|
|
68
|
-
"node-fetch": "2.
|
|
68
|
+
"node-fetch": "2.7.0",
|
|
69
69
|
"open": "10.1.0",
|
|
70
70
|
"ora": "5.4.0",
|
|
71
71
|
"parse-gitignore": "0.5.1",
|
|
72
|
-
"prettier": "
|
|
73
|
-
"read": "
|
|
74
|
-
"semver": "7.
|
|
72
|
+
"prettier": "3.4.1",
|
|
73
|
+
"read": "4.0.0",
|
|
74
|
+
"semver": "7.6.3",
|
|
75
75
|
"string-length": "4.0.2",
|
|
76
76
|
"through2": "4.0.2",
|
|
77
|
-
"tmp": "0.2.
|
|
78
|
-
"traverse": "0.6.
|
|
77
|
+
"tmp": "0.2.3",
|
|
78
|
+
"traverse": "0.6.10",
|
|
79
79
|
"update-notifier": "5.1.0",
|
|
80
|
-
"yeoman-environment": "3.3
|
|
80
|
+
"yeoman-environment": "3.19.3",
|
|
81
81
|
"yeoman-generator": "5.9.0"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@oclif/
|
|
85
|
-
"@
|
|
84
|
+
"@oclif/test": "^4.0.9",
|
|
85
|
+
"@types/jscodeshift": "^0.12.0",
|
|
86
|
+
"@types/mocha": "^10.0.9",
|
|
86
87
|
"chai": "^4.3.7",
|
|
87
88
|
"decompress": "4.2.1",
|
|
88
89
|
"mock-fs": "^5.2.0",
|
|
89
90
|
"nock": "^13.3.1",
|
|
90
|
-
"
|
|
91
|
+
"oclif": "^4.15.30",
|
|
92
|
+
"typescript": "^5.6.3",
|
|
91
93
|
"yamljs": "0.3.0"
|
|
92
94
|
},
|
|
93
95
|
"bin": {
|
|
@@ -95,20 +97,28 @@
|
|
|
95
97
|
},
|
|
96
98
|
"oclif": {
|
|
97
99
|
"commands": "src/oclif/commands",
|
|
100
|
+
"additionalHelpFlags": [
|
|
101
|
+
"-h"
|
|
102
|
+
],
|
|
103
|
+
"additionalVersionFlags": [
|
|
104
|
+
"-v"
|
|
105
|
+
],
|
|
98
106
|
"bin": "zapier",
|
|
107
|
+
"dirname": "zapier",
|
|
99
108
|
"plugins": [
|
|
109
|
+
"@oclif/plugin-autocomplete",
|
|
100
110
|
"@oclif/plugin-help",
|
|
101
111
|
"@oclif/plugin-not-found",
|
|
102
|
-
"@oclif/plugin-
|
|
112
|
+
"@oclif/plugin-version"
|
|
103
113
|
],
|
|
104
114
|
"hooks": {
|
|
105
115
|
"init": [
|
|
106
|
-
"./src/oclif/hooks/versionInfo",
|
|
107
|
-
"./src/oclif/hooks/deprecated",
|
|
108
|
-
"./src/oclif/hooks/updateNotifier",
|
|
109
116
|
"./src/oclif/hooks/checkValidNodeVersion",
|
|
117
|
+
"./src/oclif/hooks/deprecated",
|
|
118
|
+
"./src/oclif/hooks/getAppRegistrationFieldChoices",
|
|
110
119
|
"./src/oclif/hooks/renderMarkdownHelp",
|
|
111
|
-
"./src/oclif/hooks/
|
|
120
|
+
"./src/oclif/hooks/updateNotifier",
|
|
121
|
+
"./src/oclif/hooks/versionInfo"
|
|
112
122
|
]
|
|
113
123
|
},
|
|
114
124
|
"topics": {
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Create, PerformFunction } from 'zapier-platform-core';
|
|
2
|
+
|
|
3
|
+
// create a particular <%= LOWER_NOUN %> by name
|
|
4
|
+
const perform: PerformFunction = async (z, bundle) => {
|
|
5
|
+
const response = await z.request({
|
|
6
|
+
method: 'POST',
|
|
7
|
+
url: 'https://jsonplaceholder.typicode.com/posts',
|
|
8
|
+
// if `body` is an object, it'll automatically get run through JSON.stringify
|
|
9
|
+
// if you don't want to send JSON, pass a string in your chosen format here instead
|
|
10
|
+
body: {
|
|
11
|
+
name: bundle.inputData.name
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
// this should return a single object
|
|
15
|
+
return response.data;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
// see here for a full list of available properties:
|
|
20
|
+
// https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#createschema
|
|
21
|
+
key: '<%= KEY %>',
|
|
22
|
+
noun: '<%= NOUN %>',
|
|
23
|
+
|
|
24
|
+
display: {
|
|
25
|
+
label: 'Create <%= NOUN %>',
|
|
26
|
+
description: 'Creates a new <%= LOWER_NOUN %>, probably with input from previous steps.'
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
operation: {
|
|
30
|
+
perform,
|
|
31
|
+
|
|
32
|
+
<%= INCLUDE_INTRO_COMMENTS ? [
|
|
33
|
+
'// `inputFields` defines the fields a user could provide',
|
|
34
|
+
'// Zapier will pass them in as `bundle.inputData` later. They\'re optional.',
|
|
35
|
+
'// End-users will map data into these fields. In general, they should have any fields that the API can accept. Be sure to accurately mark which fields are required!'
|
|
36
|
+
].join('\n ') : '' %>
|
|
37
|
+
inputFields: [
|
|
38
|
+
{key: 'name', required: true},
|
|
39
|
+
{key: 'fave_meal', label: 'Favorite Meal', required: false}
|
|
40
|
+
],
|
|
41
|
+
|
|
42
|
+
<%= INCLUDE_INTRO_COMMENTS ? [
|
|
43
|
+
'// In cases where Zapier needs to show an example record to the user, but we are unable to get a live example',
|
|
44
|
+
'// from the API, Zapier will fallback to this hard-coded sample. It should reflect the data structure of',
|
|
45
|
+
'// returned records, and have obvious placeholder values that we can show to any user.'
|
|
46
|
+
].join('\n ') : '' %>
|
|
47
|
+
sample: {
|
|
48
|
+
id: 1,
|
|
49
|
+
name: 'Test'
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
<%= INCLUDE_INTRO_COMMENTS ? [
|
|
53
|
+
'// If fields are custom to each user (like spreadsheet columns), `outputFields` can create human labels',
|
|
54
|
+
'// For a more complete example of using dynamic fields see',
|
|
55
|
+
'// https://github.com/zapier/zapier-platform/tree/main/packages/cli#customdynamic-fields',
|
|
56
|
+
'// Alternatively, a static field definition can be provided, to specify labels for the fields'
|
|
57
|
+
].join('\n ') : '' %>
|
|
58
|
+
outputFields: [
|
|
59
|
+
// these are placeholders to match the example `perform` above
|
|
60
|
+
// {key: 'id', label: 'Person ID'},
|
|
61
|
+
// {key: 'name', label: 'Person Name'}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
} satisfies Create;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { PerformFunction, Resource } from 'zapier-platform-core';
|
|
2
|
+
|
|
3
|
+
// get a list of <%= LOWER_NOUN %>s
|
|
4
|
+
const performList: PerformFunction = async (z, bundle) => {
|
|
5
|
+
const response = await z.request({
|
|
6
|
+
url: 'https://jsonplaceholder.typicode.com/posts',
|
|
7
|
+
params: {
|
|
8
|
+
order_by: 'id desc',
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
return response.data;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// find a particular <%= LOWER_NOUN %> by name (or other search criteria)
|
|
15
|
+
const performSearch: PerformFunction = async (z, bundle) => {
|
|
16
|
+
const response = await z.request({
|
|
17
|
+
url: 'https://jsonplaceholder.typicode.com/posts',
|
|
18
|
+
params: {
|
|
19
|
+
name: bundle.inputData.name,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
return response.data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// creates a new <%= LOWER_NOUN %>
|
|
26
|
+
const performCreate: PerformFunction = async (z, bundle) => {
|
|
27
|
+
const response = await z.request({
|
|
28
|
+
method: 'POST',
|
|
29
|
+
url: 'https://jsonplaceholder.typicode.com/posts',
|
|
30
|
+
body: {
|
|
31
|
+
name: bundle.inputData.name, // json by default
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
return response.data;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default {
|
|
38
|
+
// see here for a full list of available properties:
|
|
39
|
+
// https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#resourceschema
|
|
40
|
+
key: '<%= KEY %>',
|
|
41
|
+
noun: '<%= NOUN %>',
|
|
42
|
+
|
|
43
|
+
<%= INCLUDE_INTRO_COMMENTS ? [
|
|
44
|
+
'// If `get` is defined, it will be called after a `search` or `create`'
|
|
45
|
+
].join('\n ') : '' %>
|
|
46
|
+
// useful if your `searches` and `creates` return sparse objects
|
|
47
|
+
// get: {
|
|
48
|
+
// display: {
|
|
49
|
+
// label: 'Get <%= NOUN %>',
|
|
50
|
+
// description: 'Gets a <%= LOWER_NOUN %>.'
|
|
51
|
+
// },
|
|
52
|
+
// operation: {
|
|
53
|
+
// inputFields: [
|
|
54
|
+
// {key: 'id', required: true}
|
|
55
|
+
// ],
|
|
56
|
+
// perform: defineMe
|
|
57
|
+
// }
|
|
58
|
+
// },
|
|
59
|
+
|
|
60
|
+
list: {
|
|
61
|
+
display: {
|
|
62
|
+
label: 'New <%= NOUN %>',
|
|
63
|
+
description: 'Lists the <%= LOWER_NOUN %>s.',
|
|
64
|
+
},
|
|
65
|
+
operation: {
|
|
66
|
+
perform: performList,
|
|
67
|
+
<%= INCLUDE_INTRO_COMMENTS ? [
|
|
68
|
+
'// `inputFields` defines the fields a user could provide',
|
|
69
|
+
'// Zapier will pass them in as `bundle.inputData` later. They\'re optional on triggers, but required on searches and creates.'
|
|
70
|
+
].join('\n ') : '' %>
|
|
71
|
+
inputFields: [],
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
search: {
|
|
76
|
+
display: {
|
|
77
|
+
label: 'Find <%= NOUN %>',
|
|
78
|
+
description: 'Finds a <%= LOWER_NOUN %> give.',
|
|
79
|
+
},
|
|
80
|
+
operation: {
|
|
81
|
+
inputFields: [{ key: 'name', required: true }],
|
|
82
|
+
perform: performSearch,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
create: {
|
|
87
|
+
display: {
|
|
88
|
+
label: 'Create <%= NOUN %>',
|
|
89
|
+
description: 'Creates a new <%= LOWER_NOUN %>.',
|
|
90
|
+
},
|
|
91
|
+
operation: {
|
|
92
|
+
inputFields: [{ key: 'name', required: true }],
|
|
93
|
+
perform: performCreate,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
<%= INCLUDE_INTRO_COMMENTS ? [
|
|
98
|
+
'// In cases where Zapier needs to show an example record to the user, but we are unable to get a live example',
|
|
99
|
+
'// from the API, Zapier will fallback to this hard-coded sample. It should reflect the data structure of',
|
|
100
|
+
'// returned records, and have obvious placeholder values that we can show to any user.',
|
|
101
|
+
'// In this resource, the sample is reused across all methods'
|
|
102
|
+
].join('\n ') : '' %>
|
|
103
|
+
sample: {
|
|
104
|
+
id: 1,
|
|
105
|
+
name: 'Test',
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
<%= INCLUDE_INTRO_COMMENTS ? [
|
|
109
|
+
'// If fields are custom to each user (like spreadsheet columns), `outputFields` can create human labels',
|
|
110
|
+
'// For a more complete example of using dynamic fields see',
|
|
111
|
+
'// https://github.com/zapier/zapier-platform/tree/main/packages/cli#customdynamic-fields',
|
|
112
|
+
'// Alternatively, a static field definition can be provided, to specify labels for the fields',
|
|
113
|
+
'// In this resource, these output fields are reused across all resources'
|
|
114
|
+
].join('\n ') : '' %>
|
|
115
|
+
outputFields: [
|
|
116
|
+
{ key: 'id', label: 'ID' },
|
|
117
|
+
{ key: 'name', label: 'Name' },
|
|
118
|
+
],
|
|
119
|
+
} satisfies Resource;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { PerformFunction, Search } from 'zapier-platform-core';
|
|
2
|
+
|
|
3
|
+
// find a particular <%= LOWER_NOUN %> by name
|
|
4
|
+
const perform: PerformFunction = async (z, bundle) => {
|
|
5
|
+
const response = await z.request({
|
|
6
|
+
url: 'https://jsonplaceholder.typicode.com/posts',
|
|
7
|
+
params: {
|
|
8
|
+
name: bundle.inputData.name,
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
// this should return an array of objects (but only the first will be used)
|
|
12
|
+
return response.data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
// see here for a full list of available properties:
|
|
17
|
+
// https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#searchschema
|
|
18
|
+
key: '<%= KEY %>',
|
|
19
|
+
noun: '<%= NOUN %>',
|
|
20
|
+
|
|
21
|
+
display: {
|
|
22
|
+
label: 'Find <%= NOUN %>',
|
|
23
|
+
description: 'Finds a <%= LOWER_NOUN %> based on name.',
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
operation: {
|
|
27
|
+
perform,
|
|
28
|
+
|
|
29
|
+
<%= INCLUDE_INTRO_COMMENTS ? [
|
|
30
|
+
'// `inputFields` defines the fields a user could provide',
|
|
31
|
+
'// Zapier will pass them in as `bundle.inputData` later. Searches need at least one `inputField`.'
|
|
32
|
+
].join('\n ') : '' %>
|
|
33
|
+
inputFields: [
|
|
34
|
+
{
|
|
35
|
+
key: 'name',
|
|
36
|
+
required: true,
|
|
37
|
+
helpText: 'Find the <%= NOUN %> with this name.',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
|
|
41
|
+
<%= INCLUDE_INTRO_COMMENTS ? [
|
|
42
|
+
'// In cases where Zapier needs to show an example record to the user, but we are unable to get a live example',
|
|
43
|
+
'// from the API, Zapier will fallback to this hard-coded sample. It should reflect the data structure of',
|
|
44
|
+
'// returned records, and have obvious placeholder values that we can show to any user.'
|
|
45
|
+
].join('\n ') : '' %>
|
|
46
|
+
sample: {
|
|
47
|
+
id: 1,
|
|
48
|
+
name: 'Test',
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
<%= INCLUDE_INTRO_COMMENTS ? [
|
|
52
|
+
'// If fields are custom to each user (like spreadsheet columns), `outputFields` can create human labels',
|
|
53
|
+
'// For a more complete example of using dynamic fields see',
|
|
54
|
+
'// https://github.com/zapier/zapier-platform/tree/main/packages/cli#customdynamic-fields',
|
|
55
|
+
'// Alternatively, a static field definition can be provided, to specify labels for the fields'
|
|
56
|
+
].join('\n ') : '' %>
|
|
57
|
+
outputFields: [
|
|
58
|
+
// these are placeholders to match the example `perform` above
|
|
59
|
+
// {key: 'id', label: 'Person ID'},
|
|
60
|
+
// {key: 'name', label: 'Person Name'}
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
} satisfies Search;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import zapier from 'zapier-platform-core';
|
|
3
|
+
|
|
4
|
+
import App from '../../index';
|
|
5
|
+
|
|
6
|
+
const appTester = zapier.createAppTester(App);
|
|
7
|
+
// read the `.env` file into the environment, if available
|
|
8
|
+
zapier.tools.env.inject();
|
|
9
|
+
|
|
10
|
+
describe('<%= ACTION_PLURAL %>.<%= KEY %>', () => {
|
|
11
|
+
it('should run', async () => {
|
|
12
|
+
const bundle = { inputData: {} };
|
|
13
|
+
|
|
14
|
+
const results = await appTester(App.<%= ACTION_PLURAL %>['<%= KEY %>'].<%= MAYBE_RESOURCE %>operation.perform, bundle);
|
|
15
|
+
expect(results).toBeDefined();
|
|
16
|
+
// TODO: add more assertions
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { PerformFunction, Trigger } from 'zapier-platform-core';
|
|
2
|
+
|
|
3
|
+
// triggers on a new <%= LOWER_NOUN %> with a certain tag
|
|
4
|
+
const perform: PerformFunction = async (z, bundle) => {
|
|
5
|
+
const response = await z.request({
|
|
6
|
+
url: 'https://jsonplaceholder.typicode.com/posts',
|
|
7
|
+
params: {
|
|
8
|
+
tag: bundle.inputData.tagName,
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
// this should return an array of objects
|
|
12
|
+
return response.data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
// see here for a full list of available properties:
|
|
17
|
+
// https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#triggerschema
|
|
18
|
+
key: '<%= KEY %>' as const,
|
|
19
|
+
noun: '<%= NOUN %>',
|
|
20
|
+
|
|
21
|
+
display: {
|
|
22
|
+
label: 'New <%= NOUN %>',
|
|
23
|
+
description: 'Triggers when a new <%= LOWER_NOUN %> is created.',
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
operation: {
|
|
27
|
+
type: 'polling',
|
|
28
|
+
perform,
|
|
29
|
+
|
|
30
|
+
<%= INCLUDE_INTRO_COMMENTS ? [
|
|
31
|
+
'// `inputFields` defines the fields a user could provide',
|
|
32
|
+
'// Zapier will pass them in as `bundle.inputData` later. They\'re optional.'
|
|
33
|
+
].join('\n ') : '' %>
|
|
34
|
+
inputFields: [],
|
|
35
|
+
|
|
36
|
+
<%= INCLUDE_INTRO_COMMENTS ? [
|
|
37
|
+
'// In cases where Zapier needs to show an example record to the user, but we are unable to get a live example',
|
|
38
|
+
'// from the API, Zapier will fallback to this hard-coded sample. It should reflect the data structure of',
|
|
39
|
+
'// returned records, and have obvious placeholder values that we can show to any user.'
|
|
40
|
+
].join('\n ') : '' %>
|
|
41
|
+
sample: {
|
|
42
|
+
id: 1,
|
|
43
|
+
name: 'Test',
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
<%= INCLUDE_INTRO_COMMENTS ? [
|
|
47
|
+
'// If fields are custom to each user (like spreadsheet columns), `outputFields` can create human labels',
|
|
48
|
+
'// For a more complete example of using dynamic fields see',
|
|
49
|
+
'// https://github.com/zapier/zapier-platform/tree/main/packages/cli#customdynamic-fields',
|
|
50
|
+
'// Alternatively, a static field definition can be provided, to specify labels for the fields'
|
|
51
|
+
].join('\n ') : '' %>
|
|
52
|
+
outputFields: [
|
|
53
|
+
// these are placeholders to match the example `perform` above
|
|
54
|
+
// {key: 'id', label: 'Person ID'},
|
|
55
|
+
// {key: 'name', label: 'Person Name'}
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
} satisfies Trigger;
|
package/src/bin/run
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
.
|
|
6
|
-
|
|
3
|
+
(async () => {
|
|
4
|
+
const oclif = await import('@oclif/core');
|
|
5
|
+
await oclif.execute({ development: false, dir: __dirname });
|
|
6
|
+
})();
|
package/src/bin/run.cmd
CHANGED
package/src/generators/index.js
CHANGED
|
@@ -13,14 +13,14 @@ const writeGenericReadme = (gen) => {
|
|
|
13
13
|
gen.fs.copyTpl(
|
|
14
14
|
gen.templatePath('README.template.md'),
|
|
15
15
|
gen.destinationPath('README.md'),
|
|
16
|
-
{ name: gen.options.packageName }
|
|
16
|
+
{ name: gen.options.packageName },
|
|
17
17
|
);
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
const appendReadme = (gen) => {
|
|
21
21
|
const content = gen.fs.read(
|
|
22
22
|
gen.templatePath(gen.options.template, 'README.md'),
|
|
23
|
-
{ defaults: '' }
|
|
23
|
+
{ defaults: '' },
|
|
24
24
|
);
|
|
25
25
|
if (content) {
|
|
26
26
|
gen.fs.append(gen.destinationPath('README.md'), '\n' + content);
|
|
@@ -51,8 +51,8 @@ const writeGenericPackageJson = (gen, packageJsonExtension) => {
|
|
|
51
51
|
},
|
|
52
52
|
private: true,
|
|
53
53
|
},
|
|
54
|
-
packageJsonExtension
|
|
55
|
-
)
|
|
54
|
+
packageJsonExtension,
|
|
55
|
+
),
|
|
56
56
|
);
|
|
57
57
|
};
|
|
58
58
|
|
|
@@ -76,8 +76,8 @@ const writeTypeScriptPackageJson = (gen, packageJsonExtension) => {
|
|
|
76
76
|
},
|
|
77
77
|
private: true,
|
|
78
78
|
},
|
|
79
|
-
packageJsonExtension
|
|
80
|
-
)
|
|
79
|
+
packageJsonExtension,
|
|
80
|
+
),
|
|
81
81
|
);
|
|
82
82
|
};
|
|
83
83
|
|
|
@@ -85,7 +85,7 @@ const writeGenericIndex = (gen, hasAuth) => {
|
|
|
85
85
|
gen.fs.copyTpl(
|
|
86
86
|
gen.templatePath('index.template.js'),
|
|
87
87
|
gen.destinationPath('index.js'),
|
|
88
|
-
{ corePackageName: PLATFORM_PACKAGE, hasAuth }
|
|
88
|
+
{ corePackageName: PLATFORM_PACKAGE, hasAuth },
|
|
89
89
|
);
|
|
90
90
|
};
|
|
91
91
|
|
|
@@ -108,14 +108,14 @@ const writeGenericAuthTest = (gen) => {
|
|
|
108
108
|
const authType = authTypes[gen.options.template];
|
|
109
109
|
gen.fs.copyTpl(
|
|
110
110
|
gen.templatePath(`authTests/${authType || 'generic'}.test.js`),
|
|
111
|
-
gen.destinationPath('test/authentication.test.js')
|
|
111
|
+
gen.destinationPath('test/authentication.test.js'),
|
|
112
112
|
);
|
|
113
113
|
};
|
|
114
114
|
|
|
115
115
|
const writeGenericTest = (gen) => {
|
|
116
116
|
gen.fs.copyTpl(
|
|
117
117
|
gen.templatePath('authTests/generic.test.js'),
|
|
118
|
-
gen.destinationPath('test/example.test.js')
|
|
118
|
+
gen.destinationPath('test/example.test.js'),
|
|
119
119
|
);
|
|
120
120
|
};
|
|
121
121
|
|
|
@@ -158,7 +158,7 @@ const writeForStandaloneTemplate = (gen) => {
|
|
|
158
158
|
|
|
159
159
|
gen.fs.copy(
|
|
160
160
|
gen.templatePath(gen.options.template, '**', '*.{js,json,ts}'),
|
|
161
|
-
gen.destinationPath()
|
|
161
|
+
gen.destinationPath(),
|
|
162
162
|
);
|
|
163
163
|
};
|
|
164
164
|
|
|
@@ -187,7 +187,7 @@ const writeForStandaloneTypeScriptTemplate = (gen) => {
|
|
|
187
187
|
|
|
188
188
|
gen.fs.copy(
|
|
189
189
|
gen.templatePath(gen.options.template, '**', '*.{js,json,ts}'),
|
|
190
|
-
gen.destinationPath()
|
|
190
|
+
gen.destinationPath(),
|
|
191
191
|
);
|
|
192
192
|
};
|
|
193
193
|
|
package/src/index.js
CHANGED