-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsdmx-patterns.coffee
227 lines (192 loc) · 5.58 KB
/
sdmx-patterns.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
NCNameIDType = ///
[A-Za-z] # Must begin with a letter
[A-Za-z0-9_-]* # May be followed by letters, numbers, _ or -
///
NCNameIDTypeAlone = /// ^
#{NCNameIDType.source}
$ ///
NestedNCNameIDType = ///
#{NCNameIDType.source} # An ID
(
\. # May be followed by a dot and other IDs
#{NCNameIDType.source}
)*
///
NestedNCNameIDTypeAlone = /// ^
#{NestedNCNameIDType.source}
$ ///
IDType = ///
[A-Za-z0-9_@$-]+ # Letters, numbers, _, @, $ or -
///
IDTypeAlone = /// ^
#{IDType.source}
$ ///
VersionNumber = ///
[0-9]+(\.[0-9]+)* # A version number (e.g. 1.0)
///
SemVer = ///
\+ # Latest stable
|~ # Latest (un)stable
|(0|[1-9]\d*[\+~]?|[\+~]?) # Major part
\.(0|[1-9]\d*[\+~]?|[\+~]?) # Minor part
\.?(0|[1-9]\d*[\+~]?|[\+~]?) # Patch part
(?:-((?: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-]+)*))?
///
VersionType = ///
( # Starts the OR clause
all # The string all
| latest # Or the string latest
| #{VersionNumber.source} # Or a version number
| #{SemVer.source} # Or semver
) # Ends the OR clause
///
SingleVersionType = ///
( # Starts the OR clause
latest # the string latest
| #{VersionNumber.source} # Or a version number
| #{SemVer.source} # Or semver
) # Ends the OR clause
///
SingleVersionTypeAlone = /// ^
#{SingleVersionType.source}
$ ///
VersionNumberAlone = /// ^
#{VersionNumber.source}
$ ///
VersionTypeAlone = /// ^
#{VersionType.source}
$ ///
NestedIDType = ///
[A-Za-z0-9_@$-]+ # Letters, numbers, _, @, $ or -
(\.[A-Za-z0-9_@$-]+)* # Potentially hierarchical (e.g. A.B.C)
///
NestedIDTypeAlone = /// ^
#{NestedIDType.source}
$ ///
SeriesKeyType = /// ^
(#{IDType.source}([+]#{IDType.source})*)? # One or more dimension values
# separated by a +
(
[.] # Potentially followed by a dot
(#{IDType.source}([+]#{IDType.source})*)? # and repeating above pattern
)*
$ ///
Sdmx3SeriesKeyType = /// ^
(\* | #{IDType.source})? # One star or a dimension value
(
[.] # Potentially followed by a dot
(\* | #{IDType.source})? # and repeating above pattern
)*
$ ///
FlowRefType = /// ^
(
#{IDType.source}
| (
#{NestedNCNameIDType.source}
,#{IDType.source}
(,(latest | (#{VersionNumber.source})))?
)
)
$ ///
ProviderRefType = ///
(#{NestedNCNameIDType.source},)? # May start with the agency owning the scheme
#{IDType.source} # The id of the provider
///
MultipleProviderRefType = /// ^
(#{ProviderRefType.source}([+]#{ProviderRefType.source})*)
$///
Sdmx_3_0_all = ///\*///
MultipleAgencies = ///
(
#{Sdmx_3_0_all.source}
| #{NestedNCNameIDType.source}([+,]#{NestedNCNameIDType.source})*
)
///
MultipleAgenciesRefType = /// ^
#{MultipleAgencies.source}
$///
MultipleIDs = ///
(
#{Sdmx_3_0_all.source}
| #{IDType.source}([+,]#{IDType.source})*
)
///
MultipleIDType = /// ^
#{MultipleIDs.source}
$///
MultipleNestedIDType = /// ^
(
#{Sdmx_3_0_all.source}
| #{NestedIDType.source}([+]#{NestedIDType.source})*
)
$///
MultipleVersions = ///
(
#{Sdmx_3_0_all.source}
| #{VersionType.source}([,]#{VersionType.source})*
)
///
MultipleVersionsType = /// ^
#{VersionType.source}([+,]#{VersionType.source})*
$///
ReportingPeriodType = /// ^
\d{4}-([ASTQ]\d{1}|[MW]\d{2}|[D]\d{3})
$ ///
ContextType = ///
(datastructure|dataflow|provisionagreement)
///
MultipleContextType = ///
(
#{Sdmx_3_0_all.source}
| #{ContextType.source}([+,]#{ContextType.source})*
)
///
ContextRefType = /// ^
(
#{MultipleContextType.source} # The context
= # Then the separator between context & agency
#{MultipleAgencies.source} # Then one or more agencies
: # Then the separator between agency & id
#{MultipleIDs.source} # Then one or more artefact IDs
\( # Then an open parenthesis
#{MultipleVersions.source} # Then one or more versions
\) # Then a closing parenthesis
)
$ ///
Operators = ///
(eq|ne|lt|le|gt|ge|co|nc|sw|ew)
///
FilterValue = ///
(
(#{Operators.source}:)?#{IDType.source}
)
///
FiltersType = /// ^
(
#{NCNameIDType.source}
=
#{FilterValue.source}([+,]#{FilterValue.source})*
)
$ ///
exports.NCNameIDType = NCNameIDTypeAlone
exports.NestedNCNameIDType = NestedNCNameIDTypeAlone
exports.IDType = IDTypeAlone
exports.VersionType = VersionTypeAlone
exports.SingleVersionType = SingleVersionTypeAlone
exports.VersionNumber = VersionNumberAlone
exports.NestedIDType = NestedIDTypeAlone
exports.FlowRefType = FlowRefType
exports.ProviderRefType = ProviderRefType
exports.MultipleProviderRefType = MultipleProviderRefType
exports.AgenciesRefType = MultipleAgenciesRefType
exports.ReportingPeriodType = ReportingPeriodType
exports.SeriesKeyType = SeriesKeyType
exports.Sdmx3SeriesKeyType = Sdmx3SeriesKeyType
exports.MultipleIDType = MultipleIDType
exports.MultipleVersionsType = MultipleVersionsType
exports.MultipleNestedIDType = MultipleNestedIDType
exports.ContextRefType = ContextRefType
exports.FiltersType = FiltersType