git ssb

0+

Piet / ssb-loomio



Tree: 81f8f8f4fc3b67a1fc26efcfeebed05d1ed7c223

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

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

Built with git-ssb-web