@epam/statgpt-sdmx-toolkit 0.6.0-rc.3 → 0.6.0-rc.5
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 +2 -2
- package/index.mjs +199 -191
- package/models/structural-metadata/hierarchy.d.ts +6 -0
- package/package.json +3 -3
package/index.mjs
CHANGED
|
@@ -62,23 +62,23 @@ class Va {
|
|
|
62
62
|
this.client = e;
|
|
63
63
|
}
|
|
64
64
|
async getConstraints(e, n, r) {
|
|
65
|
-
const { agency: s, id: a, version: o } = S(e),
|
|
65
|
+
const { agency: s, id: a, version: o } = S(e), c = {
|
|
66
66
|
filters: n || [],
|
|
67
67
|
mode: st.AVAILABLE,
|
|
68
68
|
references: de.NONE
|
|
69
|
-
},
|
|
69
|
+
}, i = St(s, a, o), u = !!this.client.config.sdmxProxyUrl, d = u || this.client.config.isDialProxyMode, l = u ? this.client.config.sdmxProxyUrl : this.client.config.constrainsApiUrl || this.client.config.apiUrl;
|
|
70
70
|
if (d) {
|
|
71
71
|
const m = await this.client.postRequest(
|
|
72
|
-
|
|
73
|
-
{ body:
|
|
72
|
+
i,
|
|
73
|
+
{ body: c },
|
|
74
74
|
l,
|
|
75
75
|
r
|
|
76
76
|
);
|
|
77
77
|
return _t(m);
|
|
78
78
|
}
|
|
79
79
|
return await this.client.postRequest(
|
|
80
|
-
|
|
81
|
-
{ body:
|
|
80
|
+
i,
|
|
81
|
+
{ body: c },
|
|
82
82
|
l,
|
|
83
83
|
r
|
|
84
84
|
);
|
|
@@ -116,8 +116,8 @@ const Wt = (t, e) => {
|
|
|
116
116
|
}, ke = (t, e) => `${t}; labels=${e}`;
|
|
117
117
|
var at = /* @__PURE__ */ ((t) => (t.REFERENCE_PARTIAL = "referencepartial", t.FULL = "full", t))(at || {});
|
|
118
118
|
const Ut = "all", Ft = "sdmx/3.0/data/dataflow", Ht = "&", Ie = ":", Qt = "=", ot = "+", Ga = ",", Bt = "*", Ye = (t, e, n) => {
|
|
119
|
-
const { filterKey: r, timeFilter: s } = n, { agency: a, id: o, version:
|
|
120
|
-
return `${`${Ft}/${a}/${o}/${
|
|
119
|
+
const { filterKey: r, timeFilter: s } = n, { agency: a, id: o, version: c } = S(t), i = [s || "", e].filter((d) => !!d).join(Ht);
|
|
120
|
+
return `${`${Ft}/${a}/${o}/${c}`}/${r || Bt}?${i}`;
|
|
121
121
|
}, Vt = (t = "", e = "", n = "", r = de.DESCENDANTS) => `sdmx/3.0/structure/dataflow/${t}/${e}/${n}?references=${r}&detail=${at.REFERENCE_PARTIAL}`;
|
|
122
122
|
class Xa {
|
|
123
123
|
constructor(e) {
|
|
@@ -145,10 +145,10 @@ class Xa {
|
|
|
145
145
|
r
|
|
146
146
|
);
|
|
147
147
|
}
|
|
148
|
-
async downloadDataSet(e, n, r, s, a, o,
|
|
148
|
+
async downloadDataSet(e, n, r, s, a, o, c = !1, i) {
|
|
149
149
|
const u = new URLSearchParams({
|
|
150
150
|
compress: "false",
|
|
151
|
-
attributes:
|
|
151
|
+
attributes: c ? "all" : "none",
|
|
152
152
|
limit: "1000"
|
|
153
153
|
}).toString(), d = Ye(e, u, a);
|
|
154
154
|
return this.client.streamRequest(
|
|
@@ -161,7 +161,7 @@ class Xa {
|
|
|
161
161
|
}
|
|
162
162
|
},
|
|
163
163
|
o,
|
|
164
|
-
|
|
164
|
+
i,
|
|
165
165
|
qt(n)
|
|
166
166
|
);
|
|
167
167
|
}
|
|
@@ -199,8 +199,8 @@ function ut(t, e) {
|
|
|
199
199
|
s.setFullYear(r + 1, 0, 4), s.setHours(0, 0, 0, 0);
|
|
200
200
|
const a = $(s), o = T(n, 0);
|
|
201
201
|
o.setFullYear(r, 0, 4), o.setHours(0, 0, 0, 0);
|
|
202
|
-
const
|
|
203
|
-
return n.getTime() >= a.getTime() ? r + 1 : n.getTime() >=
|
|
202
|
+
const c = $(o);
|
|
203
|
+
return n.getTime() >= a.getTime() ? r + 1 : n.getTime() >= c.getTime() ? r : r - 1;
|
|
204
204
|
}
|
|
205
205
|
function K(t) {
|
|
206
206
|
const e = y(t), n = new Date(
|
|
@@ -232,8 +232,8 @@ function tn(t, e, n) {
|
|
|
232
232
|
n?.in,
|
|
233
233
|
t,
|
|
234
234
|
e
|
|
235
|
-
), a = $e(r), o = $e(s),
|
|
236
|
-
return Math.round((
|
|
235
|
+
), a = $e(r), o = $e(s), c = +a - K(a), i = +o - K(o);
|
|
236
|
+
return Math.round((c - i) / Kt);
|
|
237
237
|
}
|
|
238
238
|
function nn(t, e) {
|
|
239
239
|
const n = ut(t, e), r = T(t, 0);
|
|
@@ -363,11 +363,11 @@ function F(t) {
|
|
|
363
363
|
const r = n?.context ? String(n.context) : "standalone";
|
|
364
364
|
let s;
|
|
365
365
|
if (r === "formatting" && t.formattingValues) {
|
|
366
|
-
const o = t.defaultFormattingWidth || t.defaultWidth,
|
|
367
|
-
s = t.formattingValues[
|
|
366
|
+
const o = t.defaultFormattingWidth || t.defaultWidth, c = n?.width ? String(n.width) : o;
|
|
367
|
+
s = t.formattingValues[c] || t.formattingValues[o];
|
|
368
368
|
} else {
|
|
369
|
-
const o = t.defaultWidth,
|
|
370
|
-
s = t.values[
|
|
369
|
+
const o = t.defaultWidth, c = n?.width ? String(n.width) : t.defaultWidth;
|
|
370
|
+
s = t.values[c] || t.values[o];
|
|
371
371
|
}
|
|
372
372
|
const a = t.argumentCallback ? t.argumentCallback(e) : e;
|
|
373
373
|
return s[a];
|
|
@@ -529,12 +529,12 @@ function H(t) {
|
|
|
529
529
|
const r = n.width, s = r && t.matchPatterns[r] || t.matchPatterns[t.defaultMatchWidth], a = e.match(s);
|
|
530
530
|
if (!a)
|
|
531
531
|
return null;
|
|
532
|
-
const o = a[0],
|
|
532
|
+
const o = a[0], c = r && t.parsePatterns[r] || t.parsePatterns[t.defaultParseWidth], i = Array.isArray(c) ? xn(c, (l) => l.test(o)) : (
|
|
533
533
|
// [TODO] -- I challenge you to fix the type
|
|
534
|
-
Tn(
|
|
534
|
+
Tn(c, (l) => l.test(o))
|
|
535
535
|
);
|
|
536
536
|
let u;
|
|
537
|
-
u = t.valueCallback ? t.valueCallback(
|
|
537
|
+
u = t.valueCallback ? t.valueCallback(i) : i, u = n.valueCallback ? (
|
|
538
538
|
// [TODO] -- I challenge you to fix the type
|
|
539
539
|
n.valueCallback(u)
|
|
540
540
|
) : u;
|
|
@@ -560,8 +560,8 @@ function Pn(t) {
|
|
|
560
560
|
if (!a) return null;
|
|
561
561
|
let o = t.valueCallback ? t.valueCallback(a[0]) : a[0];
|
|
562
562
|
o = n.valueCallback ? n.valueCallback(o) : o;
|
|
563
|
-
const
|
|
564
|
-
return { value: o, rest:
|
|
563
|
+
const c = e.slice(s.length);
|
|
564
|
+
return { value: o, rest: c };
|
|
565
565
|
};
|
|
566
566
|
}
|
|
567
567
|
const vn = /^(\d+)(th|st|nd|rd)?/i, Mn = /\d+/i, On = {
|
|
@@ -691,10 +691,10 @@ function lt(t, e) {
|
|
|
691
691
|
function me(t, e) {
|
|
692
692
|
const n = y(t, e?.in), r = n.getFullYear(), s = W(), a = e?.firstWeekContainsDate ?? e?.locale?.options?.firstWeekContainsDate ?? s.firstWeekContainsDate ?? s.locale?.options?.firstWeekContainsDate ?? 1, o = T(e?.in || t, 0);
|
|
693
693
|
o.setFullYear(r + 1, 0, a), o.setHours(0, 0, 0, 0);
|
|
694
|
-
const
|
|
695
|
-
|
|
696
|
-
const u = I(
|
|
697
|
-
return +n >= +
|
|
694
|
+
const c = I(o, e), i = T(e?.in || t, 0);
|
|
695
|
+
i.setFullYear(r, 0, a), i.setHours(0, 0, 0, 0);
|
|
696
|
+
const u = I(i, e);
|
|
697
|
+
return +n >= +c ? r + 1 : +n >= +u ? r : r - 1;
|
|
698
698
|
}
|
|
699
699
|
function Wn(t, e) {
|
|
700
700
|
const n = W(), r = e?.firstWeekContainsDate ?? e?.locale?.options?.firstWeekContainsDate ?? n.firstWeekContainsDate ?? n.locale?.options?.firstWeekContainsDate ?? 1, s = me(t, e), a = T(e?.in || t, 0);
|
|
@@ -1361,10 +1361,10 @@ function Qn(t, e, n) {
|
|
|
1361
1361
|
}
|
|
1362
1362
|
const Bn = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g, Vn = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g, Gn = /^'([^]*?)'?$/, Xn = /''/g, jn = /[a-zA-Z]/;
|
|
1363
1363
|
function zn(t, e, n) {
|
|
1364
|
-
const r = W(), s = r.locale ?? dt, a = r.firstWeekContainsDate ?? r.locale?.options?.firstWeekContainsDate ?? 1, o = r.weekStartsOn ?? r.locale?.options?.weekStartsOn ?? 0,
|
|
1365
|
-
if (!ne(
|
|
1364
|
+
const r = W(), s = r.locale ?? dt, a = r.firstWeekContainsDate ?? r.locale?.options?.firstWeekContainsDate ?? 1, o = r.weekStartsOn ?? r.locale?.options?.weekStartsOn ?? 0, c = y(t, n?.in);
|
|
1365
|
+
if (!ne(c))
|
|
1366
1366
|
throw new RangeError("Invalid time value");
|
|
1367
|
-
let
|
|
1367
|
+
let i = e.match(Vn).map((d) => {
|
|
1368
1368
|
const l = d[0];
|
|
1369
1369
|
if (l === "p" || l === "P") {
|
|
1370
1370
|
const m = re[l];
|
|
@@ -1385,18 +1385,18 @@ function zn(t, e, n) {
|
|
|
1385
1385
|
);
|
|
1386
1386
|
return { isToken: !1, value: d };
|
|
1387
1387
|
});
|
|
1388
|
-
s.localize.preprocessor && (
|
|
1388
|
+
s.localize.preprocessor && (i = s.localize.preprocessor(c, i));
|
|
1389
1389
|
const u = {
|
|
1390
1390
|
firstWeekContainsDate: a,
|
|
1391
1391
|
weekStartsOn: o,
|
|
1392
1392
|
locale: s
|
|
1393
1393
|
};
|
|
1394
|
-
return
|
|
1394
|
+
return i.map((d) => {
|
|
1395
1395
|
if (!d.isToken) return d.value;
|
|
1396
1396
|
const l = d.value;
|
|
1397
1397
|
(wt(l) || ht(l)) && se(l, e, String(t));
|
|
1398
1398
|
const m = We[l[0]];
|
|
1399
|
-
return m(
|
|
1399
|
+
return m(c, l, s.localize, u);
|
|
1400
1400
|
}).join("");
|
|
1401
1401
|
}
|
|
1402
1402
|
function Kn(t) {
|
|
@@ -1613,8 +1613,8 @@ function yt(t, e) {
|
|
|
1613
1613
|
if (r <= 50)
|
|
1614
1614
|
s = t || 100;
|
|
1615
1615
|
else {
|
|
1616
|
-
const a = r + 50, o = Math.trunc(a / 100) * 100,
|
|
1617
|
-
s = t + o - (
|
|
1616
|
+
const a = r + 50, o = Math.trunc(a / 100) * 100, c = t >= a % 100;
|
|
1617
|
+
s = t + o - (c ? 100 : 0);
|
|
1618
1618
|
}
|
|
1619
1619
|
return n ? s : 1 - s;
|
|
1620
1620
|
}
|
|
@@ -1686,12 +1686,12 @@ class ir extends h {
|
|
|
1686
1686
|
set(e, n, r, s) {
|
|
1687
1687
|
const a = me(e, s);
|
|
1688
1688
|
if (r.isTwoDigitYear) {
|
|
1689
|
-
const
|
|
1689
|
+
const c = yt(
|
|
1690
1690
|
r.year,
|
|
1691
1691
|
a
|
|
1692
1692
|
);
|
|
1693
1693
|
return e.setFullYear(
|
|
1694
|
-
|
|
1694
|
+
c,
|
|
1695
1695
|
0,
|
|
1696
1696
|
s.firstWeekContainsDate
|
|
1697
1697
|
), e.setHours(0, 0, 0, 0), I(e, s);
|
|
@@ -2168,7 +2168,7 @@ class Er extends h {
|
|
|
2168
2168
|
];
|
|
2169
2169
|
}
|
|
2170
2170
|
function we(t, e, n) {
|
|
2171
|
-
const r = W(), s = n?.weekStartsOn ?? n?.locale?.options?.weekStartsOn ?? r.weekStartsOn ?? r.locale?.options?.weekStartsOn ?? 0, a = y(t, n?.in), o = a.getDay(),
|
|
2171
|
+
const r = W(), s = n?.weekStartsOn ?? n?.locale?.options?.weekStartsOn ?? r.weekStartsOn ?? r.locale?.options?.weekStartsOn ?? 0, a = y(t, n?.in), o = a.getDay(), i = (e % 7 + 7) % 7, u = 7 - s, d = e < 0 || e > 6 ? e - (o + u) % 7 : (i + u) % 7 - (o + u) % 7;
|
|
2172
2172
|
return ct(a, d, n);
|
|
2173
2173
|
}
|
|
2174
2174
|
class Tr extends h {
|
|
@@ -2211,8 +2211,8 @@ class xr extends h {
|
|
|
2211
2211
|
priority = 90;
|
|
2212
2212
|
parse(e, n, r, s) {
|
|
2213
2213
|
const a = (o) => {
|
|
2214
|
-
const
|
|
2215
|
-
return (o + s.weekStartsOn + 6) % 7 +
|
|
2214
|
+
const c = Math.floor((o - 1) / 7) * 7;
|
|
2215
|
+
return (o + s.weekStartsOn + 6) % 7 + c;
|
|
2216
2216
|
};
|
|
2217
2217
|
switch (n) {
|
|
2218
2218
|
// 3
|
|
@@ -2277,8 +2277,8 @@ class Pr extends h {
|
|
|
2277
2277
|
priority = 90;
|
|
2278
2278
|
parse(e, n, r, s) {
|
|
2279
2279
|
const a = (o) => {
|
|
2280
|
-
const
|
|
2281
|
-
return (o + s.weekStartsOn + 6) % 7 +
|
|
2280
|
+
const c = Math.floor((o - 1) / 7) * 7;
|
|
2281
|
+
return (o + s.weekStartsOn + 6) % 7 + c;
|
|
2282
2282
|
};
|
|
2283
2283
|
switch (n) {
|
|
2284
2284
|
// 3
|
|
@@ -2798,12 +2798,12 @@ const Ur = {
|
|
|
2798
2798
|
T: new qr()
|
|
2799
2799
|
}, Fr = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g, Hr = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g, Qr = /^'([^]*?)'?$/, Br = /''/g, Vr = /\S/, Gr = /[a-zA-Z]/;
|
|
2800
2800
|
function Xr(t, e, n, r) {
|
|
2801
|
-
const s = () => T(n, NaN), a = Jn(), o = a.locale ?? dt,
|
|
2801
|
+
const s = () => T(n, NaN), a = Jn(), o = a.locale ?? dt, c = a.firstWeekContainsDate ?? a.locale?.options?.firstWeekContainsDate ?? 1, i = a.weekStartsOn ?? a.locale?.options?.weekStartsOn ?? 0;
|
|
2802
2802
|
if (!e)
|
|
2803
2803
|
return t ? s() : y(n, r?.in);
|
|
2804
2804
|
const u = {
|
|
2805
|
-
firstWeekContainsDate:
|
|
2806
|
-
weekStartsOn:
|
|
2805
|
+
firstWeekContainsDate: c,
|
|
2806
|
+
weekStartsOn: i,
|
|
2807
2807
|
locale: o
|
|
2808
2808
|
}, d = [new sr(r?.in, n)], l = e.match(Hr).map((f) => {
|
|
2809
2809
|
const g = f[0];
|
|
@@ -2879,13 +2879,13 @@ function zr(t, e) {
|
|
|
2879
2879
|
}
|
|
2880
2880
|
if (!a || isNaN(+a)) return n();
|
|
2881
2881
|
const o = +a;
|
|
2882
|
-
let
|
|
2883
|
-
if (s.time && (
|
|
2882
|
+
let c = 0, i;
|
|
2883
|
+
if (s.time && (c = rs(s.time), isNaN(c)))
|
|
2884
2884
|
return n();
|
|
2885
2885
|
if (s.timezone) {
|
|
2886
|
-
if (
|
|
2886
|
+
if (i = ss(s.timezone), isNaN(i)) return n();
|
|
2887
2887
|
} else {
|
|
2888
|
-
const u = new Date(o +
|
|
2888
|
+
const u = new Date(o + c), d = y(0, e?.in);
|
|
2889
2889
|
return d.setFullYear(
|
|
2890
2890
|
u.getUTCFullYear(),
|
|
2891
2891
|
u.getUTCMonth(),
|
|
@@ -2897,7 +2897,7 @@ function zr(t, e) {
|
|
|
2897
2897
|
u.getUTCMilliseconds()
|
|
2898
2898
|
), d;
|
|
2899
2899
|
}
|
|
2900
|
-
return y(o +
|
|
2900
|
+
return y(o + c + i, e?.in);
|
|
2901
2901
|
}
|
|
2902
2902
|
const V = {
|
|
2903
2903
|
dateTimeDelimiter: /[T ]/,
|
|
@@ -2933,9 +2933,9 @@ function ns(t, e) {
|
|
|
2933
2933
|
if (e === null) return /* @__PURE__ */ new Date(NaN);
|
|
2934
2934
|
const n = t.match(Kr);
|
|
2935
2935
|
if (!n) return /* @__PURE__ */ new Date(NaN);
|
|
2936
|
-
const r = !!n[4], s = Q(n[1]), a = Q(n[2]) - 1, o = Q(n[3]),
|
|
2936
|
+
const r = !!n[4], s = Q(n[1]), a = Q(n[2]) - 1, o = Q(n[3]), c = Q(n[4]), i = Q(n[5]) - 1;
|
|
2937
2937
|
if (r)
|
|
2938
|
-
return us(e,
|
|
2938
|
+
return us(e, c, i) ? as(e, c, i) : /* @__PURE__ */ new Date(NaN);
|
|
2939
2939
|
{
|
|
2940
2940
|
const u = /* @__PURE__ */ new Date(0);
|
|
2941
2941
|
return !is(e, a, o) || !cs(e, s) ? /* @__PURE__ */ new Date(NaN) : (u.setUTCFullYear(e, a, Math.max(s, o)), u);
|
|
@@ -3020,15 +3020,15 @@ class ws {
|
|
|
3020
3020
|
this.decoder = new TextDecoder();
|
|
3021
3021
|
}
|
|
3022
3022
|
async streamChat(e, n, r = {}, s) {
|
|
3023
|
-
const { onMessage: a, onError: o, onComplete:
|
|
3023
|
+
const { onMessage: a, onError: o, onComplete: c, signal: i } = r;
|
|
3024
3024
|
try {
|
|
3025
3025
|
const u = await this.initializeStreamRequest(
|
|
3026
3026
|
e,
|
|
3027
3027
|
n,
|
|
3028
|
-
|
|
3028
|
+
i,
|
|
3029
3029
|
s
|
|
3030
3030
|
);
|
|
3031
|
-
await this.processStreamData(u, a),
|
|
3031
|
+
await this.processStreamData(u, a), c?.();
|
|
3032
3032
|
} catch (u) {
|
|
3033
3033
|
this.handleStreamError(u, o);
|
|
3034
3034
|
}
|
|
@@ -3049,16 +3049,16 @@ class ws {
|
|
|
3049
3049
|
}
|
|
3050
3050
|
);
|
|
3051
3051
|
if (!o.ok) {
|
|
3052
|
-
const
|
|
3053
|
-
let
|
|
3052
|
+
const c = await o.text();
|
|
3053
|
+
let i = {};
|
|
3054
3054
|
try {
|
|
3055
|
-
|
|
3055
|
+
i = JSON.parse(c);
|
|
3056
3056
|
} catch {
|
|
3057
|
-
|
|
3057
|
+
i.error = "Failed to parse error body";
|
|
3058
3058
|
}
|
|
3059
3059
|
throw new Se({
|
|
3060
3060
|
status: o.status,
|
|
3061
|
-
message:
|
|
3061
|
+
message: i.error ?? "No response body"
|
|
3062
3062
|
});
|
|
3063
3063
|
}
|
|
3064
3064
|
if (!o.body)
|
|
@@ -3079,11 +3079,11 @@ class ws {
|
|
|
3079
3079
|
}
|
|
3080
3080
|
const o = this.decoder.decode(a, { stream: !0 });
|
|
3081
3081
|
r += o;
|
|
3082
|
-
const
|
|
3082
|
+
const c = r.split(`
|
|
3083
3083
|
`);
|
|
3084
|
-
r =
|
|
3085
|
-
for (const
|
|
3086
|
-
this.parseSSEDataLine(
|
|
3084
|
+
r = c.pop() || "";
|
|
3085
|
+
for (const i of c)
|
|
3086
|
+
this.parseSSEDataLine(i, n);
|
|
3087
3087
|
}
|
|
3088
3088
|
} finally {
|
|
3089
3089
|
e.releaseLock();
|
|
@@ -3135,10 +3135,10 @@ class ja {
|
|
|
3135
3135
|
);
|
|
3136
3136
|
}
|
|
3137
3137
|
async streamRequest(e, n, r, s, a) {
|
|
3138
|
-
const o = `${this.config.apiUrl}/${e}`,
|
|
3138
|
+
const o = `${this.config.apiUrl}/${e}`, c = this.buildHeaders(s, n.headers), i = new ReadableStream({
|
|
3139
3139
|
async start(d) {
|
|
3140
3140
|
try {
|
|
3141
|
-
const l = await He(o,
|
|
3141
|
+
const l = await He(o, c, n);
|
|
3142
3142
|
if (!l.ok) {
|
|
3143
3143
|
const M = await l.text();
|
|
3144
3144
|
throw console.error(
|
|
@@ -3162,44 +3162,44 @@ class ja {
|
|
|
3162
3162
|
"Content-Disposition": `attachment; filename=${encodeURIComponent(r)}`,
|
|
3163
3163
|
...a ? { "Content-Type": a } : {}
|
|
3164
3164
|
});
|
|
3165
|
-
return new Response(
|
|
3165
|
+
return new Response(i, { headers: u });
|
|
3166
3166
|
}
|
|
3167
3167
|
async request(e, n, r, s) {
|
|
3168
|
-
const a = Date.now(), o = `${r || this.config.apiUrl}/${e}`,
|
|
3169
|
-
this.addInfoRequestLog("API Request", o, n,
|
|
3168
|
+
const a = Date.now(), o = `${r || this.config.apiUrl}/${e}`, c = this.buildHeaders(s, n.headers);
|
|
3169
|
+
this.addInfoRequestLog("API Request", o, n, c);
|
|
3170
3170
|
try {
|
|
3171
|
-
const
|
|
3171
|
+
const i = await He(o, c, n), u = Date.now() - a;
|
|
3172
3172
|
let d;
|
|
3173
|
-
const l = await
|
|
3173
|
+
const l = await i.text();
|
|
3174
3174
|
try {
|
|
3175
3175
|
d = l ? JSON.parse(l) : {};
|
|
3176
3176
|
} catch {
|
|
3177
3177
|
if (this.addErrorRequestParsing(
|
|
3178
3178
|
o,
|
|
3179
3179
|
n,
|
|
3180
|
-
|
|
3180
|
+
i,
|
|
3181
3181
|
u,
|
|
3182
3182
|
l
|
|
3183
|
-
), !
|
|
3183
|
+
), !i.ok)
|
|
3184
3184
|
throw new Error(
|
|
3185
|
-
`API request failed: ${
|
|
3185
|
+
`API request failed: ${i.status} ${i.statusText} - ${l.substring(0, 100)}`
|
|
3186
3186
|
);
|
|
3187
3187
|
d = { data: l };
|
|
3188
3188
|
}
|
|
3189
|
-
if (!
|
|
3190
|
-
this.addErrorRequestLog(o, n,
|
|
3191
|
-
const m = Gt(d,
|
|
3189
|
+
if (!i.ok) {
|
|
3190
|
+
this.addErrorRequestLog(o, n, i, u, d);
|
|
3191
|
+
const m = Gt(d, i);
|
|
3192
3192
|
throw new Error(`API request failed: ${m}`);
|
|
3193
3193
|
}
|
|
3194
3194
|
return d;
|
|
3195
|
-
} catch (
|
|
3195
|
+
} catch (i) {
|
|
3196
3196
|
const u = Date.now() - a;
|
|
3197
3197
|
throw console.error("API Request Exception", {
|
|
3198
3198
|
method: n.method,
|
|
3199
3199
|
url: o,
|
|
3200
3200
|
duration: `${u}ms`,
|
|
3201
|
-
error:
|
|
3202
|
-
}),
|
|
3201
|
+
error: i instanceof Error ? i.message : String(i)
|
|
3202
|
+
}), i;
|
|
3203
3203
|
}
|
|
3204
3204
|
}
|
|
3205
3205
|
buildHeaders(e, n) {
|
|
@@ -3274,34 +3274,34 @@ const Ka = ["FREQ", "FREQUENCY"], Ds = "TIME_PERIOD", Es = "time_period_start",
|
|
|
3274
3274
|
endPeriod: r
|
|
3275
3275
|
};
|
|
3276
3276
|
}, xs = (t, e) => t.id.localeCompare(e.id), Ps = (t, e) => t.memberValue.localeCompare(e.memberValue), vs = (t, e) => {
|
|
3277
|
-
const n = new Array(t.length), r = t.map((o,
|
|
3277
|
+
const n = new Array(t.length), r = t.map((o, c) => [o, c]);
|
|
3278
3278
|
r.sort(
|
|
3279
|
-
(o,
|
|
3279
|
+
(o, c) => xs(o[0], c[0])
|
|
3280
3280
|
);
|
|
3281
3281
|
const s = [...e];
|
|
3282
3282
|
s.sort(Ps);
|
|
3283
3283
|
let a = 0;
|
|
3284
3284
|
for (const o of r) {
|
|
3285
|
-
const
|
|
3286
|
-
for (; a < s.length && s[a].memberValue.localeCompare(
|
|
3285
|
+
const c = o[0];
|
|
3286
|
+
for (; a < s.length && s[a].memberValue.localeCompare(c.id) < 0; )
|
|
3287
3287
|
a += 1;
|
|
3288
|
-
a < s.length && s[a].memberValue ===
|
|
3288
|
+
a < s.length && s[a].memberValue === c.id && (n[o[1]] = o[0]);
|
|
3289
3289
|
}
|
|
3290
3290
|
return n.filter((o) => o != null);
|
|
3291
3291
|
}, Ms = (t) => !!t?.some((e) => e.parent), Za = (t, e, n, r, s = []) => {
|
|
3292
3292
|
let a = t || [];
|
|
3293
3293
|
if (Os(n || [], e || "")) {
|
|
3294
3294
|
const o = (n || [])[0].cubeRegions?.find(
|
|
3295
|
-
({ isIncluded:
|
|
3295
|
+
({ isIncluded: c }) => c
|
|
3296
3296
|
);
|
|
3297
3297
|
if (o) {
|
|
3298
|
-
const
|
|
3299
|
-
({ componentId:
|
|
3298
|
+
const c = o.memberSelection?.find(
|
|
3299
|
+
({ componentId: i }) => i === e
|
|
3300
3300
|
);
|
|
3301
|
-
|
|
3302
|
-
id:
|
|
3303
|
-
name:
|
|
3304
|
-
})) : vs(a,
|
|
3301
|
+
c ? a = a.length === 0 ? (c.selectionValues || []).map(({ memberValue: i }) => ({
|
|
3302
|
+
id: i,
|
|
3303
|
+
name: i
|
|
3304
|
+
})) : vs(a, c.selectionValues) : a = [];
|
|
3305
3305
|
}
|
|
3306
3306
|
} else s.length !== 0 && (a = a.filter(({ id: o }) => s.includes(o)));
|
|
3307
3307
|
return Ms(t) && (a = gs(t, a)), a?.map((o) => ({
|
|
@@ -3363,17 +3363,17 @@ const Ka = ["FREQ", "FREQUENCY"], Ds = "TIME_PERIOD", Es = "time_period_start",
|
|
|
3363
3363
|
throw new Error(`Invalid operator, expected one of ${Xe.join("|")}`);
|
|
3364
3364
|
}, oe = "+", ye = (t, e) => {
|
|
3365
3365
|
const { agency: n, id: r, version: s } = S(t), a = e.filter(
|
|
3366
|
-
(
|
|
3366
|
+
(i) => i.agencyID === n && i.id === r && !i?.version?.includes(oe)
|
|
3367
3367
|
);
|
|
3368
3368
|
if (a.length === 1)
|
|
3369
3369
|
return a[0];
|
|
3370
3370
|
if (!s?.includes(oe))
|
|
3371
|
-
return a.find((
|
|
3371
|
+
return a.find((i) => i.version === s);
|
|
3372
3372
|
const o = a.map(
|
|
3373
|
-
(
|
|
3374
|
-
),
|
|
3373
|
+
(i) => i.version
|
|
3374
|
+
), c = Cs(s, o);
|
|
3375
3375
|
return a.find(
|
|
3376
|
-
(
|
|
3376
|
+
(i) => i.version === c[0]
|
|
3377
3377
|
);
|
|
3378
3378
|
}, Cs = (t, e) => {
|
|
3379
3379
|
const n = Ss(t, e);
|
|
@@ -3428,18 +3428,18 @@ const Ka = ["FREQ", "FREQUENCY"], Ds = "TIME_PERIOD", Es = "time_period_start",
|
|
|
3428
3428
|
n?.localRepresentation?.enumeration
|
|
3429
3429
|
), o = z(
|
|
3430
3430
|
s?.coreRepresentation?.enumeration
|
|
3431
|
-
),
|
|
3432
|
-
if (
|
|
3433
|
-
return ye(
|
|
3431
|
+
), c = a || o;
|
|
3432
|
+
if (c != null)
|
|
3433
|
+
return ye(c, t);
|
|
3434
3434
|
}, Us = (t, e) => {
|
|
3435
3435
|
const n = t?.data?.dataSets?.[0], s = t?.data?.structures?.[0]?.attributes?.dimensionGroup || [], a = n?.dimensionGroupAttributes, o = {};
|
|
3436
|
-
for (const
|
|
3437
|
-
const
|
|
3436
|
+
for (const c of s) {
|
|
3437
|
+
const i = c.relationship.dimensions, { codedSeriesKey: u, decodedSeriesKey: d } = xt(
|
|
3438
3438
|
t,
|
|
3439
3439
|
e,
|
|
3440
|
-
|
|
3440
|
+
i
|
|
3441
3441
|
);
|
|
3442
|
-
o[
|
|
3442
|
+
o[c.id] = {
|
|
3443
3443
|
values: a?.[u] || [],
|
|
3444
3444
|
decodedSeriesKey: d,
|
|
3445
3445
|
codedSeriesKey: u
|
|
@@ -3451,11 +3451,11 @@ const Ka = ["FREQ", "FREQUENCY"], Ds = "TIME_PERIOD", Es = "time_period_start",
|
|
|
3451
3451
|
...r?.dimensions.series || [],
|
|
3452
3452
|
...r?.dimensions.observation || []
|
|
3453
3453
|
], a = new Array(s?.length), o = new Array(s?.length);
|
|
3454
|
-
return n?.forEach((
|
|
3455
|
-
const
|
|
3454
|
+
return n?.forEach((c) => {
|
|
3455
|
+
const i = s?.findIndex((l) => l.id === c) || 0, u = e[i], d = s[i].values.findIndex(
|
|
3456
3456
|
(l) => l.id === u || l.value === u
|
|
3457
3457
|
) || 0;
|
|
3458
|
-
a[
|
|
3458
|
+
a[i] = d >= 0 ? d : u, o[i] = u;
|
|
3459
3459
|
}), {
|
|
3460
3460
|
codedSeriesKey: a.join(":"),
|
|
3461
3461
|
decodedSeriesKey: o.join(":")
|
|
@@ -3463,11 +3463,11 @@ const Ka = ["FREQ", "FREQUENCY"], Ds = "TIME_PERIOD", Es = "time_period_start",
|
|
|
3463
3463
|
}, no = (t, e, n) => {
|
|
3464
3464
|
const r = t?.data?.dataSets?.[0], s = t?.data?.structures?.[0], a = (s?.attributes?.dimensionGroup || []).filter(
|
|
3465
3465
|
(l) => l.relationship.dimensions?.length === 1 && l.relationship.dimensions.includes(e || "")
|
|
3466
|
-
), o = r?.dimensionGroupAttributes,
|
|
3466
|
+
), o = r?.dimensionGroupAttributes, c = [
|
|
3467
3467
|
...s?.dimensions.series || [],
|
|
3468
3468
|
...s?.dimensions.observation || []
|
|
3469
|
-
],
|
|
3470
|
-
u[
|
|
3469
|
+
], i = c?.findIndex((l) => l.id === e), u = new Array(c?.length);
|
|
3470
|
+
u[i] = n || "";
|
|
3471
3471
|
const d = {};
|
|
3472
3472
|
for (const l of a) {
|
|
3473
3473
|
const m = l.relationship.dimensions, { codedSeriesKey: v, decodedSeriesKey: x } = xt(
|
|
@@ -3503,6 +3503,7 @@ const Ka = ["FREQ", "FREQUENCY"], Ds = "TIME_PERIOD", Es = "time_period_start",
|
|
|
3503
3503
|
);
|
|
3504
3504
|
return {
|
|
3505
3505
|
...a,
|
|
3506
|
+
id: a?.id ?? s.metadataAttributeReference,
|
|
3506
3507
|
attributeRelationship: s.attributeRelationship,
|
|
3507
3508
|
isMandatory: Number(a?.minOccurs) > 0
|
|
3508
3509
|
};
|
|
@@ -3528,31 +3529,38 @@ function io(t) {
|
|
|
3528
3529
|
}
|
|
3529
3530
|
const co = (t) => {
|
|
3530
3531
|
const e = /* @__PURE__ */ new Map(), n = t?.dataStructures?.[0], r = t?.metadataStructures?.[0], s = t?.conceptSchemes || [], a = t?.codelists || [];
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
id
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3532
|
+
if (t) {
|
|
3533
|
+
const o = Hs(
|
|
3534
|
+
r,
|
|
3535
|
+
n
|
|
3536
|
+
);
|
|
3537
|
+
[
|
|
3538
|
+
...ze(t)?.dimensions || [],
|
|
3539
|
+
...ze(t)?.timeDimensions || [],
|
|
3540
|
+
...o,
|
|
3541
|
+
...n?.dataStructureComponents?.attributeList?.attributes || []
|
|
3542
|
+
].forEach(
|
|
3543
|
+
(i) => {
|
|
3544
|
+
const u = be(
|
|
3545
|
+
i?.conceptIdentity,
|
|
3546
|
+
s
|
|
3547
|
+
), d = i?.localRepresentation?.enumeration || u?.coreRepresentation?.enumeration, l = ye(
|
|
3548
|
+
d,
|
|
3549
|
+
a
|
|
3550
|
+
);
|
|
3551
|
+
i?.id && (d ? e.set(i?.id, {
|
|
3552
|
+
...l,
|
|
3553
|
+
name: u?.name,
|
|
3554
|
+
names: u?.names
|
|
3555
|
+
}) : e.set(i?.id, {
|
|
3556
|
+
id: i?.id,
|
|
3557
|
+
name: u?.name,
|
|
3558
|
+
names: u?.names
|
|
3559
|
+
}));
|
|
3560
|
+
}
|
|
3561
|
+
);
|
|
3562
|
+
}
|
|
3563
|
+
return e;
|
|
3556
3564
|
}, uo = (t) => t?.find(
|
|
3557
3565
|
(e) => e.id === ge.SERIES_COUNT
|
|
3558
3566
|
)?.title || "", Ee = 1440 * 60 * 1e3, Te = 7 * Ee;
|
|
@@ -3597,8 +3605,8 @@ function Xs(t) {
|
|
|
3597
3605
|
return new Date(s);
|
|
3598
3606
|
}
|
|
3599
3607
|
const Je = "/api/download", js = 6e4, zs = /[\x00-\x1F\x7F<>:"/\\|?*]/g, vt = (t) => t.normalize("NFKC").replace(zs, "_").replace(/_+/g, "_").replace(/\s+/g, " ").replace(/^[._ ]+/, "").trim() || "download", Ks = (t, e, n, r, s, a, o) => {
|
|
3600
|
-
const
|
|
3601
|
-
if (
|
|
3608
|
+
const c = new URL(Je, window.location.origin);
|
|
3609
|
+
if (c.search = new URLSearchParams({
|
|
3602
3610
|
urn: t,
|
|
3603
3611
|
format: e,
|
|
3604
3612
|
compress: "false",
|
|
@@ -3607,28 +3615,28 @@ const Je = "/api/download", js = 6e4, zs = /[\x00-\x1F\x7F<>:"/\\|?*]/g, vt = (t
|
|
|
3607
3615
|
attribute: r,
|
|
3608
3616
|
language: n,
|
|
3609
3617
|
isMetadata: o ? "true" : "none"
|
|
3610
|
-
}).toString(),
|
|
3618
|
+
}).toString(), c.origin !== window.location.origin || c.pathname !== Je)
|
|
3611
3619
|
throw new Error("Invalid download URL");
|
|
3612
|
-
return
|
|
3620
|
+
return c.toString();
|
|
3613
3621
|
}, Js = (t, e) => {
|
|
3614
3622
|
const n = URL.createObjectURL(t), r = document.createElement("a");
|
|
3615
3623
|
r.href = n, r.download = vt(e), r.rel = "noopener noreferrer", r.click(), window.setTimeout(
|
|
3616
3624
|
() => URL.revokeObjectURL(n),
|
|
3617
3625
|
js
|
|
3618
3626
|
);
|
|
3619
|
-
}, lo = async (t, e, n, r, s, a, o,
|
|
3620
|
-
const
|
|
3627
|
+
}, lo = async (t, e, n, r, s, a, o, c) => {
|
|
3628
|
+
const i = vt(a), u = Ks(
|
|
3621
3629
|
t,
|
|
3622
3630
|
e,
|
|
3623
3631
|
n,
|
|
3624
3632
|
r,
|
|
3625
3633
|
s,
|
|
3626
|
-
|
|
3634
|
+
i,
|
|
3627
3635
|
o
|
|
3628
3636
|
), d = await fetch(u, {
|
|
3629
3637
|
method: "GET",
|
|
3630
3638
|
credentials: "same-origin",
|
|
3631
|
-
signal:
|
|
3639
|
+
signal: c
|
|
3632
3640
|
});
|
|
3633
3641
|
if (!d.ok) {
|
|
3634
3642
|
const m = await d.text();
|
|
@@ -3637,7 +3645,7 @@ const Je = "/api/download", js = 6e4, zs = /[\x00-\x1F\x7F<>:"/\\|?*]/g, vt = (t
|
|
|
3637
3645
|
);
|
|
3638
3646
|
}
|
|
3639
3647
|
const l = await d.blob();
|
|
3640
|
-
|
|
3648
|
+
c?.aborted || Js(l, i);
|
|
3641
3649
|
}, fo = (t, e) => {
|
|
3642
3650
|
const n = [];
|
|
3643
3651
|
for (const r of t) {
|
|
@@ -3664,11 +3672,11 @@ const Je = "/api/download", js = 6e4, zs = /[\x00-\x1F\x7F<>:"/\\|?*]/g, vt = (t
|
|
|
3664
3672
|
return n ? Zs(n, e?.id) : null;
|
|
3665
3673
|
}, ea = (t, e) => {
|
|
3666
3674
|
const n = e.id, r = t?.filters?.find(
|
|
3667
|
-
(
|
|
3675
|
+
(i) => i.componentCode === n
|
|
3668
3676
|
);
|
|
3669
3677
|
if (!r || !r.values)
|
|
3670
3678
|
return null;
|
|
3671
|
-
const s = r.values?.filter((
|
|
3679
|
+
const s = r.values?.filter((i) => !!i);
|
|
3672
3680
|
if (!s.length)
|
|
3673
3681
|
return null;
|
|
3674
3682
|
const a = r.operator;
|
|
@@ -3676,20 +3684,20 @@ const Je = "/api/download", js = 6e4, zs = /[\x00-\x1F\x7F<>:"/\\|?*]/g, vt = (t
|
|
|
3676
3684
|
return { startPeriod: null, endPeriod: G(s[0]) };
|
|
3677
3685
|
if (a === _.GREATER_OR_EQUAL || a === _.GREATER)
|
|
3678
3686
|
return { startPeriod: G(s[0]), endPeriod: null };
|
|
3679
|
-
const o = G(s[0]),
|
|
3680
|
-
return { startPeriod: o, endPeriod:
|
|
3687
|
+
const o = G(s[0]), c = G(s[1]);
|
|
3688
|
+
return { startPeriod: o, endPeriod: c };
|
|
3681
3689
|
}, ta = "Observation", ho = (t) => {
|
|
3682
3690
|
const e = t?.data?.dataSets, n = t?.data?.structures?.[0];
|
|
3683
3691
|
if (!e || !n)
|
|
3684
3692
|
return [];
|
|
3685
|
-
const r = n.attributes, s = n.dimensions, a = r?.dimensionGroup || [], o = e[0].series || e[0].observations,
|
|
3693
|
+
const r = n.attributes, s = n.dimensions, a = r?.dimensionGroup || [], o = e[0].series || e[0].observations, c = s.series?.length ? s.series : s.observation, i = [];
|
|
3686
3694
|
for (const u in o) {
|
|
3687
3695
|
const d = [], { name: l, parsedTimeSeriesValue: m } = na(
|
|
3688
3696
|
u,
|
|
3689
|
-
|
|
3697
|
+
c
|
|
3690
3698
|
), v = o[u], x = v.attributes || [];
|
|
3691
3699
|
if (Object.keys(v).length === 0) {
|
|
3692
|
-
|
|
3700
|
+
i.push({
|
|
3693
3701
|
name: l,
|
|
3694
3702
|
parsedTimeSeriesValue: m,
|
|
3695
3703
|
values: d,
|
|
@@ -3721,7 +3729,7 @@ const Je = "/api/download", js = 6e4, zs = /[\x00-\x1F\x7F<>:"/\\|?*]/g, vt = (t
|
|
|
3721
3729
|
dimensionGroupData: U
|
|
3722
3730
|
};
|
|
3723
3731
|
});
|
|
3724
|
-
|
|
3732
|
+
i.push({
|
|
3725
3733
|
name: l,
|
|
3726
3734
|
parsedTimeSeriesValue: m,
|
|
3727
3735
|
values: d,
|
|
@@ -3730,19 +3738,19 @@ const Je = "/api/download", js = 6e4, zs = /[\x00-\x1F\x7F<>:"/\\|?*]/g, vt = (t
|
|
|
3730
3738
|
dimensionGroupAttributes: P
|
|
3731
3739
|
});
|
|
3732
3740
|
}
|
|
3733
|
-
return
|
|
3741
|
+
return i;
|
|
3734
3742
|
}, na = (t, e) => {
|
|
3735
3743
|
const n = t.split(new RegExp("(?<!\\|):(?!\\||$)")), r = [];
|
|
3736
3744
|
for (let s = 0; s < n.length; s++) {
|
|
3737
3745
|
const a = e?.[s], o = Number(n[s]);
|
|
3738
3746
|
if (o < 0 || a == null)
|
|
3739
3747
|
continue;
|
|
3740
|
-
const
|
|
3741
|
-
if (
|
|
3748
|
+
const c = a.values[o];
|
|
3749
|
+
if (c == null) {
|
|
3742
3750
|
r.push(n[s].replace("|:", ":"));
|
|
3743
3751
|
continue;
|
|
3744
3752
|
}
|
|
3745
|
-
r.push(
|
|
3753
|
+
r.push(c?.id || c?.value || "");
|
|
3746
3754
|
}
|
|
3747
3755
|
return {
|
|
3748
3756
|
name: sa(r),
|
|
@@ -3776,16 +3784,16 @@ const Je = "/api/download", js = 6e4, zs = /[\x00-\x1F\x7F<>:"/\\|?*]/g, vt = (t
|
|
|
3776
3784
|
];
|
|
3777
3785
|
const r = t.observations, s = e.dimensions.observation?.[0], a = [];
|
|
3778
3786
|
for (const o in r) {
|
|
3779
|
-
const
|
|
3787
|
+
const c = s?.values[o];
|
|
3780
3788
|
a.push({
|
|
3781
|
-
dimensionAtObservation:
|
|
3789
|
+
dimensionAtObservation: c?.value || c?.id,
|
|
3782
3790
|
values: et(
|
|
3783
3791
|
r[o],
|
|
3784
3792
|
e.measures
|
|
3785
3793
|
),
|
|
3786
3794
|
obsAttributes: ie(
|
|
3787
3795
|
e.attributes?.observation || [],
|
|
3788
|
-
(
|
|
3796
|
+
(i) => r[o][i + n]
|
|
3789
3797
|
)
|
|
3790
3798
|
});
|
|
3791
3799
|
}
|
|
@@ -3887,9 +3895,9 @@ const Oa = (t) => /* @__PURE__ */ new Date(`${t}T00:00:00`), Aa = (t) => {
|
|
|
3887
3895
|
const e = /* @__PURE__ */ new Date(`${t}T23:59:00`);
|
|
3888
3896
|
return e.setMinutes(e.getMinutes() + 1), e;
|
|
3889
3897
|
}, Na = 1, Ra = (t, e, n, r = !0, s = "Q") => {
|
|
3890
|
-
const a = [], o = e && e > 3 ? La(e, r) : 1,
|
|
3891
|
-
for (let
|
|
3892
|
-
a.push(`${t}-${s}${
|
|
3898
|
+
const a = [], o = e && e > 3 ? La(e, r) : 1, c = n ? Math.floor((n - 1) / 3) : 4;
|
|
3899
|
+
for (let i = o; i <= c; i++)
|
|
3900
|
+
a.push(`${t}-${s}${i}`);
|
|
3893
3901
|
return a;
|
|
3894
3902
|
}, _a = (t, e, n, r = "S") => {
|
|
3895
3903
|
const s = [];
|
|
@@ -3938,7 +3946,7 @@ const Oa = (t) => /* @__PURE__ */ new Date(`${t}T00:00:00`), Aa = (t) => {
|
|
|
3938
3946
|
}
|
|
3939
3947
|
}, Ca = (t, e) => {
|
|
3940
3948
|
const n = k(e, !0), r = k(t), s = n.getFullYear(), a = r.getFullYear(), o = n.getTime() <= r.getTime() ? a + Na - s : 0;
|
|
3941
|
-
return Array.from({ length: o }, (
|
|
3949
|
+
return Array.from({ length: o }, (i, u) => s + u);
|
|
3942
3950
|
}, k = (t, e = !1) => {
|
|
3943
3951
|
const n = Sa(t, e);
|
|
3944
3952
|
return n ? (n.getTimezoneOffset() > 0 && n.setMinutes(n.getMinutes() + n.getTimezoneOffset()), n) : /* @__PURE__ */ new Date();
|
|
@@ -3953,18 +3961,18 @@ const Oa = (t) => /* @__PURE__ */ new Date(`${t}T00:00:00`), Aa = (t) => {
|
|
|
3953
3961
|
}
|
|
3954
3962
|
return n;
|
|
3955
3963
|
}, tt = (t) => ve(t) ? 6 : Me(t) ? 5 : Re(t) ? 4 : Ae(t) ? 3 : _e(t) ? 2 : pa(t) ? 1 : 0, nt = (t, e = !1) => (e ? Mt(t) : Ot(t))?.getTime() || 0, Nt = (t, e, n) => {
|
|
3956
|
-
const r = k(e, !0), s = k(n), a = k(t, !0), o = k(t),
|
|
3964
|
+
const r = k(e, !0), s = k(n), a = k(t, !0), o = k(t), c = r.getTime() > a.getTime() ? r : a, i = s.getTime() < o.getTime() ? s : o;
|
|
3957
3965
|
return {
|
|
3958
|
-
start:
|
|
3959
|
-
end:
|
|
3966
|
+
start: c,
|
|
3967
|
+
end: i
|
|
3960
3968
|
};
|
|
3961
3969
|
}, $a = (t, e, n, r = "W") => {
|
|
3962
3970
|
const s = +t, { start: a, end: o } = Nt(t, e, n);
|
|
3963
3971
|
if (a.getTime() > o.getTime())
|
|
3964
3972
|
return [];
|
|
3965
|
-
const
|
|
3966
|
-
if (
|
|
3967
|
-
for (let m =
|
|
3973
|
+
const c = Z(a, r), i = c.weekYear === s ? c.weekNumber : c.weekYear < s ? 1 : Ke(s, r), u = Z(o, r), d = u.weekYear === s ? u.weekNumber : u.weekYear > s ? Ke(s, r) : 1, l = [];
|
|
3974
|
+
if (i < d)
|
|
3975
|
+
for (let m = i; m <= d; m++)
|
|
3968
3976
|
l.push(Pt(s, m, r));
|
|
3969
3977
|
return l;
|
|
3970
3978
|
}, Wa = (t) => {
|
|
@@ -3978,10 +3986,10 @@ const Oa = (t) => /* @__PURE__ */ new Date(`${t}T00:00:00`), Aa = (t) => {
|
|
|
3978
3986
|
r.getFullYear(),
|
|
3979
3987
|
r.getMonth(),
|
|
3980
3988
|
r.getDate()
|
|
3981
|
-
),
|
|
3982
|
-
for (; o.getTime() <
|
|
3983
|
-
const
|
|
3984
|
-
a.push(
|
|
3989
|
+
), c = new Date(s.getFullYear(), s.getMonth(), s.getDate());
|
|
3990
|
+
for (; o.getTime() < c.getTime(); ) {
|
|
3991
|
+
const i = Wa(o);
|
|
3992
|
+
a.push(i), o.setDate(o.getDate() + 1);
|
|
3985
3993
|
}
|
|
3986
3994
|
return a;
|
|
3987
3995
|
}, Ua = (t) => ({
|
|
@@ -3998,9 +4006,9 @@ const Oa = (t) => /* @__PURE__ */ new Date(`${t}T00:00:00`), Aa = (t) => {
|
|
|
3998
4006
|
return { startMonth: s, endMonth: a };
|
|
3999
4007
|
}, Ha = ["FREQUENCY", "FREQ"], yo = (t, e) => {
|
|
4000
4008
|
const n = t?.[0]?.cubeRegions?.[0]?.memberSelection?.find(
|
|
4001
|
-
(
|
|
4002
|
-
)?.selectionValues, r = Ua(n || []), s = e?.startPeriod?.getTime() || 1, a = e?.endPeriod?.getTime() || 1, o = Ca(a, s),
|
|
4003
|
-
return o.forEach((
|
|
4009
|
+
(i) => Ha.includes(i.componentId)
|
|
4010
|
+
)?.selectionValues, r = Ua(n || []), s = e?.startPeriod?.getTime() || 1, a = e?.endPeriod?.getTime() || 1, o = Ca(a, s), c = [];
|
|
4011
|
+
return o.forEach((i, u) => {
|
|
4004
4012
|
const d = [], { startMonth: l, endMonth: m } = Fa(
|
|
4005
4013
|
o,
|
|
4006
4014
|
new Date(s),
|
|
@@ -4014,14 +4022,14 @@ const Oa = (t) => /* @__PURE__ */ new Date(`${t}T00:00:00`), Aa = (t) => {
|
|
|
4014
4022
|
isSemiAnnualExist: g,
|
|
4015
4023
|
isYearlyExist: P
|
|
4016
4024
|
} = r;
|
|
4017
|
-
P && d.push(
|
|
4018
|
-
...Ra(
|
|
4019
|
-
), M && d.push(...Ya(
|
|
4020
|
-
...$a(
|
|
4025
|
+
P && d.push(i.toString()), g && d.push(..._a(i, l, m)), f && d.push(
|
|
4026
|
+
...Ra(i, l, m, !1)
|
|
4027
|
+
), M && d.push(...Ya(i, l, m)), x && d.push(
|
|
4028
|
+
...$a(i, s.toString(), a.toString())
|
|
4021
4029
|
), v && d.push(
|
|
4022
|
-
...qa(
|
|
4023
|
-
),
|
|
4024
|
-
}),
|
|
4030
|
+
...qa(i, s.toString(), a.toString())
|
|
4031
|
+
), c.push(...d);
|
|
4032
|
+
}), c;
|
|
4025
4033
|
};
|
|
4026
4034
|
function Qa(t) {
|
|
4027
4035
|
const { urn: e } = t.details;
|
|
@@ -4076,12 +4084,12 @@ function ce(t) {
|
|
|
4076
4084
|
}
|
|
4077
4085
|
function Rt(t, e, n) {
|
|
4078
4086
|
e?.forEach((r) => {
|
|
4079
|
-
const { childId: s, agency: a, id: o, version:
|
|
4080
|
-
(l) => Ba(
|
|
4087
|
+
const { childId: s, agency: a, id: o, version: c } = rt(r.code), i = ue(o, c, a), u = n?.find(
|
|
4088
|
+
(l) => Ba(i, ce(l))
|
|
4081
4089
|
), d = u?.codes?.find((l) => l.id === s);
|
|
4082
4090
|
if (d != null) {
|
|
4083
4091
|
const l = r.code.replace(
|
|
4084
|
-
|
|
4092
|
+
i,
|
|
4085
4093
|
ce(u)
|
|
4086
4094
|
);
|
|
4087
4095
|
t.push({ ...d, code: l });
|
|
@@ -4118,20 +4126,20 @@ class Po {
|
|
|
4118
4126
|
this.client = e;
|
|
4119
4127
|
}
|
|
4120
4128
|
async getAvailableHierarchies(e, n, r) {
|
|
4121
|
-
const { agency: s, id: a, version: o } = S(e),
|
|
4129
|
+
const { agency: s, id: a, version: o } = S(e), i = `${this.client.config.sdmxProxyUrl ? this.client.config.sdmxProxyUrl : this.client.config.apiUrl}/sdmx/3.0/structure/codelist`, u = r ? { [Ce]: r } : void 0;
|
|
4122
4130
|
return this.client.request(
|
|
4123
4131
|
`${s}/${a}/${o}?references=hierarchy&detail=allcompletestubs`,
|
|
4124
4132
|
{ method: "GET", headers: u },
|
|
4125
|
-
|
|
4133
|
+
i,
|
|
4126
4134
|
n
|
|
4127
4135
|
);
|
|
4128
4136
|
}
|
|
4129
4137
|
async getHierarchy(e, n, r) {
|
|
4130
|
-
const { agency: s, id: a, version: o } = S(e),
|
|
4138
|
+
const { agency: s, id: a, version: o } = S(e), i = `${this.client.config.sdmxProxyUrl ? this.client.config.sdmxProxyUrl : this.client.config.apiUrl}/sdmx/3.0/structure/hierarchy`, u = r ? { [Ce]: r } : void 0;
|
|
4131
4139
|
return this.client.request(
|
|
4132
4140
|
`${s}/${a}/${o}?references=descendants&detail=full`,
|
|
4133
4141
|
{ method: "GET", headers: u },
|
|
4134
|
-
|
|
4142
|
+
i,
|
|
4135
4143
|
n
|
|
4136
4144
|
);
|
|
4137
4145
|
}
|