@sockethub/schemas 3.0.0-alpha.10 → 3.0.0-alpha.12

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 (46) hide show
  1. package/dist/context.js +101 -0
  2. package/dist/context.js.map +10 -0
  3. package/dist/contexts/platform/dummy/v1.jsonld +8 -0
  4. package/dist/contexts/platform/error/v1.jsonld +8 -0
  5. package/dist/contexts/platform/feeds/v1.jsonld +8 -0
  6. package/dist/contexts/platform/irc/v1.jsonld +8 -0
  7. package/dist/contexts/platform/metadata/v1.jsonld +8 -0
  8. package/dist/contexts/platform/sockethub%3Ainternal/v1.jsonld +8 -0
  9. package/dist/contexts/platform/xmpp/v1.jsonld +8 -0
  10. package/dist/contexts/v1.jsonld +7 -0
  11. package/dist/index.js +533 -796
  12. package/dist/index.js.map +10 -15
  13. package/dist/maps/context-map.json +35 -0
  14. package/dist/schemas/platform/dummy/v1/credentials.schema.json +1 -0
  15. package/dist/schemas/platform/dummy/v1/messages.schema.json +22 -0
  16. package/dist/schemas/platform/error/v1/credentials.schema.json +1 -0
  17. package/dist/schemas/platform/error/v1/messages.schema.json +1 -0
  18. package/dist/schemas/platform/feeds/v1/credentials.schema.json +1 -0
  19. package/dist/schemas/platform/feeds/v1/messages.schema.json +36 -0
  20. package/dist/schemas/platform/irc/v1/credentials.schema.json +48 -0
  21. package/dist/schemas/platform/irc/v1/messages.schema.json +19 -0
  22. package/dist/schemas/platform/metadata/v1/credentials.schema.json +1 -0
  23. package/dist/schemas/platform/metadata/v1/messages.schema.json +29 -0
  24. package/dist/schemas/platform/sockethub%3Ainternal/v1/credentials.schema.json +1 -0
  25. package/dist/schemas/platform/sockethub%3Ainternal/v1/messages.schema.json +1 -0
  26. package/dist/schemas/platform/xmpp/v1/credentials.schema.json +43 -0
  27. package/dist/schemas/platform/xmpp/v1/messages.schema.json +21 -0
  28. package/package.json +15 -8
  29. package/src/context.ts +125 -0
  30. package/src/helpers/error-parser.ts +65 -18
  31. package/src/helpers/objects.ts +59 -3
  32. package/src/index.test.data.credentials.ts +37 -5
  33. package/src/index.test.data.platform.ts +3 -0
  34. package/src/index.test.data.streams.ts +117 -25
  35. package/src/index.test.ts +31 -3
  36. package/src/index.ts +30 -1
  37. package/src/schemas/activity-stream.ts +30 -9
  38. package/src/schemas/json/activity-object.json +50 -1
  39. package/src/schemas/json/activity-stream.json +77 -44
  40. package/src/schemas/json/platform.json +22 -2
  41. package/src/schemas/json/sockethub-config.json +120 -28
  42. package/src/schemas/platform.ts +25 -1
  43. package/src/schemas/sockethub-config.ts +94 -14
  44. package/src/types/ajv-formats-draft2019.d.ts +5 -0
  45. package/src/types.ts +29 -12
  46. package/src/validator.ts +138 -25
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://sockethub.org/schemas/3.0.0-alpha.10/activity-object.json",
2
+ "$id": "https://sockethub.org/schemas/3.0.0-alpha.12/activity-object.json",
3
3
  "description": "Schema for Sockethub Activity Objects",
4
4
  "type": "object",
5
5
  "required": [
@@ -27,6 +27,9 @@
27
27
  {
28
28
  "$ref": "#/definitions/type/service"
29
29
  },
30
+ {
31
+ "$ref": "#/definitions/type/platform"
32
+ },
30
33
  {
31
34
  "$ref": "#/definitions/type/website"
32
35
  },
@@ -44,6 +47,9 @@
44
47
  },
45
48
  {
46
49
  "$ref": "#/definitions/type/address"
50
+ },
51
+ {
52
+ "$ref": "#/definitions/type/heartbeat"
47
53
  }
48
54
  ]
49
55
  }
@@ -180,6 +186,26 @@
180
186
  }
181
187
  }
182
188
  },
189
+ "platform": {
190
+ "required": [
191
+ "id",
192
+ "type"
193
+ ],
194
+ "additionalProperties": true,
195
+ "properties": {
196
+ "id": {
197
+ "type": "string"
198
+ },
199
+ "type": {
200
+ "enum": [
201
+ "platform"
202
+ ]
203
+ },
204
+ "name": {
205
+ "type": "string"
206
+ }
207
+ }
208
+ },
183
209
  "website": {
184
210
  "required": [
185
211
  "id",
@@ -300,6 +326,9 @@
300
326
  {
301
327
  "$ref": "#/definitions/type/service"
302
328
  },
329
+ {
330
+ "$ref": "#/definitions/type/platform"
331
+ },
303
332
  {
304
333
  "$ref": "#/definitions/type/website"
305
334
  },
@@ -317,6 +346,9 @@
317
346
  },
318
347
  {
319
348
  "$ref": "#/definitions/type/address"
349
+ },
350
+ {
351
+ "$ref": "#/definitions/type/heartbeat"
320
352
  }
321
353
  ]
322
354
  }
@@ -350,6 +382,23 @@
350
382
  ]
351
383
  }
352
384
  }
385
+ },
386
+ "heartbeat": {
387
+ "required": [
388
+ "type",
389
+ "timestamp"
390
+ ],
391
+ "additionalProperties": false,
392
+ "properties": {
393
+ "type": {
394
+ "enum": [
395
+ "heartbeat"
396
+ ]
397
+ },
398
+ "timestamp": {
399
+ "type": "number"
400
+ }
401
+ }
353
402
  }
354
403
  }
355
404
  }
@@ -1,34 +1,42 @@
1
1
  {
2
- "$id": "https://sockethub.org/schemas/3.0.0-alpha.10/activity-stream.json",
2
+ "$id": "https://sockethub.org/schemas/3.0.0-alpha.12/activity-stream.json",
3
3
  "description": "Schema for Sockethub Activity Streams",
4
4
  "type": "object",
5
5
  "required": [
6
- "context",
6
+ "@context",
7
7
  "type",
8
8
  "actor"
9
9
  ],
10
10
  "properties": {
11
+ "@context": {
12
+ "type": "array",
13
+ "minItems": 3,
14
+ "maxItems": 3,
15
+ "items": {
16
+ "type": "string"
17
+ },
18
+ "allOf": [
19
+ {
20
+ "contains": {
21
+ "const": "https://www.w3.org/ns/activitystreams"
22
+ }
23
+ },
24
+ {
25
+ "contains": {
26
+ "const": "https://sockethub.org/ns/context/v1.jsonld"
27
+ }
28
+ }
29
+ ]
30
+ },
11
31
  "id": {
12
32
  "type": "string"
13
33
  },
14
34
  "type": {
15
35
  "type": "string"
16
36
  },
17
- "context": {
18
- "type": "string"
19
- },
20
37
  "actor": {
21
38
  "type": "object",
22
39
  "oneOf": [
23
- {
24
- "$ref": "#/definitions/type/feed"
25
- },
26
- {
27
- "$ref": "#/definitions/type/message"
28
- },
29
- {
30
- "$ref": "#/definitions/type/me"
31
- },
32
40
  {
33
41
  "$ref": "#/definitions/type/person"
34
42
  },
@@ -39,37 +47,19 @@
39
47
  "$ref": "#/definitions/type/service"
40
48
  },
41
49
  {
42
- "$ref": "#/definitions/type/website"
43
- },
44
- {
45
- "$ref": "#/definitions/type/attendance"
46
- },
47
- {
48
- "$ref": "#/definitions/type/presence"
49
- },
50
- {
51
- "$ref": "#/definitions/type/relationship"
50
+ "$ref": "#/definitions/type/feed"
52
51
  },
53
52
  {
54
- "$ref": "#/definitions/type/topic"
53
+ "$ref": "#/definitions/type/website"
55
54
  },
56
55
  {
57
- "$ref": "#/definitions/type/address"
56
+ "$ref": "#/definitions/type/platform"
58
57
  }
59
58
  ]
60
59
  },
61
60
  "target": {
62
61
  "type": "object",
63
62
  "oneOf": [
64
- {
65
- "$ref": "#/definitions/type/feed"
66
- },
67
- {
68
- "$ref": "#/definitions/type/message"
69
- },
70
- {
71
- "$ref": "#/definitions/type/me"
72
- },
73
63
  {
74
64
  "$ref": "#/definitions/type/person"
75
65
  },
@@ -80,19 +70,13 @@
80
70
  "$ref": "#/definitions/type/service"
81
71
  },
82
72
  {
83
- "$ref": "#/definitions/type/website"
84
- },
85
- {
86
- "$ref": "#/definitions/type/attendance"
87
- },
88
- {
89
- "$ref": "#/definitions/type/presence"
73
+ "$ref": "#/definitions/type/feed"
90
74
  },
91
75
  {
92
- "$ref": "#/definitions/type/relationship"
76
+ "$ref": "#/definitions/type/website"
93
77
  },
94
78
  {
95
- "$ref": "#/definitions/type/topic"
79
+ "$ref": "#/definitions/type/platform"
96
80
  },
97
81
  {
98
82
  "$ref": "#/definitions/type/address"
@@ -123,6 +107,9 @@
123
107
  {
124
108
  "$ref": "#/definitions/type/service"
125
109
  },
110
+ {
111
+ "$ref": "#/definitions/type/platform"
112
+ },
126
113
  {
127
114
  "$ref": "#/definitions/type/website"
128
115
  },
@@ -140,6 +127,9 @@
140
127
  },
141
128
  {
142
129
  "$ref": "#/definitions/type/address"
130
+ },
131
+ {
132
+ "$ref": "#/definitions/type/heartbeat"
143
133
  }
144
134
  ]
145
135
  },
@@ -293,6 +283,26 @@
293
283
  }
294
284
  }
295
285
  },
286
+ "platform": {
287
+ "required": [
288
+ "id",
289
+ "type"
290
+ ],
291
+ "additionalProperties": true,
292
+ "properties": {
293
+ "id": {
294
+ "type": "string"
295
+ },
296
+ "type": {
297
+ "enum": [
298
+ "platform"
299
+ ]
300
+ },
301
+ "name": {
302
+ "type": "string"
303
+ }
304
+ }
305
+ },
296
306
  "website": {
297
307
  "required": [
298
308
  "id",
@@ -413,6 +423,9 @@
413
423
  {
414
424
  "$ref": "#/definitions/type/service"
415
425
  },
426
+ {
427
+ "$ref": "#/definitions/type/platform"
428
+ },
416
429
  {
417
430
  "$ref": "#/definitions/type/website"
418
431
  },
@@ -430,6 +443,9 @@
430
443
  },
431
444
  {
432
445
  "$ref": "#/definitions/type/address"
446
+ },
447
+ {
448
+ "$ref": "#/definitions/type/heartbeat"
433
449
  }
434
450
  ]
435
451
  }
@@ -463,6 +479,23 @@
463
479
  ]
464
480
  }
465
481
  }
482
+ },
483
+ "heartbeat": {
484
+ "required": [
485
+ "type",
486
+ "timestamp"
487
+ ],
488
+ "additionalProperties": false,
489
+ "properties": {
490
+ "type": {
491
+ "enum": [
492
+ "heartbeat"
493
+ ]
494
+ },
495
+ "timestamp": {
496
+ "type": "number"
497
+ }
498
+ }
466
499
  }
467
500
  }
468
501
  }
@@ -1,13 +1,33 @@
1
1
  {
2
- "$id": "https://sockethub.org/schemas/3.0.0-alpha.10/platform.json",
2
+ "$id": "https://sockethub.org/schemas/3.0.0-alpha.12/platform.json",
3
3
  "type": "object",
4
4
  "required": [
5
5
  "name",
6
6
  "version",
7
- "messages"
7
+ "messages",
8
+ "contextUrl",
9
+ "contextVersion",
10
+ "schemaVersion"
8
11
  ],
9
12
  "additionalProperties": false,
10
13
  "properties": {
14
+ "contextUrl": {
15
+ "title": "contextUrl",
16
+ "type": "string",
17
+ "format": "uri"
18
+ },
19
+ "contextVersion": {
20
+ "title": "contextVersion",
21
+ "type": "string"
22
+ },
23
+ "schemaVersion": {
24
+ "title": "schemaVersion",
25
+ "type": "string"
26
+ },
27
+ "messageConstraints": {
28
+ "title": "messageConstraints",
29
+ "type": "object"
30
+ },
11
31
  "credentials": {
12
32
  "title": "credentials",
13
33
  "type": "object"
@@ -1,33 +1,55 @@
1
1
  {
2
- "$id": "https://sockethub.org/schemas/3.0.0-alpha.10/sockethub-config.json",
2
+ "$id": "https://sockethub.org/schemas/3.0.0-alpha.12/sockethub-config.json",
3
3
  "description": "Sockethub Config Schema",
4
4
  "type": "object",
5
5
  "required": [
6
6
  "platforms"
7
7
  ],
8
+ "additionalProperties": false,
8
9
  "properties": {
10
+ "$schema": {
11
+ "type": "string"
12
+ },
9
13
  "examples": {
14
+ "type": "boolean",
15
+ "default": true
16
+ },
17
+ "logging": {
10
18
  "type": "object",
19
+ "additionalProperties": false,
11
20
  "properties": {
12
- "enabled": {
13
- "type": "boolean",
14
- "default": false
21
+ "level": {
22
+ "type": "string",
23
+ "enum": [
24
+ "error",
25
+ "warn",
26
+ "info",
27
+ "debug"
28
+ ],
29
+ "default": "info"
15
30
  },
16
- "secret": {
31
+ "fileLevel": {
17
32
  "type": "string",
18
- "default": "1234567890"
33
+ "enum": [
34
+ "error",
35
+ "warn",
36
+ "info",
37
+ "debug"
38
+ ],
39
+ "default": "debug"
40
+ },
41
+ "file": {
42
+ "type": "string",
43
+ "default": "sockethub.log"
19
44
  }
20
- },
21
- "additionalProperties": false
22
- },
23
- "log_file": {
24
- "type": "string"
45
+ }
25
46
  },
26
47
  "packageConfig": {
27
48
  "type": "object",
28
49
  "properties": {
29
50
  "@sockethub/activity-streams": {
30
51
  "type": "object",
52
+ "additionalProperties": false,
31
53
  "properties": {
32
54
  "specialObjs": {
33
55
  "type": "array",
@@ -42,45 +64,44 @@
42
64
  "type": "boolean",
43
65
  "default": true
44
66
  }
45
- },
46
- "additionalProperties": false
67
+ }
47
68
  },
48
69
  "@sockethub/platform-dummy": {
49
70
  "type": "object",
71
+ "additionalProperties": false,
50
72
  "properties": {
51
73
  "greeting": {
52
74
  "type": "string",
53
75
  "default": "Hello"
54
76
  }
55
- },
56
- "additionalProperties": false
77
+ }
57
78
  },
58
79
  "@sockethub/platform-feeds": {
59
80
  "type": "object",
81
+ "additionalProperties": false,
60
82
  "properties": {
61
83
  "connectTimeoutMs": {
62
84
  "type": "number"
63
85
  }
64
- },
65
- "additionalProperties": false
86
+ }
66
87
  },
67
88
  "@sockethub/platform-irc": {
68
89
  "type": "object",
90
+ "additionalProperties": false,
69
91
  "properties": {
70
92
  "connectTimeoutMs": {
71
93
  "type": "number"
72
94
  }
73
- },
74
- "additionalProperties": false
95
+ }
75
96
  },
76
97
  "@sockethub/platform-xmpp": {
77
98
  "type": "object",
99
+ "additionalProperties": false,
78
100
  "properties": {
79
101
  "connectTimeoutMs": {
80
102
  "type": "number"
81
103
  }
82
- },
83
- "additionalProperties": false
104
+ }
84
105
  }
85
106
  }
86
107
  },
@@ -88,10 +109,18 @@
88
109
  "type": "array",
89
110
  "items": {
90
111
  "type": "string"
91
- }
112
+ },
113
+ "default": [
114
+ "@sockethub/platform-dummy",
115
+ "@sockethub/platform-feeds",
116
+ "@sockethub/platform-irc",
117
+ "@sockethub/platform-metadata",
118
+ "@sockethub/platform-xmpp"
119
+ ]
92
120
  },
93
121
  "public": {
94
122
  "type": "object",
123
+ "additionalProperties": false,
95
124
  "properties": {
96
125
  "protocol": {
97
126
  "type": "string",
@@ -109,21 +138,71 @@
109
138
  "type": "string",
110
139
  "default": "/"
111
140
  }
112
- },
113
- "additionalProperties": false
141
+ }
142
+ },
143
+ "rateLimiter": {
144
+ "type": "object",
145
+ "additionalProperties": false,
146
+ "properties": {
147
+ "windowMs": {
148
+ "type": "number",
149
+ "default": 1000
150
+ },
151
+ "maxRequests": {
152
+ "type": "number",
153
+ "default": 100
154
+ },
155
+ "blockDurationMs": {
156
+ "type": "number",
157
+ "default": 5000
158
+ }
159
+ }
114
160
  },
115
161
  "redis": {
116
162
  "type": "object",
163
+ "additionalProperties": false,
117
164
  "properties": {
118
165
  "url": {
119
166
  "type": "string",
120
167
  "default": "redis://127.0.0.1:6379"
168
+ },
169
+ "connectTimeout": {
170
+ "type": "number",
171
+ "default": 10000,
172
+ "description": "Connection timeout in milliseconds"
173
+ },
174
+ "disconnectTimeout": {
175
+ "type": "number",
176
+ "default": 5000,
177
+ "description": "Disconnect timeout in milliseconds"
178
+ },
179
+ "maxRetriesPerRequest": {
180
+ "type": [
181
+ "number",
182
+ "null"
183
+ ],
184
+ "default": null,
185
+ "description": "Maximum number of retries per request (null for BullMQ default)"
121
186
  }
122
- },
123
- "additionalProperties": false
187
+ }
188
+ },
189
+ "sentry": {
190
+ "type": "object",
191
+ "additionalProperties": false,
192
+ "properties": {
193
+ "dsn": {
194
+ "type": "string",
195
+ "default": ""
196
+ },
197
+ "traceSampleRate": {
198
+ "type": "number",
199
+ "default": 1
200
+ }
201
+ }
124
202
  },
125
203
  "sockethub": {
126
204
  "type": "object",
205
+ "additionalProperties": false,
127
206
  "properties": {
128
207
  "port": {
129
208
  "type": "number",
@@ -137,8 +216,21 @@
137
216
  "type": "string",
138
217
  "default": "/sockethub"
139
218
  }
140
- },
141
- "additionalProperties": false
219
+ }
220
+ },
221
+ "platformHeartbeat": {
222
+ "type": "object",
223
+ "additionalProperties": false,
224
+ "properties": {
225
+ "intervalMs": {
226
+ "type": "number",
227
+ "default": 5000
228
+ },
229
+ "timeoutMs": {
230
+ "type": "number",
231
+ "default": 15000
232
+ }
233
+ }
142
234
  }
143
235
  }
144
236
  }
@@ -21,9 +21,33 @@
21
21
  export const PlatformSchema = {
22
22
  $id: "https://sockethub.org/schemas/v/platform.json",
23
23
  type: "object",
24
- required: ["name", "version", "messages"],
24
+ required: [
25
+ "name",
26
+ "version",
27
+ "messages",
28
+ "contextUrl",
29
+ "contextVersion",
30
+ "schemaVersion",
31
+ ],
25
32
  additionalProperties: false,
26
33
  properties: {
34
+ contextUrl: {
35
+ title: "contextUrl",
36
+ type: "string",
37
+ format: "uri",
38
+ },
39
+ contextVersion: {
40
+ title: "contextVersion",
41
+ type: "string",
42
+ },
43
+ schemaVersion: {
44
+ title: "schemaVersion",
45
+ type: "string",
46
+ },
47
+ messageConstraints: {
48
+ title: "messageConstraints",
49
+ type: "object",
50
+ },
27
51
  credentials: {
28
52
  title: "credentials",
29
53
  type: "object",