-
Notifications
You must be signed in to change notification settings - Fork 187
/
Copy pathSearchOrCreateSchema.js
84 lines (81 loc) · 2.56 KB
/
SearchOrCreateSchema.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
'use strict';
const makeSchema = require('../utils/makeSchema');
const BasicDisplaySchema = require('./BasicDisplaySchema');
const KeySchema = require('./KeySchema');
module.exports = makeSchema(
{
id: '/SearchOrCreateSchema',
description:
'Pair an existing search and a create to enable "Find or Create" functionality in your app',
type: 'object',
required: ['key', 'display', 'search', 'create'],
properties: {
key: {
description:
'A key to uniquely identify this search-or-create. Must match the search key.',
$ref: KeySchema.id,
},
display: {
description: 'Configures the UI for this search-or-create.',
$ref: BasicDisplaySchema.id,
},
search: {
description: 'The key of the search that powers this search-or-create',
$ref: KeySchema.id,
},
create: {
description: 'The key of the create that powers this search-or-create',
$ref: KeySchema.id,
},
},
additionalProperties: false,
examples: [
{
key: 'searchOrCreateWidgets',
display: {
label: 'Search or Create Widgets',
description:
'Searches for a widget matching the provided query, or creates one if it does not exist.',
important: true,
hidden: false,
},
search: 'searchWidgets',
create: 'createWidget',
},
],
antiExamples: [
{
example: {
key: '01_Search_or_Create_Widgets',
display: {
label: 'Search or Create Widgets',
description:
'Searches for a widget matching the provided query, or creates one if it does not exist.',
important: true,
hidden: false,
},
search: 'searchWidgets',
create: 'createWidget',
},
reason: 'Invalid value for key: key (must start with a letter)',
},
{
example: {
key: 'searchOrCreateWidgets',
display: {
label: 'Search or Create Widgets',
description:
'Searches for a widget matching the provided query, or creates one if it does not exist.',
important: true,
hidden: false,
},
search: { require: 'path/to/some/file.js' },
create: { require: 'path/to/some/file.js' },
},
reason:
'Invalid values for keys: search and create (must be a string that matches the key of a registered search or create)',
},
],
},
[BasicDisplaySchema, KeySchema]
);