prez-lib 4.3.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 +1 -0
- package/dist/prez-lib.js +1329 -1256
- package/dist/prez-lib.umd.cjs +8 -8
- package/dist/service.d.ts +3 -2
- package/dist/store.d.ts +12 -3
- package/dist/types.d.ts +46 -5
- package/package.json +2 -1
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
|
|
@@ -125,7 +127,14 @@ export declare class RDFStore {
|
|
|
125
127
|
/**
|
|
126
128
|
* Returns search results
|
|
127
129
|
*/
|
|
128
|
-
|
|
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[];
|
|
129
138
|
/**
|
|
130
139
|
* Returns a list of facets
|
|
131
140
|
*
|
package/dist/types.d.ts
CHANGED
|
@@ -184,16 +184,48 @@ export interface PrezProperty {
|
|
|
184
184
|
export interface PrezProperties {
|
|
185
185
|
[predicateIri: string]: PrezProperty;
|
|
186
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;
|
|
195
|
+
/**
|
|
196
|
+
* Represents a single predicate/snippet pair inside a Lucene SHACL search result.
|
|
197
|
+
*/
|
|
198
|
+
export type PrezSearchMatch = {
|
|
199
|
+
predicate: PrezNode;
|
|
200
|
+
match: PrezLiteral;
|
|
201
|
+
};
|
|
187
202
|
/**
|
|
188
|
-
* Represents
|
|
203
|
+
* Represents the default flat Prez search result shape.
|
|
189
204
|
*/
|
|
190
|
-
export type
|
|
205
|
+
export type PrezFlatSearchResult = {
|
|
191
206
|
hash: string;
|
|
192
207
|
weight: number;
|
|
193
208
|
predicate: PrezNode;
|
|
194
209
|
match: PrezLiteral;
|
|
195
210
|
resource: PrezFocusNode;
|
|
196
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;
|
|
197
229
|
/**
|
|
198
230
|
* Represents an item in Prez that contains node info and its related properties
|
|
199
231
|
*/
|
|
@@ -220,7 +252,7 @@ export type PrezMediatype = {
|
|
|
220
252
|
export type PrezDataTypes = 'item' | 'list' | 'search';
|
|
221
253
|
export interface PrezData {
|
|
222
254
|
type: PrezDataTypes;
|
|
223
|
-
data: PrezFocusNode | PrezFocusNode[] |
|
|
255
|
+
data: PrezFocusNode | PrezFocusNode[] | PrezAnySearchResult[];
|
|
224
256
|
profiles: PrezProfileHeader[];
|
|
225
257
|
parents: PrezLinkParent[];
|
|
226
258
|
facets: PrezFacet[];
|
|
@@ -236,12 +268,21 @@ export interface PrezDataItem extends PrezData {
|
|
|
236
268
|
data: PrezFocusNode | PrezConceptSchemeNode | PrezOntologyNode | PrezConceptSchemeOntologyNode | PrezBBlockNode;
|
|
237
269
|
store: RDFStore;
|
|
238
270
|
}
|
|
239
|
-
export interface
|
|
271
|
+
export interface PrezDataSearchBase extends Omit<PrezData, "type" | "data"> {
|
|
240
272
|
type: 'search';
|
|
273
|
+
parserMode: PrezSearchParserMode;
|
|
241
274
|
count: number;
|
|
242
|
-
data: PrezSearchResult[];
|
|
243
275
|
maxReached: boolean;
|
|
244
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;
|
|
245
286
|
export type PrezFacetValue = {
|
|
246
287
|
term: (PrezLiteral | PrezNode);
|
|
247
288
|
count: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prez-lib",
|
|
3
|
-
"version": "4.3.
|
|
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",
|
|
@@ -39,6 +39,7 @@
|
|
|
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"
|