@epam/statgpt-sdmx-toolkit 0.7.0-dev.19 → 0.7.0-dev.21
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/index.cjs +1 -1
- package/index.mjs +928 -1271
- package/models/datasets-metadata.d.ts +2 -0
- package/package.json +3 -3
- package/utils/build-dataset-dimensions-metadata-map.d.ts +2 -1
- package/LICENSE +0 -21
package/index.mjs
CHANGED
|
@@ -1,1286 +1,943 @@
|
|
|
1
|
-
import { getErrorMessage as
|
|
2
|
-
import {
|
|
3
|
-
import { compare as
|
|
4
|
-
import { format as
|
|
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
|
-
selectionValues: e.values.map(Le)
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
function Le(e) {
|
|
59
|
-
return {
|
|
60
|
-
memberValue: e.value
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
const Ue = (e = "", t = "", n = "") => `sdmx/3.0/availability/dataflow/${e}/${t}/${n}`;
|
|
64
|
-
class yn {
|
|
65
|
-
constructor(t) {
|
|
66
|
-
this.client = t;
|
|
67
|
-
}
|
|
68
|
-
async getConstraints(t, n, s) {
|
|
69
|
-
const { agency: r, id: o, version: i } = y(t), c = {
|
|
70
|
-
filters: n || [],
|
|
71
|
-
mode: de.AVAILABLE,
|
|
72
|
-
references: N.NONE
|
|
73
|
-
}, a = Ue(r, o, i), d = !!this.client.config.sdmxProxyUrl, u = d || this.client.config.isDialProxyMode, l = d ? this.client.config.sdmxProxyUrl : this.client.config.constrainsApiUrl || this.client.config.apiUrl;
|
|
74
|
-
if (u) {
|
|
75
|
-
const m = await this.client.postRequest(
|
|
76
|
-
a,
|
|
77
|
-
{ body: c },
|
|
78
|
-
l,
|
|
79
|
-
s
|
|
80
|
-
);
|
|
81
|
-
return Pe(m);
|
|
82
|
-
}
|
|
83
|
-
return await this.client.postRequest(
|
|
84
|
-
a,
|
|
85
|
-
{ body: c },
|
|
86
|
-
l,
|
|
87
|
-
s
|
|
88
|
-
);
|
|
89
|
-
}
|
|
1
|
+
import { getErrorMessage as e } from "@epam/statgpt-dial-toolkit";
|
|
2
|
+
import { OCP_APIM_SUBSCRIPTION_KEY_HEADER as t, X_SOURCE_ARTEFACT_URN_HEADER as n, getHeaders as r, getTimePeriod as i, sanitizeHeaders as a, sendRequest as o } from "@epam/statgpt-shared-toolkit";
|
|
3
|
+
import { compare as s } from "compare-versions";
|
|
4
|
+
import { format as c } from "date-fns";
|
|
5
|
+
//#region libs/sdmx-toolkit/src/utils/urn.ts
|
|
6
|
+
var l = (e) => {
|
|
7
|
+
if (e != null) {
|
|
8
|
+
let t = e.split("=");
|
|
9
|
+
return t.length === 1 ? e : t[1];
|
|
10
|
+
}
|
|
11
|
+
}, u = (e) => {
|
|
12
|
+
if (e == null) return {};
|
|
13
|
+
let t = l(e), n = {
|
|
14
|
+
agency: "",
|
|
15
|
+
id: "",
|
|
16
|
+
version: ""
|
|
17
|
+
};
|
|
18
|
+
return t && (t.includes(":") && (n.agency = t.split(":")[0], n.id = t.split(":")[1].split("(")[0]), t.includes("(") && t.includes(")") && (n.version = t.split("(")[1]?.split(")")[0])), n;
|
|
19
|
+
}, d = (e) => {
|
|
20
|
+
let [t, n] = e.split(")."), { agency: r, id: i, version: a } = u(t + ")");
|
|
21
|
+
return {
|
|
22
|
+
childId: n,
|
|
23
|
+
agency: r,
|
|
24
|
+
id: i,
|
|
25
|
+
version: a
|
|
26
|
+
};
|
|
27
|
+
}, f = (e, t, n) => `${n}:${e}${t === "" ? "" : `(${t})`}`, p = /* @__PURE__ */ function(e) {
|
|
28
|
+
return e.DESCENDANTS = "descendants", e.NONE = "none", e.ALL = "all", e;
|
|
29
|
+
}({}), m = /* @__PURE__ */ function(e) {
|
|
30
|
+
return e.EXACT = "exact", e.AVAILABLE = "available", e;
|
|
31
|
+
}({});
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region libs/sdmx-toolkit/src/utils/map-availability.ts
|
|
34
|
+
function h(e) {
|
|
35
|
+
return { data: {
|
|
36
|
+
codelists: e.data.codelists,
|
|
37
|
+
conceptSchemes: e.data.conceptSchemes,
|
|
38
|
+
dataConstraints: e.data.dataConstraints?.map(ee),
|
|
39
|
+
dataflows: e.data.dataflows,
|
|
40
|
+
dataStructures: e.data.dataStructures,
|
|
41
|
+
metadataStructures: e.data.metadataStructures
|
|
42
|
+
} };
|
|
43
|
+
}
|
|
44
|
+
function ee(e) {
|
|
45
|
+
return {
|
|
46
|
+
...e,
|
|
47
|
+
cubeRegions: e.cubeRegions?.map(te)
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function te(e) {
|
|
51
|
+
return {
|
|
52
|
+
isIncluded: e.include,
|
|
53
|
+
memberSelection: e.keyValues.map(ne)
|
|
54
|
+
};
|
|
90
55
|
}
|
|
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
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
function
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
},
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
56
|
+
function ne(e) {
|
|
57
|
+
return {
|
|
58
|
+
included: e.include,
|
|
59
|
+
componentId: e.id,
|
|
60
|
+
selectionValues: e.values.map(re)
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function re(e) {
|
|
64
|
+
return { memberValue: e.value };
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region libs/sdmx-toolkit/src/api/availability-api.ts
|
|
68
|
+
var ie = (e = "", t = "", n = "") => `sdmx/3.0/availability/dataflow/${e}/${t}/${n}`, ae = class {
|
|
69
|
+
constructor(e) {
|
|
70
|
+
this.client = e;
|
|
71
|
+
}
|
|
72
|
+
async getConstraints(e, t, n) {
|
|
73
|
+
let { agency: r, id: i, version: a } = u(e), o = {
|
|
74
|
+
filters: t || [],
|
|
75
|
+
mode: m.AVAILABLE,
|
|
76
|
+
references: p.NONE
|
|
77
|
+
}, s = ie(r, i, a), c = !!this.client.config.sdmxProxyUrl, l = c || this.client.config.isDialProxyMode, d = c ? this.client.config.sdmxProxyUrl : this.client.config.constrainsApiUrl || this.client.config.apiUrl;
|
|
78
|
+
return l ? h(await this.client.postRequest(s, { body: o }, d, n)) : await this.client.postRequest(s, { body: o }, d, n);
|
|
79
|
+
}
|
|
80
|
+
}, g = /* @__PURE__ */ function(e) {
|
|
81
|
+
return e.CSV = "csv", e.JSON = "json", e.XML = "xml", e;
|
|
82
|
+
}({}), oe = /* @__PURE__ */ function(e) {
|
|
83
|
+
return e.ID = "id", e.NAME = "name", e.ID_NAME = "both", e;
|
|
84
|
+
}({}), se = /* @__PURE__ */ function(e) {
|
|
85
|
+
return e.FULL_DATASET = "full", e.DATA_IN_TABLE = "query", e;
|
|
86
|
+
}({}), ce = (e, t) => {
|
|
87
|
+
switch (e) {
|
|
88
|
+
case g.CSV: return ue("application/vnd.sdmx.data+csv;version=2.0.0", t);
|
|
89
|
+
case g.XML: return "application/vnd.sdmx.data+xml;version=3.0.0";
|
|
90
|
+
case g.JSON: return "application/vnd.sdmx.data+json;version=2.1";
|
|
91
|
+
default: return ue("application/vnd.sdmx.data+csv;version=2.0.0", t);
|
|
92
|
+
}
|
|
93
|
+
}, le = (e) => {
|
|
94
|
+
switch (e) {
|
|
95
|
+
case g.CSV: return "text/csv; charset=utf-8";
|
|
96
|
+
case g.XML: return "application/xml; charset=utf-8";
|
|
97
|
+
case g.JSON: return "application/json; charset=utf-8";
|
|
98
|
+
default: return "text/csv; charset=utf-8";
|
|
99
|
+
}
|
|
100
|
+
}, ue = (e, t) => `${e}; labels=${t}`, de = /* @__PURE__ */ function(e) {
|
|
101
|
+
return e.REFERENCE_PARTIAL = "referencepartial", e.FULL = "full", e;
|
|
102
|
+
}({}), fe = "sdmx/3.0/data/dataflow", pe = "+", me = ",", he = "*", _ = (e, t, n) => {
|
|
103
|
+
let { filterKey: r, timeFilter: i } = n, { agency: a, id: o, version: s } = u(e), c = [i || "", t].filter((e) => !!e).join("&");
|
|
104
|
+
return `${`${fe}/${a}/${o}/${s}`}/${r || "*"}?${c}`;
|
|
105
|
+
}, ge = (e = "", t = "", n = "", r = p.DESCENDANTS) => `sdmx/3.0/structure/dataflow/${e}/${t}/${n}?references=${r}&detail=${de.REFERENCE_PARTIAL}`, _e = class {
|
|
106
|
+
constructor(e) {
|
|
107
|
+
this.client = e;
|
|
108
|
+
}
|
|
109
|
+
async getDataSet(e, t, n) {
|
|
110
|
+
let { agency: r, id: i, version: a } = u(e);
|
|
111
|
+
return await this.client.getRequest(ge(r, i, a, t), void 0, n);
|
|
112
|
+
}
|
|
113
|
+
async getDatasetData(e, t, n) {
|
|
114
|
+
let r = _(e, new URLSearchParams({
|
|
115
|
+
includeHistory: "false",
|
|
116
|
+
limit: "1000",
|
|
117
|
+
attributes: "all",
|
|
118
|
+
dimensionAtObservation: "TIME_PERIOD"
|
|
119
|
+
}).toString(), t);
|
|
120
|
+
return await this.client.getRequest(r, void 0, n);
|
|
121
|
+
}
|
|
122
|
+
async downloadDataSet(e, t, n, r, i, a, o = !1, s) {
|
|
123
|
+
let c = _(e, new URLSearchParams({
|
|
124
|
+
compress: "false",
|
|
125
|
+
attributes: o ? "all" : "none",
|
|
126
|
+
limit: "1000"
|
|
127
|
+
}).toString(), i);
|
|
128
|
+
return this.client.streamRequest(c, {
|
|
129
|
+
method: "GET",
|
|
130
|
+
headers: {
|
|
131
|
+
Accept: ce(t, r),
|
|
132
|
+
"Accept-language": n
|
|
133
|
+
}
|
|
134
|
+
}, a, s, le(t));
|
|
135
|
+
}
|
|
136
|
+
}, ve = class {
|
|
137
|
+
constructor(e) {
|
|
138
|
+
this.config = e, console.info("SdmxApiClient initialized", { apiUrl: e.apiUrl || "NOT SET" });
|
|
139
|
+
}
|
|
140
|
+
async getRequest(e, t, n) {
|
|
141
|
+
return this.request(e, {
|
|
142
|
+
...t,
|
|
143
|
+
method: "GET"
|
|
144
|
+
}, void 0, n);
|
|
145
|
+
}
|
|
146
|
+
async postRequest(e, t, n, r) {
|
|
147
|
+
return this.request(e, {
|
|
148
|
+
...t,
|
|
149
|
+
method: "POST"
|
|
150
|
+
}, n, r);
|
|
151
|
+
}
|
|
152
|
+
async streamRequest(e, t, n, r, i) {
|
|
153
|
+
let a = `${this.config.apiUrl}/${e}`, s = this.buildHeaders(r, t.headers), c = new ReadableStream({ async start(e) {
|
|
154
|
+
try {
|
|
155
|
+
let n = await o(a, s, t);
|
|
156
|
+
if (!n.ok) {
|
|
157
|
+
let e = await n.text();
|
|
158
|
+
throw console.error(`Fetch failed! Status: ${n.status}, Body: ${e}`), Error(`Fetch failed with status ${n.status}`);
|
|
159
|
+
}
|
|
160
|
+
let r = n.body?.getReader();
|
|
161
|
+
if (!r) throw Error("Failed to create stream reader");
|
|
162
|
+
let i = new Uint8Array([
|
|
163
|
+
239,
|
|
164
|
+
187,
|
|
165
|
+
191
|
|
166
|
+
]);
|
|
167
|
+
e.enqueue(i);
|
|
168
|
+
let c = async () => {
|
|
169
|
+
let { done: t, value: n } = await r.read();
|
|
170
|
+
t ? e.close() : (e.enqueue(n), await c());
|
|
171
|
+
};
|
|
172
|
+
c();
|
|
173
|
+
} catch (t) {
|
|
174
|
+
e.error(t);
|
|
175
|
+
}
|
|
176
|
+
} }), l = new Headers({
|
|
177
|
+
"Content-Disposition": `attachment; filename=${encodeURIComponent(n)}`,
|
|
178
|
+
...i ? { "Content-Type": i } : {}
|
|
179
|
+
});
|
|
180
|
+
return new Response(c, { headers: l });
|
|
181
|
+
}
|
|
182
|
+
async request(t, n, r, i) {
|
|
183
|
+
let a = Date.now(), s = `${r || this.config.apiUrl}/${t}`, c = this.buildHeaders(i, n.headers);
|
|
184
|
+
this.addInfoRequestLog("API Request", s, n, c);
|
|
185
|
+
try {
|
|
186
|
+
let t = await o(s, c, n), r = Date.now() - a, i, l = await t.text();
|
|
187
|
+
try {
|
|
188
|
+
i = l ? JSON.parse(l) : {};
|
|
189
|
+
} catch {
|
|
190
|
+
if (this.addErrorRequestParsing(s, n, t, r, l), !t.ok) throw Error(`API request failed: ${t.status} ${t.statusText} - ${l.substring(0, 100)}`);
|
|
191
|
+
i = { data: l };
|
|
192
|
+
}
|
|
193
|
+
if (!t.ok) {
|
|
194
|
+
this.addErrorRequestLog(s, n, t, r, i);
|
|
195
|
+
let a = e(i, t);
|
|
196
|
+
throw Error(`API request failed: ${a}`);
|
|
197
|
+
}
|
|
198
|
+
return i;
|
|
199
|
+
} catch (e) {
|
|
200
|
+
let t = Date.now() - a;
|
|
201
|
+
throw console.error("API Request Exception", {
|
|
202
|
+
method: n.method,
|
|
203
|
+
url: s,
|
|
204
|
+
duration: `${t}ms`,
|
|
205
|
+
error: e instanceof Error ? e.message : String(e)
|
|
206
|
+
}), e;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
buildHeaders(e, n) {
|
|
210
|
+
if (this.config.isDialProxyMode) return {
|
|
211
|
+
...r(this.config.dialApiKey, { jwt: e }),
|
|
212
|
+
...n
|
|
213
|
+
};
|
|
214
|
+
let i = {
|
|
215
|
+
...r(void 0, { jwt: this.config.jwt }),
|
|
216
|
+
...n
|
|
217
|
+
};
|
|
218
|
+
return this.config.apiKey != null && (i[t] = this.config.apiKey), i;
|
|
219
|
+
}
|
|
220
|
+
addInfoRequestLog(e, t, n, r) {
|
|
221
|
+
let i = {
|
|
222
|
+
method: n.method || "GET",
|
|
223
|
+
url: t,
|
|
224
|
+
headers: a(r)
|
|
225
|
+
};
|
|
226
|
+
n.body && (i.body = n.body), console.info(e, i);
|
|
227
|
+
}
|
|
228
|
+
addErrorRequestLog(e, t, n, r, i) {
|
|
229
|
+
console.error("API Request Failed", {
|
|
230
|
+
method: t.method,
|
|
231
|
+
url: e,
|
|
232
|
+
status: n.status,
|
|
233
|
+
statusText: n.statusText,
|
|
234
|
+
duration: `${r}ms`,
|
|
235
|
+
response: i
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
addErrorRequestParsing(e, t, n, r, i) {
|
|
239
|
+
console.error("API Response Parse Error", {
|
|
240
|
+
method: t.method,
|
|
241
|
+
url: e,
|
|
242
|
+
status: n.status,
|
|
243
|
+
statusText: n.statusText,
|
|
244
|
+
duration: `${r}ms`,
|
|
245
|
+
responseText: i.substring(0, 200),
|
|
246
|
+
error: "Response is not valid JSON"
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
}, v = /* @__PURE__ */ function(e) {
|
|
250
|
+
return e.LAST_UPDATE_AT = "lastUpdatedAt", e.SERIES_COUNT = "series_count", e;
|
|
251
|
+
}({});
|
|
252
|
+
//#endregion
|
|
253
|
+
//#region libs/sdmx-toolkit/src/utils/annotations.ts
|
|
254
|
+
function ye(e) {
|
|
255
|
+
return e?.annotations?.find((e) => {
|
|
256
|
+
if (e.id === v.LAST_UPDATE_AT) return e;
|
|
257
|
+
})?.text;
|
|
258
|
+
}
|
|
259
|
+
//#endregion
|
|
260
|
+
//#region libs/sdmx-toolkit/src/utils/get-localized-name.ts
|
|
261
|
+
var y = (e, t) => e?.names && e?.names[t] || e?.name, be = (e, t, n) => {
|
|
262
|
+
if (!(!e || t?.has(e?.id)) && (t?.set(e?.id, e), e?.parent)) {
|
|
263
|
+
let r = n?.get(e?.parent);
|
|
264
|
+
be(r, t, n);
|
|
265
|
+
}
|
|
266
|
+
}, xe = (e, t) => {
|
|
267
|
+
let n = /* @__PURE__ */ new Map(), r = new Map(e?.map((e) => [e.id, e]));
|
|
268
|
+
return t?.forEach((e) => {
|
|
269
|
+
be(e, n, r);
|
|
270
|
+
}), Array.from(n?.values());
|
|
271
|
+
}, Se = /* @__PURE__ */ function(e) {
|
|
272
|
+
return e.C = "c", e;
|
|
273
|
+
}({}), b = /* @__PURE__ */ function(e) {
|
|
274
|
+
return e.EQUALS = "eq", e.NOT_EQUALS = "ne", e.LESS = "lt", e.LESS_OR_EQUAL = "le", e.GREATER = "gt", e.GREATER_OR_EQUAL = "ge", e.CONTAINS = "co", e.NOT_CONTAINS = "nc", e.STARTS = "sw", e.ENDS = "ew", e;
|
|
275
|
+
}({}), Ce = /* @__PURE__ */ function(e) {
|
|
276
|
+
return e.BOOLEAN = "Boolean", e.DATE_TIME = "DateTime", e.DECIMAL = "Decimal", e.INTEGER = "Integer", e.OBSERVATION_TIME_PERIOD = "ObservationalTimePeriod", e.STRING = "String", e.TIME = "Time", e.TIME_RANGE = "TimeRange", e.URI = "URI", e;
|
|
277
|
+
}({}), we = /* @__PURE__ */ function(e) {
|
|
278
|
+
return e.ANNUAL = "A", e.QUARTERLY = "Q", e.MONTHLY = "M", e;
|
|
279
|
+
}({}), Te = ["FREQ", "FREQUENCY"], Ee = "TIME_PERIOD", De = "time_period_start", x = "time_period_end", Oe = (e) => {
|
|
280
|
+
let t = e?.find((e) => e.id === De), n = e?.find((e) => e.id === x), r = n?.title ? new Date(n?.title) : null;
|
|
281
|
+
return {
|
|
282
|
+
startPeriod: t?.title ? new Date(t?.title) : null,
|
|
283
|
+
endPeriod: r
|
|
284
|
+
};
|
|
285
|
+
}, ke = (e, t) => e.id.localeCompare(t.id), Ae = (e, t) => e.memberValue.localeCompare(t.memberValue), je = (e, t) => {
|
|
286
|
+
let n = Array(e.length), r = e.map((e, t) => [e, t]);
|
|
287
|
+
r.sort((e, t) => ke(e[0], t[0]));
|
|
288
|
+
let i = [...t];
|
|
289
|
+
i.sort(Ae);
|
|
290
|
+
let a = 0;
|
|
291
|
+
for (let e of r) {
|
|
292
|
+
let t = e[0];
|
|
293
|
+
for (; a < i.length && i[a].memberValue.localeCompare(t.id) < 0;) a += 1;
|
|
294
|
+
a < i.length && i[a].memberValue === t.id && (n[e[1]] = e[0]);
|
|
295
|
+
}
|
|
296
|
+
return n.filter((e) => e != null);
|
|
297
|
+
}, Me = (e) => !!e?.some((e) => e.parent), Ne = (e, t, n, r, i = []) => {
|
|
298
|
+
let a = e || [];
|
|
299
|
+
if (Pe(n || [], t || "")) {
|
|
300
|
+
let e = (n || [])[0].cubeRegions?.find(({ isIncluded: e }) => e);
|
|
301
|
+
if (e) {
|
|
302
|
+
let n = e.memberSelection?.find(({ componentId: e }) => e === t);
|
|
303
|
+
a = n ? a.length === 0 ? (n.selectionValues || []).map(({ memberValue: e }) => ({
|
|
304
|
+
id: e,
|
|
305
|
+
name: e
|
|
306
|
+
})) : je(a, n.selectionValues) : [];
|
|
307
|
+
}
|
|
308
|
+
} else i.length !== 0 && (a = a.filter(({ id: e }) => i.includes(e)));
|
|
309
|
+
return Me(e) && (a = xe(e, a)), a?.map((e) => ({
|
|
310
|
+
...e,
|
|
311
|
+
name: r ? y(e, r) : e?.name
|
|
312
|
+
}));
|
|
313
|
+
}, Pe = (e, t) => e != null && e.length > 0 && t != null, Fe = (e) => {
|
|
314
|
+
let t = [];
|
|
315
|
+
return e?.filters?.forEach((e) => {
|
|
316
|
+
e.componentCode !== "TIME_PERIOD" && t.push({
|
|
317
|
+
componentCode: e.componentCode,
|
|
318
|
+
operator: b.EQUALS,
|
|
319
|
+
value: e.values.join(",")
|
|
320
|
+
});
|
|
321
|
+
}), t;
|
|
322
|
+
}, Ie = (e) => {
|
|
323
|
+
let t = /* @__PURE__ */ new Map();
|
|
324
|
+
return e?.forEach((e) => {
|
|
325
|
+
t.set(e.urn, Fe(e));
|
|
326
|
+
}), t;
|
|
327
|
+
}, Le = "+", S = (e, t) => {
|
|
328
|
+
let { agency: n, id: r, version: i } = u(e), a = t.filter((e) => e.agencyID === n && e.id === r && !e?.version?.includes("+"));
|
|
329
|
+
if (a.length === 1) return a[0];
|
|
330
|
+
if (!i?.includes("+")) return a.find((e) => e.version === i);
|
|
331
|
+
let o = C(i, a.map((e) => e.version));
|
|
332
|
+
return a.find((e) => e.version === o[0]);
|
|
333
|
+
}, C = (e, t) => {
|
|
334
|
+
let n = Re(e, t);
|
|
335
|
+
return n.length > 0 ? [n[0]] : [];
|
|
336
|
+
}, Re = (e, t) => {
|
|
337
|
+
let n = [];
|
|
338
|
+
return t.forEach((t) => {
|
|
339
|
+
T(e, t) && n.push(t);
|
|
340
|
+
}), n;
|
|
341
|
+
}, w = (e) => {
|
|
342
|
+
let t = e.trim(), n = t.indexOf("+");
|
|
343
|
+
if (n <= 0) return "";
|
|
344
|
+
let r = n;
|
|
345
|
+
for (; r > 0 && t[r - 1] >= "0" && t[r - 1] <= "9";) r--;
|
|
346
|
+
return r > 0 ? t.slice(0, r) : "";
|
|
347
|
+
}, T = (e, t) => {
|
|
348
|
+
let n = e.trim().replace(/\+/, ""), r = w(e);
|
|
349
|
+
return t.startsWith(r) && s(t, n, ">=");
|
|
350
|
+
}, E = (e, t) => {
|
|
351
|
+
let { concept: n } = ze(e, t);
|
|
352
|
+
return n;
|
|
353
|
+
}, ze = (e, t) => {
|
|
354
|
+
if (e == null) return {
|
|
355
|
+
concept: void 0,
|
|
356
|
+
scheme: void 0
|
|
357
|
+
};
|
|
358
|
+
let { childId: n, agency: r, id: i, version: a } = d(e);
|
|
359
|
+
if (a?.includes("+")) {
|
|
360
|
+
let r = S(e, t);
|
|
361
|
+
return {
|
|
362
|
+
concept: D(r?.concepts || [], n),
|
|
363
|
+
scheme: r
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
for (let e of t) if (Be(e, i, r, a)) return {
|
|
367
|
+
concept: D(e?.concepts || [], n),
|
|
368
|
+
scheme: e
|
|
369
|
+
};
|
|
370
|
+
return {
|
|
371
|
+
concept: void 0,
|
|
372
|
+
scheme: void 0
|
|
373
|
+
};
|
|
374
|
+
}, D = (e, t) => e?.find((e) => e.id === t), Be = (e, t, n, r) => e.id === t && e.agencyID === n && e.version === r, Ve = (e = [], t = [], n) => {
|
|
375
|
+
let r = E(n?.conceptIdentity || "", t), i = l(n?.localRepresentation?.enumeration), a = l(r?.coreRepresentation?.enumeration), o = i || a;
|
|
376
|
+
if (o != null) return S(o, e);
|
|
377
|
+
}, He = (e, t) => {
|
|
378
|
+
let n = e?.data?.dataSets?.[0], r = (e?.data?.structures?.[0])?.attributes?.dimensionGroup || [], i = n?.dimensionGroupAttributes, a = {};
|
|
379
|
+
for (let n of r) {
|
|
380
|
+
let r = n.relationship.dimensions, { codedSeriesKey: o, decodedSeriesKey: s } = O(e, t, r);
|
|
381
|
+
a[n.id] = {
|
|
382
|
+
values: i?.[o] || [],
|
|
383
|
+
decodedSeriesKey: s,
|
|
384
|
+
codedSeriesKey: o
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
return a;
|
|
388
|
+
}, O = (e, t, n) => {
|
|
389
|
+
let r = e?.data?.structures?.[0], i = [...r?.dimensions.series || [], ...r?.dimensions.observation || []], a = Array(i?.length), o = Array(i?.length);
|
|
390
|
+
return n?.forEach((e) => {
|
|
391
|
+
let n = i?.findIndex((t) => t.id === e) || 0, r = t[n], s = i[n].values.findIndex((e) => e.id === r || e.value === r) || 0;
|
|
392
|
+
a[n] = s >= 0 ? s : r, o[n] = r;
|
|
393
|
+
}), {
|
|
394
|
+
codedSeriesKey: a.join(":"),
|
|
395
|
+
decodedSeriesKey: o.join(":")
|
|
396
|
+
};
|
|
397
|
+
}, Ue = (e, t, n) => {
|
|
398
|
+
let r = e?.data?.dataSets?.[0], i = e?.data?.structures?.[0], a = (i?.attributes?.dimensionGroup || []).filter((e) => e.relationship.dimensions?.length === 1 && e.relationship.dimensions.includes(t || "")), o = r?.dimensionGroupAttributes, s = [...i?.dimensions.series || [], ...i?.dimensions.observation || []], c = s?.findIndex((e) => e.id === t), l = Array(s?.length);
|
|
399
|
+
l[c] = n || "";
|
|
400
|
+
let u = {};
|
|
401
|
+
for (let t of a) {
|
|
402
|
+
let n = t.relationship.dimensions, { codedSeriesKey: r, decodedSeriesKey: i } = O(e, l, n);
|
|
403
|
+
u[t.id] = {
|
|
404
|
+
values: o?.[r] || [],
|
|
405
|
+
decodedSeriesKey: i,
|
|
406
|
+
codedSeriesKey: r
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
return u;
|
|
410
|
+
}, We = (e, t) => t == null ? void 0 : e.values?.[t] ?? (t instanceof Array ? { values: t } : { value: t.toString() }), Ge = (e, t, n, r) => {
|
|
411
|
+
let i = t?.find((t) => t?.id === e?.id)?.values;
|
|
412
|
+
return n?.filter((e) => i?.some((t) => t.id === e.id))?.map((e) => ({
|
|
413
|
+
...e,
|
|
414
|
+
name: r ? y(e, r) : e?.name
|
|
415
|
+
})) || [];
|
|
416
|
+
}, Ke = (e, t) => {
|
|
417
|
+
let n = t?.dataStructureComponents?.attributeList, r = e?.metadataStructureComponents?.metadataAttributeList;
|
|
418
|
+
return n?.metadataAttributeUsages?.map((e) => {
|
|
419
|
+
let t = r?.metadataAttributes?.find((t) => t?.id === e?.metadataAttributeReference);
|
|
420
|
+
return {
|
|
421
|
+
...t,
|
|
422
|
+
id: t?.id ?? e.metadataAttributeReference,
|
|
423
|
+
attributeRelationship: e.attributeRelationship,
|
|
424
|
+
isMandatory: Number(t?.minOccurs) > 0
|
|
425
|
+
};
|
|
426
|
+
});
|
|
427
|
+
}, qe = (e = [], t, n) => {
|
|
428
|
+
let r = E(l(t?.conceptIdentity) || "", e);
|
|
429
|
+
return n ? y(r, n) : r?.name ?? r?.id ?? t?.id;
|
|
430
|
+
}, Je = /* @__PURE__ */ function(e) {
|
|
431
|
+
return e.CONDITIONAL = "Conditional", e.MANDATORY = "Mandatory", e;
|
|
432
|
+
}({}), k = /* @__PURE__ */ function(e) {
|
|
433
|
+
return e.DIMENSION = "Dimension", e.MEASURE_DIMENSION = "MeasureDimension", e.TIME_DIMENSION = "TimeDimension", e;
|
|
434
|
+
}({}), Ye = /* @__PURE__ */ function(e) {
|
|
435
|
+
return e.UNBOUNDED = "unbounded", e;
|
|
436
|
+
}({});
|
|
437
|
+
//#endregion
|
|
438
|
+
//#region libs/sdmx-toolkit/src/utils/get-dimensions.ts
|
|
439
|
+
function A(e) {
|
|
440
|
+
return e?.dataStructures?.[0]?.dataStructureComponents?.dimensionList;
|
|
441
|
+
}
|
|
442
|
+
function Xe(e) {
|
|
443
|
+
return e?.data?.structures?.[0]?.dimensions?.series || [];
|
|
444
|
+
}
|
|
445
|
+
function Ze(e) {
|
|
446
|
+
return e?.data?.structures?.[0]?.dimensions?.observation?.[0].values.map((e) => e.value ? e.value : e.id).filter((e) => e != null) || [];
|
|
447
|
+
}
|
|
448
|
+
function Qe(e) {
|
|
449
|
+
return e.find((e) => e.type === k.TIME_DIMENSION);
|
|
450
|
+
}
|
|
451
|
+
//#endregion
|
|
452
|
+
//#region libs/sdmx-toolkit/src/utils/get-structure-components.ts
|
|
453
|
+
var $e = (e) => {
|
|
454
|
+
let t = /* @__PURE__ */ new Map(), n = e?.dataStructures?.[0], r = e?.metadataStructures?.[0], i = e?.conceptSchemes || [], a = e?.codelists || [];
|
|
455
|
+
if (e) {
|
|
456
|
+
let o = Ke(r, n);
|
|
457
|
+
[
|
|
458
|
+
...A(e)?.dimensions || [],
|
|
459
|
+
...A(e)?.timeDimensions || [],
|
|
460
|
+
...o,
|
|
461
|
+
...n?.dataStructureComponents?.attributeList?.attributes || []
|
|
462
|
+
].forEach((e) => {
|
|
463
|
+
let n = E(e?.conceptIdentity, i), r = e?.localRepresentation?.enumeration || n?.coreRepresentation?.enumeration, o = S(r, a);
|
|
464
|
+
e?.id && (r ? t.set(e?.id, {
|
|
465
|
+
...o,
|
|
466
|
+
name: n?.name,
|
|
467
|
+
names: n?.names
|
|
468
|
+
}) : t.set(e?.id, {
|
|
469
|
+
id: e?.id,
|
|
470
|
+
name: n?.name,
|
|
471
|
+
names: n?.names
|
|
472
|
+
}));
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
return t;
|
|
476
|
+
}, et = (e) => e?.find((e) => e.id === v.SERIES_COUNT)?.title || "", j = 1440 * 60 * 1e3, M = 7 * j;
|
|
477
|
+
function N(e) {
|
|
478
|
+
let t = `${e}-01-01`, n = new Date(t);
|
|
479
|
+
if (n.getDay() !== 4) {
|
|
480
|
+
let e = 1 + (4 - n.getDay() + 7) % 7;
|
|
481
|
+
n.setMonth(0, e);
|
|
482
|
+
}
|
|
483
|
+
return n;
|
|
484
|
+
}
|
|
485
|
+
function tt(e) {
|
|
486
|
+
let t = new Date(e), n = -((t.getDay() + 6) % 7) + 3;
|
|
487
|
+
return t.setDate(t.getDate() + n), new Date(t.valueOf());
|
|
488
|
+
}
|
|
489
|
+
function P(e, t = "W") {
|
|
490
|
+
let n = `${e}-12-31`, r = I(new Date(n), t);
|
|
491
|
+
if (r.weekYear === e) return r.weekNumber;
|
|
492
|
+
let i = `${e}-12-24`;
|
|
493
|
+
return I(new Date(i), t).weekNumber;
|
|
494
|
+
}
|
|
495
|
+
function F(e, t, n = "W") {
|
|
496
|
+
return `${e}-${n}${t < 10 ? "0" + t : t}`;
|
|
497
|
+
}
|
|
498
|
+
function I(e, t = "W") {
|
|
499
|
+
let n = tt(e), r = n.getFullYear(), i = N(r), a = 1 + Math.ceil((n.getTime() - i.getTime()) / M);
|
|
500
|
+
return {
|
|
501
|
+
code: F(r, a, t),
|
|
502
|
+
weekNumber: a,
|
|
503
|
+
weekYear: r
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
function nt(e) {
|
|
507
|
+
let [t, n] = e.split("-W"), r = N(+t).getTime() + (n - 1) * M - 3 * j;
|
|
508
|
+
return new Date(r);
|
|
509
|
+
}
|
|
510
|
+
function rt(e) {
|
|
511
|
+
let [t, n] = e.split("-W"), r = N(+t).getTime() + (n - 1) * M + 3 * j;
|
|
512
|
+
return new Date(r);
|
|
513
|
+
}
|
|
514
|
+
//#endregion
|
|
515
|
+
//#region libs/sdmx-toolkit/src/utils/download.ts
|
|
516
|
+
var it = "/api/download", at = 6e4, ot = /[\x00-\x1F\x7F<>:"/\\|?*]/g, L = (e) => e.normalize("NFKC").replace(ot, "_").replace(/_+/g, "_").replace(/\s+/g, " ").replace(/^[._ ]+/, "").trim() || "download", st = (e, t, n, r, i, a, o) => {
|
|
517
|
+
let s = new URL(it, window.location.origin);
|
|
518
|
+
if (s.search = new URLSearchParams({
|
|
519
|
+
urn: e,
|
|
520
|
+
format: t,
|
|
521
|
+
compress: "false",
|
|
522
|
+
filename: a,
|
|
523
|
+
filters: JSON.stringify(i),
|
|
524
|
+
attribute: r,
|
|
525
|
+
language: n,
|
|
526
|
+
isMetadata: o ? "true" : "none"
|
|
527
|
+
}).toString(), s.origin !== window.location.origin || s.pathname !== it) throw Error("Invalid download URL");
|
|
528
|
+
return s.toString();
|
|
418
529
|
}, ct = (e, t) => {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
return {
|
|
442
|
-
concept: void 0,
|
|
443
|
-
scheme: void 0
|
|
444
|
-
};
|
|
445
|
-
}, te = (e, t) => e?.find((n) => n.id === t), ut = (e, t, n, s) => e.id === t && e.agencyID === n && e.version === s, Pn = (e = [], t = [], n) => {
|
|
446
|
-
const s = n?.conceptIdentity || "", r = O(s, t), o = T(
|
|
447
|
-
n?.localRepresentation?.enumeration
|
|
448
|
-
), i = T(
|
|
449
|
-
r?.coreRepresentation?.enumeration
|
|
450
|
-
), c = o || i;
|
|
451
|
-
if (c != null)
|
|
452
|
-
return U(c, e);
|
|
530
|
+
let n = URL.createObjectURL(e), r = document.createElement("a");
|
|
531
|
+
r.href = n, r.download = L(t), r.rel = "noopener noreferrer", r.click(), window.setTimeout(() => URL.revokeObjectURL(n), at);
|
|
532
|
+
}, lt = async (e, t, n, r, i, a, o, s) => {
|
|
533
|
+
let c = L(a), l = st(e, t, n, r, i, c, o), u = await fetch(l, {
|
|
534
|
+
method: "GET",
|
|
535
|
+
credentials: "same-origin",
|
|
536
|
+
signal: s
|
|
537
|
+
});
|
|
538
|
+
if (!u.ok) {
|
|
539
|
+
let e = await u.text();
|
|
540
|
+
throw Error(`Download request failed: ${u.status} ${u.statusText}${e ? ` - ${e}` : ""}`);
|
|
541
|
+
}
|
|
542
|
+
let d = await u.blob();
|
|
543
|
+
s?.aborted || ct(d, c);
|
|
544
|
+
}, ut = (e, t) => {
|
|
545
|
+
let n = [];
|
|
546
|
+
for (let r of e) {
|
|
547
|
+
if (r.type !== k.DIMENSION) continue;
|
|
548
|
+
let e = t.find((e) => e.componentCode === r.id);
|
|
549
|
+
e != null && e.values?.length > 0 ? n.push(e.values?.join("+")) : n.push("*");
|
|
550
|
+
}
|
|
551
|
+
return n.join(".");
|
|
453
552
|
}, dt = (e, t) => {
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
values: o?.[d] || [],
|
|
463
|
-
decodedSeriesKey: u,
|
|
464
|
-
codedSeriesKey: d
|
|
465
|
-
};
|
|
466
|
-
}
|
|
467
|
-
return i;
|
|
468
|
-
}, ge = (e, t, n) => {
|
|
469
|
-
const s = e?.data?.structures?.[0], r = [
|
|
470
|
-
...s?.dimensions.series || [],
|
|
471
|
-
...s?.dimensions.observation || []
|
|
472
|
-
], o = new Array(r?.length), i = new Array(r?.length);
|
|
473
|
-
return n?.forEach((c) => {
|
|
474
|
-
const a = r?.findIndex((l) => l.id === c) || 0, d = t[a], u = r[a].values.findIndex(
|
|
475
|
-
(l) => l.id === d || l.value === d
|
|
476
|
-
) || 0;
|
|
477
|
-
o[a] = u >= 0 ? u : d, i[a] = d;
|
|
478
|
-
}), {
|
|
479
|
-
codedSeriesKey: o.join(":"),
|
|
480
|
-
decodedSeriesKey: i.join(":")
|
|
481
|
-
};
|
|
482
|
-
}, _n = (e, t, n) => {
|
|
483
|
-
const s = e?.data?.dataSets?.[0], r = e?.data?.structures?.[0], o = (r?.attributes?.dimensionGroup || []).filter(
|
|
484
|
-
(l) => l.relationship.dimensions?.length === 1 && l.relationship.dimensions.includes(t || "")
|
|
485
|
-
), i = s?.dimensionGroupAttributes, c = [
|
|
486
|
-
...r?.dimensions.series || [],
|
|
487
|
-
...r?.dimensions.observation || []
|
|
488
|
-
], a = c?.findIndex((l) => l.id === t), d = new Array(c?.length);
|
|
489
|
-
d[a] = n || "";
|
|
490
|
-
const u = {};
|
|
491
|
-
for (const l of o) {
|
|
492
|
-
const m = l.relationship.dimensions, { codedSeriesKey: f, decodedSeriesKey: g } = ge(
|
|
493
|
-
e,
|
|
494
|
-
d,
|
|
495
|
-
m
|
|
496
|
-
);
|
|
497
|
-
u[l.id] = {
|
|
498
|
-
values: i?.[f] || [],
|
|
499
|
-
decodedSeriesKey: g,
|
|
500
|
-
codedSeriesKey: f
|
|
501
|
-
};
|
|
502
|
-
}
|
|
503
|
-
return u;
|
|
504
|
-
}, lt = (e, t) => {
|
|
505
|
-
if (t == null)
|
|
506
|
-
return;
|
|
507
|
-
const n = e.values?.[t];
|
|
508
|
-
return n ?? (t instanceof Array ? { values: t } : { value: t.toString() });
|
|
509
|
-
}, Nn = (e, t, n, s) => {
|
|
510
|
-
const r = t?.find(
|
|
511
|
-
(o) => o?.id === e?.id
|
|
512
|
-
)?.values;
|
|
513
|
-
return n?.filter((o) => r?.some((i) => i.id === o.id))?.map((o) => ({
|
|
514
|
-
...o,
|
|
515
|
-
name: s ? L(o, s) : o?.name
|
|
516
|
-
})) || [];
|
|
553
|
+
if (!e || !e.startPeriod && !e.endPeriod) return null;
|
|
554
|
+
let n = [], { startPeriod: r, endPeriod: i } = e;
|
|
555
|
+
if (r && n.push(`${b.GREATER_OR_EQUAL}:${ft(r)}`), i && n.push(`${b.LESS_OR_EQUAL}:${ft(i)}`), n.length === 0) return null;
|
|
556
|
+
let a = t, o = n.join("+");
|
|
557
|
+
return `${encodeURIComponent(`c[${a}]`)}=${encodeURIComponent(o)}`;
|
|
558
|
+
}, ft = (e) => c(e, "yyyy-MM-dd"), pt = (e, t) => {
|
|
559
|
+
let n = mt(e, t) || null;
|
|
560
|
+
return n ? dt(n, t?.id) : null;
|
|
517
561
|
}, mt = (e, t) => {
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
function ht(e) {
|
|
595
|
-
const t = new Date(e), s = -((t.getDay() + 6) % 7) + 3;
|
|
596
|
-
return t.setDate(t.getDate() + s), new Date(t.valueOf());
|
|
597
|
-
}
|
|
598
|
-
function se(e, t = "W") {
|
|
599
|
-
const n = `${e}-12-31`, s = R(new Date(n), t);
|
|
600
|
-
if (s.weekYear === e)
|
|
601
|
-
return s.weekNumber;
|
|
602
|
-
const r = `${e}-12-24`;
|
|
603
|
-
return R(new Date(r), t).weekNumber;
|
|
604
|
-
}
|
|
605
|
-
function he(e, t, n = "W") {
|
|
606
|
-
return `${e}-${n}${t < 10 ? "0" + t : t}`;
|
|
607
|
-
}
|
|
608
|
-
function R(e, t = "W") {
|
|
609
|
-
const n = ht(e), s = n.getFullYear(), r = V(s), o = 1 + Math.ceil(
|
|
610
|
-
(n.getTime() - r.getTime()) / Y
|
|
611
|
-
);
|
|
612
|
-
return {
|
|
613
|
-
code: he(s, o, t),
|
|
614
|
-
weekNumber: o,
|
|
615
|
-
weekYear: s
|
|
616
|
-
};
|
|
617
|
-
}
|
|
618
|
-
function pt(e) {
|
|
619
|
-
const [t, n] = e.split("-W"), r = V(+t).getTime() + (+n - 1) * Y - 3 * x;
|
|
620
|
-
return new Date(r);
|
|
621
|
-
}
|
|
622
|
-
function Et(e) {
|
|
623
|
-
const [t, n] = e.split("-W"), r = V(+t).getTime() + (+n - 1) * Y + 3 * x;
|
|
624
|
-
return new Date(r);
|
|
625
|
-
}
|
|
626
|
-
const re = "/api/download", Dt = 6e4, At = /[\x00-\x1F\x7F<>:"/\\|?*]/g, pe = (e) => e.normalize("NFKC").replace(At, "_").replace(/_+/g, "_").replace(/\s+/g, " ").replace(/^[._ ]+/, "").trim() || "download", yt = (e, t, n, s, r, o, i) => {
|
|
627
|
-
const c = new URL(re, window.location.origin);
|
|
628
|
-
if (c.search = new URLSearchParams({
|
|
629
|
-
urn: e,
|
|
630
|
-
format: t,
|
|
631
|
-
compress: "false",
|
|
632
|
-
filename: o,
|
|
633
|
-
filters: JSON.stringify(r),
|
|
634
|
-
attribute: s,
|
|
635
|
-
language: n,
|
|
636
|
-
isMetadata: i ? "true" : "none"
|
|
637
|
-
}).toString(), c.origin !== window.location.origin || c.pathname !== re)
|
|
638
|
-
throw new Error("Invalid download URL");
|
|
639
|
-
return c.toString();
|
|
562
|
+
let n = t.id, r = e?.filters?.find((e) => e.componentCode === n);
|
|
563
|
+
if (!r || !r.values) return null;
|
|
564
|
+
let a = r.values?.filter((e) => !!e);
|
|
565
|
+
if (!a.length) return null;
|
|
566
|
+
let o = r.operator;
|
|
567
|
+
return o === b.LESS_OR_EQUAL || o === b.LESS ? {
|
|
568
|
+
startPeriod: null,
|
|
569
|
+
endPeriod: i(a[0])
|
|
570
|
+
} : o === b.GREATER_OR_EQUAL || o === b.GREATER ? {
|
|
571
|
+
startPeriod: i(a[0]),
|
|
572
|
+
endPeriod: null
|
|
573
|
+
} : {
|
|
574
|
+
startPeriod: i(a[0]),
|
|
575
|
+
endPeriod: i(a[1])
|
|
576
|
+
};
|
|
577
|
+
}, ht = "Observation", gt = (e) => {
|
|
578
|
+
let t = e?.data?.dataSets, n = e?.data?.structures?.[0];
|
|
579
|
+
if (!t || !n) return [];
|
|
580
|
+
let r = n.attributes, i = n.dimensions, a = r?.dimensionGroup || [], o = t[0].series || t[0].observations, s = i.series?.length ? i.series : i.observation, c = [];
|
|
581
|
+
for (let i in o) {
|
|
582
|
+
let l = [], { name: u, parsedTimeSeriesValue: d } = _t(i, s), f = o[i], p = f.attributes || [];
|
|
583
|
+
if (Object.keys(f).length === 0) {
|
|
584
|
+
c.push({
|
|
585
|
+
name: u,
|
|
586
|
+
parsedTimeSeriesValue: d,
|
|
587
|
+
values: l,
|
|
588
|
+
attributes: [],
|
|
589
|
+
dataSetAttrs: []
|
|
590
|
+
});
|
|
591
|
+
continue;
|
|
592
|
+
}
|
|
593
|
+
l.push(...xt(f, n));
|
|
594
|
+
let m = R(r?.series || [], (e) => p[e]), h = Ct(n.attributes?.dataSet || [], t[0].attributes?.filter((e) => e != null) || []), ee = He(e, d), te = a.map((e, t) => {
|
|
595
|
+
let n = ee[e.id];
|
|
596
|
+
return {
|
|
597
|
+
attribute: e,
|
|
598
|
+
dimensionGroupValue: We(e, n.values[t]),
|
|
599
|
+
dimensionGroupData: n
|
|
600
|
+
};
|
|
601
|
+
});
|
|
602
|
+
c.push({
|
|
603
|
+
name: u,
|
|
604
|
+
parsedTimeSeriesValue: d,
|
|
605
|
+
values: l,
|
|
606
|
+
attributes: m,
|
|
607
|
+
dataSetAttrs: h,
|
|
608
|
+
dimensionGroupAttributes: te
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
return c;
|
|
612
|
+
}, _t = (e, t) => {
|
|
613
|
+
let n = e.split(/(?<!\|):(?!\||$)/), r = [];
|
|
614
|
+
for (let e = 0; e < n.length; e++) {
|
|
615
|
+
let i = t?.[e], a = Number(n[e]);
|
|
616
|
+
if (a < 0 || i == null) continue;
|
|
617
|
+
let o = i.values[a];
|
|
618
|
+
if (o == null) {
|
|
619
|
+
r.push(n[e].replace("|:", ":"));
|
|
620
|
+
continue;
|
|
621
|
+
}
|
|
622
|
+
r.push(o?.id || o?.value || "");
|
|
623
|
+
}
|
|
624
|
+
return {
|
|
625
|
+
name: yt(r),
|
|
626
|
+
parsedTimeSeriesValue: r
|
|
627
|
+
};
|
|
628
|
+
}, R = (e, t) => {
|
|
629
|
+
let n = [];
|
|
630
|
+
for (let r = 0; r < e.length; r++) {
|
|
631
|
+
let i = e[r], a = t(r), o = a != null && i.values != null ? vt(a, i) : void 0;
|
|
632
|
+
n.push({
|
|
633
|
+
name: i.id,
|
|
634
|
+
value: o
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
return n;
|
|
640
638
|
}, vt = (e, t) => {
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
const n = [], { startPeriod: s, endPeriod: r } = e;
|
|
681
|
-
if (s && n.push(
|
|
682
|
-
`${h.GREATER_OR_EQUAL}${Z}${oe(s)}`
|
|
683
|
-
), r && n.push(
|
|
684
|
-
`${h.LESS_OR_EQUAL}${Z}${oe(r)}`
|
|
685
|
-
), n.length === 0)
|
|
686
|
-
return null;
|
|
687
|
-
const o = t, i = n.join(me);
|
|
688
|
-
return `${encodeURIComponent(`c[${o}]`)}${qe}${encodeURIComponent(i)}`;
|
|
689
|
-
}, oe = (e) => $e(e, "yyyy-MM-dd"), Wn = (e, t) => {
|
|
690
|
-
const n = Tt(e, t) || null;
|
|
691
|
-
return n ? St(n, t?.id) : null;
|
|
692
|
-
}, Tt = (e, t) => {
|
|
693
|
-
const n = t.id, s = e?.filters?.find(
|
|
694
|
-
(a) => a.componentCode === n
|
|
695
|
-
);
|
|
696
|
-
if (!s || !s.values)
|
|
697
|
-
return null;
|
|
698
|
-
const r = s.values?.filter((a) => !!a);
|
|
699
|
-
if (!r.length)
|
|
700
|
-
return null;
|
|
701
|
-
const o = s.operator;
|
|
702
|
-
if (o === h.LESS_OR_EQUAL || o === h.LESS)
|
|
703
|
-
return { startPeriod: null, endPeriod: S(r[0]) };
|
|
704
|
-
if (o === h.GREATER_OR_EQUAL || o === h.GREATER)
|
|
705
|
-
return { startPeriod: S(r[0]), endPeriod: null };
|
|
706
|
-
const i = S(r[0]), c = S(r[1]);
|
|
707
|
-
return { startPeriod: i, endPeriod: c };
|
|
708
|
-
}, Rt = "Observation", kn = (e) => {
|
|
709
|
-
const t = e?.data?.dataSets, n = e?.data?.structures?.[0];
|
|
710
|
-
if (!t || !n)
|
|
711
|
-
return [];
|
|
712
|
-
const s = n.attributes, r = n.dimensions, o = s?.dimensionGroup || [], i = t[0].series || t[0].observations, c = r.series?.length ? r.series : r.observation, a = [];
|
|
713
|
-
for (const d in i) {
|
|
714
|
-
const u = [], { name: l, parsedTimeSeriesValue: m } = wt(
|
|
715
|
-
d,
|
|
716
|
-
c
|
|
717
|
-
), f = i[d], g = f.attributes || [];
|
|
718
|
-
if (Object.keys(f).length === 0) {
|
|
719
|
-
a.push({
|
|
720
|
-
name: l,
|
|
721
|
-
parsedTimeSeriesValue: m,
|
|
722
|
-
values: u,
|
|
723
|
-
attributes: [],
|
|
724
|
-
dataSetAttrs: []
|
|
725
|
-
});
|
|
726
|
-
continue;
|
|
727
|
-
}
|
|
728
|
-
u.push(
|
|
729
|
-
...Pt(f, n)
|
|
730
|
-
);
|
|
731
|
-
const E = $(
|
|
732
|
-
s?.series || [],
|
|
733
|
-
(D) => g[D]
|
|
734
|
-
), v = _t(
|
|
735
|
-
n.attributes?.dataSet || [],
|
|
736
|
-
t[0].attributes?.filter((D) => D != null) || []
|
|
737
|
-
), w = dt(
|
|
738
|
-
e,
|
|
739
|
-
m
|
|
740
|
-
), I = o.map((D, Se) => {
|
|
741
|
-
const H = w[D.id], Te = lt(
|
|
742
|
-
D,
|
|
743
|
-
H.values[Se]
|
|
744
|
-
);
|
|
745
|
-
return {
|
|
746
|
-
attribute: D,
|
|
747
|
-
dimensionGroupValue: Te,
|
|
748
|
-
dimensionGroupData: H
|
|
749
|
-
};
|
|
750
|
-
});
|
|
751
|
-
a.push({
|
|
752
|
-
name: l,
|
|
753
|
-
parsedTimeSeriesValue: m,
|
|
754
|
-
values: u,
|
|
755
|
-
attributes: E,
|
|
756
|
-
dataSetAttrs: v,
|
|
757
|
-
dimensionGroupAttributes: I
|
|
758
|
-
});
|
|
759
|
-
}
|
|
760
|
-
return a;
|
|
761
|
-
}, wt = (e, t) => {
|
|
762
|
-
const n = e.split(new RegExp("(?<!\\|):(?!\\||$)")), s = [];
|
|
763
|
-
for (let r = 0; r < n.length; r++) {
|
|
764
|
-
const o = t?.[r], i = Number(n[r]);
|
|
765
|
-
if (i < 0 || o == null)
|
|
766
|
-
continue;
|
|
767
|
-
const c = o.values[i];
|
|
768
|
-
if (c == null) {
|
|
769
|
-
s.push(n[r].replace("|:", ":"));
|
|
770
|
-
continue;
|
|
771
|
-
}
|
|
772
|
-
s.push(c?.id || c?.value || "");
|
|
773
|
-
}
|
|
774
|
-
return {
|
|
775
|
-
name: bt(s),
|
|
776
|
-
parsedTimeSeriesValue: s
|
|
777
|
-
};
|
|
778
|
-
}, $ = (e, t) => {
|
|
779
|
-
const n = [];
|
|
780
|
-
for (let s = 0; s < e.length; s++) {
|
|
781
|
-
const r = e[s], o = t(s), i = o != null && r.values != null ? It(o, r) : void 0;
|
|
782
|
-
n.push({
|
|
783
|
-
name: r.id,
|
|
784
|
-
value: i
|
|
785
|
-
});
|
|
786
|
-
}
|
|
787
|
-
return n;
|
|
788
|
-
}, It = (e, t) => {
|
|
789
|
-
const n = t.values[e];
|
|
790
|
-
return n == null ? typeof e == "object" ? e : e.toString() : n?.id || n?.value || n?.ids || n?.values;
|
|
791
|
-
}, bt = (e) => e.map((t) => t ? $t(t) : "").join("."), $t = (e) => e.replace(/\./g, "|.").replace(/:/g, "|:"), Pt = (e, t) => {
|
|
792
|
-
const n = t.measures?.observation?.length;
|
|
793
|
-
if (e.observations == null)
|
|
794
|
-
return [
|
|
795
|
-
{
|
|
796
|
-
values: ie(e, t.measures),
|
|
797
|
-
obsAttributes: $(
|
|
798
|
-
t.attributes?.observation || [],
|
|
799
|
-
(i) => e[i + n]
|
|
800
|
-
),
|
|
801
|
-
dimensionAtObservation: Rt
|
|
802
|
-
}
|
|
803
|
-
];
|
|
804
|
-
const s = e.observations, r = t.dimensions.observation?.[0], o = [];
|
|
805
|
-
for (const i in s) {
|
|
806
|
-
const c = r?.values[i];
|
|
807
|
-
o.push({
|
|
808
|
-
dimensionAtObservation: c?.value || c?.id,
|
|
809
|
-
values: ie(
|
|
810
|
-
s[i],
|
|
811
|
-
t.measures
|
|
812
|
-
),
|
|
813
|
-
obsAttributes: $(
|
|
814
|
-
t.attributes?.observation || [],
|
|
815
|
-
(a) => s[i][a + n]
|
|
816
|
-
)
|
|
817
|
-
});
|
|
818
|
-
}
|
|
819
|
-
return o;
|
|
820
|
-
}, ie = (e, t) => t?.observation?.map((n, s) => ({ name: n.id, value: e[s] })) || [], _t = (e, t) => e.reduce(
|
|
821
|
-
(n, s, r) => {
|
|
822
|
-
const o = t[r];
|
|
823
|
-
return Nt(n, s, o, ""), n;
|
|
824
|
-
},
|
|
825
|
-
[]
|
|
826
|
-
), Nt = (e, t, n, s) => {
|
|
827
|
-
const r = n != null ? t?.values?.length > 0 ? t.values[n]?.id || t.values[n]?.value : String(n) : s;
|
|
828
|
-
e.push({
|
|
829
|
-
name: t.id,
|
|
830
|
-
value: r || ""
|
|
831
|
-
});
|
|
832
|
-
}, Mt = /^[0-9][0-9][0-9][0-9]-Q[1-4]$/, Lt = /^[0-9][0-9][0-9][0-9]-W(0[1-9]|[1-4][0-9]|5[0-3])$/, Ut = /^[0-9][0-9][0-9][0-9]-S[1-2]$/, Ot = /^[0-9][0-9][0-9][0-9]$/, Ct = /^[0-9][0-9][0-9][0-9]-(0[1-9]|1[0-2])-[0-9][0-9]$/, xt = /^[0-9][0-9][0-9][0-9]-M(0[1-9]|(1[0-2]))$/, W = (e) => Ot.exec(e), k = (e) => !!W(e), Yt = (e) => Ut.exec(e), q = (e) => !!Yt(e), Q = (e) => xt.exec(e), F = (e) => !!Q(e), B = (e) => Mt.exec(e), G = (e) => !!B(e), Vt = (e) => Ct.exec(e), Wt = (e) => !!Vt(e), kt = (e) => Lt.exec(e), K = (e) => !!kt(e);
|
|
833
|
-
function Ee(e) {
|
|
834
|
-
return k(e) ? qt(e) : q(e) ? Ft(e) : G(e) ? Gt(e) : F(e) ? Ht(e) : K(e) ? pt(e) : zt(e);
|
|
835
|
-
}
|
|
836
|
-
function De(e) {
|
|
837
|
-
return k(e) ? Qt(e) : q(e) ? Bt(e) : G(e) ? Kt(e) : F(e) ? jt(e) : K(e) ? Et(e) : Jt(e);
|
|
838
|
-
}
|
|
839
|
-
function qt(e) {
|
|
840
|
-
const t = W(e);
|
|
841
|
-
if (t)
|
|
842
|
-
return new Date(Number(t[0]), 0, 1);
|
|
843
|
-
}
|
|
844
|
-
function Qt(e) {
|
|
845
|
-
const t = W(e);
|
|
846
|
-
if (t)
|
|
847
|
-
return new Date(Number(t[0]) + 1, 0, 1);
|
|
639
|
+
let n = t.values[e];
|
|
640
|
+
return n == null ? typeof e == "object" ? e : e.toString() : n?.id || n?.value || n?.ids || n?.values;
|
|
641
|
+
}, yt = (e) => e.map((e) => e ? bt(e) : "").join("."), bt = (e) => e.replace(/\./g, "|.").replace(/:/g, "|:"), xt = (e, t) => {
|
|
642
|
+
let n = t.measures?.observation?.length;
|
|
643
|
+
if (e.observations == null) return [{
|
|
644
|
+
values: St(e, t.measures),
|
|
645
|
+
obsAttributes: R(t.attributes?.observation || [], (t) => e[t + n]),
|
|
646
|
+
dimensionAtObservation: ht
|
|
647
|
+
}];
|
|
648
|
+
let r = e.observations, i = t.dimensions.observation?.[0], a = [];
|
|
649
|
+
for (let e in r) {
|
|
650
|
+
let o = i?.values[e];
|
|
651
|
+
a.push({
|
|
652
|
+
dimensionAtObservation: o?.value || o?.id,
|
|
653
|
+
values: St(r[e], t.measures),
|
|
654
|
+
obsAttributes: R(t.attributes?.observation || [], (t) => r[e][t + n])
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
return a;
|
|
658
|
+
}, St = (e, t) => t?.observation?.map((t, n) => ({
|
|
659
|
+
name: t.id,
|
|
660
|
+
value: e[n]
|
|
661
|
+
})) || [], Ct = (e, t) => e.reduce((e, n, r) => {
|
|
662
|
+
let i = t[r];
|
|
663
|
+
return wt(e, n, i, ""), e;
|
|
664
|
+
}, []), wt = (e, t, n, r) => {
|
|
665
|
+
let i = n == null ? r : t?.values?.length > 0 ? t.values[n]?.id || t.values[n]?.value : String(n);
|
|
666
|
+
e.push({
|
|
667
|
+
name: t.id,
|
|
668
|
+
value: i || ""
|
|
669
|
+
});
|
|
670
|
+
}, Tt = /^[0-9][0-9][0-9][0-9]-Q[1-4]$/, Et = /^[0-9][0-9][0-9][0-9]-W(0[1-9]|[1-4][0-9]|5[0-3])$/, Dt = /^[0-9][0-9][0-9][0-9]-S[1-2]$/, Ot = /^[0-9][0-9][0-9][0-9]$/, kt = /^[0-9][0-9][0-9][0-9]-(0[1-9]|1[0-2])-[0-9][0-9]$/, At = /^[0-9][0-9][0-9][0-9]-M(0[1-9]|(1[0-2]))$/, z = (e) => Ot.exec(e), B = (e) => !!z(e), jt = (e) => Dt.exec(e), V = (e) => !!jt(e), H = (e) => At.exec(e), U = (e) => !!H(e), W = (e) => Tt.exec(e), G = (e) => !!W(e), Mt = (e) => kt.exec(e), Nt = (e) => !!Mt(e), Pt = (e) => Et.exec(e), K = (e) => !!Pt(e);
|
|
671
|
+
//#endregion
|
|
672
|
+
//#region libs/sdmx-toolkit/src/parsers/time-period-parser/time-period.ts
|
|
673
|
+
function q(e) {
|
|
674
|
+
return B(e) ? Ft(e) : V(e) ? Lt(e) : G(e) ? zt(e) : U(e) ? Vt(e) : K(e) ? nt(e) : Ut(e);
|
|
675
|
+
}
|
|
676
|
+
function J(e) {
|
|
677
|
+
return B(e) ? It(e) : V(e) ? Rt(e) : G(e) ? Bt(e) : U(e) ? Ht(e) : K(e) ? rt(e) : Wt(e);
|
|
848
678
|
}
|
|
849
679
|
function Ft(e) {
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
680
|
+
let t = z(e);
|
|
681
|
+
if (t) return new Date(Number(t[0]), 0, 1);
|
|
682
|
+
}
|
|
683
|
+
function It(e) {
|
|
684
|
+
let t = z(e);
|
|
685
|
+
if (t) return new Date(Number(t[0]) + 1, 0, 1);
|
|
686
|
+
}
|
|
687
|
+
function Lt(e) {
|
|
688
|
+
let [t, n] = e.split("-S");
|
|
689
|
+
switch (+n) {
|
|
690
|
+
case 1: return new Date(+t, 0, 1);
|
|
691
|
+
case 2: return new Date(+t, 6, 1);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
function Rt(e) {
|
|
695
|
+
let [t, n] = e.split("-S");
|
|
696
|
+
switch (+n) {
|
|
697
|
+
case 1: return new Date(+t, 6, 1);
|
|
698
|
+
case 2: return new Date(+t + 1, 0, 1);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
function zt(e) {
|
|
702
|
+
let t = W(e);
|
|
703
|
+
if (!t) return;
|
|
704
|
+
let [n, r] = t[0].split("-Q");
|
|
705
|
+
switch (+r) {
|
|
706
|
+
case 1: return new Date(+n, 0, 1);
|
|
707
|
+
case 2: return new Date(+n, 3, 1);
|
|
708
|
+
case 3: return new Date(+n, 6, 1);
|
|
709
|
+
case 4: return new Date(+n, 9, 1);
|
|
710
|
+
}
|
|
857
711
|
}
|
|
858
712
|
function Bt(e) {
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
return new Date(+n, 0, 1);
|
|
875
|
-
case 2:
|
|
876
|
-
return new Date(+n, 3, 1);
|
|
877
|
-
case 3:
|
|
878
|
-
return new Date(+n, 6, 1);
|
|
879
|
-
case 4:
|
|
880
|
-
return new Date(+n, 9, 1);
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
function Kt(e) {
|
|
884
|
-
const t = B(e);
|
|
885
|
-
if (!t)
|
|
886
|
-
return;
|
|
887
|
-
const [n, s] = t[0].split("-Q");
|
|
888
|
-
switch (+s) {
|
|
889
|
-
case 1:
|
|
890
|
-
return new Date(+n, 3, 1);
|
|
891
|
-
case 2:
|
|
892
|
-
return new Date(+n, 6, 1);
|
|
893
|
-
case 3:
|
|
894
|
-
return new Date(+n, 9, 1);
|
|
895
|
-
case 4:
|
|
896
|
-
return new Date(+n + 1, 0, 1);
|
|
897
|
-
}
|
|
713
|
+
let t = W(e);
|
|
714
|
+
if (!t) return;
|
|
715
|
+
let [n, r] = t[0].split("-Q");
|
|
716
|
+
switch (+r) {
|
|
717
|
+
case 1: return new Date(+n, 3, 1);
|
|
718
|
+
case 2: return new Date(+n, 6, 1);
|
|
719
|
+
case 3: return new Date(+n, 9, 1);
|
|
720
|
+
case 4: return new Date(+n + 1, 0, 1);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
function Vt(e) {
|
|
724
|
+
let t = H(e);
|
|
725
|
+
if (!t) return;
|
|
726
|
+
let [n, r] = t[0].split("-M");
|
|
727
|
+
return new Date(+n, r - 1, 1);
|
|
898
728
|
}
|
|
899
729
|
function Ht(e) {
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
}
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
end: a
|
|
987
|
-
};
|
|
988
|
-
}, cn = (e, t, n, s = "W") => {
|
|
989
|
-
const r = +e, { start: o, end: i } = ye(e, t, n);
|
|
990
|
-
if (o.getTime() > i.getTime())
|
|
991
|
-
return [];
|
|
992
|
-
const c = R(o, s), a = c.weekYear === r ? c.weekNumber : c.weekYear < r ? 1 : se(r, s), d = R(i, s), u = d.weekYear === r ? d.weekNumber : d.weekYear > r ? se(r, s) : 1, l = [];
|
|
993
|
-
if (a < u)
|
|
994
|
-
for (let m = a; m <= u; m++)
|
|
995
|
-
l.push(he(r, m, s));
|
|
996
|
-
return l;
|
|
997
|
-
}, un = (e) => {
|
|
998
|
-
const t = new Date(e);
|
|
999
|
-
return t.setMinutes(t.getMinutes() - t.getTimezoneOffset()), t.toISOString().slice(0, 10);
|
|
1000
|
-
}, dn = (e, t, n) => {
|
|
1001
|
-
const { start: s, end: r } = ye(e, t, n);
|
|
1002
|
-
if (s.getTime() > r.getTime())
|
|
1003
|
-
return [];
|
|
1004
|
-
const o = [], i = new Date(
|
|
1005
|
-
s.getFullYear(),
|
|
1006
|
-
s.getMonth(),
|
|
1007
|
-
s.getDate()
|
|
1008
|
-
), c = new Date(r.getFullYear(), r.getMonth(), r.getDate());
|
|
1009
|
-
for (; i.getTime() < c.getTime(); ) {
|
|
1010
|
-
const a = un(i);
|
|
1011
|
-
o.push(a), i.setDate(i.getDate() + 1);
|
|
1012
|
-
}
|
|
1013
|
-
return o;
|
|
730
|
+
let t = H(e);
|
|
731
|
+
if (!t) return;
|
|
732
|
+
let [n, r] = t[0].split("-M");
|
|
733
|
+
return new Date(+n, +r, 1);
|
|
734
|
+
}
|
|
735
|
+
var Ut = (e) => /* @__PURE__ */ new Date(`${e}T00:00:00`), Wt = (e) => {
|
|
736
|
+
let t = /* @__PURE__ */ new Date(`${e}T23:59:00`);
|
|
737
|
+
return t.setMinutes(t.getMinutes() + 1), t;
|
|
738
|
+
}, Gt = 1, Kt = (e, t, n, r = !0, i = "Q") => {
|
|
739
|
+
let a = [], o = t && t > 3 ? nn(t, r) : 1, s = n ? Math.floor((n - 1) / 3) : 4;
|
|
740
|
+
for (let t = o; t <= s; t++) a.push(`${e}-${i}${t}`);
|
|
741
|
+
return a;
|
|
742
|
+
}, qt = (e, t, n, r = "S") => {
|
|
743
|
+
let i = [];
|
|
744
|
+
return (t || 1) < 7 && (n || 12) > 6 && i.push(`${e}-${r}1`), n ?? i.push(`${e}-${r}2`), i;
|
|
745
|
+
}, Jt = (e) => Math.ceil(e / 3), Yt = (e, t, n = "M") => `${e}-${n}${t.toString().padStart(2, "0")}`, Xt = (e, t, n = "M") => {
|
|
746
|
+
let r = [];
|
|
747
|
+
for (let i = t; i <= 12; i++) r.push(Yt(e, i, n));
|
|
748
|
+
return r;
|
|
749
|
+
}, Zt = (e, t, n, r = "M") => {
|
|
750
|
+
let i = [];
|
|
751
|
+
for (let a = t; a < n; a++) i.push(Yt(e, a, r));
|
|
752
|
+
return i;
|
|
753
|
+
}, Qt = (e, t, n, r = "M") => {
|
|
754
|
+
let i = t || 1;
|
|
755
|
+
return n == null ? Xt(e, i, r) : Zt(e, i, n || 12, r);
|
|
756
|
+
}, $t = (e, t, n = "M") => {
|
|
757
|
+
switch (t) {
|
|
758
|
+
case 0: return [
|
|
759
|
+
`${e}-${n}01`,
|
|
760
|
+
`${e}-${n}02`,
|
|
761
|
+
`${e}-${n}03`
|
|
762
|
+
];
|
|
763
|
+
case 1: return [
|
|
764
|
+
`${e}-${n}04`,
|
|
765
|
+
`${e}-${n}05`,
|
|
766
|
+
`${e}-${n}06`
|
|
767
|
+
];
|
|
768
|
+
case 2: return [
|
|
769
|
+
`${e}-${n}07`,
|
|
770
|
+
`${e}-${n}08`,
|
|
771
|
+
`${e}-${n}09`
|
|
772
|
+
];
|
|
773
|
+
case 3: return [
|
|
774
|
+
`${e}-${n}10`,
|
|
775
|
+
`${e}-${n}11`,
|
|
776
|
+
`${e}-${n}12`
|
|
777
|
+
];
|
|
778
|
+
default: return [];
|
|
779
|
+
}
|
|
780
|
+
}, en = (e, t) => {
|
|
781
|
+
let n = Y(t, !0), r = Y(e), i = n.getFullYear(), a = r.getFullYear(), o = n.getTime() <= r.getTime() ? a + Gt - i : 0;
|
|
782
|
+
return Array.from({ length: o }, (e, t) => i + t);
|
|
783
|
+
}, Y = (e, t = !1) => {
|
|
784
|
+
let n = tn(e, t);
|
|
785
|
+
return n ? (n.getTimezoneOffset() > 0 && n.setMinutes(n.getMinutes() + n.getTimezoneOffset()), n) : /* @__PURE__ */ new Date();
|
|
786
|
+
}, tn = (e, t = !1) => {
|
|
787
|
+
let n = Number(e);
|
|
788
|
+
return e.toString().length === 13 ? isNaN(n) ? /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`) : new Date(n) : t ? q(e) : J(e);
|
|
789
|
+
}, nn = (e, t) => t ? Math.floor((e + 1) / 3) : Math.ceil((e + 1) / 3), rn = (e, t) => {
|
|
790
|
+
let n = an(e) - an(t);
|
|
791
|
+
return n === 0 && e !== t ? X(e) - X(t) : n;
|
|
792
|
+
}, X = (e) => B(e) ? 6 : V(e) ? 5 : G(e) ? 4 : U(e) ? 3 : K(e) ? 2 : +!!Nt(e), an = (e, t = !1) => (t ? q(e) : J(e))?.getTime() || 0, Z = (e, t, n) => {
|
|
793
|
+
let r = Y(t, !0), i = Y(n), a = Y(e, !0), o = Y(e);
|
|
794
|
+
return {
|
|
795
|
+
start: r.getTime() > a.getTime() ? r : a,
|
|
796
|
+
end: i.getTime() < o.getTime() ? i : o
|
|
797
|
+
};
|
|
798
|
+
}, on = (e, t, n, r = "W") => {
|
|
799
|
+
let i = +e, { start: a, end: o } = Z(e, t, n);
|
|
800
|
+
if (a.getTime() > o.getTime()) return [];
|
|
801
|
+
let s = I(a, r), c = s.weekYear === i ? s.weekNumber : s.weekYear < i ? 1 : P(i, r), l = I(o, r), u = l.weekYear === i ? l.weekNumber : l.weekYear > i ? P(i, r) : 1, d = [];
|
|
802
|
+
if (c < u) for (let e = c; e <= u; e++) d.push(F(i, e, r));
|
|
803
|
+
return d;
|
|
804
|
+
}, sn = (e) => {
|
|
805
|
+
let t = new Date(e);
|
|
806
|
+
return t.setMinutes(t.getMinutes() - t.getTimezoneOffset()), t.toISOString().slice(0, 10);
|
|
807
|
+
}, cn = (e, t, n) => {
|
|
808
|
+
let { start: r, end: i } = Z(e, t, n);
|
|
809
|
+
if (r.getTime() > i.getTime()) return [];
|
|
810
|
+
let a = [], o = new Date(r.getFullYear(), r.getMonth(), r.getDate()), s = new Date(i.getFullYear(), i.getMonth(), i.getDate());
|
|
811
|
+
for (; o.getTime() < s.getTime();) {
|
|
812
|
+
let e = sn(o);
|
|
813
|
+
a.push(e), o.setDate(o.getDate() + 1);
|
|
814
|
+
}
|
|
815
|
+
return a;
|
|
1014
816
|
}, ln = (e) => ({
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
return i.forEach((a, d) => {
|
|
1031
|
-
const u = [], { startMonth: l, endMonth: m } = mn(
|
|
1032
|
-
i,
|
|
1033
|
-
new Date(r),
|
|
1034
|
-
new Date(o),
|
|
1035
|
-
d
|
|
1036
|
-
), {
|
|
1037
|
-
isDailyExist: f,
|
|
1038
|
-
isWeeklyExist: g,
|
|
1039
|
-
isMonthlyExist: E,
|
|
1040
|
-
isQuarterlyExist: v,
|
|
1041
|
-
isSemiAnnualExist: w,
|
|
1042
|
-
isYearlyExist: I
|
|
1043
|
-
} = s;
|
|
1044
|
-
I && u.push(a.toString()), w && u.push(...en(a, l, m)), v && u.push(
|
|
1045
|
-
...Zt(a, l, m, !1)
|
|
1046
|
-
), E && u.push(...sn(a, l, m)), g && u.push(
|
|
1047
|
-
...cn(a, r.toString(), o.toString())
|
|
1048
|
-
), f && u.push(
|
|
1049
|
-
...dn(a, r.toString(), o.toString())
|
|
1050
|
-
), c.push(...u);
|
|
1051
|
-
}), c;
|
|
817
|
+
isDailyExist: !!e?.some(({ memberValue: e }) => e === "D"),
|
|
818
|
+
isWeeklyExist: !!e?.some(({ memberValue: e }) => e === "W"),
|
|
819
|
+
isMonthlyExist: !!e?.some(({ memberValue: e }) => e === "M"),
|
|
820
|
+
isQuarterlyExist: !!e?.some(({ memberValue: e }) => e === "Q"),
|
|
821
|
+
isSemiAnnualExist: !!e?.some(({ memberValue: e }) => e === "S"),
|
|
822
|
+
isYearlyExist: !!e?.some(({ memberValue: e }) => e === "A" || e === "Y")
|
|
823
|
+
}), un = (e, t, n, r) => ({
|
|
824
|
+
startMonth: r === 0 ? Y(t.toString(), !0)?.getMonth() + 1 : void 0,
|
|
825
|
+
endMonth: r === e.length - 1 ? Y(n.toString())?.getMonth() + 1 || 1 : void 0
|
|
826
|
+
}), dn = ["FREQUENCY", "FREQ"], fn = (e, t) => {
|
|
827
|
+
let n = e?.[0]?.cubeRegions?.[0]?.memberSelection?.find((e) => dn.includes(e.componentId))?.selectionValues, r = ln(n || []), i = t?.startPeriod?.getTime() || 1, a = t?.endPeriod?.getTime() || 1, o = en(a, i), s = [];
|
|
828
|
+
return o.forEach((e, t) => {
|
|
829
|
+
let n = [], { startMonth: c, endMonth: l } = un(o, new Date(i), new Date(a), t), { isDailyExist: u, isWeeklyExist: d, isMonthlyExist: f, isQuarterlyExist: p, isSemiAnnualExist: m, isYearlyExist: h } = r;
|
|
830
|
+
h && n.push(e.toString()), m && n.push(...qt(e, c, l)), p && n.push(...Kt(e, c, l, !1)), f && n.push(...Qt(e, c, l)), d && n.push(...on(e, i.toString(), a.toString())), u && n.push(...cn(e, i.toString(), a.toString())), s.push(...n);
|
|
831
|
+
}), s;
|
|
1052
832
|
};
|
|
833
|
+
//#endregion
|
|
834
|
+
//#region libs/sdmx-toolkit/src/utils/build-dataset-dimensions-metadata-map.ts
|
|
835
|
+
function pn(e) {
|
|
836
|
+
let { urn: t } = e.details;
|
|
837
|
+
return f(t.resourceId, t.version, t.agencyId);
|
|
838
|
+
}
|
|
839
|
+
function mn(e) {
|
|
840
|
+
let t = {};
|
|
841
|
+
for (let n of e.datasets) {
|
|
842
|
+
let e = n.dataset, r = pn(e);
|
|
843
|
+
t[r] = e.details.dimensions;
|
|
844
|
+
}
|
|
845
|
+
return t;
|
|
846
|
+
}
|
|
847
|
+
function hn(e) {
|
|
848
|
+
let t = {};
|
|
849
|
+
for (let n of e.datasets) n.last_updated_at && (t[pn(n.dataset)] = n.last_updated_at);
|
|
850
|
+
return t;
|
|
851
|
+
}
|
|
852
|
+
//#endregion
|
|
853
|
+
//#region libs/sdmx-toolkit/src/utils/hierarchy-utils.ts
|
|
1053
854
|
function gn(e) {
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
}
|
|
1088
|
-
function
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
}
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
const o = new Set(r.selectionValues.map((i) => i.memberValue));
|
|
1141
|
-
return e.filter((i) => o.has(i.id));
|
|
1142
|
-
}
|
|
1143
|
-
class Jn {
|
|
1144
|
-
constructor(t) {
|
|
1145
|
-
this.client = t;
|
|
1146
|
-
}
|
|
1147
|
-
async getAvailableHierarchies(t, n, s) {
|
|
1148
|
-
const { agency: r, id: o, version: i } = y(t), a = `${this.client.config.sdmxProxyUrl ? this.client.config.sdmxProxyUrl : this.client.config.apiUrl}/sdmx/3.0/structure/codelist`, d = s ? { [J]: s } : void 0;
|
|
1149
|
-
return this.client.request(
|
|
1150
|
-
`${r}/${o}/${i}?references=hierarchy&detail=allcompletestubs`,
|
|
1151
|
-
{ method: "GET", headers: d },
|
|
1152
|
-
a,
|
|
1153
|
-
n
|
|
1154
|
-
);
|
|
1155
|
-
}
|
|
1156
|
-
async getHierarchy(t, n, s) {
|
|
1157
|
-
const { agency: r, id: o, version: i } = y(t), a = `${this.client.config.sdmxProxyUrl ? this.client.config.sdmxProxyUrl : this.client.config.apiUrl}/sdmx/3.0/structure/hierarchy`, d = s ? { [J]: s } : void 0;
|
|
1158
|
-
return this.client.request(
|
|
1159
|
-
`${r}/${o}/${i}?references=descendants&detail=full`,
|
|
1160
|
-
{ method: "GET", headers: d },
|
|
1161
|
-
a,
|
|
1162
|
-
n
|
|
1163
|
-
);
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1166
|
-
export {
|
|
1167
|
-
M as Annotations,
|
|
1168
|
-
ft as AssignmentStatus,
|
|
1169
|
-
yn as AvailabilityApi,
|
|
1170
|
-
We as DATASET_DATA_URL,
|
|
1171
|
-
Sn as DatasetApi,
|
|
1172
|
-
C as DimensionType,
|
|
1173
|
-
Ce as DownloadType,
|
|
1174
|
-
wn as FREQUENCY_DIMENSION_ID,
|
|
1175
|
-
fn as FREQUENCY_DIM_ID,
|
|
1176
|
-
Oe as FileColumnsAttribute,
|
|
1177
|
-
Qe as GET_v3_FILTER_ALL,
|
|
1178
|
-
vn as GET_v3_FILTER_AND,
|
|
1179
|
-
me as GET_v3_FILTER_OR,
|
|
1180
|
-
Jn as HierarchyApi,
|
|
1181
|
-
Rt as OBSERVATION_KEY,
|
|
1182
|
-
gt as OccurrenceType,
|
|
1183
|
-
He as Periods,
|
|
1184
|
-
Ke as RepresentationTextType,
|
|
1185
|
-
Ge as SDMX_DATA_QUERY_PARAMS,
|
|
1186
|
-
b as SINGLE_WILDCARD_SYMBOL,
|
|
1187
|
-
Tn as SdmxApiClient,
|
|
1188
|
-
de as SdmxAvailabilityMode,
|
|
1189
|
-
A as SdmxDataFormat,
|
|
1190
|
-
le as SdmxDetails,
|
|
1191
|
-
N as SdmxReferences,
|
|
1192
|
-
h as SeriesFilterOperator,
|
|
1193
|
-
je as TIME_PERIOD,
|
|
1194
|
-
Je as TIME_PERIOD_END_ANNOTATION_KEY,
|
|
1195
|
-
ze as TIME_PERIOD_START_ANNOTATION_KEY,
|
|
1196
|
-
Gn as buildDatasetDimensionsMetadataMap,
|
|
1197
|
-
Ct as dailyPattern,
|
|
1198
|
-
$t as decodeDimensionId,
|
|
1199
|
-
Pn as findCodelistByDimension,
|
|
1200
|
-
ee as generateDatasetDataRequest,
|
|
1201
|
-
_ as generateShortUrn,
|
|
1202
|
-
Bn as getAdditionalColumns,
|
|
1203
|
-
In as getAnnotationPeriod,
|
|
1204
|
-
U as getArtifactByUrnWithWildCard,
|
|
1205
|
-
_n as getAttachedDimensionsSeriesByDimension,
|
|
1206
|
-
dt as getAttachedDimensionsSeriesByTsId,
|
|
1207
|
-
ge as getAttachedDimensionsSeriesKey,
|
|
1208
|
-
lt as getAttributeValueFromDataQueryResponse,
|
|
1209
|
-
Nn as getAvailableCodes,
|
|
1210
|
-
bn as getAvailableCodesFromConstrains,
|
|
1211
|
-
ue as getChildParsedUrn,
|
|
1212
|
-
jn as getCodeListsData,
|
|
1213
|
-
O as getConcept,
|
|
1214
|
-
te as getConceptByUrn,
|
|
1215
|
-
ct as getConceptWithScheme,
|
|
1216
|
-
mt as getConvertedMetaAttributes,
|
|
1217
|
-
Vt as getDailyRegExp,
|
|
1218
|
-
dn as getDaysColumns,
|
|
1219
|
-
Mn as getDimensionTitle,
|
|
1220
|
-
ne as getDimensions,
|
|
1221
|
-
Be as getFilteredItemsWithParents,
|
|
1222
|
-
st as getFiltersDtoFromDataQuery,
|
|
1223
|
-
$n as getFiltersDtoMapFromDataQuery,
|
|
1224
|
-
zn as getHierarchyAvailableCodes,
|
|
1225
|
-
Hn as getHierarchyCodes,
|
|
1226
|
-
R as getISOWeek,
|
|
1227
|
-
T as getKeyFromUrn,
|
|
1228
|
-
Rn as getLastUpdatedTime,
|
|
1229
|
-
se as getLastWeekNumberOfYear,
|
|
1230
|
-
L as getLocalizedName,
|
|
1231
|
-
sn as getMonthlyData,
|
|
1232
|
-
Qn as getMonthlyDataByQuarter,
|
|
1233
|
-
Q as getMonthlyRegExp,
|
|
1234
|
-
De as getParsedEndPeriodDate,
|
|
1235
|
-
kn as getParsedResponse,
|
|
1236
|
-
Ee as getParsedStartPeriodDate,
|
|
1237
|
-
p as getPeriodDate,
|
|
1238
|
-
ln as getPeriods,
|
|
1239
|
-
qn as getQuarterByMonth,
|
|
1240
|
-
B as getQuarterlyRegExp,
|
|
1241
|
-
Zt as getQuartersData,
|
|
1242
|
-
St as getQueryTimePeriodFilters,
|
|
1243
|
-
xe as getRequestAcceptHeader,
|
|
1244
|
-
rt as getResolvedVersionBySingleWildcard,
|
|
1245
|
-
Ye as getResponseContentType,
|
|
1246
|
-
en as getSemiAnnualData,
|
|
1247
|
-
Yt as getSemiAnnuallyRegExp,
|
|
1248
|
-
$ as getSeriesAttributes,
|
|
1249
|
-
wt as getSeriesName,
|
|
1250
|
-
Cn as getStructureComponentsMap,
|
|
1251
|
-
Ln as getStructureDimensions,
|
|
1252
|
-
On as getTimeDimension,
|
|
1253
|
-
Un as getTimePeriods,
|
|
1254
|
-
Wn as getTimeQueryFilter,
|
|
1255
|
-
Tt as getTimeRangeFromAttachment,
|
|
1256
|
-
xn as getTimeSeriesCount,
|
|
1257
|
-
Vn as getTimeSeriesFilterKey,
|
|
1258
|
-
bt as getTimeSeriesId,
|
|
1259
|
-
he as getWeekCode,
|
|
1260
|
-
Et as getWeeklyPeriodEndDate,
|
|
1261
|
-
pt as getWeeklyPeriodStartDate,
|
|
1262
|
-
kt as getWeeklyRegExp,
|
|
1263
|
-
cn as getWeeksColumns,
|
|
1264
|
-
it as getWildCardPrefix,
|
|
1265
|
-
ye as getYearPeriod,
|
|
1266
|
-
W as getYearlyRegExp,
|
|
1267
|
-
rn as getYears,
|
|
1268
|
-
Wt as isDaily,
|
|
1269
|
-
F as isMonthly,
|
|
1270
|
-
G as isQuarterly,
|
|
1271
|
-
q as isSemiAnnually,
|
|
1272
|
-
K as isWeekly,
|
|
1273
|
-
at as isWildCardVersionCorrect,
|
|
1274
|
-
k as isYearly,
|
|
1275
|
-
xt as monthlyPattern,
|
|
1276
|
-
Yn as openDownloadWindow,
|
|
1277
|
-
Mt as quarterPattern,
|
|
1278
|
-
Kn as resolveCodelistsFromResponse,
|
|
1279
|
-
pe as sanitizeDownloadFilename,
|
|
1280
|
-
Ut as semiAnnuallyPattern,
|
|
1281
|
-
Fn as sortPeriods,
|
|
1282
|
-
y as splitUrn,
|
|
1283
|
-
hn as urnMatchesIgnoreVersion,
|
|
1284
|
-
Lt as weeklyPattern,
|
|
1285
|
-
Ot as yearlyPattern
|
|
855
|
+
return e?.codelists?.length ? e.codelists.map((e) => ({
|
|
856
|
+
id: e.id,
|
|
857
|
+
agencyID: e.agencyID ?? "",
|
|
858
|
+
version: e.version ?? "",
|
|
859
|
+
name: e.name,
|
|
860
|
+
codes: e.codes?.map((e) => ({
|
|
861
|
+
id: e.id,
|
|
862
|
+
name: e.name,
|
|
863
|
+
description: e.description
|
|
864
|
+
}))
|
|
865
|
+
})) : (e?.glossaries ?? []).map((e) => ({
|
|
866
|
+
id: e.id,
|
|
867
|
+
agencyID: e.agencyID ?? "",
|
|
868
|
+
version: e.version ?? "",
|
|
869
|
+
name: e.name,
|
|
870
|
+
codes: e.terms?.map((e) => ({
|
|
871
|
+
id: e.id,
|
|
872
|
+
name: e.name,
|
|
873
|
+
description: e.description
|
|
874
|
+
}))
|
|
875
|
+
}));
|
|
876
|
+
}
|
|
877
|
+
function _n(e, t) {
|
|
878
|
+
let n = (e) => {
|
|
879
|
+
let t = e.indexOf("(");
|
|
880
|
+
if (t === -1) return e;
|
|
881
|
+
let n = e.indexOf(")", t);
|
|
882
|
+
return n === -1 ? e : e.slice(0, t + 1) + "*" + e.slice(n);
|
|
883
|
+
};
|
|
884
|
+
return n(e) === n(t);
|
|
885
|
+
}
|
|
886
|
+
function Q(e) {
|
|
887
|
+
return f(e.id, e.version ?? "", e.agencyID ?? "");
|
|
888
|
+
}
|
|
889
|
+
function $(e, t, n) {
|
|
890
|
+
t?.forEach((t) => {
|
|
891
|
+
let { childId: r, agency: i, id: a, version: o } = d(t.code), s = f(a, o, i), c = n?.find((e) => _n(s, Q(e))), l = c?.codes?.find((e) => e.id === r);
|
|
892
|
+
if (l != null) {
|
|
893
|
+
let n = t.code.replace(s, Q(c));
|
|
894
|
+
e.push({
|
|
895
|
+
...l,
|
|
896
|
+
code: n
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
$(e, t.hierarchicalCodes, n);
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
function vn(e, t) {
|
|
903
|
+
let n = [];
|
|
904
|
+
return $(n, e?.hierarchicalCodes, t), n;
|
|
905
|
+
}
|
|
906
|
+
function yn(e) {
|
|
907
|
+
let t = {};
|
|
908
|
+
return e?.forEach((e) => {
|
|
909
|
+
t[Q(e)] = e.codes;
|
|
910
|
+
}), t;
|
|
911
|
+
}
|
|
912
|
+
function bn(e, t, n) {
|
|
913
|
+
if (!n || n.length === 0 || !t) return e;
|
|
914
|
+
let r = n[0].cubeRegions?.find((e) => e.isIncluded);
|
|
915
|
+
if (!r) return e;
|
|
916
|
+
let i = r.memberSelection?.find((e) => e.componentId === t);
|
|
917
|
+
if (!i) return [];
|
|
918
|
+
let a = new Set(i.selectionValues.map((e) => e.memberValue));
|
|
919
|
+
return e.filter((e) => a.has(e.id));
|
|
920
|
+
}
|
|
921
|
+
//#endregion
|
|
922
|
+
//#region libs/sdmx-toolkit/src/api/hierarchy-api.ts
|
|
923
|
+
var xn = class {
|
|
924
|
+
constructor(e) {
|
|
925
|
+
this.client = e;
|
|
926
|
+
}
|
|
927
|
+
async getAvailableHierarchies(e, t, r) {
|
|
928
|
+
let { agency: i, id: a, version: o } = u(e), s = `${this.client.config.sdmxProxyUrl ? this.client.config.sdmxProxyUrl : this.client.config.apiUrl}/sdmx/3.0/structure/codelist`, c = r ? { [n]: r } : void 0;
|
|
929
|
+
return this.client.request(`${i}/${a}/${o}?references=hierarchy&detail=allcompletestubs`, {
|
|
930
|
+
method: "GET",
|
|
931
|
+
headers: c
|
|
932
|
+
}, s, t);
|
|
933
|
+
}
|
|
934
|
+
async getHierarchy(e, t, r) {
|
|
935
|
+
let { agency: i, id: a, version: o } = u(e), s = `${this.client.config.sdmxProxyUrl ? this.client.config.sdmxProxyUrl : this.client.config.apiUrl}/sdmx/3.0/structure/hierarchy`, c = r ? { [n]: r } : void 0;
|
|
936
|
+
return this.client.request(`${i}/${a}/${o}?references=descendants&detail=full`, {
|
|
937
|
+
method: "GET",
|
|
938
|
+
headers: c
|
|
939
|
+
}, s, t);
|
|
940
|
+
}
|
|
1286
941
|
};
|
|
942
|
+
//#endregion
|
|
943
|
+
export { v as Annotations, Je as AssignmentStatus, ae as AvailabilityApi, fe as DATASET_DATA_URL, _e as DatasetApi, k as DimensionType, se as DownloadType, Te as FREQUENCY_DIMENSION_ID, dn as FREQUENCY_DIM_ID, oe as FileColumnsAttribute, he as GET_v3_FILTER_ALL, me as GET_v3_FILTER_AND, pe as GET_v3_FILTER_OR, xn as HierarchyApi, ht as OBSERVATION_KEY, Ye as OccurrenceType, we as Periods, Ce as RepresentationTextType, Se as SDMX_DATA_QUERY_PARAMS, Le as SINGLE_WILDCARD_SYMBOL, ve as SdmxApiClient, m as SdmxAvailabilityMode, g as SdmxDataFormat, de as SdmxDetails, p as SdmxReferences, b as SeriesFilterOperator, Ee as TIME_PERIOD, x as TIME_PERIOD_END_ANNOTATION_KEY, De as TIME_PERIOD_START_ANNOTATION_KEY, mn as buildDatasetDimensionsMetadataMap, hn as buildDatasetLastUpdatedMap, kt as dailyPattern, bt as decodeDimensionId, Ve as findCodelistByDimension, _ as generateDatasetDataRequest, f as generateShortUrn, fn as getAdditionalColumns, Oe as getAnnotationPeriod, S as getArtifactByUrnWithWildCard, Ue as getAttachedDimensionsSeriesByDimension, He as getAttachedDimensionsSeriesByTsId, O as getAttachedDimensionsSeriesKey, We as getAttributeValueFromDataQueryResponse, Ge as getAvailableCodes, Ne as getAvailableCodesFromConstrains, d as getChildParsedUrn, yn as getCodeListsData, E as getConcept, D as getConceptByUrn, ze as getConceptWithScheme, Ke as getConvertedMetaAttributes, Mt as getDailyRegExp, cn as getDaysColumns, qe as getDimensionTitle, A as getDimensions, xe as getFilteredItemsWithParents, Fe as getFiltersDtoFromDataQuery, Ie as getFiltersDtoMapFromDataQuery, bn as getHierarchyAvailableCodes, vn as getHierarchyCodes, I as getISOWeek, l as getKeyFromUrn, ye as getLastUpdatedTime, P as getLastWeekNumberOfYear, y as getLocalizedName, Qt as getMonthlyData, $t as getMonthlyDataByQuarter, H as getMonthlyRegExp, J as getParsedEndPeriodDate, gt as getParsedResponse, q as getParsedStartPeriodDate, Y as getPeriodDate, ln as getPeriods, Jt as getQuarterByMonth, W as getQuarterlyRegExp, Kt as getQuartersData, dt as getQueryTimePeriodFilters, ce as getRequestAcceptHeader, C as getResolvedVersionBySingleWildcard, le as getResponseContentType, qt as getSemiAnnualData, jt as getSemiAnnuallyRegExp, R as getSeriesAttributes, _t as getSeriesName, $e as getStructureComponentsMap, Xe as getStructureDimensions, Qe as getTimeDimension, Ze as getTimePeriods, pt as getTimeQueryFilter, mt as getTimeRangeFromAttachment, et as getTimeSeriesCount, ut as getTimeSeriesFilterKey, yt as getTimeSeriesId, F as getWeekCode, rt as getWeeklyPeriodEndDate, nt as getWeeklyPeriodStartDate, Pt as getWeeklyRegExp, on as getWeeksColumns, w as getWildCardPrefix, Z as getYearPeriod, z as getYearlyRegExp, en as getYears, Nt as isDaily, U as isMonthly, G as isQuarterly, V as isSemiAnnually, K as isWeekly, T as isWildCardVersionCorrect, B as isYearly, At as monthlyPattern, lt as openDownloadWindow, Tt as quarterPattern, gn as resolveCodelistsFromResponse, L as sanitizeDownloadFilename, Dt as semiAnnuallyPattern, rn as sortPeriods, u as splitUrn, _n as urnMatchesIgnoreVersion, Et as weeklyPattern, Ot as yearlyPattern };
|