@sockethub/schemas 3.0.0-alpha.9 → 3.0.0-beta.0
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/dist/activity-stream-helper.d.ts +5 -0
- package/dist/activity-stream-helper.js +36 -0
- package/dist/activity-stream-helper.js.map +10 -0
- package/dist/context.d.ts +56 -0
- package/dist/context.js +80 -0
- package/dist/context.js.map +10 -0
- package/dist/contexts/platform/caldav/v1.jsonld +8 -0
- package/dist/contexts/platform/carddav/v1.jsonld +8 -0
- package/dist/contexts/platform/dummy/v1.jsonld +8 -0
- package/dist/contexts/platform/error/v1.jsonld +8 -0
- package/dist/contexts/platform/feeds/v1.jsonld +8 -0
- package/dist/contexts/platform/irc/v1.jsonld +8 -0
- package/dist/contexts/platform/metadata/v1.jsonld +8 -0
- package/dist/contexts/platform/sockethub%3Ainternal/v1.jsonld +8 -0
- package/dist/contexts/platform/xmpp/v1.jsonld +8 -0
- package/dist/contexts/v1.jsonld +7 -0
- package/dist/helpers/error-parser.d.ts +13 -0
- package/dist/helpers/objects.d.ts +157 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +1235 -1143
- package/dist/index.js.map +15 -17
- package/dist/maps/context-map.json +41 -0
- package/dist/object-types.d.ts +2 -0
- package/dist/object-types.js +299 -0
- package/dist/object-types.js.map +12 -0
- package/dist/schema-id.d.ts +11 -0
- package/dist/schemas/activity-stream.d.ts +196 -0
- package/{src/schemas/json/activity-object.json → dist/schemas/json/activity-stream.json} +99 -158
- package/dist/schemas/json/platform.json +52 -0
- package/dist/schemas/json/service-descriptor.json +58 -0
- package/dist/schemas/json/sockethub-config.json +500 -0
- package/dist/schemas/platform/caldav/v1/credentials.schema.json +71 -0
- package/dist/schemas/platform/caldav/v1/messages.schema.json +769 -0
- package/dist/schemas/platform/carddav/v1/credentials.schema.json +67 -0
- package/dist/schemas/platform/carddav/v1/messages.schema.json +375 -0
- package/dist/schemas/platform/dummy/v1/credentials.schema.json +1 -0
- package/dist/schemas/platform/dummy/v1/messages.schema.json +22 -0
- package/dist/schemas/platform/error/v1/credentials.schema.json +1 -0
- package/dist/schemas/platform/error/v1/messages.schema.json +1 -0
- package/dist/schemas/platform/feeds/v1/credentials.schema.json +1 -0
- package/dist/schemas/platform/feeds/v1/messages.schema.json +27 -0
- package/dist/schemas/platform/irc/v1/credentials.schema.json +118 -0
- package/dist/schemas/platform/irc/v1/messages.schema.json +149 -0
- package/dist/schemas/platform/metadata/v1/credentials.schema.json +1 -0
- package/dist/schemas/platform/metadata/v1/messages.schema.json +14 -0
- package/dist/schemas/platform/sockethub%3Ainternal/v1/credentials.schema.json +1 -0
- package/dist/schemas/platform/sockethub%3Ainternal/v1/messages.schema.json +1 -0
- package/dist/schemas/platform/xmpp/v1/credentials.schema.json +43 -0
- package/dist/schemas/platform/xmpp/v1/messages.schema.json +129 -0
- package/dist/schemas/platform.d.ts +62 -0
- package/dist/schemas/service-descriptor.d.ts +84 -0
- package/dist/schemas/sockethub-config.d.ts +466 -0
- package/dist/service-descriptor.d.ts +4 -0
- package/dist/service-descriptor.js +6280 -0
- package/dist/service-descriptor.js.map +77 -0
- package/{src/types.ts → dist/types.d.ts} +52 -53
- package/dist/validator.d.ts +26 -0
- package/package.json +32 -11
- package/src/helpers/error-parser.ts +0 -113
- package/src/helpers/objects.ts +0 -227
- package/src/index.test.data.credentials.ts +0 -71
- package/src/index.test.data.objects.ts +0 -241
- package/src/index.test.data.platform.ts +0 -45
- package/src/index.test.data.streams.ts +0 -498
- package/src/index.test.ts +0 -99
- package/src/index.ts +0 -27
- package/src/schemas/activity-object.ts +0 -19
- package/src/schemas/activity-stream.ts +0 -54
- package/src/schemas/json/activity-stream.json +0 -469
- package/src/schemas/json/platform.json +0 -28
- package/src/schemas/json/sockethub-config.json +0 -144
- package/src/schemas/platform.ts +0 -47
- package/src/schemas/sockethub-config.ts +0 -140
- package/src/validator.ts +0 -94
|
@@ -1,498 +0,0 @@
|
|
|
1
|
-
import { ObjectTypesList } from "./helpers/objects";
|
|
2
|
-
|
|
3
|
-
export default [
|
|
4
|
-
[
|
|
5
|
-
"type:send, object:message",
|
|
6
|
-
{
|
|
7
|
-
type: "send",
|
|
8
|
-
context: "irc",
|
|
9
|
-
actor: {
|
|
10
|
-
id: "dood@irc.freenode.net",
|
|
11
|
-
type: "person",
|
|
12
|
-
name: "dood",
|
|
13
|
-
},
|
|
14
|
-
target: {
|
|
15
|
-
id: "irc.freenode.net/server",
|
|
16
|
-
type: "room",
|
|
17
|
-
name: "sockethub",
|
|
18
|
-
},
|
|
19
|
-
object: {
|
|
20
|
-
type: "message",
|
|
21
|
-
content: "some kind of message",
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
true,
|
|
25
|
-
"",
|
|
26
|
-
],
|
|
27
|
-
|
|
28
|
-
[
|
|
29
|
-
"type:send, object:message bad published value",
|
|
30
|
-
{
|
|
31
|
-
type: "send",
|
|
32
|
-
context: "irc",
|
|
33
|
-
published: "foo",
|
|
34
|
-
actor: {
|
|
35
|
-
id: "dood@irc.freenode.net",
|
|
36
|
-
type: "person",
|
|
37
|
-
name: "dood",
|
|
38
|
-
},
|
|
39
|
-
target: {
|
|
40
|
-
id: "irc.freenode.net/server",
|
|
41
|
-
type: "room",
|
|
42
|
-
name: "sockethub",
|
|
43
|
-
},
|
|
44
|
-
object: {
|
|
45
|
-
type: "message",
|
|
46
|
-
content: "some kind of message",
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
false,
|
|
50
|
-
'[irc] /published: must match format "date-time"',
|
|
51
|
-
],
|
|
52
|
-
|
|
53
|
-
[
|
|
54
|
-
"type:credentials, object:credentials",
|
|
55
|
-
{
|
|
56
|
-
type: "credentials",
|
|
57
|
-
context: "irc",
|
|
58
|
-
actor: {
|
|
59
|
-
id: "dood@irc.freenode.net",
|
|
60
|
-
type: "person",
|
|
61
|
-
name: "dood",
|
|
62
|
-
},
|
|
63
|
-
target: {
|
|
64
|
-
id: "irc.freenode.net/server",
|
|
65
|
-
type: "room",
|
|
66
|
-
name: "sockethub",
|
|
67
|
-
},
|
|
68
|
-
object: {
|
|
69
|
-
type: "credentials",
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
true,
|
|
73
|
-
"",
|
|
74
|
-
],
|
|
75
|
-
|
|
76
|
-
[
|
|
77
|
-
"type:credentials",
|
|
78
|
-
{
|
|
79
|
-
context: "irc",
|
|
80
|
-
type: "credentials",
|
|
81
|
-
actor: {
|
|
82
|
-
id: "dood@irc.freenode.net",
|
|
83
|
-
type: "person",
|
|
84
|
-
name: "dood",
|
|
85
|
-
},
|
|
86
|
-
object: {
|
|
87
|
-
type: "credentials",
|
|
88
|
-
user: "foo",
|
|
89
|
-
pass: "bar",
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
true,
|
|
93
|
-
"",
|
|
94
|
-
],
|
|
95
|
-
|
|
96
|
-
[
|
|
97
|
-
"bad target",
|
|
98
|
-
{
|
|
99
|
-
id: "blah",
|
|
100
|
-
type: "send",
|
|
101
|
-
context: "dood",
|
|
102
|
-
actor: {
|
|
103
|
-
id: "dood@irc.freenode.net",
|
|
104
|
-
type: "person",
|
|
105
|
-
name: "dood",
|
|
106
|
-
},
|
|
107
|
-
target: {
|
|
108
|
-
type: "person",
|
|
109
|
-
name: "bob",
|
|
110
|
-
},
|
|
111
|
-
object: {
|
|
112
|
-
type: "credentials",
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
false,
|
|
116
|
-
"[dood] /target: must have required property 'id'",
|
|
117
|
-
],
|
|
118
|
-
|
|
119
|
-
[
|
|
120
|
-
"bad iri in object id",
|
|
121
|
-
{
|
|
122
|
-
type: "feed",
|
|
123
|
-
context: "dood",
|
|
124
|
-
actor: {
|
|
125
|
-
id: "dood@irc.freenode.net",
|
|
126
|
-
type: "person",
|
|
127
|
-
},
|
|
128
|
-
object: {
|
|
129
|
-
id: "example.org/some/path.html",
|
|
130
|
-
type: "website",
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
false,
|
|
134
|
-
'[dood] /object/id: must match format "iri"',
|
|
135
|
-
],
|
|
136
|
-
|
|
137
|
-
[
|
|
138
|
-
"valid iri in object id",
|
|
139
|
-
{
|
|
140
|
-
type: "feed",
|
|
141
|
-
context: "dood",
|
|
142
|
-
actor: {
|
|
143
|
-
id: "dood@irc.freenode.net",
|
|
144
|
-
type: "person",
|
|
145
|
-
},
|
|
146
|
-
object: {
|
|
147
|
-
id: "https://example.org/some/path.html",
|
|
148
|
-
type: "website",
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
true,
|
|
152
|
-
"",
|
|
153
|
-
],
|
|
154
|
-
|
|
155
|
-
[
|
|
156
|
-
"wrong actor type",
|
|
157
|
-
{
|
|
158
|
-
type: "send",
|
|
159
|
-
context: "dood",
|
|
160
|
-
actor: {
|
|
161
|
-
id: "doobar@freenode.net/channel",
|
|
162
|
-
type: "foo",
|
|
163
|
-
content: "hi there",
|
|
164
|
-
},
|
|
165
|
-
object: {
|
|
166
|
-
type: "feed",
|
|
167
|
-
id: "http://rss.example.org/feed.rss",
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
false,
|
|
171
|
-
`[dood] /actor: must match exactly one schema in oneOf: ${ObjectTypesList.join(
|
|
172
|
-
", ",
|
|
173
|
-
)}`,
|
|
174
|
-
],
|
|
175
|
-
|
|
176
|
-
[
|
|
177
|
-
"missing actor id",
|
|
178
|
-
{
|
|
179
|
-
id: "blah",
|
|
180
|
-
type: "send",
|
|
181
|
-
context: "dood",
|
|
182
|
-
actor: {
|
|
183
|
-
type: "person",
|
|
184
|
-
name: "dood",
|
|
185
|
-
},
|
|
186
|
-
target: {
|
|
187
|
-
id: "bob@crusty.net/Home",
|
|
188
|
-
type: "person",
|
|
189
|
-
name: "bob",
|
|
190
|
-
},
|
|
191
|
-
object: {
|
|
192
|
-
type: "feed",
|
|
193
|
-
id: "http://rss.example.org/feed.rss",
|
|
194
|
-
},
|
|
195
|
-
},
|
|
196
|
-
false,
|
|
197
|
-
"[dood] /actor: must have required property 'id'",
|
|
198
|
-
],
|
|
199
|
-
|
|
200
|
-
[
|
|
201
|
-
"attendance request",
|
|
202
|
-
{
|
|
203
|
-
id: "blah",
|
|
204
|
-
type: "observe",
|
|
205
|
-
context: "dood",
|
|
206
|
-
actor: {
|
|
207
|
-
id: "dood",
|
|
208
|
-
type: "person",
|
|
209
|
-
},
|
|
210
|
-
target: {
|
|
211
|
-
id: "chatroom@crusty.net",
|
|
212
|
-
type: "room",
|
|
213
|
-
},
|
|
214
|
-
object: {
|
|
215
|
-
type: "attendance",
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
true,
|
|
219
|
-
"",
|
|
220
|
-
],
|
|
221
|
-
|
|
222
|
-
[
|
|
223
|
-
"attendance response",
|
|
224
|
-
{
|
|
225
|
-
id: "blah",
|
|
226
|
-
type: "observe",
|
|
227
|
-
context: "dood",
|
|
228
|
-
actor: {
|
|
229
|
-
id: "chatroom@crusty.net",
|
|
230
|
-
type: "room",
|
|
231
|
-
name: "chatroom",
|
|
232
|
-
},
|
|
233
|
-
object: {
|
|
234
|
-
type: "attendance",
|
|
235
|
-
members: ["bill", "bob", "hank"],
|
|
236
|
-
},
|
|
237
|
-
},
|
|
238
|
-
true,
|
|
239
|
-
"",
|
|
240
|
-
],
|
|
241
|
-
|
|
242
|
-
[
|
|
243
|
-
"invalid attendance request",
|
|
244
|
-
{
|
|
245
|
-
id: "blah",
|
|
246
|
-
type: "observe",
|
|
247
|
-
context: "dood",
|
|
248
|
-
actor: {
|
|
249
|
-
id: "dood",
|
|
250
|
-
type: "person",
|
|
251
|
-
},
|
|
252
|
-
target: {
|
|
253
|
-
id: "chatroom@crusty.net",
|
|
254
|
-
type: "room",
|
|
255
|
-
},
|
|
256
|
-
object: {
|
|
257
|
-
type: "attendance",
|
|
258
|
-
status: "foobar",
|
|
259
|
-
},
|
|
260
|
-
},
|
|
261
|
-
false,
|
|
262
|
-
"[dood] /object: must NOT have additional properties: status",
|
|
263
|
-
],
|
|
264
|
-
|
|
265
|
-
[
|
|
266
|
-
"setting presence",
|
|
267
|
-
{
|
|
268
|
-
id: "blah",
|
|
269
|
-
type: "observe",
|
|
270
|
-
context: "dood",
|
|
271
|
-
actor: {
|
|
272
|
-
id: "dood",
|
|
273
|
-
type: "person",
|
|
274
|
-
},
|
|
275
|
-
object: {
|
|
276
|
-
type: "presence",
|
|
277
|
-
presence: "away",
|
|
278
|
-
content: "forgot the milk",
|
|
279
|
-
},
|
|
280
|
-
target: {
|
|
281
|
-
id: "chatroom@crusty.net",
|
|
282
|
-
type: "room",
|
|
283
|
-
},
|
|
284
|
-
},
|
|
285
|
-
true,
|
|
286
|
-
"",
|
|
287
|
-
],
|
|
288
|
-
|
|
289
|
-
[
|
|
290
|
-
"setting invalid presence",
|
|
291
|
-
{
|
|
292
|
-
id: "blah",
|
|
293
|
-
type: "observe",
|
|
294
|
-
context: "dood",
|
|
295
|
-
actor: {
|
|
296
|
-
id: "dood",
|
|
297
|
-
type: "person",
|
|
298
|
-
},
|
|
299
|
-
object: {
|
|
300
|
-
type: "presence",
|
|
301
|
-
presence: "afk",
|
|
302
|
-
content: "forgot the milk",
|
|
303
|
-
},
|
|
304
|
-
target: {
|
|
305
|
-
id: "chatroom@crusty.net",
|
|
306
|
-
type: "room",
|
|
307
|
-
},
|
|
308
|
-
},
|
|
309
|
-
false,
|
|
310
|
-
"[dood] /object/presence: must be equal to one of the allowed values: " +
|
|
311
|
-
"away, chat, dnd, xa, offline, online",
|
|
312
|
-
],
|
|
313
|
-
|
|
314
|
-
[
|
|
315
|
-
"setting topic",
|
|
316
|
-
{
|
|
317
|
-
id: "blah",
|
|
318
|
-
type: "observe",
|
|
319
|
-
context: "dood",
|
|
320
|
-
actor: {
|
|
321
|
-
id: "dood",
|
|
322
|
-
type: "person",
|
|
323
|
-
},
|
|
324
|
-
object: {
|
|
325
|
-
type: "topic",
|
|
326
|
-
content: "the topic is goats",
|
|
327
|
-
},
|
|
328
|
-
target: {
|
|
329
|
-
id: "chatroom@crusty.net",
|
|
330
|
-
type: "room",
|
|
331
|
-
},
|
|
332
|
-
},
|
|
333
|
-
true,
|
|
334
|
-
"",
|
|
335
|
-
],
|
|
336
|
-
|
|
337
|
-
[
|
|
338
|
-
"setting topic incorrectly",
|
|
339
|
-
{
|
|
340
|
-
id: "blah",
|
|
341
|
-
type: "observe",
|
|
342
|
-
context: "dood",
|
|
343
|
-
actor: {
|
|
344
|
-
id: "dood",
|
|
345
|
-
type: "person",
|
|
346
|
-
},
|
|
347
|
-
object: {
|
|
348
|
-
type: "topic",
|
|
349
|
-
topic: "the topic is goats",
|
|
350
|
-
},
|
|
351
|
-
target: {
|
|
352
|
-
id: "chatroom@crusty.net",
|
|
353
|
-
type: "room",
|
|
354
|
-
},
|
|
355
|
-
},
|
|
356
|
-
false,
|
|
357
|
-
"[dood] /object: must NOT have additional properties: topic",
|
|
358
|
-
],
|
|
359
|
-
|
|
360
|
-
[
|
|
361
|
-
"receive topic",
|
|
362
|
-
{
|
|
363
|
-
id: "blah",
|
|
364
|
-
type: "observe",
|
|
365
|
-
context: "dood",
|
|
366
|
-
actor: {
|
|
367
|
-
id: "chatroom@crusty.net",
|
|
368
|
-
type: "room",
|
|
369
|
-
},
|
|
370
|
-
object: {
|
|
371
|
-
type: "topic",
|
|
372
|
-
content: "the topic is goats",
|
|
373
|
-
},
|
|
374
|
-
},
|
|
375
|
-
true,
|
|
376
|
-
"",
|
|
377
|
-
],
|
|
378
|
-
|
|
379
|
-
[
|
|
380
|
-
"change user address",
|
|
381
|
-
{
|
|
382
|
-
id: "blah",
|
|
383
|
-
type: "update",
|
|
384
|
-
context: "dood",
|
|
385
|
-
actor: {
|
|
386
|
-
id: "foobar@example.com",
|
|
387
|
-
type: "person",
|
|
388
|
-
},
|
|
389
|
-
object: {
|
|
390
|
-
type: "address",
|
|
391
|
-
},
|
|
392
|
-
target: {
|
|
393
|
-
id: "futurebar@example.com",
|
|
394
|
-
type: "person",
|
|
395
|
-
},
|
|
396
|
-
},
|
|
397
|
-
true,
|
|
398
|
-
"",
|
|
399
|
-
],
|
|
400
|
-
|
|
401
|
-
[
|
|
402
|
-
"change user address incorrectly",
|
|
403
|
-
{
|
|
404
|
-
type: "update",
|
|
405
|
-
context: "dood",
|
|
406
|
-
actor: {
|
|
407
|
-
id: "foobar@example.com",
|
|
408
|
-
type: "person",
|
|
409
|
-
},
|
|
410
|
-
object: {
|
|
411
|
-
type: "address",
|
|
412
|
-
id: "futurebar@example.com",
|
|
413
|
-
},
|
|
414
|
-
},
|
|
415
|
-
false,
|
|
416
|
-
"[dood] /object: must NOT have additional properties: id",
|
|
417
|
-
],
|
|
418
|
-
|
|
419
|
-
[
|
|
420
|
-
"invalid activity stream",
|
|
421
|
-
{
|
|
422
|
-
actor: { id: "irc://uuu@localhost", type: "person" },
|
|
423
|
-
context: "irc",
|
|
424
|
-
target: { id: "irc://irc.dooder.net/a-room", type: "room" },
|
|
425
|
-
},
|
|
426
|
-
false,
|
|
427
|
-
"[irc] activity stream: must have required property 'type'",
|
|
428
|
-
],
|
|
429
|
-
|
|
430
|
-
[
|
|
431
|
-
"invalid room",
|
|
432
|
-
{
|
|
433
|
-
context: "irc",
|
|
434
|
-
type: "credentials",
|
|
435
|
-
actor: {
|
|
436
|
-
id: "sh-9K3Vk@irc.freenode.net",
|
|
437
|
-
type: "person",
|
|
438
|
-
},
|
|
439
|
-
target: {
|
|
440
|
-
type: "room",
|
|
441
|
-
name: "sh-9K3Vk",
|
|
442
|
-
},
|
|
443
|
-
},
|
|
444
|
-
false,
|
|
445
|
-
"[irc] /target: must have required property 'id'",
|
|
446
|
-
],
|
|
447
|
-
|
|
448
|
-
[
|
|
449
|
-
"relationship",
|
|
450
|
-
{
|
|
451
|
-
context: "irc",
|
|
452
|
-
type: "add",
|
|
453
|
-
actor: { type: "person", id: "alice@localhost", name: "alice" },
|
|
454
|
-
target: { type: "person", id: "Kilroy@localhost", name: "Kilroy" },
|
|
455
|
-
object: {
|
|
456
|
-
type: "relationship",
|
|
457
|
-
relationship: "role",
|
|
458
|
-
subject: {
|
|
459
|
-
type: "presence",
|
|
460
|
-
role: "owner",
|
|
461
|
-
},
|
|
462
|
-
object: {
|
|
463
|
-
type: "room",
|
|
464
|
-
id: "localhost/#Finnish",
|
|
465
|
-
name: "#Finnish",
|
|
466
|
-
},
|
|
467
|
-
},
|
|
468
|
-
},
|
|
469
|
-
true,
|
|
470
|
-
"",
|
|
471
|
-
],
|
|
472
|
-
|
|
473
|
-
[
|
|
474
|
-
"invalid role in relationship",
|
|
475
|
-
{
|
|
476
|
-
context: "irc",
|
|
477
|
-
type: "add",
|
|
478
|
-
actor: { type: "person", id: "alice@localhost", name: "alice" },
|
|
479
|
-
target: { type: "person", id: "Kilroy@localhost", name: "Kilroy" },
|
|
480
|
-
object: {
|
|
481
|
-
type: "relationship",
|
|
482
|
-
relationship: "role",
|
|
483
|
-
subject: {
|
|
484
|
-
type: "presence",
|
|
485
|
-
role: "manager",
|
|
486
|
-
},
|
|
487
|
-
object: {
|
|
488
|
-
type: "room",
|
|
489
|
-
id: "localhost/#Finnish",
|
|
490
|
-
name: "#Finnish",
|
|
491
|
-
},
|
|
492
|
-
},
|
|
493
|
-
},
|
|
494
|
-
false,
|
|
495
|
-
"[irc] /object/subject/role: must be equal to one of the allowed values: " +
|
|
496
|
-
"owner, member, participant, admin",
|
|
497
|
-
],
|
|
498
|
-
];
|
package/src/index.test.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "bun:test";
|
|
2
|
-
import type { ActivityStream } from "./types";
|
|
3
|
-
|
|
4
|
-
import testCredentialsData from "./index.test.data.credentials";
|
|
5
|
-
import testActivityObjectsData from "./index.test.data.objects";
|
|
6
|
-
import testPlatformSchemaData from "./index.test.data.platform";
|
|
7
|
-
import testActivityStreamsData from "./index.test.data.streams";
|
|
8
|
-
import { ActivityObjectSchema } from "./schemas/activity-object";
|
|
9
|
-
import { ActivityStreamSchema } from "./schemas/activity-stream";
|
|
10
|
-
import {
|
|
11
|
-
addPlatformSchema,
|
|
12
|
-
getPlatformSchema,
|
|
13
|
-
validateActivityObject,
|
|
14
|
-
validateActivityStream,
|
|
15
|
-
validateCredentials,
|
|
16
|
-
validatePlatformSchema,
|
|
17
|
-
} from "./validator";
|
|
18
|
-
|
|
19
|
-
describe("schemas/src/index.ts", () => {
|
|
20
|
-
describe("Platform schema validation", () => {
|
|
21
|
-
it("returns an empty error for a valid schema", () => {
|
|
22
|
-
const err = validatePlatformSchema(testPlatformSchemaData);
|
|
23
|
-
expect(err).toEqual("");
|
|
24
|
-
});
|
|
25
|
-
it("returns an error for an invalid schema", () => {
|
|
26
|
-
const err = validatePlatformSchema({ foo: "bar" });
|
|
27
|
-
expect(err).toEqual(
|
|
28
|
-
"platform schema failed to validate: must have required property 'name'",
|
|
29
|
-
);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
describe("Adding a PlatformSchema", () => {
|
|
34
|
-
it("returns the same schema when fetched", () => {
|
|
35
|
-
const platform_type = "test-platform/credentials";
|
|
36
|
-
addPlatformSchema(testPlatformSchemaData.credentials, platform_type);
|
|
37
|
-
const compiledSchema = getPlatformSchema(platform_type);
|
|
38
|
-
expect(compiledSchema.schema).toEqual(
|
|
39
|
-
testPlatformSchemaData.credentials,
|
|
40
|
-
);
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
describe("Credentials", () => {
|
|
45
|
-
testCredentialsData.forEach(
|
|
46
|
-
([name, creds, expectedResult, expectedFailureMessage]) => {
|
|
47
|
-
describe("validateCredential " + name, () => {
|
|
48
|
-
it(`returns expected result`, () => {
|
|
49
|
-
const err = validateCredentials(creds as ActivityStream);
|
|
50
|
-
expect(err).toEqual(expectedFailureMessage);
|
|
51
|
-
expect(!err).toEqual(expectedResult);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
},
|
|
55
|
-
);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
describe("ActivityObject", () => {
|
|
59
|
-
it("has expected properties", () => {
|
|
60
|
-
expect(typeof ActivityObjectSchema).toEqual("object");
|
|
61
|
-
expect(ActivityObjectSchema["$id"]).toEqual(
|
|
62
|
-
"https://sockethub.org/schemas/v/activity-object.json",
|
|
63
|
-
);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
testActivityObjectsData.forEach(
|
|
67
|
-
([name, ao, expectedResult, expectedFailureMessage]) => {
|
|
68
|
-
describe("validateActivityObject " + name, () => {
|
|
69
|
-
it(`returns expected result`, () => {
|
|
70
|
-
const err = validateActivityObject(ao as ActivityStream);
|
|
71
|
-
expect(err).toEqual(expectedFailureMessage);
|
|
72
|
-
expect(!err).toEqual(expectedResult);
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
},
|
|
76
|
-
);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
describe("ActivityStream", () => {
|
|
80
|
-
it("has expected properties", () => {
|
|
81
|
-
expect(typeof ActivityStreamSchema).toEqual("object");
|
|
82
|
-
expect(ActivityStreamSchema["$id"]).toEqual(
|
|
83
|
-
"https://sockethub.org/schemas/v/activity-stream.json",
|
|
84
|
-
);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
testActivityStreamsData.forEach(
|
|
88
|
-
([name, as, expectedResult, expectedFailureMessage]) => {
|
|
89
|
-
describe("validateActivityStream " + name, () => {
|
|
90
|
-
it(`returns expected result`, () => {
|
|
91
|
-
const err = validateActivityStream(as as ActivityStream);
|
|
92
|
-
expect(err).toEqual(expectedFailureMessage);
|
|
93
|
-
expect(!err).toEqual(expectedResult);
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
},
|
|
97
|
-
);
|
|
98
|
-
});
|
|
99
|
-
});
|
package/src/index.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { ObjectTypesList } from "./helpers/objects.js";
|
|
2
|
-
import { ActivityObjectSchema } from "./schemas/activity-object.js";
|
|
3
|
-
import { ActivityStreamSchema } from "./schemas/activity-stream.js";
|
|
4
|
-
import { PlatformSchema } from "./schemas/platform.js";
|
|
5
|
-
import {
|
|
6
|
-
addPlatformSchema,
|
|
7
|
-
getPlatformSchema,
|
|
8
|
-
validateActivityObject,
|
|
9
|
-
validateActivityStream,
|
|
10
|
-
validateCredentials,
|
|
11
|
-
validatePlatformSchema,
|
|
12
|
-
} from "./validator.js";
|
|
13
|
-
|
|
14
|
-
export {
|
|
15
|
-
addPlatformSchema,
|
|
16
|
-
getPlatformSchema,
|
|
17
|
-
validatePlatformSchema,
|
|
18
|
-
validateCredentials,
|
|
19
|
-
validateActivityStream,
|
|
20
|
-
validateActivityObject,
|
|
21
|
-
PlatformSchema,
|
|
22
|
-
ActivityObjectSchema,
|
|
23
|
-
ActivityStreamSchema,
|
|
24
|
-
ObjectTypesList,
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export * from "./types.js";
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { validObjectDefs, validObjectRefs } from "../helpers/objects.js";
|
|
2
|
-
|
|
3
|
-
export const ActivityObjectSchema = {
|
|
4
|
-
$id: "https://sockethub.org/schemas/v/activity-object.json",
|
|
5
|
-
description: "Schema for Sockethub Activity Objects",
|
|
6
|
-
|
|
7
|
-
type: "object",
|
|
8
|
-
required: ["object"],
|
|
9
|
-
properties: {
|
|
10
|
-
object: {
|
|
11
|
-
type: "object",
|
|
12
|
-
oneOf: validObjectRefs,
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
definitions: {
|
|
17
|
-
type: validObjectDefs,
|
|
18
|
-
},
|
|
19
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { ObjectTypesList, ObjectTypesSchema } from "../helpers/objects.js";
|
|
2
|
-
import { ActivityObjectSchema } from "./activity-object.js";
|
|
3
|
-
|
|
4
|
-
const validActorRefs = ActivityObjectSchema.properties.object.oneOf;
|
|
5
|
-
const validTargetRefs = ActivityObjectSchema.properties.object.oneOf;
|
|
6
|
-
// console.log(validActorRefs);
|
|
7
|
-
|
|
8
|
-
const validObjectRefs = [];
|
|
9
|
-
|
|
10
|
-
for (const type of ObjectTypesList) {
|
|
11
|
-
validObjectRefs.push({ $ref: `#/definitions/type/${type}` });
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const contextSchema = {
|
|
15
|
-
type: "string",
|
|
16
|
-
};
|
|
17
|
-
const typeSchema = {
|
|
18
|
-
type: "string",
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const ActivityStreamSchema = {
|
|
22
|
-
$id: "https://sockethub.org/schemas/v/activity-stream.json",
|
|
23
|
-
description: "Schema for Sockethub Activity Streams",
|
|
24
|
-
|
|
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
|
-
published: {
|
|
46
|
-
type: "string",
|
|
47
|
-
format: "date-time",
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
definitions: {
|
|
52
|
-
type: ObjectTypesSchema,
|
|
53
|
-
},
|
|
54
|
-
};
|