@openpronoun/schema 0.0.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/README.md +62 -0
- package/package.json +18 -0
- package/pronoun-set.schema.json +64 -0
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# @openpronoun/schema
|
|
2
|
+
|
|
3
|
+
The canonical [JSON Schema](https://json-schema.org/) (draft 2020-12) for the
|
|
4
|
+
[OpenPronoun](https://openpronoun.org) data model — `PronounPreference` and
|
|
5
|
+
`PronounSet`. This is the normative model the rest of the ecosystem builds on:
|
|
6
|
+
the runtime library, the conformance fixtures, and any community port all
|
|
7
|
+
validate against this one schema.
|
|
8
|
+
|
|
9
|
+
## Contents
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
packages/schema/
|
|
13
|
+
├── package.json
|
|
14
|
+
├── README.md
|
|
15
|
+
└── pronoun-set.schema.json # PronounPreference / PronounSet (JSON Schema 2020-12)
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
Import the schema as JSON and feed it to any validator (e.g. Ajv):
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
import Ajv from "ajv/dist/2020.js";
|
|
24
|
+
import schema from "@openpronoun/schema" with { type: "json" };
|
|
25
|
+
|
|
26
|
+
const validate = new Ajv({ strict: false }).compile(schema);
|
|
27
|
+
|
|
28
|
+
validate([{ subjective: "she", objective: "her", possessive_adjective: "her",
|
|
29
|
+
possessive_pronoun: "hers", reflexive: "herself" }]); // true
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
CommonJS and bundler-resolved paths also work via the package exports:
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
const schema = require("@openpronoun/schema");
|
|
36
|
+
// or resolve the file directly:
|
|
37
|
+
import schemaUrl from "@openpronoun/schema/pronoun-set.schema.json";
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## What it validates
|
|
41
|
+
|
|
42
|
+
A `PronounPreference` is an array of one or more entries. Each entry is one of:
|
|
43
|
+
|
|
44
|
+
- a **standard set** — five English forms in full keys (`subjective`, `objective`,
|
|
45
|
+
`possessive_adjective`, `possessive_pronoun`, `reflexive`) or compact keys
|
|
46
|
+
(`sub`, `obj`, `p_a`, `p_pn`, `ref`);
|
|
47
|
+
- a **special preference** — `{ "type": "any" | "none" | "ask" | "unspecified" }`;
|
|
48
|
+
- a **custom** entry — `{ "type": "custom", "display": "…" }`, optionally with
|
|
49
|
+
form fields.
|
|
50
|
+
|
|
51
|
+
Optional per-entry fields: `ranking`/`rnk`, `context`/`ctx`, `privacy`/`pvc`,
|
|
52
|
+
`language`/`lang` (ISO 639-1), and `exclude`/`exc`.
|
|
53
|
+
|
|
54
|
+
See the [data model](https://openpronoun.org/specification/data-model/) and
|
|
55
|
+
[conformance](https://openpronoun.org/specification/conformance/) docs for the
|
|
56
|
+
full normative definition.
|
|
57
|
+
|
|
58
|
+
## Note
|
|
59
|
+
|
|
60
|
+
This package ships only the schema. TypeScript types can be generated from it at
|
|
61
|
+
build time (e.g. with `json-schema-to-typescript`) in a downstream package if
|
|
62
|
+
desired.
|
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@openpronoun/schema",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Canonical JSON Schema for the OpenPronoun data model (PronounPreference / PronounSet).",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"files": [
|
|
8
|
+
"pronoun-set.schema.json",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
11
|
+
"exports": {
|
|
12
|
+
".": "./pronoun-set.schema.json",
|
|
13
|
+
"./pronoun-set.schema.json": "./pronoun-set.schema.json"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://openpronoun.org/schemas/pronoun-set.schema.json",
|
|
4
|
+
"title": "PronounPreference",
|
|
5
|
+
"description": "An ordered collection of one or more pronoun entries. Each entry is a standard pronoun set, a special preference (any/none/ask), or a custom entry.",
|
|
6
|
+
"type": "array",
|
|
7
|
+
"minItems": 1,
|
|
8
|
+
"items": { "$ref": "#/$defs/pronounEntry" },
|
|
9
|
+
|
|
10
|
+
"$defs": {
|
|
11
|
+
"pronounEntry": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"additionalProperties": false,
|
|
14
|
+
"properties": {
|
|
15
|
+
"subjective": { "type": "string", "minLength": 1 },
|
|
16
|
+
"objective": { "type": "string", "minLength": 1 },
|
|
17
|
+
"possessive_adjective": { "type": "string", "minLength": 1 },
|
|
18
|
+
"possessive_pronoun": { "type": "string", "minLength": 1 },
|
|
19
|
+
"reflexive": { "type": "string", "minLength": 1 },
|
|
20
|
+
|
|
21
|
+
"sub": { "type": "string", "minLength": 1 },
|
|
22
|
+
"obj": { "type": "string", "minLength": 1 },
|
|
23
|
+
"p_a": { "type": "string", "minLength": 1 },
|
|
24
|
+
"p_pn": { "type": "string", "minLength": 1 },
|
|
25
|
+
"ref": { "type": "string", "minLength": 1 },
|
|
26
|
+
|
|
27
|
+
"type": { "enum": ["any", "none", "ask", "unspecified", "custom"] },
|
|
28
|
+
"display": { "type": "string", "minLength": 1 },
|
|
29
|
+
|
|
30
|
+
"ranking": { "type": "integer" },
|
|
31
|
+
"rnk": { "type": "integer" },
|
|
32
|
+
"exclude": { "type": "boolean" },
|
|
33
|
+
"exc": { "type": "boolean" },
|
|
34
|
+
"context": { "type": "string" },
|
|
35
|
+
"ctx": { "type": "string" },
|
|
36
|
+
"privacy": { "type": "integer", "minimum": 0 },
|
|
37
|
+
"pvc": { "type": "integer", "minimum": 0 },
|
|
38
|
+
"language": { "type": "string", "pattern": "^[a-z]{2}$" },
|
|
39
|
+
"lang": { "type": "string", "pattern": "^[a-z]{2}$" }
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
"allOf": [
|
|
43
|
+
{
|
|
44
|
+
"$comment": "A standard set (no type) MUST provide all five forms, in either full or compact keys.",
|
|
45
|
+
"if": { "not": { "required": ["type"] } },
|
|
46
|
+
"then": {
|
|
47
|
+
"oneOf": [
|
|
48
|
+
{ "required": ["subjective", "objective", "possessive_adjective", "possessive_pronoun", "reflexive"] },
|
|
49
|
+
{ "required": ["sub", "obj", "p_a", "p_pn", "ref"] }
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"$comment": "A custom entry MUST carry a display string; form fields are optional.",
|
|
55
|
+
"if": {
|
|
56
|
+
"properties": { "type": { "const": "custom" } },
|
|
57
|
+
"required": ["type"]
|
|
58
|
+
},
|
|
59
|
+
"then": { "required": ["display"] }
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|