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