git ssb

0+

Piet / ssb-loomio



Tree: ff7663e73e7aedeb75242d658e91bb048df0253f

Files: ff7663e73e7aedeb75242d658e91bb048df0253f / poll / schema / poll.js

2644 bytesRaw
1const { msgIdRegex, feedIdRegex, blobIdRegex } = require('ssb-ref')
2
3const dotDetails = require('./details/dot.js')
4const proposalDetails = require('./details/proposal.js')
5const scoreDetails = require('./details/score.js')
6const chooseOneDetails = require('./details/chooseOne.js')
7
8const schema = {
9 $schema: 'http://json-schema.org/schema#',
10 type: 'object',
11 required: ['type', 'pollDetails', 'title'],
12 properties: {
13 version: {
14 type: 'string',
15 pattern: '^0.1.0$'
16 },
17 type: {
18 type: 'string',
19 pattern: '^poll$'
20 },
21 pollDetails: {
22 oneOf: [
23 // { $ref: '#/definitions/pollDetails/dot'},
24 // { $ref: '#/definitions/pollDetails/proposal'},
25 // { $ref: '#/definitions/pollDetails/score'},
26 { $ref: '#/definitions/pollDetails/chooseOne' }
27 // { $ref: '#/definitions/pollDetails/rsvp'},
28 // { $ref: '#/definitions/pollDetails/meeting'},
29 ]
30 },
31 title: { type: 'string' },
32 body: { type: 'string' },
33 mentions: {
34 oneOf: [
35 { type: 'null' },
36 {
37 type: 'array',
38 items: {
39 oneOf: [
40 { $ref: '#/definitions/mentions/message' },
41 { $ref: '#/definitions/mentions/feed' },
42 { $ref: '#/definitions/mentions/blob' }
43 ]
44 }
45 }
46 ]
47 },
48 recps: {
49 oneOf: [
50 { type: 'null' },
51 {
52 type: 'array',
53 items: {
54 oneOf: [
55 { $ref: '#/definitions/feedId' },
56 { $ref: '#/definitions/mentions/feed' }
57 ]
58 }
59 }
60 ]
61 }
62 },
63 definitions: {
64 messageId: {
65 type: 'string',
66 pattern: msgIdRegex
67 },
68 feedId: {
69 type: 'string',
70 pattern: feedIdRegex
71 },
72 blobId: {
73 type: 'string',
74 pattern: blobIdRegex
75 },
76 pollDetails: {
77 type: 'object',
78 dot: dotDetails,
79 proposal: proposalDetails,
80 score: scoreDetails,
81 chooseOne: chooseOneDetails
82 },
83 mentions: {
84 message: {
85 type: 'object',
86 required: ['link'],
87 properties: {
88 link: { $ref: '#/definitions/messageId'}
89 }
90 },
91 feed: {
92 type: 'object',
93 required: ['link', 'name'],
94 properties: {
95 link: { $ref: '#/definitions/feedId'},
96 name: { type: 'string' }
97 }
98 },
99 blob: {
100 type: 'object',
101 required: ['link', 'name'],
102 properties: {
103 link: { $ref: '#/definitions/blobId'},
104 name: { type: 'string' }
105 }
106 }
107 }
108 }
109}
110
111module.exports = schema
112

Built with git-ssb-web