@sockethub/schemas 3.0.0-alpha.3
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.
- package/LICENSE +22 -0
- package/README.md +11 -0
- package/dist/helpers/error-parser.d.ts +9 -0
- package/dist/helpers/error-parser.js +91 -0
- package/dist/helpers/objects.d.ts +206 -0
- package/dist/helpers/objects.js +217 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +22 -0
- package/dist/index.test.data.credentials.d.ts +37 -0
- package/dist/index.test.data.credentials.js +69 -0
- package/dist/index.test.data.objects.d.ts +50 -0
- package/dist/index.test.data.objects.js +214 -0
- package/dist/index.test.data.platform.d.ts +44 -0
- package/dist/index.test.data.platform.js +47 -0
- package/dist/index.test.data.streams.d.ts +256 -0
- package/dist/index.test.data.streams.js +449 -0
- package/dist/schemas/activity-object.d.ts +16 -0
- package/dist/schemas/activity-object.js +18 -0
- package/dist/schemas/activity-stream.d.ts +235 -0
- package/dist/schemas/activity-stream.js +49 -0
- package/dist/schemas/json/activity-object.json +356 -0
- package/dist/schemas/json/activity-stream.json +465 -0
- package/dist/schemas/json/platform.json +27 -0
- package/dist/schemas/platform.d.ts +41 -0
- package/dist/schemas/platform.js +44 -0
- package/dist/types.d.ts +20 -0
- package/dist/types.js +2 -0
- package/dist/validator.d.ts +8 -0
- package/dist/validator.js +78 -0
- package/package.json +58 -0
- package/src/helpers/error-parser.ts +99 -0
- package/src/helpers/objects.ts +230 -0
- package/src/index.test.data.credentials.ts +71 -0
- package/src/index.test.data.objects.ts +235 -0
- package/src/index.test.data.platform.ts +45 -0
- package/src/index.test.data.streams.ts +470 -0
- package/src/index.test.ts +84 -0
- package/src/index.ts +26 -0
- package/src/schemas/activity-object.ts +19 -0
- package/src/schemas/activity-stream.ts +51 -0
- package/src/schemas/platform.ts +47 -0
- package/src/types.ts +23 -0
- package/src/validator.ts +79 -0
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sockethub/schemas",
|
|
3
|
+
"description": "JSON schema files for validating Sockethub Activity Streams",
|
|
4
|
+
"version": "3.0.0-alpha.3",
|
|
5
|
+
"private": false,
|
|
6
|
+
"author": "Nick Jennings <nick@silverbucket.net>",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"sockethub",
|
|
10
|
+
"sockethub schema",
|
|
11
|
+
"activity streams",
|
|
12
|
+
"activity objects",
|
|
13
|
+
"sockethub platforms"
|
|
14
|
+
],
|
|
15
|
+
"main": "dist/index.js",
|
|
16
|
+
"types": "dist/index.d.ts",
|
|
17
|
+
"files": [
|
|
18
|
+
"dist/",
|
|
19
|
+
"src/"
|
|
20
|
+
],
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/sockethub/sockethub.git",
|
|
24
|
+
"directory": "packages/schemas"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/sockethub/sockethub/tree/master/packages/schemas",
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/chai": "4.3.0",
|
|
29
|
+
"@types/debug": "4.1.7",
|
|
30
|
+
"@types/eslint": "8.4.1",
|
|
31
|
+
"@types/mocha": "9.1.0",
|
|
32
|
+
"@types/node": "17.0.13",
|
|
33
|
+
"@typescript-eslint/parser": "5.12.1",
|
|
34
|
+
"c8": "7.11.0",
|
|
35
|
+
"chai": "4.3.6",
|
|
36
|
+
"eslint": "8.9.0",
|
|
37
|
+
"eslint-cli": "1.1.1",
|
|
38
|
+
"mocha": "9.2.1",
|
|
39
|
+
"ts-node": "10.5.0",
|
|
40
|
+
"typescript": "4.5.5"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "npx rimraf dist && tsc && ./scripts/export-json-schema.js",
|
|
44
|
+
"clean": "npx rimraf coverage dist",
|
|
45
|
+
"clean:deps": "npx rimraf node_modules",
|
|
46
|
+
"compliance": "yarn test && yarn coverage",
|
|
47
|
+
"coverage": "c8 check-coverage --statements 95 --branches 95 --functions 95 --lines 95",
|
|
48
|
+
"lint": "eslint \"**/*.ts\"",
|
|
49
|
+
"lint:fix": "eslint --fix \"**/*.ts\"",
|
|
50
|
+
"test": "c8 mocha -r ts-node/register src/**/*.test.ts"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"ajv": "8.10.0",
|
|
54
|
+
"ajv-formats-draft2019": "1.6.1",
|
|
55
|
+
"debug": "^4.3.1"
|
|
56
|
+
},
|
|
57
|
+
"gitHead": "f02238a478b7ffd3f31d8deea292eb67e630a86b"
|
|
58
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import {ErrorObject} from "ajv";
|
|
2
|
+
import {ObjectTypesList} from "./objects";
|
|
3
|
+
import {IActivityStream, IActivityObject} from "../types";
|
|
4
|
+
|
|
5
|
+
interface TypeBreakdown {
|
|
6
|
+
actor: Array<string>,
|
|
7
|
+
object: Array<string>,
|
|
8
|
+
target: Array<string>
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function parseMsg(error: ErrorObject): string {
|
|
12
|
+
let err = `${error.instancePath ? error.instancePath : 'activity stream'}: ${error.message}`;
|
|
13
|
+
if (error.keyword === 'additionalProperties') {
|
|
14
|
+
err += `: ${error.params.additionalProperty}`;
|
|
15
|
+
} else if (error.keyword === 'enum') {
|
|
16
|
+
err += `: ${error.params.allowedValues.join(', ')}`;
|
|
17
|
+
}
|
|
18
|
+
return err;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function getTypeList(msg: IActivityStream | IActivityObject): Array<string> {
|
|
22
|
+
let types = [];
|
|
23
|
+
if ((typeof msg === 'object') && (msg.type)) {
|
|
24
|
+
types.push(msg.type);
|
|
25
|
+
} else {
|
|
26
|
+
types.push(undefined);
|
|
27
|
+
}
|
|
28
|
+
for (let prop in msg) {
|
|
29
|
+
if ((typeof msg[prop] === 'object') && (msg[prop].type)) {
|
|
30
|
+
types = [...types, ...getTypeList(msg[prop])];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return types;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function getSchemaType(error: ErrorObject): string {
|
|
37
|
+
const schemaTypeRes = error.schemaPath.match(/#\/\w+\/\w+\/([\w-]+)\//);
|
|
38
|
+
return schemaTypeRes ? schemaTypeRes[1] : undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function getErrType(error: ErrorObject): string {
|
|
42
|
+
const errTypeRes = error.instancePath.match(/\/([\w]+)/);
|
|
43
|
+
return errTypeRes ? errTypeRes[1] : undefined;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function getPartsCount(error: ErrorObject, types: TypeBreakdown): number {
|
|
47
|
+
const schemaType = getSchemaType(error);
|
|
48
|
+
const errType = getErrType(error);
|
|
49
|
+
if (!errType) { return -1; }
|
|
50
|
+
if (!types[errType].includes(schemaType)) { return -1; }
|
|
51
|
+
const parts = error.instancePath.split('/');
|
|
52
|
+
return parts.length;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function getTypes(msg: IActivityStream): TypeBreakdown {
|
|
56
|
+
return {
|
|
57
|
+
actor: getTypeList(msg.actor),
|
|
58
|
+
target: getTypeList(msg.target),
|
|
59
|
+
object: getTypeList(msg.context ? msg.object : msg)
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Traverses the errors array from ajv, and makes a series of filtering decisions to
|
|
65
|
+
* try to arrive at the most useful error.
|
|
66
|
+
* @param msg
|
|
67
|
+
* @param errors
|
|
68
|
+
* @returns {string}
|
|
69
|
+
*/
|
|
70
|
+
export default function getErrorMessage(msg, errors: Array<ErrorObject>): string {
|
|
71
|
+
const types = getTypes(msg);
|
|
72
|
+
let deepest_entry = 0, highest_depth = -1;
|
|
73
|
+
|
|
74
|
+
for (let i = 0; i < errors.length; i++) {
|
|
75
|
+
const partsCount = getPartsCount(errors[i], types);
|
|
76
|
+
if (partsCount > highest_depth) {
|
|
77
|
+
highest_depth = partsCount;
|
|
78
|
+
deepest_entry = i;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return highest_depth >= 0 ?
|
|
83
|
+
parseMsg(errors[deepest_entry]) :
|
|
84
|
+
composeFinalError(errors[errors.length - 1]);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function composeFinalError(error) {
|
|
88
|
+
// if we have yet to build an error message, assume this is an invalid type value (oneOf),
|
|
89
|
+
// try to build a list of valid types
|
|
90
|
+
let msg = "";
|
|
91
|
+
if (error.keyword === 'oneOf') {
|
|
92
|
+
msg = `${error.instancePath}: ${error.message}: ` +
|
|
93
|
+
`${ObjectTypesList.join(', ')}`;
|
|
94
|
+
} else {
|
|
95
|
+
msg = `${error.instancePath ?
|
|
96
|
+
error.instancePath : 'activity stream'}: ${error.message}`;
|
|
97
|
+
}
|
|
98
|
+
return msg;
|
|
99
|
+
}
|
|
@@ -0,0 +1,230 @@
|
|
|
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, i) {
|
|
225
|
+
if (type === 'credentials') {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
validObjectRefs.push({ "$ref": "#/definitions/type/" + type });
|
|
229
|
+
validObjectDefs[type] = ObjectTypesSchema[type];
|
|
230
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
];
|
|
@@ -0,0 +1,235 @@
|
|
|
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
|
+
];
|