git ssb

0+

Piet / ssb-loomio



Tree: 81f8f8f4fc3b67a1fc26efcfeebed05d1ed7c223

Files: 81f8f8f4fc3b67a1fc26efcfeebed05d1ed7c223 / poll / schema / poll.js

2694 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', 'closesAt'],
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 closesAt: { type: 'integer' },
33 body: { type: 'string' },
34 mentions: {
35 oneOf: [
36 { type: 'null' },
37 {
38 type: 'array',
39 items: {
40 oneOf: [
41 { $ref: '#/definitions/mentions/message' },
42 { $ref: '#/definitions/mentions/feed' },
43 { $ref: '#/definitions/mentions/blob' }
44 ]
45 }
46 }
47 ]
48 },
49 recps: {
50 oneOf: [
51 { type: 'null' },
52 {
53 type: 'array',
54 items: {
55 oneOf: [
56 { $ref: '#/definitions/feedId' },
57 { $ref: '#/definitions/mentions/feed' }
58 ]
59 }
60 }
61 ]
62 }
63 },
64 definitions: {
65 messageId: {
66 type: 'string',
67 pattern: msgIdRegex
68 },
69 feedId: {
70 type: 'string',
71 pattern: feedIdRegex
72 },
73 blobId: {
74 type: 'string',
75 pattern: blobIdRegex
76 },
77 pollDetails: {
78 type: 'object',
79 dot: dotDetails,
80 proposal: proposalDetails,
81 score: scoreDetails,
82 chooseOne: chooseOneDetails
83 },
84 mentions: {
85 message: {
86 type: 'object',
87 required: ['link'],
88 properties: {
89 link: { $ref: '#/definitions/messageId' }
90 }
91 },
92 feed: {
93 type: 'object',
94 required: ['link', 'name'],
95 properties: {
96 link: { $ref: '#/definitions/feedId' },
97 name: { type: 'string' }
98 }
99 },
100 blob: {
101 type: 'object',
102 required: ['link', 'name'],
103 properties: {
104 link: { $ref: '#/definitions/blobId' },
105 name: { type: 'string' }
106 }
107 }
108 }
109 }
110}
111
112module.exports = schema
113

Built with git-ssb-web