@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.
Files changed (43) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +11 -0
  3. package/dist/helpers/error-parser.d.ts +9 -0
  4. package/dist/helpers/error-parser.js +91 -0
  5. package/dist/helpers/objects.d.ts +206 -0
  6. package/dist/helpers/objects.js +217 -0
  7. package/dist/index.d.ts +15 -0
  8. package/dist/index.js +22 -0
  9. package/dist/index.test.data.credentials.d.ts +37 -0
  10. package/dist/index.test.data.credentials.js +69 -0
  11. package/dist/index.test.data.objects.d.ts +50 -0
  12. package/dist/index.test.data.objects.js +214 -0
  13. package/dist/index.test.data.platform.d.ts +44 -0
  14. package/dist/index.test.data.platform.js +47 -0
  15. package/dist/index.test.data.streams.d.ts +256 -0
  16. package/dist/index.test.data.streams.js +449 -0
  17. package/dist/schemas/activity-object.d.ts +16 -0
  18. package/dist/schemas/activity-object.js +18 -0
  19. package/dist/schemas/activity-stream.d.ts +235 -0
  20. package/dist/schemas/activity-stream.js +49 -0
  21. package/dist/schemas/json/activity-object.json +356 -0
  22. package/dist/schemas/json/activity-stream.json +465 -0
  23. package/dist/schemas/json/platform.json +27 -0
  24. package/dist/schemas/platform.d.ts +41 -0
  25. package/dist/schemas/platform.js +44 -0
  26. package/dist/types.d.ts +20 -0
  27. package/dist/types.js +2 -0
  28. package/dist/validator.d.ts +8 -0
  29. package/dist/validator.js +78 -0
  30. package/package.json +58 -0
  31. package/src/helpers/error-parser.ts +99 -0
  32. package/src/helpers/objects.ts +230 -0
  33. package/src/index.test.data.credentials.ts +71 -0
  34. package/src/index.test.data.objects.ts +235 -0
  35. package/src/index.test.data.platform.ts +45 -0
  36. package/src/index.test.data.streams.ts +470 -0
  37. package/src/index.test.ts +84 -0
  38. package/src/index.ts +26 -0
  39. package/src/schemas/activity-object.ts +19 -0
  40. package/src/schemas/activity-stream.ts +51 -0
  41. package/src/schemas/platform.ts +47 -0
  42. package/src/types.ts +23 -0
  43. package/src/validator.ts +79 -0
@@ -0,0 +1,49 @@
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
+ const activity_object_1 = __importDefault(require("./activity-object"));
7
+ const objects_1 = require("../helpers/objects");
8
+ const validActorRefs = activity_object_1.default.properties.object.oneOf;
9
+ const validTargetRefs = activity_object_1.default.properties.object.oneOf;
10
+ // eslint-disable-next-line security-node/detect-crlf
11
+ console.log(validActorRefs);
12
+ let validObjectRefs = [];
13
+ objects_1.ObjectTypesList.forEach(function (type, i) {
14
+ validObjectRefs.push({ "$ref": "#/definitions/type/" + type });
15
+ });
16
+ const contextSchema = {
17
+ "type": "string"
18
+ };
19
+ const typeSchema = {
20
+ "type": "string"
21
+ };
22
+ exports.default = {
23
+ "$id": "https://sockethub.org/schemas/v0/activity-stream#",
24
+ "description": "Schema for Sockethub Activity Streams",
25
+ "type": "object",
26
+ "required": ["context", "type", "actor"],
27
+ "properties": {
28
+ "id": {
29
+ "type": "string"
30
+ },
31
+ "type": typeSchema,
32
+ "context": contextSchema,
33
+ "actor": {
34
+ "type": "object",
35
+ "oneOf": validActorRefs
36
+ },
37
+ "target": {
38
+ "type": "object",
39
+ "oneOf": validTargetRefs
40
+ },
41
+ "object": {
42
+ "type": "object",
43
+ "oneOf": validObjectRefs
44
+ }
45
+ },
46
+ "definitions": {
47
+ "type": objects_1.ObjectTypesSchema
48
+ }
49
+ };
@@ -0,0 +1,356 @@
1
+ {
2
+ "$id": "https://sockethub.org/schemas/v0/activity-object#",
3
+ "description": "Schema for Sockethub Activity Objects",
4
+ "type": "object",
5
+ "required": [
6
+ "object"
7
+ ],
8
+ "properties": {
9
+ "object": {
10
+ "type": "object",
11
+ "oneOf": [
12
+ {
13
+ "$ref": "#/definitions/type/feed"
14
+ },
15
+ {
16
+ "$ref": "#/definitions/type/message"
17
+ },
18
+ {
19
+ "$ref": "#/definitions/type/me"
20
+ },
21
+ {
22
+ "$ref": "#/definitions/type/person"
23
+ },
24
+ {
25
+ "$ref": "#/definitions/type/room"
26
+ },
27
+ {
28
+ "$ref": "#/definitions/type/service"
29
+ },
30
+ {
31
+ "$ref": "#/definitions/type/website"
32
+ },
33
+ {
34
+ "$ref": "#/definitions/type/attendance"
35
+ },
36
+ {
37
+ "$ref": "#/definitions/type/presence"
38
+ },
39
+ {
40
+ "$ref": "#/definitions/type/relationship"
41
+ },
42
+ {
43
+ "$ref": "#/definitions/type/topic"
44
+ },
45
+ {
46
+ "$ref": "#/definitions/type/address"
47
+ }
48
+ ]
49
+ }
50
+ },
51
+ "definitions": {
52
+ "type": {
53
+ "feed": {
54
+ "required": [
55
+ "id",
56
+ "type"
57
+ ],
58
+ "additionalProperties": true,
59
+ "properties": {
60
+ "type": {
61
+ "enum": [
62
+ "feed"
63
+ ]
64
+ },
65
+ "id": {
66
+ "type": "string",
67
+ "format": "iri"
68
+ },
69
+ "name": {
70
+ "type": "string"
71
+ },
72
+ "description": {
73
+ "type": "string"
74
+ },
75
+ "author": {
76
+ "type": "string"
77
+ },
78
+ "favicon": {
79
+ "type": "string"
80
+ }
81
+ }
82
+ },
83
+ "message": {
84
+ "required": [
85
+ "type",
86
+ "content"
87
+ ],
88
+ "additionalProperties": true,
89
+ "properties": {
90
+ "type": {
91
+ "enum": [
92
+ "message"
93
+ ]
94
+ },
95
+ "id": {
96
+ "type": "string"
97
+ },
98
+ "name": {
99
+ "type": "string"
100
+ },
101
+ "content": {
102
+ "type": "string"
103
+ }
104
+ }
105
+ },
106
+ "me": {
107
+ "required": [
108
+ "type",
109
+ "content"
110
+ ],
111
+ "additionalProperties": true,
112
+ "properties": {
113
+ "type": {
114
+ "enum": [
115
+ "me"
116
+ ]
117
+ },
118
+ "content": {
119
+ "type": "string"
120
+ }
121
+ }
122
+ },
123
+ "person": {
124
+ "required": [
125
+ "id",
126
+ "type"
127
+ ],
128
+ "additionalProperties": true,
129
+ "properties": {
130
+ "id": {
131
+ "type": "string"
132
+ },
133
+ "type": {
134
+ "enum": [
135
+ "person"
136
+ ]
137
+ },
138
+ "name": {
139
+ "type": "string"
140
+ }
141
+ }
142
+ },
143
+ "room": {
144
+ "required": [
145
+ "id",
146
+ "type"
147
+ ],
148
+ "additionalProperties": true,
149
+ "properties": {
150
+ "id": {
151
+ "type": "string"
152
+ },
153
+ "type": {
154
+ "enum": [
155
+ "room"
156
+ ]
157
+ },
158
+ "name": {
159
+ "type": "string"
160
+ }
161
+ }
162
+ },
163
+ "service": {
164
+ "required": [
165
+ "id",
166
+ "type"
167
+ ],
168
+ "additionalProperties": true,
169
+ "properties": {
170
+ "id": {
171
+ "type": "string"
172
+ },
173
+ "type": {
174
+ "enum": [
175
+ "service"
176
+ ]
177
+ },
178
+ "name": {
179
+ "type": "string"
180
+ }
181
+ }
182
+ },
183
+ "website": {
184
+ "required": [
185
+ "id",
186
+ "type"
187
+ ],
188
+ "additionalProperties": true,
189
+ "properties": {
190
+ "id": {
191
+ "type": "string",
192
+ "format": "iri"
193
+ },
194
+ "type": {
195
+ "enum": [
196
+ "website"
197
+ ]
198
+ },
199
+ "name": {
200
+ "type": "string"
201
+ }
202
+ }
203
+ },
204
+ "attendance": {
205
+ "required": [
206
+ "type"
207
+ ],
208
+ "additionalProperties": false,
209
+ "properties": {
210
+ "type": {
211
+ "enum": [
212
+ "attendance"
213
+ ]
214
+ },
215
+ "members": {
216
+ "type": "array",
217
+ "items": {
218
+ "type": "string"
219
+ }
220
+ }
221
+ }
222
+ },
223
+ "presence": {
224
+ "required": [
225
+ "type"
226
+ ],
227
+ "additionalProperties": false,
228
+ "properties": {
229
+ "type": {
230
+ "enum": [
231
+ "presence"
232
+ ]
233
+ },
234
+ "presence": {
235
+ "enum": [
236
+ "away",
237
+ "chat",
238
+ "dnd",
239
+ "xa",
240
+ "offline",
241
+ "online"
242
+ ]
243
+ },
244
+ "role": {
245
+ "enum": [
246
+ "owner",
247
+ "member",
248
+ "participant",
249
+ "admin"
250
+ ]
251
+ },
252
+ "content": {
253
+ "type": "string"
254
+ }
255
+ }
256
+ },
257
+ "relationship": {
258
+ "required": [
259
+ "type",
260
+ "relationship"
261
+ ],
262
+ "additionalProperties": false,
263
+ "properties": {
264
+ "type": {
265
+ "enum": [
266
+ "relationship"
267
+ ]
268
+ },
269
+ "relationship": {
270
+ "enum": [
271
+ "role"
272
+ ]
273
+ },
274
+ "subject": {
275
+ "type": "object",
276
+ "oneOf": [
277
+ {
278
+ "$ref": "#/definitions/type/presence"
279
+ }
280
+ ]
281
+ },
282
+ "object": {
283
+ "type": "object",
284
+ "oneOf": [
285
+ {
286
+ "$ref": "#/definitions/type/feed"
287
+ },
288
+ {
289
+ "$ref": "#/definitions/type/message"
290
+ },
291
+ {
292
+ "$ref": "#/definitions/type/me"
293
+ },
294
+ {
295
+ "$ref": "#/definitions/type/person"
296
+ },
297
+ {
298
+ "$ref": "#/definitions/type/room"
299
+ },
300
+ {
301
+ "$ref": "#/definitions/type/service"
302
+ },
303
+ {
304
+ "$ref": "#/definitions/type/website"
305
+ },
306
+ {
307
+ "$ref": "#/definitions/type/attendance"
308
+ },
309
+ {
310
+ "$ref": "#/definitions/type/presence"
311
+ },
312
+ {
313
+ "$ref": "#/definitions/type/relationship"
314
+ },
315
+ {
316
+ "$ref": "#/definitions/type/topic"
317
+ },
318
+ {
319
+ "$ref": "#/definitions/type/address"
320
+ }
321
+ ]
322
+ }
323
+ }
324
+ },
325
+ "topic": {
326
+ "required": [
327
+ "type"
328
+ ],
329
+ "additionalProperties": false,
330
+ "properties": {
331
+ "type": {
332
+ "enum": [
333
+ "topic"
334
+ ]
335
+ },
336
+ "content": {
337
+ "type": "string"
338
+ }
339
+ }
340
+ },
341
+ "address": {
342
+ "required": [
343
+ "type"
344
+ ],
345
+ "additionalProperties": false,
346
+ "properties": {
347
+ "type": {
348
+ "enum": [
349
+ "address"
350
+ ]
351
+ }
352
+ }
353
+ }
354
+ }
355
+ }
356
+ }