taflor-protocol 0.1.0__py3-none-any.whl
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.
- taflor_protocol/__init__.py +91 -0
- taflor_protocol/conformance/FORMAT.md +117 -0
- taflor_protocol/conformance/v2/core/gm-only-key.yaml +52 -0
- taflor_protocol/conformance/v2/core/join.yaml +37 -0
- taflor_protocol/conformance/v2/core/object-create.yaml +24 -0
- taflor_protocol/conformance/v2/core/object-move.yaml +32 -0
- taflor_protocol/conformance/v2/core/protocol-mismatch.yaml +18 -0
- taflor_protocol/data/capabilities.json +80 -0
- taflor_protocol/schemas/common/v1.json +110 -0
- taflor_protocol/schemas/conformance/v2/scenario.json +320 -0
- taflor_protocol/schemas/extension/v1.json +31 -0
- taflor_protocol/schemas/manifest/v1.json +391 -0
- taflor_protocol/schemas/protocol/v2/capabilities.json +36 -0
- taflor_protocol/schemas/protocol/v2/client/battlemap.remove.json +19 -0
- taflor_protocol/schemas/protocol/v2/client/combat.activate.json +19 -0
- taflor_protocol/schemas/protocol/v2/client/combat.add.json +24 -0
- taflor_protocol/schemas/protocol/v2/client/combat.begin.json +15 -0
- taflor_protocol/schemas/protocol/v2/client/combat.end.json +15 -0
- taflor_protocol/schemas/protocol/v2/client/combat.next.json +15 -0
- taflor_protocol/schemas/protocol/v2/client/combat.prev.json +15 -0
- taflor_protocol/schemas/protocol/v2/client/combat.remove.json +24 -0
- taflor_protocol/schemas/protocol/v2/client/combat.roll.json +48 -0
- taflor_protocol/schemas/protocol/v2/client/combat.set_initiative.json +25 -0
- taflor_protocol/schemas/protocol/v2/client/cursor.json +23 -0
- taflor_protocol/schemas/protocol/v2/client/cursor.leave.json +15 -0
- taflor_protocol/schemas/protocol/v2/client/die.roll.json +19 -0
- taflor_protocol/schemas/protocol/v2/client/die.set.json +26 -0
- taflor_protocol/schemas/protocol/v2/client/doc.create.json +52 -0
- taflor_protocol/schemas/protocol/v2/client/doc.delete.json +23 -0
- taflor_protocol/schemas/protocol/v2/client/doc.subscribe.json +35 -0
- taflor_protocol/schemas/protocol/v2/client/doc.update.json +32 -0
- taflor_protocol/schemas/protocol/v2/client/fog.reset.json +19 -0
- taflor_protocol/schemas/protocol/v2/client/object.convert.json +29 -0
- taflor_protocol/schemas/protocol/v2/client/object.create.json +62 -0
- taflor_protocol/schemas/protocol/v2/client/object.delete.json +19 -0
- taflor_protocol/schemas/protocol/v2/client/object.duplicate.json +31 -0
- taflor_protocol/schemas/protocol/v2/client/object.preview.json +55 -0
- taflor_protocol/schemas/protocol/v2/client/object.update.json +41 -0
- taflor_protocol/schemas/protocol/v2/client/ping.json +23 -0
- taflor_protocol/schemas/protocol/v2/client/plugin.error.json +46 -0
- taflor_protocol/schemas/protocol/v2/client/presence.ping.json +29 -0
- taflor_protocol/schemas/protocol/v2/client/ruler.json +60 -0
- taflor_protocol/schemas/protocol/v2/client/saved_views.set.json +23 -0
- taflor_protocol/schemas/protocol/v2/client/showcase.hide.json +15 -0
- taflor_protocol/schemas/protocol/v2/client/showcase.show.json +19 -0
- taflor_protocol/schemas/protocol/v2/client/table.update.json +28 -0
- taflor_protocol/schemas/protocol/v2/client/tokens.gather.json +23 -0
- taflor_protocol/schemas/protocol/v2/client/view.pull.json +33 -0
- taflor_protocol/schemas/protocol/v2/client-message.json +585 -0
- taflor_protocol/schemas/protocol/v2/common.json +276 -0
- taflor_protocol/schemas/protocol/v2/envelope.json +18 -0
- taflor_protocol/schemas/protocol/v2/error.json +24 -0
- taflor_protocol/schemas/protocol/v2/object.json +76 -0
- taflor_protocol/schemas/protocol/v2/server/combat.json +26 -0
- taflor_protocol/schemas/protocol/v2/server/cursor.json +36 -0
- taflor_protocol/schemas/protocol/v2/server/cursor.leave.json +19 -0
- taflor_protocol/schemas/protocol/v2/server/dice.rolled.json +130 -0
- taflor_protocol/schemas/protocol/v2/server/doc.deleted.json +22 -0
- taflor_protocol/schemas/protocol/v2/server/doc.upserted.json +22 -0
- taflor_protocol/schemas/protocol/v2/server/looks.json +19 -0
- taflor_protocol/schemas/protocol/v2/server/object.converted.json +25 -0
- taflor_protocol/schemas/protocol/v2/server/object.created.json +23 -0
- taflor_protocol/schemas/protocol/v2/server/object.deleted.json +19 -0
- taflor_protocol/schemas/protocol/v2/server/object.duplicated.json +26 -0
- taflor_protocol/schemas/protocol/v2/server/object.preview.json +27 -0
- taflor_protocol/schemas/protocol/v2/server/object.upserted.json +54 -0
- taflor_protocol/schemas/protocol/v2/server/ping.json +36 -0
- taflor_protocol/schemas/protocol/v2/server/presence.json +22 -0
- taflor_protocol/schemas/protocol/v2/server/presence.pong.json +19 -0
- taflor_protocol/schemas/protocol/v2/server/protocol.json +20 -0
- taflor_protocol/schemas/protocol/v2/server/ruler.json +47 -0
- taflor_protocol/schemas/protocol/v2/server/saved_views.updated.json +22 -0
- taflor_protocol/schemas/protocol/v2/server/showcase.json +26 -0
- taflor_protocol/schemas/protocol/v2/server/table.updated.json +19 -0
- taflor_protocol/schemas/protocol/v2/server/tokens.gathered.json +25 -0
- taflor_protocol/schemas/protocol/v2/server/view.pull.json +22 -0
- taflor_protocol/schemas/protocol/v2/server-message.json +425 -0
- taflor_protocol/schemas/protocol/v2/state.json +75 -0
- taflor_protocol/schemas/sheet/v1/message.json +156 -0
- taflor_protocol-0.1.0.dist-info/METADATA +109 -0
- taflor_protocol-0.1.0.dist-info/RECORD +82 -0
- taflor_protocol-0.1.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"""Taflor's protocol package: versions, the JSON Schemas and the conformance scenarios.
|
|
2
|
+
|
|
3
|
+
The schemas are the normative definition of the wire protocol, the plugin manifest and the sheet
|
|
4
|
+
protocol (SPEC §6.1, §6.10). This module only locates and loads them; validating needs the
|
|
5
|
+
optional ``jsonschema`` package (see :func:`validator`).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import json
|
|
9
|
+
from functools import cache
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"API_VERSION",
|
|
14
|
+
"__version__",
|
|
15
|
+
"BASE_URI",
|
|
16
|
+
"PROTOCOL_VERSION",
|
|
17
|
+
"capabilities",
|
|
18
|
+
"conformance_dir",
|
|
19
|
+
"load_schemas",
|
|
20
|
+
"schema",
|
|
21
|
+
"schema_dir",
|
|
22
|
+
"validator",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
#: The product version (scripts/version.py keeps it equal to VERSION in the repository root).
|
|
26
|
+
__version__ = "0.1.0"
|
|
27
|
+
|
|
28
|
+
#: The wire protocol version (SPEC §6.2). Version 2 is Taflor's first.
|
|
29
|
+
PROTOCOL_VERSION = 2
|
|
30
|
+
|
|
31
|
+
#: The plugin API version (SPEC §3.7). Pre-release: no API has been published yet.
|
|
32
|
+
API_VERSION = "1.0.0"
|
|
33
|
+
|
|
34
|
+
#: Every schema's ``$id`` starts with this.
|
|
35
|
+
BASE_URI = "https://taflor.org/schemas/"
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _root(name):
|
|
39
|
+
# Installed wheel: the folders sit inside the package. Source checkout: next to it.
|
|
40
|
+
here = Path(__file__).resolve().parent
|
|
41
|
+
for candidate in (here / name, here.parent / name):
|
|
42
|
+
if candidate.is_dir():
|
|
43
|
+
return candidate
|
|
44
|
+
raise FileNotFoundError(f"taflor_protocol: folder {name!r} not found")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def schema_dir():
|
|
48
|
+
return _root("schemas")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def conformance_dir():
|
|
52
|
+
return _root("conformance")
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@cache
|
|
56
|
+
def load_schemas():
|
|
57
|
+
"""All schemas, keyed by ``$id``."""
|
|
58
|
+
schemas = {}
|
|
59
|
+
for path in sorted(schema_dir().rglob("*.json")):
|
|
60
|
+
data = json.loads(path.read_text(encoding="utf-8"))
|
|
61
|
+
schemas[data["$id"]] = data
|
|
62
|
+
return schemas
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def schema(name):
|
|
66
|
+
"""One schema by ``$id`` or by its path below BASE_URI, e.g. ``"manifest/v1.json"``."""
|
|
67
|
+
schemas = load_schemas()
|
|
68
|
+
return schemas[name if name in schemas else BASE_URI + name]
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@cache
|
|
72
|
+
def capabilities():
|
|
73
|
+
"""The capability catalogue (SPEC §6.4) as a dict keyed by capability name."""
|
|
74
|
+
data = json.loads((_root("data") / "capabilities.json").read_text(encoding="utf-8"))
|
|
75
|
+
return {entry["name"]: entry for entry in data["capabilities"]}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def validator(name):
|
|
79
|
+
"""A ``jsonschema`` validator for one schema, with every other schema resolvable by ``$ref``."""
|
|
80
|
+
from jsonschema import Draft202012Validator
|
|
81
|
+
from referencing import Registry, Resource
|
|
82
|
+
|
|
83
|
+
registry = Registry().with_resources(
|
|
84
|
+
(uri, Resource.from_contents(contents))
|
|
85
|
+
for uri, contents in load_schemas().items()
|
|
86
|
+
)
|
|
87
|
+
return Draft202012Validator(
|
|
88
|
+
schema(name),
|
|
89
|
+
registry=registry,
|
|
90
|
+
format_checker=Draft202012Validator.FORMAT_CHECKER,
|
|
91
|
+
)
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Conformance scenarios
|
|
2
|
+
|
|
3
|
+
A scenario describes one behaviour of the table protocol that every server and host has to show
|
|
4
|
+
(SPEC §13.2): a table set up with seats and objects, then messages sent and the messages each seat
|
|
5
|
+
must, or must never, receive. Runners play the scenarios against a server: in process against
|
|
6
|
+
`taflor_server`, over the network against any server started with `TABLE_CONFORMANCE=1`, and in
|
|
7
|
+
process against `OfflineSync`. The runners don't exist yet.
|
|
8
|
+
|
|
9
|
+
Files live in `conformance/v<PROTOCOL_VERSION>/<capability>/<scenario>.yaml` and validate against
|
|
10
|
+
the JSON Schema `https://taflor.org/schemas/conformance/v2/scenario.json`. A server claims a
|
|
11
|
+
capability only if it passes every scenario in that capability's folder.
|
|
12
|
+
|
|
13
|
+
## Example
|
|
14
|
+
|
|
15
|
+
```yaml
|
|
16
|
+
scenario: object-move # = the file name
|
|
17
|
+
title: A player moves the token they control; others may not
|
|
18
|
+
capability: core # = the folder name
|
|
19
|
+
protocol: 2
|
|
20
|
+
spec: ["§5.3", "§6.7"] # optional: what it checks
|
|
21
|
+
fixture:
|
|
22
|
+
seats:
|
|
23
|
+
gm: {role: gm}
|
|
24
|
+
alice: {role: player}
|
|
25
|
+
bob: {role: player}
|
|
26
|
+
objects:
|
|
27
|
+
- {ref: mira, kind: token, name: Mira, x: 100, y: 100, controlled_by: ["@alice"]}
|
|
28
|
+
steps:
|
|
29
|
+
- send:
|
|
30
|
+
from: alice
|
|
31
|
+
message: {type: object.update, id: "@mira", patch: {x: 160, y: 120}}
|
|
32
|
+
- expect:
|
|
33
|
+
to: all
|
|
34
|
+
message: {type: object.upserted, object: {id: "@mira", x: 160}}
|
|
35
|
+
- send:
|
|
36
|
+
from: bob
|
|
37
|
+
message: {type: object.update, id: "@mira", patch: {x: 0, y: 0}}
|
|
38
|
+
- expect:
|
|
39
|
+
to: bob
|
|
40
|
+
message: {type: error, code: "@*"}
|
|
41
|
+
- never:
|
|
42
|
+
to: all
|
|
43
|
+
message: {type: object.upserted, object: {id: "@mira", x: 0}}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Fixture
|
|
47
|
+
|
|
48
|
+
- `table` (optional): `name`, `capabilities` (default: every core capability of
|
|
49
|
+
`data/capabilities.json`) and `settings`.
|
|
50
|
+
- `seats`: the users at the table by ref. `role` is `gm`, `player`, `viewer` or `denied`.
|
|
51
|
+
`anonymous: true` (viewers only) gives a visitor without a user id. `protocol` is the `?v=` the
|
|
52
|
+
seat connects with (default: the scenario's `protocol`). `connect: false` keeps the seat off
|
|
53
|
+
the table; it is there for its user id only. The ref `all` is reserved.
|
|
54
|
+
- `policies`: data-key policies (SPEC §5.3) the table has, as a host or plugin would declare them.
|
|
55
|
+
- `objects`: objects on the table before the first step, each with a `ref` and a `kind`. Fields not
|
|
56
|
+
given take the kind's defaults. `"@alice"` stands for the user id of seat `alice`.
|
|
57
|
+
|
|
58
|
+
Before the first step every seat with `connect` true connects, in the order given. The messages it
|
|
59
|
+
receives from then on, `state` included, go into its inbox.
|
|
60
|
+
|
|
61
|
+
## Steps
|
|
62
|
+
|
|
63
|
+
Each step is an object with exactly one key.
|
|
64
|
+
|
|
65
|
+
| step | fields | meaning |
|
|
66
|
+
|---|---|---|
|
|
67
|
+
| `send` | `from`, `message` | the seat sends the message |
|
|
68
|
+
| `expect` | `to`, `message` | each seat in `to` receives a message that matches |
|
|
69
|
+
| `never` | `to`, `message` | no seat in `to` receives a matching message from the last `send` before this step to the end of the scenario (from connecting when there is none) |
|
|
70
|
+
| `expectClose` | `to`, `code` | the server closes each seat's socket with this close code |
|
|
71
|
+
|
|
72
|
+
`to` is a seat ref, a list of refs, or `all` (every seat that connected).
|
|
73
|
+
|
|
74
|
+
**Ordering per recipient.** Every seat's inbox is read in order. An `expect` looks at the messages
|
|
75
|
+
after the one the seat's previous `expect` matched and takes the first that matches; messages it
|
|
76
|
+
skips over are fine. So two `expect`s for one seat must come in the order the seat receives the
|
|
77
|
+
messages, while the order between seats is free. A runner waits for a matching message up to its
|
|
78
|
+
timeout, then fails the step.
|
|
79
|
+
|
|
80
|
+
**Settling.** Before the scenario ends, the runner waits until no message has arrived for its
|
|
81
|
+
settle time, then checks every `never`.
|
|
82
|
+
|
|
83
|
+
## Matcher
|
|
84
|
+
|
|
85
|
+
A `message` in `expect` and `never` is a pattern:
|
|
86
|
+
|
|
87
|
+
- Objects match partially: every key in the pattern must match, other keys of the message are
|
|
88
|
+
ignored.
|
|
89
|
+
- Arrays match element by element and must have the same length. For other checks use the
|
|
90
|
+
operators below.
|
|
91
|
+
- Numbers match by value (`1` matches `1.0`). Other scalars must be equal.
|
|
92
|
+
- Strings starting with `@` are special:
|
|
93
|
+
|
|
94
|
+
| pattern | matches |
|
|
95
|
+
|---|---|
|
|
96
|
+
| `"@alice"` | the value the ref stands for: a seat's user id, a fixture object's id, or a bound value |
|
|
97
|
+
| `"@=name"` | any value, and binds it to `name` (the first match wins); later steps use `"@name"` |
|
|
98
|
+
| `"@*"` | any value, the key must be present |
|
|
99
|
+
| `"@absent"` | the key must be missing (only as the value of an object key) |
|
|
100
|
+
| `"@@text"` | the literal string `@text` |
|
|
101
|
+
|
|
102
|
+
- An object whose keys all start with `@` is a set of array operators, all of which must hold:
|
|
103
|
+
|
|
104
|
+
| operator | matches an array that |
|
|
105
|
+
|---|---|
|
|
106
|
+
| `{"@contains": [p, …]}` | has, for every pattern `p`, a different element matching it, in any order |
|
|
107
|
+
| `{"@excludes": [p, …]}` | has no element matching any of the patterns |
|
|
108
|
+
|
|
109
|
+
Refs in `send` messages are replaced by their values before sending. A ref that is not defined by
|
|
110
|
+
the fixture or bound by an earlier step is an error of the scenario.
|
|
111
|
+
|
|
112
|
+
## Schema checks
|
|
113
|
+
|
|
114
|
+
Every `send` message, with its refs replaced, MUST validate against
|
|
115
|
+
`protocol/v2/client-message.json`; the package's tests check that. Patterns are partial, so the
|
|
116
|
+
runner validates every message a seat actually receives against
|
|
117
|
+
`protocol/v2/server-message.json` instead.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
scenario: gm-only-key
|
|
2
|
+
title: A GM-only data key and a hidden token never reach players
|
|
3
|
+
description: >-
|
|
4
|
+
The policy is the example of SPEC §5.3. The GM sets the key and later hides the token: players
|
|
5
|
+
get the object without the key, then object.deleted, and never the key or the hidden object.
|
|
6
|
+
capability: core
|
|
7
|
+
protocol: 2
|
|
8
|
+
spec: ["§5.3", "§6.7"]
|
|
9
|
+
fixture:
|
|
10
|
+
seats:
|
|
11
|
+
gm: {role: gm}
|
|
12
|
+
alice: {role: player}
|
|
13
|
+
policies:
|
|
14
|
+
- {kind: token, key: health, writable_by: controller, visible_to: all}
|
|
15
|
+
- {kind: token, key: hide_status, writable_by: gm, visible_to: gm}
|
|
16
|
+
objects:
|
|
17
|
+
- {ref: goblin, kind: token, name: Goblin, x: 0, y: 0, data: {health: {value: 7, max: 7}}}
|
|
18
|
+
steps:
|
|
19
|
+
- send:
|
|
20
|
+
from: gm
|
|
21
|
+
message: {type: object.update, id: "@goblin", patch: {data: {hide_status: true}}}
|
|
22
|
+
- expect:
|
|
23
|
+
to: gm
|
|
24
|
+
message:
|
|
25
|
+
type: object.upserted
|
|
26
|
+
object: {id: "@goblin", data: {hide_status: true, health: {value: 7}}}
|
|
27
|
+
- expect:
|
|
28
|
+
to: alice
|
|
29
|
+
message:
|
|
30
|
+
type: object.upserted
|
|
31
|
+
object: {id: "@goblin", data: {hide_status: "@absent", health: {value: 7}}}
|
|
32
|
+
- never:
|
|
33
|
+
to: alice
|
|
34
|
+
message:
|
|
35
|
+
type: object.upserted
|
|
36
|
+
object: {data: {hide_status: "@*"}}
|
|
37
|
+
- send:
|
|
38
|
+
from: gm
|
|
39
|
+
message: {type: object.update, id: "@goblin", patch: {hidden: true}}
|
|
40
|
+
- expect:
|
|
41
|
+
to: gm
|
|
42
|
+
message:
|
|
43
|
+
type: object.upserted
|
|
44
|
+
object: {id: "@goblin", hidden: true}
|
|
45
|
+
- expect:
|
|
46
|
+
to: alice
|
|
47
|
+
message: {type: object.deleted, id: "@goblin"}
|
|
48
|
+
- never:
|
|
49
|
+
to: alice
|
|
50
|
+
message:
|
|
51
|
+
type: object.upserted
|
|
52
|
+
object: {id: "@goblin"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
scenario: join
|
|
2
|
+
title: Every seat gets a state shaped for its role
|
|
3
|
+
description: >-
|
|
4
|
+
The GM sees the hidden token, the player and the anonymous viewer do not. The viewer has no
|
|
5
|
+
user id.
|
|
6
|
+
capability: core
|
|
7
|
+
protocol: 2
|
|
8
|
+
spec: ["§4.3", "§6.4", "§6.7"]
|
|
9
|
+
fixture:
|
|
10
|
+
seats:
|
|
11
|
+
gm: {role: gm}
|
|
12
|
+
alice: {role: player}
|
|
13
|
+
visitor: {role: viewer, anonymous: true}
|
|
14
|
+
objects:
|
|
15
|
+
- {ref: map, kind: map, name: Ruins, x: 0, y: 0, width: 1200, height: 800, layer: map}
|
|
16
|
+
- {ref: trap, kind: token, name: Trap, x: 300, y: 200, hidden: true}
|
|
17
|
+
steps:
|
|
18
|
+
- expect:
|
|
19
|
+
to: gm
|
|
20
|
+
message:
|
|
21
|
+
type: state
|
|
22
|
+
me: {user_id: "@gm", role: gm, is_gm: true}
|
|
23
|
+
capabilities: {"@contains": [core]}
|
|
24
|
+
objects: {"@contains": [{id: "@map"}, {id: "@trap", hidden: true}]}
|
|
25
|
+
- expect:
|
|
26
|
+
to: alice
|
|
27
|
+
message:
|
|
28
|
+
type: state
|
|
29
|
+
me: {user_id: "@alice", role: player, is_gm: false}
|
|
30
|
+
objects: {"@contains": [{id: "@map"}], "@excludes": [{id: "@trap"}]}
|
|
31
|
+
- expect:
|
|
32
|
+
to: visitor
|
|
33
|
+
message:
|
|
34
|
+
type: state
|
|
35
|
+
me: {user_id: null, role: viewer, is_gm: false}
|
|
36
|
+
objects: {"@excludes": [{id: "@trap"}]}
|
|
37
|
+
saved_views: []
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
scenario: object-create
|
|
2
|
+
title: A created object reaches everyone, the answer only the sender
|
|
3
|
+
capability: core
|
|
4
|
+
protocol: 2
|
|
5
|
+
spec: ["§6.3", "§6.6"]
|
|
6
|
+
fixture:
|
|
7
|
+
seats:
|
|
8
|
+
gm: {role: gm}
|
|
9
|
+
alice: {role: player}
|
|
10
|
+
steps:
|
|
11
|
+
- send:
|
|
12
|
+
from: gm
|
|
13
|
+
message: {type: object.create, request: c1, kind: note, x: 40, y: 60, name: Clue}
|
|
14
|
+
- expect:
|
|
15
|
+
to: gm
|
|
16
|
+
message: {type: object.created, request: c1, id: "@=clue"}
|
|
17
|
+
- expect:
|
|
18
|
+
to: alice
|
|
19
|
+
message:
|
|
20
|
+
type: object.upserted
|
|
21
|
+
object: {id: "@clue", kind: note, name: Clue, hidden: false}
|
|
22
|
+
- never:
|
|
23
|
+
to: alice
|
|
24
|
+
message: {type: object.created}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
scenario: object-move
|
|
2
|
+
title: A player moves the token they control; others may not
|
|
3
|
+
capability: core
|
|
4
|
+
protocol: 2
|
|
5
|
+
spec: ["§5.3", "§6.3", "§6.7"]
|
|
6
|
+
fixture:
|
|
7
|
+
seats:
|
|
8
|
+
gm: {role: gm}
|
|
9
|
+
alice: {role: player}
|
|
10
|
+
bob: {role: player}
|
|
11
|
+
objects:
|
|
12
|
+
- {ref: mira, kind: token, name: Mira, x: 100, y: 100, controlled_by: ["@alice"]}
|
|
13
|
+
steps:
|
|
14
|
+
- send:
|
|
15
|
+
from: alice
|
|
16
|
+
message: {type: object.update, id: "@mira", patch: {x: 160, y: 120}}
|
|
17
|
+
- expect:
|
|
18
|
+
to: all
|
|
19
|
+
message:
|
|
20
|
+
type: object.upserted
|
|
21
|
+
object: {id: "@mira", x: 160, y: 120, controlled_by: ["@alice"]}
|
|
22
|
+
- send:
|
|
23
|
+
from: bob
|
|
24
|
+
message: {type: object.update, id: "@mira", patch: {x: 0, y: 0}}
|
|
25
|
+
- expect:
|
|
26
|
+
to: bob
|
|
27
|
+
message: {type: error, code: "@*", id: "@mira"}
|
|
28
|
+
- never:
|
|
29
|
+
to: all
|
|
30
|
+
message:
|
|
31
|
+
type: object.upserted
|
|
32
|
+
object: {id: "@mira", x: 0}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
scenario: protocol-mismatch
|
|
2
|
+
title: A client with another protocol version gets the server's version and close 4426
|
|
3
|
+
capability: core
|
|
4
|
+
protocol: 2
|
|
5
|
+
spec: ["§6.2", "§6.3"]
|
|
6
|
+
fixture:
|
|
7
|
+
seats:
|
|
8
|
+
old: {role: player, protocol: 1}
|
|
9
|
+
steps:
|
|
10
|
+
- expect:
|
|
11
|
+
to: old
|
|
12
|
+
message: {type: protocol, version: 2}
|
|
13
|
+
- expectClose:
|
|
14
|
+
to: old
|
|
15
|
+
code: 4426
|
|
16
|
+
- never:
|
|
17
|
+
to: old
|
|
18
|
+
message: {type: state}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://taflor.org/schemas/protocol/v2/capabilities.json",
|
|
3
|
+
"capabilities": [
|
|
4
|
+
{
|
|
5
|
+
"name": "core",
|
|
6
|
+
"description": "The table itself: objects, layers, pings, rulers, the showcase, saved views and table settings. Every table has it; it gates nothing.",
|
|
7
|
+
"gates": [],
|
|
8
|
+
"since": "1.0.0"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"name": "players",
|
|
12
|
+
"description": "Player seats and player permissions. Without it the host seats no players (a GM-only table such as a master table) and the client hides the players tab; it gates no message.",
|
|
13
|
+
"gates": [],
|
|
14
|
+
"since": "1.0.0"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "fog",
|
|
18
|
+
"description": "Fog of war on battlemaps.",
|
|
19
|
+
"gates": ["fog.reset"],
|
|
20
|
+
"since": "1.0.0"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "combat",
|
|
24
|
+
"description": "The combat tracker and initiative.",
|
|
25
|
+
"gates": ["combat.*", "combat"],
|
|
26
|
+
"since": "1.0.0"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "dice",
|
|
30
|
+
"description": "Placed dice: die objects, set and rolled on the table with the server's RNG (SPEC §8.5).",
|
|
31
|
+
"gates": ["die.set", "die.roll"],
|
|
32
|
+
"kinds": ["die"],
|
|
33
|
+
"since": "1.0.0"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"name": "paths",
|
|
37
|
+
"description": "Path objects (drawn lines and routes).",
|
|
38
|
+
"gates": [],
|
|
39
|
+
"kinds": ["path"],
|
|
40
|
+
"since": "1.0.0"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"name": "gminfo",
|
|
44
|
+
"description": "GM info objects: text only the GM sees, and turning notes into GM info and back.",
|
|
45
|
+
"gates": ["object.convert"],
|
|
46
|
+
"kinds": ["gminfo"],
|
|
47
|
+
"since": "1.0.0"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"name": "presence",
|
|
51
|
+
"description": "Who is at the table.",
|
|
52
|
+
"gates": ["presence.ping", "presence.pong", "presence"],
|
|
53
|
+
"since": "1.0.0"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"name": "cursors",
|
|
57
|
+
"description": "Other users' cursors.",
|
|
58
|
+
"gates": ["cursor", "cursor.leave"],
|
|
59
|
+
"since": "1.0.0"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"name": "view-pull",
|
|
63
|
+
"description": "The GM pulls everyone's view to theirs.",
|
|
64
|
+
"gates": ["view.pull"],
|
|
65
|
+
"since": "1.0.0"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"name": "docs",
|
|
69
|
+
"description": "The document store (SPEC §5.5).",
|
|
70
|
+
"gates": ["doc.*"],
|
|
71
|
+
"since": "1.0.0"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"name": "rolls",
|
|
75
|
+
"description": "The game keeps a roll log (TableHost.roll_log, SPEC §8.5): the dice log and its history over HTTP (§6.9). dice.rolled is sent with or without it; it gates no message.",
|
|
76
|
+
"gates": [],
|
|
77
|
+
"since": "1.0.0"
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://taflor.org/schemas/common/v1.json",
|
|
4
|
+
"title": "Shared definitions",
|
|
5
|
+
"description": "Identifiers, versions and paths shared by the protocol, manifest and sheet schemas.",
|
|
6
|
+
"$defs": {
|
|
7
|
+
"pluginId": {
|
|
8
|
+
"description": "A plugin or server extension id (SPEC §7.3, §9.2: one namespace).",
|
|
9
|
+
"type": "string",
|
|
10
|
+
"pattern": "^[a-z0-9][a-z0-9-]{1,31}$"
|
|
11
|
+
},
|
|
12
|
+
"shortName": {
|
|
13
|
+
"description": "A short name a plugin registers or declares (SPEC §7.3 contributes): no '.' or ':' (§10.2).",
|
|
14
|
+
"type": "string",
|
|
15
|
+
"pattern": "^[a-z0-9][a-z0-9-]{0,31}$"
|
|
16
|
+
},
|
|
17
|
+
"persistedId": {
|
|
18
|
+
"description": "A catalogue id stored in data: '<plugin>:<name>', or a bare name reserved by a bundled base plugin (SPEC §3.6, §7.11).",
|
|
19
|
+
"type": "string",
|
|
20
|
+
"pattern": "^([a-z0-9][a-z0-9-]{1,31}:)?[a-z0-9][a-z0-9-]{0,31}$"
|
|
21
|
+
},
|
|
22
|
+
"pluginKindId": {
|
|
23
|
+
"description": "An object kind on the wire: a core kind name, or '<plugin>.<name>' for a plugin kind (SPEC §7.7).",
|
|
24
|
+
"type": "string",
|
|
25
|
+
"pattern": "^([a-z0-9][a-z0-9-]{1,31}\\.)?[a-z0-9][a-z0-9-]{0,31}$"
|
|
26
|
+
},
|
|
27
|
+
"namespacedType": {
|
|
28
|
+
"description": "Wire type of a plugin or extension message: 'x.<id>.<name>', <name> a short name (SPEC §6.6, §7.3).",
|
|
29
|
+
"type": "string",
|
|
30
|
+
"pattern": "^x\\.[a-z0-9][a-z0-9-]{1,31}\\.[a-z0-9][a-z0-9-]{0,31}$"
|
|
31
|
+
},
|
|
32
|
+
"capabilityName": {
|
|
33
|
+
"description": "A table capability: a core name from the catalogue, or '<id>.<name>' for a server extension's (SPEC §6.4).",
|
|
34
|
+
"type": "string",
|
|
35
|
+
"pattern": "^([a-z0-9][a-z0-9-]{1,31}\\.)?[a-z0-9][a-z0-9-]{0,31}$"
|
|
36
|
+
},
|
|
37
|
+
"errorCode": {
|
|
38
|
+
"description": "A stable error code: '<area>.<reason>' for the core, 'x.<plugin>.<reason>' for plugins; lower case, the reason may contain '_' and '-' (SPEC §6.3).",
|
|
39
|
+
"type": "string",
|
|
40
|
+
"pattern": "^(x\\.[a-z0-9][a-z0-9-]{1,31}\\.[a-z0-9][a-z0-9_-]*|[a-z][a-z0-9-]*\\.[a-z][a-z0-9_-]*)$"
|
|
41
|
+
},
|
|
42
|
+
"request": {
|
|
43
|
+
"description": "Correlation id of a client request, any text of at most 64 characters; the answer echoes it (SPEC §6.3).",
|
|
44
|
+
"type": "string",
|
|
45
|
+
"maxLength": 64
|
|
46
|
+
},
|
|
47
|
+
"role": {
|
|
48
|
+
"description": "A user's role at a table (SPEC §4.3); 'denied' never reaches a socket.",
|
|
49
|
+
"enum": ["gm", "player", "viewer"]
|
|
50
|
+
},
|
|
51
|
+
"userId": {
|
|
52
|
+
"description": "A user id. Anonymous viewers have none (SPEC §4.3).",
|
|
53
|
+
"type": "integer",
|
|
54
|
+
"minimum": 1
|
|
55
|
+
},
|
|
56
|
+
"semver": {
|
|
57
|
+
"description": "A strict semantic version (semver.org 2.0.0).",
|
|
58
|
+
"type": "string",
|
|
59
|
+
"pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(-((0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(\\.(0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\\+([0-9a-zA-Z-]+(\\.[0-9a-zA-Z-]+)*))?$"
|
|
60
|
+
},
|
|
61
|
+
"semverRange": {
|
|
62
|
+
"description": "An npm-style semver range, e.g. '^1.2' (SPEC §7.3, §9.2). The range grammar is checked by the install pipeline, not here.",
|
|
63
|
+
"type": "string",
|
|
64
|
+
"minLength": 1,
|
|
65
|
+
"maxLength": 128
|
|
66
|
+
},
|
|
67
|
+
"protocolVersions": {
|
|
68
|
+
"description": "The PROTOCOL_VERSIONs a plugin or extension works with (SPEC §7.3, §9.2).",
|
|
69
|
+
"type": "array",
|
|
70
|
+
"items": {"type": "integer", "minimum": 1},
|
|
71
|
+
"minItems": 1,
|
|
72
|
+
"uniqueItems": true
|
|
73
|
+
},
|
|
74
|
+
"lang": {
|
|
75
|
+
"description": "A language tag (BCP 47), e.g. 'en' or 'de'.",
|
|
76
|
+
"type": "string",
|
|
77
|
+
"pattern": "^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$"
|
|
78
|
+
},
|
|
79
|
+
"localizedText": {
|
|
80
|
+
"description": "Text per language; 'en' MUST be present (SPEC §7.3).",
|
|
81
|
+
"type": "object",
|
|
82
|
+
"required": ["en"],
|
|
83
|
+
"propertyNames": {"$ref": "#/$defs/lang"},
|
|
84
|
+
"additionalProperties": {"type": "string", "minLength": 1}
|
|
85
|
+
},
|
|
86
|
+
"relativePath": {
|
|
87
|
+
"description": "A path inside the plugin folder. Refused: absolute paths, '..', backslashes, drive letters, NUL and control characters (SPEC §10.2).",
|
|
88
|
+
"type": "string",
|
|
89
|
+
"minLength": 1,
|
|
90
|
+
"maxLength": 255,
|
|
91
|
+
"pattern": "^(?![/])(?![A-Za-z]:)(?!.*(^|/)\\.\\.(/|$))[^\\\\\\u0000-\\u001f\\u007f]+$"
|
|
92
|
+
},
|
|
93
|
+
"httpsUrl": {
|
|
94
|
+
"description": "An absolute https URL (SPEC §10.1: network fetches use https only).",
|
|
95
|
+
"type": "string",
|
|
96
|
+
"format": "uri",
|
|
97
|
+
"pattern": "^https://"
|
|
98
|
+
},
|
|
99
|
+
"origin": {
|
|
100
|
+
"description": "A web origin: scheme, host name and optional port; no path, wildcard or keyword.",
|
|
101
|
+
"type": "string",
|
|
102
|
+
"pattern": "^https?://([A-Za-z0-9-]+\\.)*[A-Za-z0-9-]+(:[0-9]{1,5})?$",
|
|
103
|
+
"x-taflor-open": "SPEC does not say whether plain http origins are allowed (e.g. for local development); this pattern accepts them."
|
|
104
|
+
},
|
|
105
|
+
"sha256": {
|
|
106
|
+
"type": "string",
|
|
107
|
+
"pattern": "^[0-9a-f]{64}$"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|