@polytric/openws-spec 0.0.1 → 0.0.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/README.md +399 -71
- package/dist/builder.cjs +380 -0
- package/dist/builder.cjs.map +1 -0
- package/dist/builder.d.cts +77 -0
- package/dist/builder.d.ts +77 -0
- package/dist/builder.js +345 -0
- package/dist/builder.js.map +1 -0
- package/dist/index.cjs +162 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +139 -0
- package/dist/index.d.ts +139 -0
- package/dist/index.js +123 -0
- package/dist/index.js.map +1 -0
- package/dist/types.cjs +19 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +42 -0
- package/dist/types.d.ts +42 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/package.json +41 -14
- package/index.js +0 -11
- package/spec.js +0 -62
- package/spec.json +0 -1
package/spec.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
const S = require("@pocketgems/schema");
|
|
2
|
-
|
|
3
|
-
const keyPattern = "[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9]";
|
|
4
|
-
|
|
5
|
-
const OpenWSSchema = S.obj({
|
|
6
|
-
openws: S.str.enum("0.0.1").desc("The OpenWS schema version"),
|
|
7
|
-
info: S.obj({
|
|
8
|
-
title: S.str.desc("A title for the overall system.").optional(),
|
|
9
|
-
description: S.str
|
|
10
|
-
.desc(
|
|
11
|
-
"A high level description of the overall system, including all networks and all participants"
|
|
12
|
-
)
|
|
13
|
-
.optional(),
|
|
14
|
-
version: S.str.desc("A version string").optional(),
|
|
15
|
-
}),
|
|
16
|
-
networks: S.map
|
|
17
|
-
.min(1)
|
|
18
|
-
.keyPattern(keyPattern)
|
|
19
|
-
.value(
|
|
20
|
-
S.obj({
|
|
21
|
-
participants: S.map
|
|
22
|
-
.min(2)
|
|
23
|
-
.keyPattern(keyPattern)
|
|
24
|
-
.desc(
|
|
25
|
-
"A participant is a server or client in the network. Multiple server and clients can coexist in the same network. The simplest network contains a server-client pair."
|
|
26
|
-
)
|
|
27
|
-
.value(
|
|
28
|
-
S.obj({
|
|
29
|
-
endpoints: S.arr(
|
|
30
|
-
S.obj({
|
|
31
|
-
host: S.str,
|
|
32
|
-
port: S.int.min(0).max(65535).default(443),
|
|
33
|
-
path: S.str.default('/'),
|
|
34
|
-
})
|
|
35
|
-
).min(1).optional().desc('A participant can declare an endpoint to accept connections from other participants, normally used by servers'),
|
|
36
|
-
handlers: S.map
|
|
37
|
-
.min(1)
|
|
38
|
-
.keyPattern(keyPattern)
|
|
39
|
-
.value(
|
|
40
|
-
S.obj({
|
|
41
|
-
payload: S.obj({})
|
|
42
|
-
.min(1)
|
|
43
|
-
.desc(
|
|
44
|
-
"Must be a valid JSON schema spec. For brevity, openws omits this spec, but implementations should valid this"
|
|
45
|
-
),
|
|
46
|
-
description: S.str.optional()
|
|
47
|
-
})
|
|
48
|
-
)
|
|
49
|
-
.desc(
|
|
50
|
-
"A handler is implemented by a participant, and participants can invoke others handlers. The OpenWS spec only defines the shape of the payload, and how things get encoded / decoded on the wire, it doesn't determine behavior (through through description the behavior can be documented)."
|
|
51
|
-
),
|
|
52
|
-
})
|
|
53
|
-
),
|
|
54
|
-
})
|
|
55
|
-
),
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
if (require.main === module) {
|
|
59
|
-
console.log(JSON.stringify(OpenWSSchema.jsonSchema()));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
module.exports = OpenWSSchema;
|
package/spec.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"object","properties":{"openws":{"type":"string","enum":["0.0.1"],"description":"The OpenWS schema version"},"info":{"type":"object","properties":{"title":{"type":"string","description":"A title for the overall system."},"description":{"type":"string","description":"A high level description of the overall system, including all networks and all participants"},"version":{"type":"string","description":"A version string"}},"additionalProperties":false},"networks":{"type":"object","minProperties":1,"patternProperties":{"^[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9]$":{"type":"object","properties":{"participants":{"type":"object","minProperties":2,"description":"A participant is a server or client in the network. Multiple server and clients can coexist in the same network. The simplest network contains a server-client pair.","patternProperties":{"^[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9]$":{"type":"object","properties":{"endpoints":{"type":"array","items":{"type":"object","properties":{"host":{"type":"string"},"port":{"type":"integer","minimum":0,"maximum":65535,"default":443},"path":{"type":"string","default":"/"}},"required":["host","port","path"],"additionalProperties":false},"minItems":1,"description":"A participant can declare an endpoint to accept connections from other participants, normally used by servers"},"handlers":{"type":"object","minProperties":1,"patternProperties":{"^[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9]$":{"type":"object","properties":{"payload":{"type":"object","minProperties":1,"description":"Must be a valid JSON schema spec. For brevity, openws omits this spec, but implementations should valid this","additionalProperties":true},"description":{"type":"string"}},"required":["payload"],"additionalProperties":false}},"description":"A handler is implemented by a participant, and participants can invoke others handlers. The OpenWS spec only defines the shape of the payload, and how things get encoded / decoded on the wire, it doesn't determine behavior (through through description the behavior can be documented).","additionalProperties":false}},"required":["handlers"],"additionalProperties":false}},"additionalProperties":false}},"required":["participants"],"additionalProperties":false}},"additionalProperties":false}},"required":["openws","info","networks"],"additionalProperties":false,"$schema":"http://json-schema.org/draft-07/schema#"}
|