prez-lib 4.2.0 → 4.3.1
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 +16 -0
- package/dist/consts.d.ts +12 -0
- package/dist/prez-lib.js +2537 -2415
- package/dist/prez-lib.umd.cjs +13 -18
- package/dist/service.d.ts +3 -2
- package/dist/store.d.ts +16 -4
- package/dist/types.d.ts +64 -10
- package/package.json +8 -7
package/dist/service.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PrezDataItem, PrezDataList,
|
|
1
|
+
import { PrezDataItem, PrezDataList, PrezDataSearchDefault, PrezDataSearchLuceneShacl, PrezNodeList, PrezProfileHeader, PrezProfiles, PrezSearchOptionsDefault, PrezSearchOptionsLuceneShacl } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Does a GET request to a Prez API endpoint
|
|
4
4
|
*
|
|
@@ -31,7 +31,8 @@ export declare function getItem(baseUrl: string, path: string): Promise<PrezData
|
|
|
31
31
|
* @param path Search path along with any query parameters
|
|
32
32
|
* @returns
|
|
33
33
|
*/
|
|
34
|
-
export declare function search(baseUrl: string, path: string): Promise<
|
|
34
|
+
export declare function search(baseUrl: string, path: string, options?: PrezSearchOptionsDefault): Promise<PrezDataSearchDefault>;
|
|
35
|
+
export declare function search(baseUrl: string, path: string, options: PrezSearchOptionsLuceneShacl): Promise<PrezDataSearchLuceneShacl>;
|
|
35
36
|
/**
|
|
36
37
|
* Returns the full list of Prez Profiles used for the global profile list
|
|
37
38
|
*
|
package/dist/store.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Store, Quad_Object, Quad_Subject, Term } from 'n3';
|
|
2
|
-
import {
|
|
2
|
+
import { PrezBBlockNode, PrezConceptNode, PrezConceptSchemeNode, PrezConceptSchemeOntologyNode, PrezFacet, PrezFlatSearchResult, PrezFocusNode, PrezLink, PrezLinkParent, PrezLuceneShaclSearchResult, PrezNode, PrezOntologyNode, PrezProperties, PrezSearchOptionsDefault, PrezSearchOptionsLuceneShacl } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* An in-memory N3.js store containing convenience functions
|
|
5
5
|
*/
|
|
@@ -50,6 +50,8 @@ export declare class RDFStore {
|
|
|
50
50
|
*/
|
|
51
51
|
fromIri(iri: string): string;
|
|
52
52
|
private getObjectLiteral;
|
|
53
|
+
private toSubjectTerm;
|
|
54
|
+
private getRequiredObject;
|
|
53
55
|
getProperties(term: Term, options?: {
|
|
54
56
|
excludePrefix?: string;
|
|
55
57
|
includePrefix?: string;
|
|
@@ -78,7 +80,7 @@ export declare class RDFStore {
|
|
|
78
80
|
* @param predicate a string or string array of predicate IRIs
|
|
79
81
|
* @returns the array of objects
|
|
80
82
|
*/
|
|
81
|
-
getObjects(subject: string, predicate: string | string[]): Quad_Object[];
|
|
83
|
+
getObjects(subject: string | Quad_Subject | Quad_Object, predicate: string | string[]): Quad_Object[];
|
|
82
84
|
getMembers(subject: string): PrezLink | undefined;
|
|
83
85
|
/**
|
|
84
86
|
* Returns the concept hierarchy for a vocab
|
|
@@ -105,13 +107,16 @@ export declare class RDFStore {
|
|
|
105
107
|
*/
|
|
106
108
|
getList(): PrezFocusNode[];
|
|
107
109
|
getSkosCollections(vocab: Quad_Object): PrezNode[];
|
|
110
|
+
getOntologyClasses(vocab: Quad_Object): PrezNode[];
|
|
111
|
+
getOntologyProperties(vocab: Quad_Object): PrezNode[];
|
|
112
|
+
getBBlockDependencies(vocab: Quad_Object): PrezNode[];
|
|
108
113
|
/**
|
|
109
114
|
* Returns an item object
|
|
110
115
|
*
|
|
111
116
|
* @param id the id of the object to return
|
|
112
117
|
* @returns the item object
|
|
113
118
|
*/
|
|
114
|
-
getItem(): PrezFocusNode;
|
|
119
|
+
getItem(): PrezFocusNode | PrezConceptSchemeNode | PrezOntologyNode | PrezConceptSchemeOntologyNode | PrezBBlockNode;
|
|
115
120
|
/**
|
|
116
121
|
* Return nested subitems for a given predicate
|
|
117
122
|
*
|
|
@@ -122,7 +127,14 @@ export declare class RDFStore {
|
|
|
122
127
|
/**
|
|
123
128
|
* Returns search results
|
|
124
129
|
*/
|
|
125
|
-
|
|
130
|
+
private extractSearchResultHash;
|
|
131
|
+
private getSearchResultBase;
|
|
132
|
+
private getOptionalFlatSearchMatch;
|
|
133
|
+
private parseSearchMatch;
|
|
134
|
+
private parseDefaultSearchResult;
|
|
135
|
+
private parseJenaLuceneShaclSearchResult;
|
|
136
|
+
search(options?: PrezSearchOptionsDefault): PrezFlatSearchResult[];
|
|
137
|
+
search(options: PrezSearchOptionsLuceneShacl): PrezLuceneShaclSearchResult[];
|
|
126
138
|
/**
|
|
127
139
|
* Returns a list of facets
|
|
128
140
|
*
|
package/dist/types.d.ts
CHANGED
|
@@ -89,6 +89,16 @@ export interface PrezConceptSchemeNode extends PrezFocusNode {
|
|
|
89
89
|
*/
|
|
90
90
|
collections: PrezNode[];
|
|
91
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* A FocusNode for an Ontology
|
|
94
|
+
*/
|
|
95
|
+
export interface PrezOntologyNode extends PrezFocusNode {
|
|
96
|
+
ontologyClasses: PrezNode[];
|
|
97
|
+
ontologyProperties: PrezNode[];
|
|
98
|
+
}
|
|
99
|
+
/** A FocusNode for a combination of an Ontology and a Concept Scheme */
|
|
100
|
+
export interface PrezConceptSchemeOntologyNode extends PrezConceptSchemeNode, PrezOntologyNode {
|
|
101
|
+
}
|
|
92
102
|
/**
|
|
93
103
|
* A recursive list of child concept schemes
|
|
94
104
|
*/
|
|
@@ -102,6 +112,13 @@ export interface PrezConceptNode extends PrezFocusNode {
|
|
|
102
112
|
*/
|
|
103
113
|
hasChildren: boolean;
|
|
104
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* A FocusNode for an OGC Building Block
|
|
117
|
+
*/
|
|
118
|
+
export interface PrezBBlockNode extends PrezFocusNode {
|
|
119
|
+
dependsOn: PrezNode[];
|
|
120
|
+
isBBlock: boolean;
|
|
121
|
+
}
|
|
105
122
|
/** Represents a node and list of subnodes */
|
|
106
123
|
export type PrezNodeList = {
|
|
107
124
|
node: PrezNode;
|
|
@@ -167,16 +184,48 @@ export interface PrezProperty {
|
|
|
167
184
|
export interface PrezProperties {
|
|
168
185
|
[predicateIri: string]: PrezProperty;
|
|
169
186
|
}
|
|
187
|
+
export type PrezSearchParserMode = "default" | "jena-lucene-shacl";
|
|
188
|
+
export type PrezSearchOptionsDefault = {
|
|
189
|
+
parserMode?: "default";
|
|
190
|
+
};
|
|
191
|
+
export type PrezSearchOptionsLuceneShacl = {
|
|
192
|
+
parserMode: "jena-lucene-shacl";
|
|
193
|
+
};
|
|
194
|
+
export type PrezSearchOptions = PrezSearchOptionsDefault | PrezSearchOptionsLuceneShacl;
|
|
170
195
|
/**
|
|
171
|
-
* Represents a search result
|
|
196
|
+
* Represents a single predicate/snippet pair inside a Lucene SHACL search result.
|
|
172
197
|
*/
|
|
173
|
-
export type
|
|
198
|
+
export type PrezSearchMatch = {
|
|
199
|
+
predicate: PrezNode;
|
|
200
|
+
match: PrezLiteral;
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* Represents the default flat Prez search result shape.
|
|
204
|
+
*/
|
|
205
|
+
export type PrezFlatSearchResult = {
|
|
174
206
|
hash: string;
|
|
175
207
|
weight: number;
|
|
176
208
|
predicate: PrezNode;
|
|
177
209
|
match: PrezLiteral;
|
|
178
210
|
resource: PrezFocusNode;
|
|
179
211
|
};
|
|
212
|
+
/**
|
|
213
|
+
* Backwards-compatible alias for the default flat search result shape.
|
|
214
|
+
*/
|
|
215
|
+
export type PrezSearchResult = PrezFlatSearchResult;
|
|
216
|
+
/**
|
|
217
|
+
* Represents the Jena Lucene SHACL search result shape.
|
|
218
|
+
*/
|
|
219
|
+
export type PrezLuceneShaclSearchResult = {
|
|
220
|
+
hash: string;
|
|
221
|
+
weight: number;
|
|
222
|
+
resource: PrezFocusNode;
|
|
223
|
+
matches: PrezSearchMatch[];
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Represents any supported Prez search result shape.
|
|
227
|
+
*/
|
|
228
|
+
export type PrezAnySearchResult = PrezFlatSearchResult | PrezLuceneShaclSearchResult;
|
|
180
229
|
/**
|
|
181
230
|
* Represents an item in Prez that contains node info and its related properties
|
|
182
231
|
*/
|
|
@@ -203,7 +252,7 @@ export type PrezMediatype = {
|
|
|
203
252
|
export type PrezDataTypes = 'item' | 'list' | 'search';
|
|
204
253
|
export interface PrezData {
|
|
205
254
|
type: PrezDataTypes;
|
|
206
|
-
data: PrezFocusNode | PrezFocusNode[] |
|
|
255
|
+
data: PrezFocusNode | PrezFocusNode[] | PrezAnySearchResult[];
|
|
207
256
|
profiles: PrezProfileHeader[];
|
|
208
257
|
parents: PrezLinkParent[];
|
|
209
258
|
facets: PrezFacet[];
|
|
@@ -216,19 +265,24 @@ export interface PrezDataList extends PrezData {
|
|
|
216
265
|
}
|
|
217
266
|
export interface PrezDataItem extends PrezData {
|
|
218
267
|
type: 'item';
|
|
219
|
-
data: PrezFocusNode | PrezConceptSchemeNode;
|
|
268
|
+
data: PrezFocusNode | PrezConceptSchemeNode | PrezOntologyNode | PrezConceptSchemeOntologyNode | PrezBBlockNode;
|
|
220
269
|
store: RDFStore;
|
|
221
270
|
}
|
|
222
|
-
export interface
|
|
223
|
-
type: 'item';
|
|
224
|
-
data: PrezFocusNode | PrezConceptSchemeNode;
|
|
225
|
-
}
|
|
226
|
-
export interface PrezDataSearch extends PrezData {
|
|
271
|
+
export interface PrezDataSearchBase extends Omit<PrezData, "type" | "data"> {
|
|
227
272
|
type: 'search';
|
|
273
|
+
parserMode: PrezSearchParserMode;
|
|
228
274
|
count: number;
|
|
229
|
-
data: PrezSearchResult[];
|
|
230
275
|
maxReached: boolean;
|
|
231
276
|
}
|
|
277
|
+
export interface PrezDataSearchDefault extends PrezDataSearchBase {
|
|
278
|
+
parserMode: "default";
|
|
279
|
+
data: PrezFlatSearchResult[];
|
|
280
|
+
}
|
|
281
|
+
export interface PrezDataSearchLuceneShacl extends PrezDataSearchBase {
|
|
282
|
+
parserMode: "jena-lucene-shacl";
|
|
283
|
+
data: PrezLuceneShaclSearchResult[];
|
|
284
|
+
}
|
|
285
|
+
export type PrezDataSearch = PrezDataSearchDefault | PrezDataSearchLuceneShacl;
|
|
232
286
|
export type PrezFacetValue = {
|
|
233
287
|
term: (PrezLiteral | PrezNode);
|
|
234
288
|
count: number;
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prez-lib",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.1",
|
|
4
4
|
"description": "A JS library for processing RDF data for use with Prez UI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/
|
|
9
|
+
"url": "git+https://github.com/RDFLib/prez-ui.git",
|
|
10
10
|
"directory": "packages/prez-lib"
|
|
11
11
|
},
|
|
12
|
-
"homepage": "https://github.com/
|
|
12
|
+
"homepage": "https://github.com/RDFLib/prez-ui/tree/main/packages/prez-lib#readme",
|
|
13
13
|
"bugs": {
|
|
14
|
-
"url": "https://github.com/
|
|
14
|
+
"url": "https://github.com/RDFLib/prez-ui/issues"
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
17
17
|
"dist"
|
|
@@ -28,17 +28,18 @@
|
|
|
28
28
|
"types": "./dist/index.d.ts",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@rdfjs/types": "^1.1.2",
|
|
31
|
-
"@types/n3": "^1.
|
|
31
|
+
"@types/n3": "^1.26.1",
|
|
32
32
|
"typescript": "5.9.2",
|
|
33
|
-
"vite": "^7.
|
|
33
|
+
"vite": "^7.3.0",
|
|
34
34
|
"vite-plugin-dts": "^4.5.4"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"n3": "^1.
|
|
37
|
+
"n3": "^1.26.0"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"dev": "vite",
|
|
41
41
|
"build": "tsc && vite build",
|
|
42
|
+
"test": "node --test tests/**/*.test.mjs",
|
|
42
43
|
"types": "tsc",
|
|
43
44
|
"preview": "vite preview",
|
|
44
45
|
"preinstall": "npx only-allow pnpm"
|