-
Notifications
You must be signed in to change notification settings - Fork 190
/
Copy pathTriggersSchema.js
61 lines (58 loc) · 1.56 KB
/
TriggersSchema.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
'use strict';
const makeSchema = require('../utils/makeSchema');
const { SKIP_KEY } = require('../constants');
const TriggerSchema = require('./TriggerSchema');
module.exports = makeSchema(
{
id: '/TriggersSchema',
description: 'Enumerates the triggers your app has available for users.',
type: 'object',
patternProperties: {
'^[a-zA-Z]+[a-zA-Z0-9_]*$': {
description:
'Any unique key can be used and its values will be validated against the TriggerSchema.',
$ref: TriggerSchema.id,
},
},
additionalProperties: false,
examples: [
{
newRecipe: {
key: 'newRecipe',
noun: 'Recipe',
display: {
label: 'New Recipe',
description: 'Triggers when a new recipe is added.',
},
operation: {
type: 'polling',
perform: '$func$0$f$',
sample: { id: 1 },
},
},
},
],
antiExamples: [
{
example: {
[SKIP_KEY]: true, // Cannot validate that keys don't match
newRecipe: {
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 },
},
},
},
reason: 'Key must match the key on the associated /TriggerSchema',
},
],
},
[TriggerSchema]
);