Links

filter

This parser helps you filter a SDTF graph.

Interface

interface parser {
name: 'filter';
options: {
query: SDTFQuery;
resolveAliases?: boolean;
allowUnresolvableAliases?: boolean;
};
}

Options

Parameter
Required
Type
Default
Description
query
required
SDTFQuery
The query that select items in the graph.
resolveAliases
optional
boolean
false
Whether to resolve the aliases of the graph. Thus, preventing aliases to become unresolvable when their source is not included in the selected items.
allowUnresolvableAliases
optional
boolean
true
Whether to allow unresolvable aliases to flow through. This option is only available when resolveAliases = true

Basic usage: select all tokens from a group in a collection

Input
Config
Output
1
{
2
"colors": {
3
"$collection": {
4
"$modes": ["light", "dark"]
5
},
6
"info": {
7
"infoToken": {
8
"$type": "color",
9
"$value": {
10
"light": {
11
"model": "rgb",
12
"red": 219,
13
"green": 234,
14
"blue": 254,
15
"alpha": 1
16
},
17
"dark": {
18
"model": "rgb",
19
"red": 219,
20
"green": 234,
21
"blue": 254,
22
"alpha": 1
23
}
24
}
25
}
26
},
27
"danger": {
28
"dangerToken": {
29
"$type": "color",
30
"$value": {
31
"light": {
32
"model": "rgb",
33
"red": 209,
34
"green": 204,
35
"blue": 204,
36
"alpha": 1
37
},
38
"dark": {
39
"model": "rgb",
40
"red": 19,
41
"green": 34,
42
"blue": 54,
43
"alpha": 1
44
}
45
}
46
}
47
}
48
}
49
}
  1. 1.
    We want to get all tokens in all groups named "info"
  2. 2.
    We also want to get the parent collection...
  3. 3.
    ... and all children tokens within the "info" group(s)
  4. 4.
    We eventually generate our transformed SDTF graph in a JSON file thanks to the to-sdtf parser.
.specifyrc.json
1
{
2
"version": "2",
3
"repository": "@owner/repository",
4
"personalAccessToken": "<your-personal-access-token>",
5
"rules": [
6
{
7
"name": "filter",
8
"options": {
9
"query": {
10
"where": {
11
"group": "info",
12
"select": {
13
"parents": true,
14
"children": true
15
}
16
}
17
}
18
}
19
},
20
{
21
"name": "to-sdtf",
22
"output": {
23
"type": "file",
24
"filePath": "tokens.json"
25
}
26
}
27
]
28
}
tokens.json
1
{
2
"colors": {
3
"$collection": {
4
"$modes": ["light", "dark"]
5
},
6
"info": {
7
"infoToken": {
8
"$type": "color",
9
"$value": {
10
"light": {
11
"model": "rgb",
12
"red": 219,
13
"green": 234,
14
"blue": 254,
15
"alpha": 1
16
},
17
"dark": {
18
"model": "rgb",
19
"red": 219,
20
"green": 234,
21
"blue": 254,
22
"alpha": 1
23
}
24
}
25
}
26
}
27
}
28
}