Created
February 1, 2021 16:41
-
-
Save zbraniecki/ea8f906cea2c65b10fdca5ae2b0287f7 to your computer and use it in GitHub Desktop.
MF2.0 Data Model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Changed NumberLiteral to be a float+precision | |
// Added Variant::default | |
// Separated Arguments and Options on a FunctionReference | |
// Added KeyValuePair used in FunctionReference and maybe in MessageReference | |
// Added optional MessageReference if we decide to go for it | |
export type Message = MessageValue; | |
export type MessageValue = Single | Multi; | |
export type Single = Pattern; | |
export interface Multi { | |
selector: InlineExpression[]; | |
variants: Variant[]; | |
} | |
export type Pattern = PatternElement[]; | |
export type PatternElement = Text | Placeholder; | |
export type Text = string; | |
export type Placeholder = InlineExpression; | |
export interface Variant { | |
key: VariantKey[]; | |
value: Pattern; | |
default: bool; | |
} | |
export type VariantKey = StringLiteral | NumberLiteral; | |
export type InlineExpression = StringLiteral | NumberLiteral | FunctionReference | VariableReference | MessageReference; | |
export type StringLiteral = string; | |
export interface NumberLiteral = { | |
value: Float; | |
precision: Number; | |
} | |
export interface FunctionReference { | |
id: Identifier; | |
arguments: InlineExpression[]; | |
options: KeyValuePair[]; | |
} | |
export interface KeyValuePair { | |
key: Identifier; | |
value: InlineExpression; | |
} | |
export type VariableReference = Identifier[]; | |
// If we decide to go for syntax, we could also just have a function MSG_REF() | |
export interface MessageReference = { | |
id: Identifier[]; | |
arguments: KeyValuePair[]; | |
} | |
export type Identifier = string; // [a-zA-Z][a-zA-Z0-9_-] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment