@iqb/metadata-resolver 0.1.0 → 0.2.0
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/README.md +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +9 -50
- package/dist/index.d.mts +9 -50
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @iqb/metadata-resolver
|
|
2
2
|
|
|
3
|
-
TypeScript library for loading metadata profiles and vocabularies.
|
|
3
|
+
Framework-agnostic TypeScript library for loading metadata profiles and vocabularies.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
```bash
|
|
@@ -30,4 +30,4 @@ See [GETTING_STARTED.md](./GETTING_STARTED.md) for detailed usage guide.
|
|
|
30
30
|
|
|
31
31
|
## License
|
|
32
32
|
|
|
33
|
-
MIT © IQB Berlin
|
|
33
|
+
MIT © IQB Berlin
|
package/dist/index.cjs
CHANGED
|
@@ -54,7 +54,7 @@ var MetadataResolver = class {
|
|
|
54
54
|
const urls = /* @__PURE__ */ new Set();
|
|
55
55
|
profile.groups?.forEach((group) => {
|
|
56
56
|
group.entries?.forEach((entry) => {
|
|
57
|
-
if (entry.type === "
|
|
57
|
+
if (entry.type.toUpperCase() === "VOCABULARY" && entry.parameters) {
|
|
58
58
|
const params = entry.parameters;
|
|
59
59
|
if (params.url) urls.add(params.url);
|
|
60
60
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,35 +1,12 @@
|
|
|
1
|
-
import { MDProfile } from "@
|
|
1
|
+
import { LanguageCodedText, LanguageCodedText as LanguageCodedText$1, MDProfile, MDProfile as MDProfile$1 } from "@iqbspecs/metadata-profile";
|
|
2
2
|
|
|
3
3
|
//#region src/types.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Configuration options for the MetadataResolver
|
|
7
|
-
*/
|
|
8
4
|
interface LoaderOptions {
|
|
9
|
-
/**
|
|
10
|
-
* CORS proxy URL (e.g., 'https://corsproxy.io/?')
|
|
11
|
-
* If provided, all fetch requests will be proxied through this URL
|
|
12
|
-
*/
|
|
13
5
|
corsProxy?: string;
|
|
14
|
-
/**
|
|
15
|
-
* Enable caching of loaded resources
|
|
16
|
-
* @default true
|
|
17
|
-
*/
|
|
18
6
|
cache?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Preferred language for vocabulary labels
|
|
21
|
-
* @default 'de'
|
|
22
|
-
*/
|
|
23
7
|
preferredLanguage?: string;
|
|
24
|
-
/**
|
|
25
|
-
* Request timeout in milliseconds
|
|
26
|
-
* @default 10000
|
|
27
|
-
*/
|
|
28
8
|
requestTimeout?: number;
|
|
29
9
|
}
|
|
30
|
-
/**
|
|
31
|
-
* Vocabulary concept node structure
|
|
32
|
-
*/
|
|
33
10
|
interface VocabConcept {
|
|
34
11
|
id: string;
|
|
35
12
|
notation?: string[];
|
|
@@ -41,9 +18,6 @@ interface VocabConcept {
|
|
|
41
18
|
description?: string;
|
|
42
19
|
narrower?: VocabConcept[];
|
|
43
20
|
}
|
|
44
|
-
/**
|
|
45
|
-
* Raw vocabulary data structure from vocabulary JSON files
|
|
46
|
-
*/
|
|
47
21
|
interface VocabularyData {
|
|
48
22
|
id?: string;
|
|
49
23
|
type?: string;
|
|
@@ -55,45 +29,33 @@ interface VocabularyEntry {
|
|
|
55
29
|
name: string;
|
|
56
30
|
notation: string[];
|
|
57
31
|
description?: string;
|
|
58
|
-
text:
|
|
32
|
+
text: LanguageCodedText$1[];
|
|
59
33
|
}
|
|
60
|
-
/**
|
|
61
|
-
* Resolved vocabulary with data and lookup dictionary
|
|
62
|
-
*/
|
|
63
34
|
interface ResolvedVocabulary {
|
|
64
35
|
url: string;
|
|
65
36
|
data: VocabularyData;
|
|
66
37
|
dictionary: Record<string, VocabularyEntry>;
|
|
67
38
|
error?: string;
|
|
68
39
|
}
|
|
69
|
-
/**
|
|
70
|
-
* Profile loaded with all its vocabularies
|
|
71
|
-
*/
|
|
72
40
|
interface ProfileWithVocabularies {
|
|
73
|
-
profile: MDProfile;
|
|
41
|
+
profile: MDProfile$1;
|
|
74
42
|
vocabularies: ResolvedVocabulary[];
|
|
75
43
|
}
|
|
76
|
-
/**
|
|
77
|
-
* Complete metadata package with profile, metadata, and vocabularies
|
|
78
|
-
*/
|
|
79
44
|
interface MetadataWithProfile {
|
|
80
|
-
profile: MDProfile;
|
|
45
|
+
profile: MDProfile$1;
|
|
81
46
|
metadata: any;
|
|
82
47
|
vocabularies: ResolvedVocabulary[];
|
|
83
48
|
}
|
|
84
49
|
/**
|
|
85
|
-
*
|
|
50
|
+
* @deprecated Use LanguageCodedText instead.
|
|
86
51
|
*/
|
|
87
|
-
|
|
88
|
-
lang: string;
|
|
89
|
-
value: string;
|
|
90
|
-
}
|
|
52
|
+
type TextWithLanguage = LanguageCodedText$1;
|
|
91
53
|
/**
|
|
92
|
-
*
|
|
54
|
+
* @deprecated Will be removed when values spec is adopted.
|
|
93
55
|
*/
|
|
94
56
|
interface TextWithLanguageAndId {
|
|
95
57
|
id: string;
|
|
96
|
-
text:
|
|
58
|
+
text: LanguageCodedText$1[];
|
|
97
59
|
}
|
|
98
60
|
//#endregion
|
|
99
61
|
//#region src/metadata-resolver.d.ts
|
|
@@ -145,10 +107,7 @@ declare class MetadataResolver {
|
|
|
145
107
|
/**
|
|
146
108
|
* Extract text from a label (string or multilingual array)
|
|
147
109
|
*/
|
|
148
|
-
static extractLabelText(label: string |
|
|
149
|
-
lang: string;
|
|
150
|
-
value: string;
|
|
151
|
-
}>, preferredLanguage?: string): string;
|
|
110
|
+
static extractLabelText(label: string | LanguageCodedText[], preferredLanguage?: string): string;
|
|
152
111
|
/**
|
|
153
112
|
* Clear all caches (profiles, metadata, and vocabularies)
|
|
154
113
|
*/
|
package/dist/index.d.mts
CHANGED
|
@@ -1,35 +1,12 @@
|
|
|
1
|
-
import { MDProfile } from "@
|
|
1
|
+
import { LanguageCodedText, LanguageCodedText as LanguageCodedText$1, MDProfile, MDProfile as MDProfile$1 } from "@iqbspecs/metadata-profile";
|
|
2
2
|
|
|
3
3
|
//#region src/types.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Configuration options for the MetadataResolver
|
|
7
|
-
*/
|
|
8
4
|
interface LoaderOptions {
|
|
9
|
-
/**
|
|
10
|
-
* CORS proxy URL (e.g., 'https://corsproxy.io/?')
|
|
11
|
-
* If provided, all fetch requests will be proxied through this URL
|
|
12
|
-
*/
|
|
13
5
|
corsProxy?: string;
|
|
14
|
-
/**
|
|
15
|
-
* Enable caching of loaded resources
|
|
16
|
-
* @default true
|
|
17
|
-
*/
|
|
18
6
|
cache?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Preferred language for vocabulary labels
|
|
21
|
-
* @default 'de'
|
|
22
|
-
*/
|
|
23
7
|
preferredLanguage?: string;
|
|
24
|
-
/**
|
|
25
|
-
* Request timeout in milliseconds
|
|
26
|
-
* @default 10000
|
|
27
|
-
*/
|
|
28
8
|
requestTimeout?: number;
|
|
29
9
|
}
|
|
30
|
-
/**
|
|
31
|
-
* Vocabulary concept node structure
|
|
32
|
-
*/
|
|
33
10
|
interface VocabConcept {
|
|
34
11
|
id: string;
|
|
35
12
|
notation?: string[];
|
|
@@ -41,9 +18,6 @@ interface VocabConcept {
|
|
|
41
18
|
description?: string;
|
|
42
19
|
narrower?: VocabConcept[];
|
|
43
20
|
}
|
|
44
|
-
/**
|
|
45
|
-
* Raw vocabulary data structure from vocabulary JSON files
|
|
46
|
-
*/
|
|
47
21
|
interface VocabularyData {
|
|
48
22
|
id?: string;
|
|
49
23
|
type?: string;
|
|
@@ -55,45 +29,33 @@ interface VocabularyEntry {
|
|
|
55
29
|
name: string;
|
|
56
30
|
notation: string[];
|
|
57
31
|
description?: string;
|
|
58
|
-
text:
|
|
32
|
+
text: LanguageCodedText$1[];
|
|
59
33
|
}
|
|
60
|
-
/**
|
|
61
|
-
* Resolved vocabulary with data and lookup dictionary
|
|
62
|
-
*/
|
|
63
34
|
interface ResolvedVocabulary {
|
|
64
35
|
url: string;
|
|
65
36
|
data: VocabularyData;
|
|
66
37
|
dictionary: Record<string, VocabularyEntry>;
|
|
67
38
|
error?: string;
|
|
68
39
|
}
|
|
69
|
-
/**
|
|
70
|
-
* Profile loaded with all its vocabularies
|
|
71
|
-
*/
|
|
72
40
|
interface ProfileWithVocabularies {
|
|
73
|
-
profile: MDProfile;
|
|
41
|
+
profile: MDProfile$1;
|
|
74
42
|
vocabularies: ResolvedVocabulary[];
|
|
75
43
|
}
|
|
76
|
-
/**
|
|
77
|
-
* Complete metadata package with profile, metadata, and vocabularies
|
|
78
|
-
*/
|
|
79
44
|
interface MetadataWithProfile {
|
|
80
|
-
profile: MDProfile;
|
|
45
|
+
profile: MDProfile$1;
|
|
81
46
|
metadata: any;
|
|
82
47
|
vocabularies: ResolvedVocabulary[];
|
|
83
48
|
}
|
|
84
49
|
/**
|
|
85
|
-
*
|
|
50
|
+
* @deprecated Use LanguageCodedText instead.
|
|
86
51
|
*/
|
|
87
|
-
|
|
88
|
-
lang: string;
|
|
89
|
-
value: string;
|
|
90
|
-
}
|
|
52
|
+
type TextWithLanguage = LanguageCodedText$1;
|
|
91
53
|
/**
|
|
92
|
-
*
|
|
54
|
+
* @deprecated Will be removed when values spec is adopted.
|
|
93
55
|
*/
|
|
94
56
|
interface TextWithLanguageAndId {
|
|
95
57
|
id: string;
|
|
96
|
-
text:
|
|
58
|
+
text: LanguageCodedText$1[];
|
|
97
59
|
}
|
|
98
60
|
//#endregion
|
|
99
61
|
//#region src/metadata-resolver.d.ts
|
|
@@ -145,10 +107,7 @@ declare class MetadataResolver {
|
|
|
145
107
|
/**
|
|
146
108
|
* Extract text from a label (string or multilingual array)
|
|
147
109
|
*/
|
|
148
|
-
static extractLabelText(label: string |
|
|
149
|
-
lang: string;
|
|
150
|
-
value: string;
|
|
151
|
-
}>, preferredLanguage?: string): string;
|
|
110
|
+
static extractLabelText(label: string | LanguageCodedText[], preferredLanguage?: string): string;
|
|
152
111
|
/**
|
|
153
112
|
* Clear all caches (profiles, metadata, and vocabularies)
|
|
154
113
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -53,7 +53,7 @@ var MetadataResolver = class {
|
|
|
53
53
|
const urls = /* @__PURE__ */ new Set();
|
|
54
54
|
profile.groups?.forEach((group) => {
|
|
55
55
|
group.entries?.forEach((entry) => {
|
|
56
|
-
if (entry.type === "
|
|
56
|
+
if (entry.type.toUpperCase() === "VOCABULARY" && entry.parameters) {
|
|
57
57
|
const params = entry.parameters;
|
|
58
58
|
if (params.url) urls.add(params.url);
|
|
59
59
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iqb/metadata-resolver",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Framework-agnostic metadata and vocabulary resolver for IQB metadata profiles",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"author": "IQB",
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@
|
|
24
|
+
"@iqbspecs/metadata-profile": "^0.11.1"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"tsdown": "^0.20.0-beta.2",
|
|
@@ -37,4 +37,4 @@
|
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
39
39
|
}
|
|
40
|
-
}
|
|
40
|
+
}
|