@sockethub/schemas 3.0.0-alpha.4 → 3.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/package.json +16 -32
  2. package/src/index.ts +23 -19
  3. package/src/schemas/activity-object.ts +15 -15
  4. package/src/schemas/activity-stream.ts +40 -41
  5. package/{dist → src}/schemas/json/activity-object.json +1 -1
  6. package/{dist → src}/schemas/json/activity-stream.json +1 -1
  7. package/{dist → src}/schemas/json/platform.json +1 -0
  8. package/src/schemas/json/sockethub-config.json +144 -0
  9. package/src/schemas/platform.ts +22 -22
  10. package/src/schemas/sockethub-config.ts +140 -0
  11. package/dist/helpers/error-parser.d.ts +0 -9
  12. package/dist/helpers/error-parser.js +0 -90
  13. package/dist/helpers/objects.d.ts +0 -206
  14. package/dist/helpers/objects.js +0 -217
  15. package/dist/index.d.ts +0 -15
  16. package/dist/index.js +0 -37
  17. package/dist/index.test.data.credentials.d.ts +0 -37
  18. package/dist/index.test.data.credentials.js +0 -69
  19. package/dist/index.test.data.objects.d.ts +0 -50
  20. package/dist/index.test.data.objects.js +0 -214
  21. package/dist/index.test.data.platform.d.ts +0 -44
  22. package/dist/index.test.data.platform.js +0 -47
  23. package/dist/index.test.data.streams.d.ts +0 -274
  24. package/dist/index.test.data.streams.js +0 -473
  25. package/dist/schemas/activity-object.d.ts +0 -16
  26. package/dist/schemas/activity-object.js +0 -18
  27. package/dist/schemas/activity-stream.d.ts +0 -239
  28. package/dist/schemas/activity-stream.js +0 -53
  29. package/dist/schemas/platform.d.ts +0 -41
  30. package/dist/schemas/platform.js +0 -44
  31. package/dist/types.d.ts +0 -34
  32. package/dist/types.js +0 -2
  33. package/dist/validator.d.ts +0 -8
  34. package/dist/validator.js +0 -80
  35. package/src/helpers/error-parser.ts +0 -96
  36. package/src/helpers/objects.ts +0 -230
  37. package/src/index.test.data.credentials.ts +0 -71
  38. package/src/index.test.data.objects.ts +0 -235
  39. package/src/index.test.data.platform.ts +0 -45
  40. package/src/index.test.data.streams.ts +0 -495
  41. package/src/index.test.ts +0 -85
  42. package/src/types.ts +0 -42
  43. package/src/validator.ts +0 -81
@@ -1,230 +0,0 @@
1
- export const validObjectRefs = [];
2
- export const validObjectDefs = {};
3
-
4
- export const ObjectTypesSchema = {
5
-
6
- "credentials": {
7
- "required": [ "type" ],
8
- "additionalProperties": true,
9
- "properties": {
10
- "type": {
11
- "enum": [ "credentials" ]
12
- }
13
- }
14
- },
15
-
16
- "feed": {
17
- "required": [ "id", "type" ],
18
- "additionalProperties": true,
19
- "properties": {
20
- "type": {
21
- "enum": [ "feed" ]
22
- },
23
- "id": {
24
- "type": "string",
25
- "format": "iri"
26
- },
27
- "name": {
28
- "type": "string"
29
- },
30
- "description": {
31
- "type": "string"
32
- },
33
- "author": {
34
- "type": "string"
35
- },
36
- "favicon": {
37
- "type": "string"
38
- }
39
- }
40
- },
41
-
42
- "message": {
43
- "required": [ "type", "content" ],
44
- "additionalProperties": true,
45
- "properties": {
46
- "type": {
47
- "enum": [ "message" ]
48
- },
49
- "id": {
50
- "type": "string",
51
- },
52
- "name": {
53
- "type": "string"
54
- },
55
- "content": {
56
- "type": "string"
57
- }
58
- }
59
- },
60
-
61
- "me": {
62
- "required": ["type", "content"],
63
- "additionalProperties": true,
64
- "properties": {
65
- "type": {
66
- "enum": ["me"]
67
- },
68
- "content": {
69
- "type": "string"
70
- }
71
- }
72
- },
73
-
74
- "person": {
75
- "required": [ "id", "type" ],
76
- "additionalProperties": true,
77
- "properties": {
78
- "id": {
79
- "type": "string"
80
- },
81
- "type": {
82
- "enum": [ "person" ]
83
- },
84
- "name": {
85
- "type": "string"
86
- }
87
- }
88
- },
89
-
90
- "room": {
91
- "required": [ "id", "type" ],
92
- "additionalProperties": true,
93
- "properties": {
94
- "id": {
95
- "type": "string"
96
- },
97
- "type": {
98
- "enum": [ "room" ]
99
- },
100
- "name": {
101
- "type": "string"
102
- }
103
- }
104
- },
105
-
106
- "service": {
107
- "required": [ "id", "type" ],
108
- "additionalProperties": true,
109
- "properties": {
110
- "id": {
111
- "type": "string"
112
- },
113
- "type": {
114
- "enum": [ "service" ]
115
- },
116
- "name": {
117
- "type": "string"
118
- }
119
- }
120
- },
121
-
122
- "website": {
123
- "required": [ "id", "type" ],
124
- "additionalProperties": true,
125
- "properties": {
126
- "id": {
127
- "type": "string",
128
- "format": "iri"
129
- },
130
- "type": {
131
- "enum": [ "website" ]
132
- },
133
- "name": {
134
- "type": "string"
135
- }
136
- }
137
- },
138
-
139
- "attendance": {
140
- "required": [ "type" ],
141
- "additionalProperties": false,
142
- "properties": {
143
- "type": {
144
- "enum": [ "attendance" ]
145
- },
146
- "members": {
147
- "type": "array",
148
- "items": {
149
- "type": "string"
150
- }
151
- }
152
- }
153
- },
154
-
155
- "presence": {
156
- "required": [ "type" ],
157
- "additionalProperties": false,
158
- "properties": {
159
- "type": {
160
- "enum": [ "presence" ]
161
- },
162
- "presence": {
163
- "enum": [ "away", "chat", "dnd", "xa", "offline", "online" ]
164
- },
165
- "role": {
166
- "enum": [ "owner", "member", "participant", "admin" ]
167
- },
168
- "content": {
169
- "type": "string"
170
- }
171
- }
172
- },
173
-
174
- // inspired by https://www.w3.org/ns/activitystreams#Relationship
175
- "relationship": {
176
- "required": [ "type", "relationship" ],
177
- "additionalProperties": false,
178
- "properties": {
179
- "type": {
180
- "enum": [ "relationship" ]
181
- },
182
- "relationship": {
183
- "enum": [ "role" ]
184
- },
185
- "subject": {
186
- "type": "object",
187
- "oneOf": [
188
- { "$ref": "#/definitions/type/presence" }
189
- ]
190
- },
191
- "object": {
192
- "type": "object",
193
- "oneOf": validObjectRefs,
194
- }
195
- }
196
- },
197
-
198
- "topic": {
199
- "required": [ "type" ],
200
- "additionalProperties": false,
201
- "properties": {
202
- "type": {
203
- "enum": [ "topic" ]
204
- },
205
- "content": {
206
- "type": "string"
207
- }
208
- }
209
- },
210
-
211
- "address": {
212
- "required": [ "type" ],
213
- "additionalProperties": false,
214
- "properties": {
215
- "type": {
216
- "enum": [ "address" ]
217
- }
218
- }
219
- }
220
- };
221
-
222
- export const ObjectTypesList = Object.keys(ObjectTypesSchema);
223
-
224
- ObjectTypesList.forEach(function (type) {
225
- if (type === 'credentials') {
226
- return;
227
- }
228
- validObjectRefs.push({ "$ref": "#/definitions/type/" + type });
229
- validObjectDefs[type] = ObjectTypesSchema[type];
230
- });
@@ -1,71 +0,0 @@
1
- export default [
2
- [
3
- 'credentials with no context',
4
- {
5
- type: 'credentials',
6
- object: {
7
- type: 'credentials'
8
- }
9
- },
10
- false,
11
- `credential activity streams must have a context set`
12
- ],
13
-
14
- [
15
- 'credentials with no type',
16
- {
17
- context: 'test-platform',
18
- object: {
19
- type: 'credentials'
20
- }
21
- },
22
- false,
23
- `credential activity streams must have credentials set as type`
24
- ],
25
-
26
- [
27
- 'credentials with props',
28
- {
29
- context: 'test-platform',
30
- type: 'credentials',
31
- object: {
32
- type: 'credentials',
33
- user: "foo",
34
- pass: "bar"
35
- }
36
- },
37
- false,
38
- `/object: must NOT have additional properties`
39
- ],
40
-
41
- [
42
- 'credentials with props',
43
- {
44
- context: 'test-platform',
45
- type: 'credentials',
46
- object: {
47
- type: 'credentials',
48
- username: "foo",
49
- password: "bar"
50
- }
51
- },
52
- false,
53
- `/object: must have required property 'host'`
54
- ],
55
-
56
- [
57
- 'credentials with props',
58
- {
59
- context: 'test-platform',
60
- type: 'credentials',
61
- object: {
62
- type: 'credentials',
63
- username: "foo",
64
- password: "bar",
65
- host: 'yarg'
66
- }
67
- },
68
- true,
69
- ""
70
- ],
71
- ];
@@ -1,235 +0,0 @@
1
- import { ObjectTypesList } from './helpers/objects';
2
-
3
- export default [
4
- [
5
- 'room object',
6
- {
7
- id: 'irc.freenode.net/server',
8
- type: 'room',
9
- name: 'sockethub'
10
- },
11
- true,
12
- ``
13
- ],
14
-
15
- [
16
- 'credentials with no props',
17
- {
18
- type: 'credentials'
19
- },
20
- false,
21
- `/object: must match exactly one schema in oneOf: ${ObjectTypesList.join(', ')}`
22
- ],
23
-
24
- [
25
- 'credentials with props',
26
- {
27
- type: 'credentials',
28
- user: "foo",
29
- pass: "bar"
30
- },
31
- false,
32
- `/object: must match exactly one schema in oneOf: ${ObjectTypesList.join(', ')}`
33
- ],
34
-
35
- [
36
- 'bad target',
37
- {
38
- type: 'person',
39
- name: 'bob'
40
- },
41
- false,
42
- '/object: must have required property \'id\''
43
- ],
44
-
45
- [
46
- 'bad iri in object id',
47
- {
48
- id: 'example.org/some/path.html',
49
- type: 'website'
50
- },
51
- false,
52
- '/object/id: must match format "iri"'
53
- ],
54
-
55
- [
56
- 'valid iri in object id',
57
- {
58
- id: 'https://example.org/some/path.html',
59
- type: 'website'
60
- },
61
- true,
62
- ''
63
- ],
64
-
65
- [
66
- 'wrong actor type',
67
- {
68
- id: 'doobar@freenode.net/channel',
69
- type: 'foo',
70
- content: 'hi there'
71
- },
72
- false,
73
- `/object: must match exactly one schema in oneOf: ${ObjectTypesList.join(', ')}`
74
- ],
75
-
76
- [
77
- 'missing actor id',
78
- {
79
- type: 'person',
80
- name: 'dood'
81
- },
82
- false,
83
- '/object: must have required property \'id\''
84
- ],
85
-
86
- [
87
- 'attendance request',
88
- {
89
- type: 'attendance',
90
- },
91
- true,
92
- ''
93
- ],
94
-
95
- [
96
- 'attendance response',
97
- {
98
- type: 'attendance',
99
- members: ['bill', 'bob', 'hank']
100
- },
101
- true,
102
- ''
103
- ],
104
-
105
- [
106
- 'invalid attendance request',
107
- {
108
- type: 'attendance',
109
- status: 'foobar'
110
- },
111
- false,
112
- '/object: must NOT have additional properties: status'
113
- ],
114
-
115
- [
116
- 'setting presence',
117
- {
118
- type: 'presence',
119
- presence: 'away',
120
- content: 'forgot the milk'
121
- },
122
- true,
123
- ''
124
- ],
125
-
126
- [
127
- 'setting invalid presence',
128
- {
129
- type: 'presence',
130
- presence: 'afk',
131
- content: 'forgot the milk'
132
- },
133
- false,
134
- '/object/presence: must be equal to one of the allowed values: ' +
135
- 'away, chat, dnd, xa, offline, online'
136
- ],
137
-
138
- [
139
- 'setting topic',
140
- {
141
- type: 'topic',
142
- content: 'the topic is goats'
143
- },
144
- true,
145
- ''
146
- ],
147
-
148
- [
149
- 'setting topic incorrectly',
150
- {
151
- type: 'topic',
152
- topic: 'the topic is goats'
153
- },
154
- false,
155
- '/object: must NOT have additional properties: topic'
156
- ],
157
-
158
-
159
- [
160
- 'send message',
161
- {
162
- type: 'message',
163
- content: 'the message is goats'
164
- },
165
- true,
166
- ''
167
- ],
168
-
169
- [
170
- 'change user address',
171
- {
172
- type: 'address'
173
- },
174
- true,
175
- ''
176
- ],
177
-
178
- [
179
- 'change user address incorrectly',
180
- {
181
- type: 'address',
182
- id: 'futurebar@example.com',
183
- },
184
- false,
185
- '/object: must NOT have additional properties: id'
186
- ],
187
-
188
-
189
- [
190
- 'invalid room',
191
- {
192
- "type":"room",
193
- "name":"sh-9K3Vk"
194
- },
195
- false,
196
- '/object: must have required property \'id\''
197
- ],
198
-
199
- [
200
- 'relationship',
201
- {
202
- "type":"relationship",
203
- "relationship":"role",
204
- "subject": {
205
- "type":"presence",
206
- "role":"owner"
207
- },
208
- "object":{
209
- "type":"room",
210
- "id":"localhost/#Finnish",
211
- "name":"#Finnish"
212
- }
213
- },
214
- true, ""
215
- ],
216
-
217
- [
218
- 'invalid role in relationship',
219
- {
220
- "type":"relationship",
221
- "relationship":"role",
222
- "subject": {
223
- "type":"presence",
224
- "role":"manager"
225
- },
226
- "object":{
227
- "type":"room",
228
- "id":"localhost/#Finnish",
229
- "name":"#Finnish"
230
- }
231
- },
232
- false, "/object/subject/role: must be equal to one of the allowed values: " +
233
- "owner, member, participant, admin"
234
- ]
235
- ];
@@ -1,45 +0,0 @@
1
- export default {
2
- "name": "fake",
3
- "version": "1.0",
4
- "messages": {
5
- "required": ['type'],
6
- "properties": {
7
- "type": {
8
- "enum": ['connect', 'update', 'send', 'join', 'query', 'foo']
9
- }
10
- }
11
- },
12
- "credentials": {
13
- "required": ['object'],
14
- "properties": {
15
- // TODO platforms shouldn't have to define the actor property if
16
- // they don't want to, just credential specifics
17
- "actor": {
18
- "type": "object",
19
- "required": ["id"]
20
- },
21
- "object": {
22
- "type": "object",
23
- "required": ['type', 'username', 'password', 'host'],
24
- "additionalProperties": false,
25
- "properties": {
26
- "type": {
27
- "type": "string"
28
- },
29
- "username": {
30
- "type": "string"
31
- },
32
- "password": {
33
- "type": "string"
34
- },
35
- "host": {
36
- "type": "string"
37
- },
38
- "port": {
39
- "type": "number"
40
- }
41
- }
42
- }
43
- }
44
- }
45
- };