-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathzapier.ts
546 lines (544 loc) · 16.4 KB
/
zapier.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
const formatFlag: Fig.Option = {
name: ["-f", "--format"],
description:
'Change the way structured data is presented. If "json" or "raw", you can pipe the output of the command into other tools, such as jq',
args: {
name: "format",
suggestions: ["plain", "json", "raw", "row", "table"],
},
};
const debugFlag: Fig.Option = {
name: ["-d", "--debug"],
description: "Show extra debugging output",
};
const completionSpec: Fig.Spec = {
name: "zapier-platform-cli",
description:
"The Zapier CLI is a developer-focused way to create and maintain Zapier integrations. See more at https://github.com/zapier/zapier-platform",
subcommands: [
{
name: "analytics",
description:
"Show the status of the analytics that are collected. Also used to change what is collected",
options: [
{
name: ["-m", "--mode"],
description:
"Choose how much information to share. Anonymous mode drops the OS type and Zapier user id, but keeps command info. Identifying information is used only for debugging purposes",
args: {
name: "mode",
suggestions: ["enabled", "anonymous", "disabled"],
},
},
debugFlag,
],
},
{
name: "build",
description: "Build a pushable zip from the current directory",
options: [
{
name: "--disable-dependency-detection",
description:
'Disable "smart" file inclusion. By default, Zapier only includes files that are required by `index.js`. If you (or your dependencies) require files dynamically (such as with `require(someVar)`), then you may see "Cannot find module" errors. Disabling this may make your `build.zip` too large. If that\'s the case, try using the `includeInBuild` option in your `.zapierapprc`. See the docs about `includeInBuild` for more info',
},
debugFlag,
],
},
{
name: "convert",
description:
"Convert a Legacy Web Builder app or Visual Builder integration to a CLI integration",
options: [
{
name: ["-v", "--version"],
description:
"Convert a specific version. Required when converting a Visual Builder integration",
args: {
name: "version",
},
},
debugFlag,
],
args: [
{
name: "integrationId",
description:
'To get the integration/app ID, go to "https://zapier.com/app/developer", click on an integration, and copy the number directly after "/app/" in the URL',
},
{
name: "path",
description:
"Relative to your current path - IE: `.` for current directory",
template: "folders",
},
],
},
{
name: ["delete:integration", "delete:app"],
description: "Delete your integration (including all versions)",
options: [debugFlag],
isDangerous: true,
},
{
name: "delete:version",
description: "Delete a specific version of your integration",
options: [debugFlag],
args: {
name: "version",
description:
"Specify the version to delete. It must have no users or Zaps",
},
isDangerous: true,
},
{
name: "deprecate",
description:
"Mark a non-production version of your integration as deprecated, with removal by a certain date",
options: [debugFlag],
args: [
{
name: "version",
description: "The version to deprecate",
},
{
name: "date",
description:
"The date (YYYY-MM-DD) when Zapier will make the specified version unavailable",
},
],
},
{
name: "describe",
description: "Describe the current integraiton",
options: [formatFlag, debugFlag],
},
{
name: "env:get",
description: "Get environment variables for a version",
options: [formatFlag],
args: {
name: "version",
description: "The version to get the environment for",
},
},
{
name: "env:set",
description: "Set environment variables for a version",
options: [debugFlag],
args: [
{
name: "version",
description:
"The version to set the environment for. Values are copied forward when a new version is created, but this command will only ever affect the specified version",
},
{
name: "key-value pairs...",
description:
"The key-value pairs to set. Keys are case-insensitive. Each pair should be space separated and pairs should be separated by an `=`. For example: `A=123 B=456`",
isOptional: true,
isVariadic: true,
},
],
},
{
name: "env:unset",
description: "Unset environment variables for a version",
options: [debugFlag],
args: [
{
name: "version",
description: "The version to set the environment for",
},
{
name: "keys...",
description: "The keys to unset. Keys are case-insensitive",
isOptional: true,
isVariadic: true,
},
],
isDangerous: true,
},
{
name: "history",
description: "Get the history of your integration",
options: [formatFlag, debugFlag],
},
{
name: "init",
description:
"Initialize a new Zapier integration with a project template",
options: [
{
name: ["-t", "--template"],
description: "The template to start your integration with",
args: {
name: "template",
suggestions: [
"basic-auth",
"callback",
"custom-auth",
"digest-auth",
"dynamic-dropdown",
"files",
"minimal",
"oauth1-trello",
"oauth2",
"search-or-create",
"session-auth",
"typescript",
],
},
},
debugFlag,
],
args: {
name: "path",
description:
"Where to create the new integration. If the directory doesn't exist, it will be created. If the directory isn't empty, we'll ask for confirmation",
template: "folders",
},
},
{
name: ["integrations", "apps"],
description: "List integrations you have admin access to",
options: [formatFlag, debugFlag],
},
{
name: "link",
description: "Link the current directory with an existing integration",
options: [debugFlag],
},
{
name: "login",
description: "Configure your `~/.zapierrc` with a deploy key",
options: [
{
name: ["-s", "--sso"],
description:
"Use this flag if you log into Zapier a Single Sign-On (SSO) button and don't have a Zapier password",
},
debugFlag,
],
},
{
name: "logout",
description: "Deactivate your active deploy key and reset `~/.zapierrc`",
options: [debugFlag],
},
{
name: "logs",
description: "Print recent logs",
options: [
{
name: ["-v", "--version"],
description: "Filter logs to the specified version",
args: {
name: "version",
},
},
{
name: ["-s", "--status"],
description: "Filter logs to only see errors or successes",
args: {
name: "status",
suggestions: ["any", "success", "error"],
},
},
{
name: ["-t", "--type"],
description: "See logs of the specified type",
args: {
name: "type",
suggestions: ["console", "bundle", "http"],
},
},
{
name: "--detailed",
description: "See extra info, like request/response body and headers",
},
{
name: ["-u", "--user"],
description: "Only show logs for this user. Defaults to your account",
args: {
name: "user",
},
},
{
name: "--limit",
description:
"Cap the number of logs returned. Max is 50 (also the default)",
args: {
name: "limit",
},
},
formatFlag,
debugFlag,
],
},
{
name: "migrate",
description:
"Migrate users from one version of your integration to another",
options: [
{
name: "--user",
description: "Migrate only this user",
args: {
name: "user",
},
},
debugFlag,
],
args: [
{
name: "fromVersion",
description: "The version FROM which to migrate users",
},
{
name: "toVersion",
description: "The version TO which to migrate users",
},
{
name: "percent",
description: "Percentage (between 1 and 100) of users to migrate",
isOptional: true,
},
],
},
{
name: "promote",
description: "Promote a specific version to public access",
options: [debugFlag],
args: {
name: "version",
description: "The version you want promote",
},
},
{
name: "push",
description: "Build and upload the current integration",
options: [
{
name: "--disable-dependency-detection",
description:
'Disable "smart" file inclusion. By default, Zapier only includes files that are required by `index.js`. If you (or your dependencies) require files dynamically (such as with `require(someVar)`), then you may see "Cannot find module" errors. Disabling this may make your `build.zip` too large. If that\'s the case, try using the `includeInBuild` option in your `.zapierapprc`. See the docs about `includeInBuild` for more info',
},
debugFlag,
],
},
{
name: "register",
description: "Register a new integration in your account",
options: [debugFlag],
args: {
name: "title",
description:
"Your integrations's public title. Asked interactively if not present",
isOptional: true,
},
},
{
name: "scaffold",
description:
"Add a starting trigger, create, search, or resource to your integration",
options: [
{
name: ["-d", "--dest"],
description:
"Specify the new file's directory. Use this flag when you want to create a different folder structure such as `src/triggers` instead of the default `triggers`. Defaults to `[triggers|searches|creates]/{noun}`",
args: {
name: "dest",
template: "folders",
},
},
{
name: "--test-dest",
description:
"Specify the new test file's directory. Use this flag when you want to create a different folder structure such as `src/triggers` instead of the default `triggers`. Defaults to `test/[triggers|searches|creates]/{noun}`",
args: {
name: "test-dest",
template: "folders",
},
},
{
name: ["-e", "--entry"],
description:
"Supply the path to your integration's root (`index.js`). Only needed if your `index.js` is in a subfolder, like `src`",
args: {
name: "entry",
template: "filepaths",
},
},
{
name: ["-f", "--force"],
description:
"Should we overwrite an existing trigger/search/create file?",
},
{
name: "--no-help",
description:
"When scaffolding, should we skip adding helpful intro comments? Useful if this isn't your first rodeo",
},
debugFlag,
],
args: [
{
name: "actionType",
suggestions: ["trigger", "search", "create", "resource"],
},
{
name: "noun",
},
],
},
{
name: ["team:add", "team:invite"],
description: "Add a team member to your integration",
options: [debugFlag],
args: [
{
name: "email",
description:
"The user to be invited. If they don't have a Zapier account, they'll be prompted to create one",
},
{
name: "role",
description:
"The level the invited team member should be at. Admins can edit everything and get email updates. Subscribers only get email updates",
suggestions: ["admin", "subscriber"],
},
{
name: "message",
description:
"A message sent in the email to your team member, if you need to provide context. Wrap the message in quotes to ensure spaces get saved",
isOptional: true,
},
],
isDangerous: true,
},
{
name: ["team:get", "team:list"],
description: "Get team members involved with your integration",
options: [formatFlag, debugFlag],
},
{
name: ["team:remove", "team:delete"],
description: "Remove a team member from all versions of your integration",
options: [debugFlag],
isDangerous: true,
},
{
name: "test",
description:
'Test your integration via the "test" script in your "package.json"',
options: [
{
name: "--skip-validate",
description:
"Forgo running `zapier validate` before tests are run. This will speed up tests if you're modifying functionality of an existing integration rather than adding new actions",
},
{
name: "--yarn",
description:
"Use `yarn` instead of `npm`. This happens automatically if there's a `yarn.lock` file, but you can manually force `yarn` if you run tests from a sub-directory",
},
debugFlag,
],
},
{
name: "upload",
description: "Upload the latest build of your integration to Zapier",
options: [debugFlag],
},
{
name: ["users:add", "users:invite"],
description: "Add a user to some or all versions of your integration",
options: [
{
name: ["-f", "--force"],
description: "Skip confirmation. Useful for running programmatically",
isDangerous: true,
},
debugFlag,
],
args: [
{
name: "email",
description:
"The user to be invited. If they don't have a Zapier account, they'll be prompted to create one",
},
{
name: "version",
description:
"A version string (like 1.2.3). Optional, used only if you want to invite a user to a specific version instead of all versions",
isOptional: true,
},
],
},
{
name: ["users:get", "users:list"],
description:
"Get a list of users who have been invited to your integration",
options: [formatFlag, debugFlag],
},
{
name: "users:links",
description:
"Get a list of links that are used to invite users to your integration",
options: [formatFlag, debugFlag],
},
{
name: ["users:remove", "users:delete"],
description: "Remove a user from all versions of your integration",
options: [
{
name: ["-f", "--force"],
description:
"Skips confirmation. Useful for running programmatically",
isDangerous: true,
},
debugFlag,
],
args: {
name: "email",
description: "The user to be removed",
},
isDangerous: true,
},
{
name: "validate",
description: "Validate your integration",
options: [
{
name: "--without-style",
description: "Forgo pinging the Zapier server to run further checks",
},
formatFlag,
debugFlag,
],
},
{
name: "versions",
description:
"List the versions of your integration available for use in the Zapier editor",
options: [formatFlag, debugFlag],
},
{
name: "help",
description: "Display help for <%= config.bin %>",
options: [
{
name: "--all",
description: "See all commands in CLI",
},
],
args: {
name: "command",
description: "Command to show help for",
isOptional: true,
},
},
],
};
export default completionSpec;