/
TriggerSchema.js
96 lines (93 loc) · 2.59 KB
/
TriggerSchema.js
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
'use strict';
const makeSchema = require('../utils/makeSchema');
const BasicDisplaySchema = require('./BasicDisplaySchema');
const BasicHookOperationSchema = require('./BasicHookOperationSchema');
const BasicHookToPollOperationSchema = require('./BasicHookToPollOperationSchema');
const BasicPollingOperationSchema = require('./BasicPollingOperationSchema');
const KeySchema = require('./KeySchema');
module.exports = makeSchema(
{
id: '/TriggerSchema',
description: 'How will Zapier get notified of new objects?',
type: 'object',
required: ['key', 'noun', 'display', 'operation'],
properties: {
key: {
description: 'A key to uniquely identify this trigger.',
$ref: KeySchema.id,
},
noun: {
description:
'A noun for this trigger that completes the sentence "triggers on a new XXX".',
type: 'string',
minLength: 2,
maxLength: 255,
},
display: {
description: 'Configures the UI for this trigger.',
$ref: BasicDisplaySchema.id,
},
operation: {
description: 'Powers the functionality for this trigger.',
anyOf: [
{ $ref: BasicPollingOperationSchema.id },
{ $ref: BasicHookOperationSchema.id },
{ $ref: BasicHookToPollOperationSchema.id },
],
},
},
additionalProperties: false,
examples: [
{
key: 'new_recipe',
noun: 'Recipe',
display: {
label: 'New Recipe',
description: 'Triggers when a new recipe is added.',
},
operation: {
type: 'polling',
perform: '$func$0$f$',
sample: { id: 1 },
},
},
{
key: 'new_recipe',
noun: 'Recipe',
display: {
label: 'New Recipe',
description: 'Triggers when a new recipe is added.',
hidden: true,
},
operation: {
type: 'polling',
perform: '$func$0$f$',
},
},
],
antiExamples: [
{
example: {
key: 'new_recipe',
noun: 'Recipe',
display: {
label: 'New Recipe',
description: 'Triggers when a new recipe is added.',
},
operation: {
perform: '$func$0$f$',
},
},
reason:
'Missing required key from operation: sample. Note - this is valid if the Recipe resource has defined a sample.',
},
],
},
[
KeySchema,
BasicDisplaySchema,
BasicPollingOperationSchema,
BasicHookOperationSchema,
BasicHookToPollOperationSchema,
]
);