prez-lib 4.0.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/LICENSE +29 -0
- package/README.md +34 -0
- package/dist/consts.d.ts +37 -0
- package/dist/factory.d.ts +5 -0
- package/dist/helpers.d.ts +76 -0
- package/dist/index.d.ts +6 -0
- package/dist/prez-lib.js +7653 -0
- package/dist/prez-lib.umd.cjs +29 -0
- package/dist/service.d.ts +42 -0
- package/dist/store.d.ts +124 -0
- package/dist/types.d.ts +229 -0
- package/dist/vite.svg +1 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, RDFLib Team
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Prez Lib
|
|
2
|
+
A JS library for processing RDF data for use with Prez UI, implementing [RDF/JS types](https://github.com/rdfjs/types) and [N3.js](https://github.com/rdfjs/N3.js).
|
|
3
|
+
|
|
4
|
+
## Installing
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npm install prez-lib
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Example Usage
|
|
11
|
+
Using the factory functions:
|
|
12
|
+
```typescript
|
|
13
|
+
import { literal, node } from "prez-lib";
|
|
14
|
+
|
|
15
|
+
const term = node({
|
|
16
|
+
value: "https://example.com",
|
|
17
|
+
label: literal("term"),
|
|
18
|
+
links: [
|
|
19
|
+
{
|
|
20
|
+
value: "/"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Using the store class:
|
|
27
|
+
```typescript
|
|
28
|
+
import { RDFStore } from "prez-lib";
|
|
29
|
+
|
|
30
|
+
const data = "<https://example.com/subject> <https://example.com/predicate> <https://example.com/object> .";
|
|
31
|
+
const store = new RDFStore();
|
|
32
|
+
store.load(data);
|
|
33
|
+
const data = store.getItem();
|
|
34
|
+
```
|
package/dist/consts.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { PrezPrefixes } from './types';
|
|
2
|
+
export declare const DEFAULT_PREFIXES: PrezPrefixes;
|
|
3
|
+
export declare const PREZ_PREDICATES: {
|
|
4
|
+
namespace: string;
|
|
5
|
+
label: string;
|
|
6
|
+
description: string;
|
|
7
|
+
provenance: string;
|
|
8
|
+
focusNode: string;
|
|
9
|
+
link: string;
|
|
10
|
+
members: string;
|
|
11
|
+
identifier: string;
|
|
12
|
+
count: string;
|
|
13
|
+
searchResult: string;
|
|
14
|
+
searchResultWeight: string;
|
|
15
|
+
searchResultPredicate: string;
|
|
16
|
+
searchResultURI: string;
|
|
17
|
+
searchResultMatch: string;
|
|
18
|
+
hasChildren: string;
|
|
19
|
+
};
|
|
20
|
+
export declare const SYSTEM_PREDICATES: {
|
|
21
|
+
skosConceptScheme: string;
|
|
22
|
+
skosConcept: string;
|
|
23
|
+
a: string;
|
|
24
|
+
rdfLangString: string;
|
|
25
|
+
xmlString: string;
|
|
26
|
+
w3Html: string;
|
|
27
|
+
w3Markdown: string;
|
|
28
|
+
shaclAllPredicates: string;
|
|
29
|
+
shaclProperty: string;
|
|
30
|
+
shaclPath: string;
|
|
31
|
+
shaclUnion: string;
|
|
32
|
+
};
|
|
33
|
+
export declare const ANNOTATION_PREDICATES: {
|
|
34
|
+
label: string[];
|
|
35
|
+
description: string[];
|
|
36
|
+
provenance: string[];
|
|
37
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PrezNode, PrezLiteral, PrezBlankNode, PrezTerm } from './types';
|
|
2
|
+
export declare function isTypePrezTerm(obj: any): obj is PrezTerm;
|
|
3
|
+
export declare function node(objOrValue: Omit<PrezNode, "termType" | "equals"> | string): PrezNode;
|
|
4
|
+
export declare function literal(objOrValue: Omit<PrezLiteral, "termType" | "equals"> | string): PrezLiteral;
|
|
5
|
+
export declare function bnode(objOrValue: Omit<PrezBlankNode, "termType" | "equals"> | string): PrezBlankNode;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { PrezPrefixes, PrezConceptNode, PrezFocusNode } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Interprets a predicate curie into its full IRI
|
|
4
|
+
*
|
|
5
|
+
* Uses the default list of prefixes by default
|
|
6
|
+
*
|
|
7
|
+
* @param s
|
|
8
|
+
* @param prefixes
|
|
9
|
+
* @returns Predicate IRI string
|
|
10
|
+
*/
|
|
11
|
+
export declare function defaultToIri(s: string, prefixes?: PrezPrefixes): string;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a curie from an IRI
|
|
14
|
+
*
|
|
15
|
+
* Uses the default list of prefixes by default
|
|
16
|
+
*
|
|
17
|
+
* @param iri
|
|
18
|
+
* @param prefixes
|
|
19
|
+
* @returns curie string
|
|
20
|
+
*/
|
|
21
|
+
export declare function defaultFromIri(iri: string, prefixes?: PrezPrefixes): string;
|
|
22
|
+
/**
|
|
23
|
+
* Get the base URL from a URL, protocol & host
|
|
24
|
+
*
|
|
25
|
+
* @param existingUrl existing URL to determine the base from
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
export declare const getBaseUrl: (existingUrl: string) => string;
|
|
29
|
+
/**
|
|
30
|
+
* Get the URL path (minus the protocol & host) from a full URL
|
|
31
|
+
*
|
|
32
|
+
*
|
|
33
|
+
* @param existingUrl existing URL to determine the base from
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
export declare const getUrlPath: (existingUrl: string) => string;
|
|
37
|
+
/**
|
|
38
|
+
* Get the narrowers URL for a hierarchy based on an a concept and existing URL context
|
|
39
|
+
*
|
|
40
|
+
* @param concept
|
|
41
|
+
* @param existingUrl
|
|
42
|
+
* @returns
|
|
43
|
+
*/
|
|
44
|
+
export declare const getNarrowersUrl: (baseUrl: string, concept: PrezConceptNode) => string;
|
|
45
|
+
/**
|
|
46
|
+
* Get the top concepts for a given focus node
|
|
47
|
+
*
|
|
48
|
+
* @param item
|
|
49
|
+
* @param existingOrBaseUrl to use for prefixing
|
|
50
|
+
* @returns
|
|
51
|
+
*/
|
|
52
|
+
export declare const getTopConceptsUrl: (item: PrezFocusNode, existingOrBaseUrl?: string) => string;
|
|
53
|
+
type PathElement = {
|
|
54
|
+
"@id"?: string;
|
|
55
|
+
"@list"?: PathElement[];
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Process a SHACL path to get the full list of predicates
|
|
59
|
+
*
|
|
60
|
+
* @param path
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
export declare const processShaclPath: (path: PathElement[]) => string[];
|
|
64
|
+
/**
|
|
65
|
+
* Build a profile object from a list of profiles
|
|
66
|
+
*
|
|
67
|
+
* @param data - list of profiles in json-ld format
|
|
68
|
+
* @returns
|
|
69
|
+
*/
|
|
70
|
+
export declare const buildProfiles: (data: any[]) => Record<string, string[]>;
|
|
71
|
+
/** this function is used to construct a simple object to show profile info in the debug panel */
|
|
72
|
+
export declare function simplifyNodeArray(input: any): any;
|
|
73
|
+
export declare function nodeArrayToTree(obj: any, prefix?: string): string;
|
|
74
|
+
/** this function is used to dump a profile node array into a simple string tree */
|
|
75
|
+
export declare function dumpNodeArray(obj: any): string;
|
|
76
|
+
export {};
|