git ssb

0+

Piet / ssb-loomio



Commit 3bc106d06cd050c026b7934dacf2076f6d847894

first pass extracting common ssb schemas

mix irving committed on 3/5/2018, 5:24:52 AM
Parent: 07a5f24f2034628892c7c9ed0782b63b30fc7911

Files changed

lib/ssbSchemaDefintions.jsadded
poll/schema/poll.jschanged
position/schema/position.jschanged
lib/ssbSchemaDefintions.jsView
@@ -1,0 +1,41 @@
1+const { msgIdRegex, feedIdRegex, blobIdRegex } = require('ssb-ref')
2+
3+module.exports = {
4+ messageId: {
5+ type: 'string',
6+ pattern: msgIdRegex
7+ },
8+ feedId: {
9+ type: 'string',
10+ pattern: feedIdRegex
11+ },
12+ blobId: {
13+ type: 'string',
14+ pattern: blobIdRegex
15+ },
16+ mentions: {
17+ message: {
18+ type: 'object',
19+ required: ['link'],
20+ properties: {
21+ link: { $ref: '#/definitions/messageId' }
22+ }
23+ },
24+ feed: {
25+ type: 'object',
26+ required: ['link', 'name'],
27+ properties: {
28+ link: { $ref: '#/definitions/feedId' },
29+ name: { type: 'string' }
30+ }
31+ },
32+ blob: {
33+ type: 'object',
34+ required: ['link', 'name'],
35+ properties: {
36+ link: { $ref: '#/definitions/blobId' },
37+ name: { type: 'string' }
38+ }
39+ }
40+ }
41+}
poll/schema/poll.jsView
@@ -1,11 +1,11 @@
1-const { msgIdRegex, feedIdRegex, blobIdRegex } = require('ssb-ref')
2-
31 const dotDetails = require('./details/dot.js')
42 const proposalDetails = require('./details/proposal.js')
53 const scoreDetails = require('./details/score.js')
64 const chooseOneDetails = require('./details/chooseOne.js')
75
6+const ssbSchemaDefintions = require('../../lib/ssbSchemaDefintions')
7+
88 const schema = {
99 $schema: 'http://json-schema.org/schema#',
1010 type: 'object',
1111 required: ['type', 'pollDetails', 'title', 'closesAt'],
@@ -60,53 +60,19 @@
6060 }
6161 ]
6262 }
6363 },
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: {
64+ definitions: Object.assign({},
65+ ssbSchemaDefintions,
66+ {
67+ pollDetails: {
8668 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- }
69+ dot: dotDetails,
70+ proposal: proposalDetails,
71+ score: scoreDetails,
72+ chooseOne: chooseOneDetails
10773 }
10874 }
109- }
75+ )
11076 }
11177
11278 module.exports = schema
position/schema/position.jsView
@@ -1,8 +1,9 @@
11 const Validate = require('is-my-json-valid')
2-const { msgIdRegex, feedIdRegex, blobIdRegex } = require('ssb-ref')
32 const chooseOneDetails = require('./details/chooseOne')
43
4+const ssbSchemaDefintions = require('../../lib/ssbSchemaDefintions')
5+
56 const schema = {
67 $schema: 'http://json-schema.org/schema#',
78 type: 'object',
89 required: ['type', 'positionDetails'],
@@ -18,9 +19,14 @@
1819 text: { type: 'string' },
1920 reason: { type: 'string' },
2021 positionDetails: {
2122 oneOf: [
23+ // { $ref: '#/definitions/positionDetails/dot'},
24+ // { $ref: '#/definitions/positionDetails/proposal'},
25+ // { $ref: '#/definitions/positionDetails/score'},
2226 { $ref: '#/definitions/positionDetails/chooseOne' }
27+ // { $ref: '#/definitions/positionDetails/rsvp'},
28+ // { $ref: '#/definitions/positionDetails/meeting'},
2329 ]
2430 },
2531 mentions: {
2632 oneOf: [
@@ -51,70 +57,16 @@
5157 }
5258 ]
5359 }
5460 },
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: {
61+ definitions: Object.assign({},
62+ ssbSchemaDefintions,
63+ {
64+ positionDetails: {
9465 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- }
66+ chooseOne: chooseOneDetails
11567 }
11668 }
117- }
69+ )
11870 }
11971
12072 module.exports = schema

Built with git-ssb-web