@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/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015 sockethub
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ErrorObject } from "ajv";
|
|
2
|
+
/**
|
|
3
|
+
* Traverses the errors array from ajv, and makes a series of filtering decisions to
|
|
4
|
+
* try to arrive at the most useful error.
|
|
5
|
+
* @param msg
|
|
6
|
+
* @param errors
|
|
7
|
+
* @returns {string}
|
|
8
|
+
*/
|
|
9
|
+
export default function getErrorMessage(msg: any, errors: Array<ErrorObject>): string;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const objects_1 = require("./objects");
|
|
4
|
+
function parseMsg(error) {
|
|
5
|
+
let err = `${error.instancePath ? error.instancePath : 'activity stream'}: ${error.message}`;
|
|
6
|
+
if (error.keyword === 'additionalProperties') {
|
|
7
|
+
err += `: ${error.params.additionalProperty}`;
|
|
8
|
+
}
|
|
9
|
+
else if (error.keyword === 'enum') {
|
|
10
|
+
err += `: ${error.params.allowedValues.join(', ')}`;
|
|
11
|
+
}
|
|
12
|
+
return err;
|
|
13
|
+
}
|
|
14
|
+
function getTypeList(msg) {
|
|
15
|
+
let types = [];
|
|
16
|
+
if ((typeof msg === 'object') && (msg.type)) {
|
|
17
|
+
types.push(msg.type);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
types.push(undefined);
|
|
21
|
+
}
|
|
22
|
+
for (let prop in msg) {
|
|
23
|
+
if ((typeof msg[prop] === 'object') && (msg[prop].type)) {
|
|
24
|
+
types = [...types, ...getTypeList(msg[prop])];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return types;
|
|
28
|
+
}
|
|
29
|
+
function getSchemaType(error) {
|
|
30
|
+
const schemaTypeRes = error.schemaPath.match(/#\/\w+\/\w+\/([\w-]+)\//);
|
|
31
|
+
return schemaTypeRes ? schemaTypeRes[1] : undefined;
|
|
32
|
+
}
|
|
33
|
+
function getErrType(error) {
|
|
34
|
+
const errTypeRes = error.instancePath.match(/\/([\w]+)/);
|
|
35
|
+
return errTypeRes ? errTypeRes[1] : undefined;
|
|
36
|
+
}
|
|
37
|
+
function getPartsCount(error, types) {
|
|
38
|
+
const schemaType = getSchemaType(error);
|
|
39
|
+
const errType = getErrType(error);
|
|
40
|
+
if (!errType) {
|
|
41
|
+
return -1;
|
|
42
|
+
}
|
|
43
|
+
if (!types[errType].includes(schemaType)) {
|
|
44
|
+
return -1;
|
|
45
|
+
}
|
|
46
|
+
const parts = error.instancePath.split('/');
|
|
47
|
+
return parts.length;
|
|
48
|
+
}
|
|
49
|
+
function getTypes(msg) {
|
|
50
|
+
return {
|
|
51
|
+
actor: getTypeList(msg.actor),
|
|
52
|
+
target: getTypeList(msg.target),
|
|
53
|
+
object: getTypeList(msg.context ? msg.object : msg)
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Traverses the errors array from ajv, and makes a series of filtering decisions to
|
|
58
|
+
* try to arrive at the most useful error.
|
|
59
|
+
* @param msg
|
|
60
|
+
* @param errors
|
|
61
|
+
* @returns {string}
|
|
62
|
+
*/
|
|
63
|
+
function getErrorMessage(msg, errors) {
|
|
64
|
+
const types = getTypes(msg);
|
|
65
|
+
let deepest_entry = 0, highest_depth = -1;
|
|
66
|
+
for (let i = 0; i < errors.length; i++) {
|
|
67
|
+
const partsCount = getPartsCount(errors[i], types);
|
|
68
|
+
if (partsCount > highest_depth) {
|
|
69
|
+
highest_depth = partsCount;
|
|
70
|
+
deepest_entry = i;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return highest_depth >= 0 ?
|
|
74
|
+
parseMsg(errors[deepest_entry]) :
|
|
75
|
+
composeFinalError(errors[errors.length - 1]);
|
|
76
|
+
}
|
|
77
|
+
exports.default = getErrorMessage;
|
|
78
|
+
function composeFinalError(error) {
|
|
79
|
+
// if we have yet to build an error message, assume this is an invalid type value (oneOf),
|
|
80
|
+
// try to build a list of valid types
|
|
81
|
+
let msg = "";
|
|
82
|
+
if (error.keyword === 'oneOf') {
|
|
83
|
+
msg = `${error.instancePath}: ${error.message}: ` +
|
|
84
|
+
`${objects_1.ObjectTypesList.join(', ')}`;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
msg = `${error.instancePath ?
|
|
88
|
+
error.instancePath : 'activity stream'}: ${error.message}`;
|
|
89
|
+
}
|
|
90
|
+
return msg;
|
|
91
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
export declare const validObjectRefs: any[];
|
|
2
|
+
export declare const validObjectDefs: {};
|
|
3
|
+
export declare const ObjectTypesSchema: {
|
|
4
|
+
credentials: {
|
|
5
|
+
required: string[];
|
|
6
|
+
additionalProperties: boolean;
|
|
7
|
+
properties: {
|
|
8
|
+
type: {
|
|
9
|
+
enum: string[];
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
feed: {
|
|
14
|
+
required: string[];
|
|
15
|
+
additionalProperties: boolean;
|
|
16
|
+
properties: {
|
|
17
|
+
type: {
|
|
18
|
+
enum: string[];
|
|
19
|
+
};
|
|
20
|
+
id: {
|
|
21
|
+
type: string;
|
|
22
|
+
format: string;
|
|
23
|
+
};
|
|
24
|
+
name: {
|
|
25
|
+
type: string;
|
|
26
|
+
};
|
|
27
|
+
description: {
|
|
28
|
+
type: string;
|
|
29
|
+
};
|
|
30
|
+
author: {
|
|
31
|
+
type: string;
|
|
32
|
+
};
|
|
33
|
+
favicon: {
|
|
34
|
+
type: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
message: {
|
|
39
|
+
required: string[];
|
|
40
|
+
additionalProperties: boolean;
|
|
41
|
+
properties: {
|
|
42
|
+
type: {
|
|
43
|
+
enum: string[];
|
|
44
|
+
};
|
|
45
|
+
id: {
|
|
46
|
+
type: string;
|
|
47
|
+
};
|
|
48
|
+
name: {
|
|
49
|
+
type: string;
|
|
50
|
+
};
|
|
51
|
+
content: {
|
|
52
|
+
type: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
me: {
|
|
57
|
+
required: string[];
|
|
58
|
+
additionalProperties: boolean;
|
|
59
|
+
properties: {
|
|
60
|
+
type: {
|
|
61
|
+
enum: string[];
|
|
62
|
+
};
|
|
63
|
+
content: {
|
|
64
|
+
type: string;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
person: {
|
|
69
|
+
required: string[];
|
|
70
|
+
additionalProperties: boolean;
|
|
71
|
+
properties: {
|
|
72
|
+
id: {
|
|
73
|
+
type: string;
|
|
74
|
+
};
|
|
75
|
+
type: {
|
|
76
|
+
enum: string[];
|
|
77
|
+
};
|
|
78
|
+
name: {
|
|
79
|
+
type: string;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
room: {
|
|
84
|
+
required: string[];
|
|
85
|
+
additionalProperties: boolean;
|
|
86
|
+
properties: {
|
|
87
|
+
id: {
|
|
88
|
+
type: string;
|
|
89
|
+
};
|
|
90
|
+
type: {
|
|
91
|
+
enum: string[];
|
|
92
|
+
};
|
|
93
|
+
name: {
|
|
94
|
+
type: string;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
service: {
|
|
99
|
+
required: string[];
|
|
100
|
+
additionalProperties: boolean;
|
|
101
|
+
properties: {
|
|
102
|
+
id: {
|
|
103
|
+
type: string;
|
|
104
|
+
};
|
|
105
|
+
type: {
|
|
106
|
+
enum: string[];
|
|
107
|
+
};
|
|
108
|
+
name: {
|
|
109
|
+
type: string;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
website: {
|
|
114
|
+
required: string[];
|
|
115
|
+
additionalProperties: boolean;
|
|
116
|
+
properties: {
|
|
117
|
+
id: {
|
|
118
|
+
type: string;
|
|
119
|
+
format: string;
|
|
120
|
+
};
|
|
121
|
+
type: {
|
|
122
|
+
enum: string[];
|
|
123
|
+
};
|
|
124
|
+
name: {
|
|
125
|
+
type: string;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
attendance: {
|
|
130
|
+
required: string[];
|
|
131
|
+
additionalProperties: boolean;
|
|
132
|
+
properties: {
|
|
133
|
+
type: {
|
|
134
|
+
enum: string[];
|
|
135
|
+
};
|
|
136
|
+
members: {
|
|
137
|
+
type: string;
|
|
138
|
+
items: {
|
|
139
|
+
type: string;
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
presence: {
|
|
145
|
+
required: string[];
|
|
146
|
+
additionalProperties: boolean;
|
|
147
|
+
properties: {
|
|
148
|
+
type: {
|
|
149
|
+
enum: string[];
|
|
150
|
+
};
|
|
151
|
+
presence: {
|
|
152
|
+
enum: string[];
|
|
153
|
+
};
|
|
154
|
+
role: {
|
|
155
|
+
enum: string[];
|
|
156
|
+
};
|
|
157
|
+
content: {
|
|
158
|
+
type: string;
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
relationship: {
|
|
163
|
+
required: string[];
|
|
164
|
+
additionalProperties: boolean;
|
|
165
|
+
properties: {
|
|
166
|
+
type: {
|
|
167
|
+
enum: string[];
|
|
168
|
+
};
|
|
169
|
+
relationship: {
|
|
170
|
+
enum: string[];
|
|
171
|
+
};
|
|
172
|
+
subject: {
|
|
173
|
+
type: string;
|
|
174
|
+
oneOf: {
|
|
175
|
+
$ref: string;
|
|
176
|
+
}[];
|
|
177
|
+
};
|
|
178
|
+
object: {
|
|
179
|
+
type: string;
|
|
180
|
+
oneOf: any[];
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
topic: {
|
|
185
|
+
required: string[];
|
|
186
|
+
additionalProperties: boolean;
|
|
187
|
+
properties: {
|
|
188
|
+
type: {
|
|
189
|
+
enum: string[];
|
|
190
|
+
};
|
|
191
|
+
content: {
|
|
192
|
+
type: string;
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
address: {
|
|
197
|
+
required: string[];
|
|
198
|
+
additionalProperties: boolean;
|
|
199
|
+
properties: {
|
|
200
|
+
type: {
|
|
201
|
+
enum: string[];
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
export declare const ObjectTypesList: string[];
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ObjectTypesList = exports.ObjectTypesSchema = exports.validObjectDefs = exports.validObjectRefs = void 0;
|
|
4
|
+
exports.validObjectRefs = [];
|
|
5
|
+
exports.validObjectDefs = {};
|
|
6
|
+
exports.ObjectTypesSchema = {
|
|
7
|
+
"credentials": {
|
|
8
|
+
"required": ["type"],
|
|
9
|
+
"additionalProperties": true,
|
|
10
|
+
"properties": {
|
|
11
|
+
"type": {
|
|
12
|
+
"enum": ["credentials"]
|
|
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
|
+
"message": {
|
|
42
|
+
"required": ["type", "content"],
|
|
43
|
+
"additionalProperties": true,
|
|
44
|
+
"properties": {
|
|
45
|
+
"type": {
|
|
46
|
+
"enum": ["message"]
|
|
47
|
+
},
|
|
48
|
+
"id": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
},
|
|
51
|
+
"name": {
|
|
52
|
+
"type": "string"
|
|
53
|
+
},
|
|
54
|
+
"content": {
|
|
55
|
+
"type": "string"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"me": {
|
|
60
|
+
"required": ["type", "content"],
|
|
61
|
+
"additionalProperties": true,
|
|
62
|
+
"properties": {
|
|
63
|
+
"type": {
|
|
64
|
+
"enum": ["me"]
|
|
65
|
+
},
|
|
66
|
+
"content": {
|
|
67
|
+
"type": "string"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"person": {
|
|
72
|
+
"required": ["id", "type"],
|
|
73
|
+
"additionalProperties": true,
|
|
74
|
+
"properties": {
|
|
75
|
+
"id": {
|
|
76
|
+
"type": "string"
|
|
77
|
+
},
|
|
78
|
+
"type": {
|
|
79
|
+
"enum": ["person"]
|
|
80
|
+
},
|
|
81
|
+
"name": {
|
|
82
|
+
"type": "string"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"room": {
|
|
87
|
+
"required": ["id", "type"],
|
|
88
|
+
"additionalProperties": true,
|
|
89
|
+
"properties": {
|
|
90
|
+
"id": {
|
|
91
|
+
"type": "string"
|
|
92
|
+
},
|
|
93
|
+
"type": {
|
|
94
|
+
"enum": ["room"]
|
|
95
|
+
},
|
|
96
|
+
"name": {
|
|
97
|
+
"type": "string"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"service": {
|
|
102
|
+
"required": ["id", "type"],
|
|
103
|
+
"additionalProperties": true,
|
|
104
|
+
"properties": {
|
|
105
|
+
"id": {
|
|
106
|
+
"type": "string"
|
|
107
|
+
},
|
|
108
|
+
"type": {
|
|
109
|
+
"enum": ["service"]
|
|
110
|
+
},
|
|
111
|
+
"name": {
|
|
112
|
+
"type": "string"
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"website": {
|
|
117
|
+
"required": ["id", "type"],
|
|
118
|
+
"additionalProperties": true,
|
|
119
|
+
"properties": {
|
|
120
|
+
"id": {
|
|
121
|
+
"type": "string",
|
|
122
|
+
"format": "iri"
|
|
123
|
+
},
|
|
124
|
+
"type": {
|
|
125
|
+
"enum": ["website"]
|
|
126
|
+
},
|
|
127
|
+
"name": {
|
|
128
|
+
"type": "string"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"attendance": {
|
|
133
|
+
"required": ["type"],
|
|
134
|
+
"additionalProperties": false,
|
|
135
|
+
"properties": {
|
|
136
|
+
"type": {
|
|
137
|
+
"enum": ["attendance"]
|
|
138
|
+
},
|
|
139
|
+
"members": {
|
|
140
|
+
"type": "array",
|
|
141
|
+
"items": {
|
|
142
|
+
"type": "string"
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
"presence": {
|
|
148
|
+
"required": ["type"],
|
|
149
|
+
"additionalProperties": false,
|
|
150
|
+
"properties": {
|
|
151
|
+
"type": {
|
|
152
|
+
"enum": ["presence"]
|
|
153
|
+
},
|
|
154
|
+
"presence": {
|
|
155
|
+
"enum": ["away", "chat", "dnd", "xa", "offline", "online"]
|
|
156
|
+
},
|
|
157
|
+
"role": {
|
|
158
|
+
"enum": ["owner", "member", "participant", "admin"]
|
|
159
|
+
},
|
|
160
|
+
"content": {
|
|
161
|
+
"type": "string"
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
// inspired by https://www.w3.org/ns/activitystreams#Relationship
|
|
166
|
+
"relationship": {
|
|
167
|
+
"required": ["type", "relationship"],
|
|
168
|
+
"additionalProperties": false,
|
|
169
|
+
"properties": {
|
|
170
|
+
"type": {
|
|
171
|
+
"enum": ["relationship"]
|
|
172
|
+
},
|
|
173
|
+
"relationship": {
|
|
174
|
+
"enum": ["role"]
|
|
175
|
+
},
|
|
176
|
+
"subject": {
|
|
177
|
+
"type": "object",
|
|
178
|
+
"oneOf": [
|
|
179
|
+
{ "$ref": "#/definitions/type/presence" }
|
|
180
|
+
]
|
|
181
|
+
},
|
|
182
|
+
"object": {
|
|
183
|
+
"type": "object",
|
|
184
|
+
"oneOf": exports.validObjectRefs,
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
"topic": {
|
|
189
|
+
"required": ["type"],
|
|
190
|
+
"additionalProperties": false,
|
|
191
|
+
"properties": {
|
|
192
|
+
"type": {
|
|
193
|
+
"enum": ["topic"]
|
|
194
|
+
},
|
|
195
|
+
"content": {
|
|
196
|
+
"type": "string"
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
"address": {
|
|
201
|
+
"required": ["type"],
|
|
202
|
+
"additionalProperties": false,
|
|
203
|
+
"properties": {
|
|
204
|
+
"type": {
|
|
205
|
+
"enum": ["address"]
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
exports.ObjectTypesList = Object.keys(exports.ObjectTypesSchema);
|
|
211
|
+
exports.ObjectTypesList.forEach(function (type, i) {
|
|
212
|
+
if (type === 'credentials') {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
exports.validObjectRefs.push({ "$ref": "#/definitions/type/" + type });
|
|
216
|
+
exports.validObjectDefs[type] = exports.ObjectTypesSchema[type];
|
|
217
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { addPlatformSchema, validateActivityObject, validateActivityStream, validateCredentials, validatePlatformSchema } from "./validator";
|
|
2
|
+
import { ObjectTypesList } from "./helpers/objects";
|
|
3
|
+
import ActivityObjectSchema from "./schemas/activity-object";
|
|
4
|
+
import ActivityStreamSchema from "./schemas/activity-stream";
|
|
5
|
+
import PlatformSchema from "./schemas/platform";
|
|
6
|
+
declare const _default: {
|
|
7
|
+
addPlatformSchema: typeof addPlatformSchema;
|
|
8
|
+
validatePlatformSchema: typeof validatePlatformSchema;
|
|
9
|
+
validateCredentials: typeof validateCredentials;
|
|
10
|
+
validateActivityStream: typeof validateActivityStream;
|
|
11
|
+
validateActivityObject: typeof validateActivityObject;
|
|
12
|
+
};
|
|
13
|
+
export default _default;
|
|
14
|
+
export { PlatformSchema, ActivityObjectSchema, ActivityStreamSchema, ObjectTypesList };
|
|
15
|
+
export { IActivityStream, IActivityObject } from "./types";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ObjectTypesList = exports.ActivityStreamSchema = exports.ActivityObjectSchema = exports.PlatformSchema = void 0;
|
|
7
|
+
const validator_1 = require("./validator");
|
|
8
|
+
const objects_1 = require("./helpers/objects");
|
|
9
|
+
Object.defineProperty(exports, "ObjectTypesList", { enumerable: true, get: function () { return objects_1.ObjectTypesList; } });
|
|
10
|
+
const activity_object_1 = __importDefault(require("./schemas/activity-object"));
|
|
11
|
+
exports.ActivityObjectSchema = activity_object_1.default;
|
|
12
|
+
const activity_stream_1 = __importDefault(require("./schemas/activity-stream"));
|
|
13
|
+
exports.ActivityStreamSchema = activity_stream_1.default;
|
|
14
|
+
const platform_1 = __importDefault(require("./schemas/platform"));
|
|
15
|
+
exports.PlatformSchema = platform_1.default;
|
|
16
|
+
exports.default = {
|
|
17
|
+
addPlatformSchema: validator_1.addPlatformSchema,
|
|
18
|
+
validatePlatformSchema: validator_1.validatePlatformSchema,
|
|
19
|
+
validateCredentials: validator_1.validateCredentials,
|
|
20
|
+
validateActivityStream: validator_1.validateActivityStream,
|
|
21
|
+
validateActivityObject: validator_1.validateActivityObject,
|
|
22
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
declare const _default: ((string | boolean | {
|
|
2
|
+
type: string;
|
|
3
|
+
object: {
|
|
4
|
+
type: string;
|
|
5
|
+
};
|
|
6
|
+
})[] | (string | boolean | {
|
|
7
|
+
context: string;
|
|
8
|
+
object: {
|
|
9
|
+
type: string;
|
|
10
|
+
};
|
|
11
|
+
})[] | (string | boolean | {
|
|
12
|
+
context: string;
|
|
13
|
+
type: string;
|
|
14
|
+
object: {
|
|
15
|
+
type: string;
|
|
16
|
+
user: string;
|
|
17
|
+
pass: string;
|
|
18
|
+
};
|
|
19
|
+
})[] | (string | boolean | {
|
|
20
|
+
context: string;
|
|
21
|
+
type: string;
|
|
22
|
+
object: {
|
|
23
|
+
type: string;
|
|
24
|
+
username: string;
|
|
25
|
+
password: string;
|
|
26
|
+
};
|
|
27
|
+
})[] | (string | boolean | {
|
|
28
|
+
context: string;
|
|
29
|
+
type: string;
|
|
30
|
+
object: {
|
|
31
|
+
type: string;
|
|
32
|
+
username: string;
|
|
33
|
+
password: string;
|
|
34
|
+
host: string;
|
|
35
|
+
};
|
|
36
|
+
})[])[];
|
|
37
|
+
export default _default;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = [
|
|
4
|
+
[
|
|
5
|
+
'credentials with no context',
|
|
6
|
+
{
|
|
7
|
+
type: 'credentials',
|
|
8
|
+
object: {
|
|
9
|
+
type: 'credentials'
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
false,
|
|
13
|
+
`credential activity streams must have a context set`
|
|
14
|
+
],
|
|
15
|
+
[
|
|
16
|
+
'credentials with no type',
|
|
17
|
+
{
|
|
18
|
+
context: 'test-platform',
|
|
19
|
+
object: {
|
|
20
|
+
type: 'credentials'
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
false,
|
|
24
|
+
`credential activity streams must have credentials set as type`
|
|
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
|
+
'credentials with props',
|
|
42
|
+
{
|
|
43
|
+
context: 'test-platform',
|
|
44
|
+
type: 'credentials',
|
|
45
|
+
object: {
|
|
46
|
+
type: 'credentials',
|
|
47
|
+
username: "foo",
|
|
48
|
+
password: "bar"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
false,
|
|
52
|
+
`/object: must have required property 'host'`
|
|
53
|
+
],
|
|
54
|
+
[
|
|
55
|
+
'credentials with props',
|
|
56
|
+
{
|
|
57
|
+
context: 'test-platform',
|
|
58
|
+
type: 'credentials',
|
|
59
|
+
object: {
|
|
60
|
+
type: 'credentials',
|
|
61
|
+
username: "foo",
|
|
62
|
+
password: "bar",
|
|
63
|
+
host: 'yarg'
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
true,
|
|
67
|
+
""
|
|
68
|
+
],
|
|
69
|
+
];
|