Skip to content

Commit d6f337f

Browse files
eemeliaphillipsgibson042
authored
Flatten JSON & TS data model Pattern element (#585)
* Flatten JSON & TS data model Pattern element * Apply suggestions from code review Co-authored-by: Addison Phillips <[email protected]> * Update spec/data-model/README.md Co-authored-by: Richard Gibson <[email protected]> --------- Co-authored-by: Addison Phillips <[email protected]> Co-authored-by: Richard Gibson <[email protected]>
1 parent a074819 commit d6f337f

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

spec/data-model/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,19 @@ interface CatchallKey {
109109

110110
## Patterns
111111

112-
Each `Pattern` represents a linear sequence, without selectors.
113-
Each element of the `body` array MUST either be a non-empty string or an `Expression` object.
114-
String values represent literal _text_,
115-
while `Expression` wraps each of the potential _expression_ shapes.
116-
The `body` strings are the "cooked" _text_ values, i.e. escape sequences are processed.
112+
Each `Pattern` contains a linear sequence of text and placeholders corresponding to potential output of a message.
113+
114+
Each element of the `Pattern` MUST either be a non-empty string or an `Expression` object.
115+
String values represent literal _text_.
116+
String values include all processing of the underlying _text_ values,
117+
including escape sequence processing.
118+
`Expression` values wrap each of the _expression_ shapes.
117119

118120
Implementations MUST NOT rely on the set of `Expression` interfaces being exhaustive,
119121
as future versions of this specification MAY define additional expressions.
120122

121123
```ts
122-
interface Pattern {
123-
body: Array<string | Expression>;
124-
}
124+
type Pattern = Array<string | Expression>;
125125

126126
type Expression = LiteralExpression | VariableExpression | FunctionExpression |
127127
UnsupportedExpression;

spec/data-model/message.json

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
"properties": {
2828
"name": { "type": "string" },
2929
"value": {
30-
"oneOf": [{ "$ref": "#/$defs/literal" }, { "$ref": "#/$defs/variable" }]
30+
"oneOf": [
31+
{ "$ref": "#/$defs/literal" },
32+
{ "$ref": "#/$defs/variable" }
33+
]
3134
}
3235
},
3336
"required": ["name", "value"]
@@ -104,16 +107,10 @@
104107
},
105108

106109
"pattern": {
107-
"type": "object",
108-
"properties": {
109-
"body": {
110-
"type": "array",
111-
"items": {
112-
"oneOf": [{ "type": "string" }, { "$ref": "#/$defs/expression" }]
113-
}
114-
}
115-
},
116-
"required": ["body"]
110+
"type": "array",
111+
"items": {
112+
"oneOf": [{ "type": "string" }, { "$ref": "#/$defs/expression" }]
113+
}
117114
},
118115

119116
"input-declaration": {

0 commit comments

Comments
 (0)