@rdfx/builder 0.0.19

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.
@@ -0,0 +1,69 @@
1
+ import type { NamespaceBuilder } from "@rdfjs/namespace";
2
+ export declare function builder<NamespaceT extends NamespaceBuilder = NamespaceBuilder>(options?: {
3
+ namespace?: NamespaceT;
4
+ }): {
5
+ sh: {
6
+ PropertyShape: ($identifier: import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode<string> | keyof NamespaceT | undefined, parameters: Omit<{
7
+ readonly $identifier?: (() => import("./shapes.js").sh_PropertyShape.Identifier) | import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode | string;
8
+ readonly and?: readonly (import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode | string | undefined)[] | import("purify-ts").Maybe<readonly (import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode)[]>;
9
+ readonly classes?: string | import("@rdfjs/types").NamedNode | readonly (string | import("@rdfjs/types").NamedNode)[];
10
+ readonly comment?: string | import("purify-ts").Maybe<string>;
11
+ readonly datatype?: string | import("@rdfjs/types").NamedNode | import("purify-ts").Maybe<import("@rdfjs/types").NamedNode>;
12
+ readonly deactivated?: boolean | import("purify-ts").Maybe<boolean>;
13
+ readonly defaultValue?: (import("@rdfjs/types").NamedNode | import("@rdfjs/types").Literal) | import("purify-ts").Maybe<import("@rdfjs/types").NamedNode | import("@rdfjs/types").Literal>;
14
+ readonly description?: string | import("purify-ts").Maybe<string>;
15
+ readonly disjoint?: string | import("@rdfjs/types").NamedNode | readonly (string | import("@rdfjs/types").NamedNode)[];
16
+ readonly display?: boolean;
17
+ readonly equals?: string | import("@rdfjs/types").NamedNode | readonly (string | import("@rdfjs/types").NamedNode)[];
18
+ readonly flags?: string | import("purify-ts").Maybe<string>;
19
+ readonly groups?: import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode | string | readonly (import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode | string | undefined)[];
20
+ readonly hasValues?: (import("@rdfjs/types").NamedNode | import("@rdfjs/types").Literal) | readonly (import("@rdfjs/types").NamedNode | import("@rdfjs/types").Literal)[];
21
+ readonly ignore?: boolean;
22
+ readonly in_?: readonly (import("@rdfjs/types").NamedNode | import("@rdfjs/types").Literal)[] | import("purify-ts").Maybe<readonly (import("@rdfjs/types").NamedNode | import("@rdfjs/types").Literal)[]>;
23
+ readonly isDefinedBy?: import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode | string | import("purify-ts").Maybe<import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode>;
24
+ readonly label?: string | import("purify-ts").Maybe<string>;
25
+ readonly languageIn?: readonly string[] | import("purify-ts").Maybe<readonly string[]>;
26
+ readonly lessThan?: string | import("@rdfjs/types").NamedNode | readonly (string | import("@rdfjs/types").NamedNode)[];
27
+ readonly lessThanOrEquals?: string | import("@rdfjs/types").NamedNode | readonly (string | import("@rdfjs/types").NamedNode)[];
28
+ readonly maxCount?: bigint | import("purify-ts").Maybe<bigint>;
29
+ readonly maxExclusive?: bigint | boolean | number | string | Date | import("@rdfjs/types").Literal | import("purify-ts").Maybe<import("@rdfjs/types").Literal>;
30
+ readonly maxInclusive?: bigint | boolean | number | string | Date | import("@rdfjs/types").Literal | import("purify-ts").Maybe<import("@rdfjs/types").Literal>;
31
+ readonly maxLength?: bigint | import("purify-ts").Maybe<bigint>;
32
+ readonly message?: string | import("purify-ts").Maybe<string>;
33
+ readonly minCount?: bigint | import("purify-ts").Maybe<bigint>;
34
+ readonly minExclusive?: bigint | boolean | number | string | Date | import("@rdfjs/types").Literal | import("purify-ts").Maybe<import("@rdfjs/types").Literal>;
35
+ readonly minInclusive?: bigint | boolean | number | string | Date | import("@rdfjs/types").Literal | import("purify-ts").Maybe<import("@rdfjs/types").Literal>;
36
+ readonly minLength?: bigint | import("purify-ts").Maybe<bigint>;
37
+ readonly mutable?: boolean | import("purify-ts").Maybe<boolean>;
38
+ readonly name?: string | import("purify-ts").Maybe<string>;
39
+ readonly node?: import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode | string | import("purify-ts").Maybe<import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode>;
40
+ readonly nodeKind?: ("http://www.w3.org/ns/shacl#BlankNode" | "http://www.w3.org/ns/shacl#BlankNodeOrIRI" | "http://www.w3.org/ns/shacl#BlankNodeOrLiteral" | "http://www.w3.org/ns/shacl#IRI" | "http://www.w3.org/ns/shacl#IRIOrLiteral" | "http://www.w3.org/ns/shacl#Literal") | import("@rdfjs/types").NamedNode<"http://www.w3.org/ns/shacl#BlankNode" | "http://www.w3.org/ns/shacl#BlankNodeOrIRI" | "http://www.w3.org/ns/shacl#BlankNodeOrLiteral" | "http://www.w3.org/ns/shacl#IRI" | "http://www.w3.org/ns/shacl#IRIOrLiteral" | "http://www.w3.org/ns/shacl#Literal"> | import("purify-ts").Maybe<import("@rdfjs/types").NamedNode<"http://www.w3.org/ns/shacl#BlankNode" | "http://www.w3.org/ns/shacl#BlankNodeOrIRI" | "http://www.w3.org/ns/shacl#BlankNodeOrLiteral" | "http://www.w3.org/ns/shacl#IRI" | "http://www.w3.org/ns/shacl#IRIOrLiteral" | "http://www.w3.org/ns/shacl#Literal">>;
41
+ readonly not?: import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode | string | readonly (import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode | string | undefined)[];
42
+ readonly or?: readonly (import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode | string | undefined)[] | import("purify-ts").Maybe<readonly (import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode)[]>;
43
+ readonly order?: number | import("purify-ts").Maybe<number>;
44
+ readonly path: import("./shapes.js").$PropertyPath;
45
+ readonly pattern?: string | import("purify-ts").Maybe<string>;
46
+ readonly qualifiedMaxCount?: bigint | import("purify-ts").Maybe<bigint>;
47
+ readonly qualifiedMinCount?: bigint | import("purify-ts").Maybe<bigint>;
48
+ readonly qualifiedValueShape?: import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode | string | import("purify-ts").Maybe<import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode>;
49
+ readonly qualifiedValueShapesDisjoint?: boolean | import("purify-ts").Maybe<boolean>;
50
+ readonly resolve?: import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode | string | import("purify-ts").Maybe<import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode>;
51
+ readonly severity?: ("http://www.w3.org/ns/shacl#Info" | "http://www.w3.org/ns/shacl#Warning" | "http://www.w3.org/ns/shacl#Violation") | import("./shapes.js").sh_Severity | import("purify-ts").Maybe<import("./shapes.js").sh_Severity>;
52
+ readonly shaclmateName?: string | import("purify-ts").Maybe<string>;
53
+ readonly targetClasses?: string | import("@rdfjs/types").NamedNode | readonly (string | import("@rdfjs/types").NamedNode)[];
54
+ readonly targetNodes?: (import("@rdfjs/types").NamedNode | import("@rdfjs/types").Literal) | readonly (import("@rdfjs/types").NamedNode | import("@rdfjs/types").Literal)[];
55
+ readonly targetObjectsOf?: string | import("@rdfjs/types").NamedNode | readonly (string | import("@rdfjs/types").NamedNode)[];
56
+ readonly targetSubjectsOf?: string | import("@rdfjs/types").NamedNode | readonly (string | import("@rdfjs/types").NamedNode)[];
57
+ readonly uniqueLang?: boolean | import("purify-ts").Maybe<boolean>;
58
+ readonly xone?: readonly (import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode | string | undefined)[] | import("purify-ts").Maybe<readonly (import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode)[]>;
59
+ }, "$identifier" | "classes" | "in_" | "node" | "maxCount" | "minCount" | "path" | "resolve"> & {
60
+ readonly cardinality: "optional" | "required" | "set";
61
+ readonly classes?: readonly (import("@rdfjs/types").NamedNode<string> | keyof NamespaceT)[] | undefined;
62
+ readonly in_?: readonly (import("@rdfjs/types").NamedNode | import("@rdfjs/types").Literal)[] | readonly bigint[] | readonly boolean[] | readonly number[] | readonly string[];
63
+ readonly node?: import("@rdfjs/types").NamedNode<string> | keyof NamespaceT | undefined;
64
+ readonly path?: import("@rdfx/resource").PropertyPath | keyof NamespaceT | undefined;
65
+ readonly resolve?: import("@rdfjs/types").NamedNode<string> | keyof NamespaceT | undefined;
66
+ }) => ReturnType<typeof import("./shapes.js").sh_PropertyShape.createUnsafe>;
67
+ };
68
+ };
69
+ //# sourceMappingURL=builder.d.ts.map
@@ -0,0 +1,9 @@
1
+ import namespace from "@rdfjs/namespace";
2
+ import { sh } from "./sh.js";
3
+ export function builder(options) {
4
+ const namespace_ = (options?.namespace ?? namespace(""));
5
+ return {
6
+ sh: sh({ namespace: namespace_ }),
7
+ };
8
+ }
9
+ //# sourceMappingURL=builder.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
package/dist/sh.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ import type { NamespaceBuilder } from "@rdfjs/namespace";
2
+ import type { BlankNode, Literal, NamedNode } from "@rdfjs/types";
3
+ import type { PropertyPath } from "@rdfx/resource";
4
+ import { sh_PropertyShape } from "./shapes.js";
5
+ export declare function sh<NamespaceT extends NamespaceBuilder>({ namespace, }: {
6
+ namespace: NamespaceT;
7
+ }): {
8
+ PropertyShape: ($identifier: BlankNode | NamedNode | keyof NamespaceT | undefined, parameters: Omit<NonNullable<Parameters<typeof sh_PropertyShape.createUnsafe>[0]>, "$identifier" | "classes" | "in_" | "maxCount" | "minCount" | "node" | "path" | "resolve"> & {
9
+ readonly cardinality: "optional" | "required" | "set";
10
+ readonly classes?: readonly (NamedNode | keyof NamespaceT)[];
11
+ readonly in_?: readonly (NamedNode | Literal)[] | readonly bigint[] | readonly boolean[] | readonly number[] | readonly string[];
12
+ readonly node?: NamedNode | keyof NamespaceT;
13
+ readonly path?: PropertyPath | keyof NamespaceT;
14
+ readonly resolve?: NamedNode | keyof NamespaceT;
15
+ }) => ReturnType<typeof sh_PropertyShape.createUnsafe>;
16
+ };
17
+ //# sourceMappingURL=sh.d.ts.map
package/dist/sh.js ADDED
@@ -0,0 +1,89 @@
1
+ import dataFactory from "@rdfx/data-factory";
2
+ import { sh_PropertyShape } from "./shapes.js";
3
+ import { toIri } from "./toIri.js";
4
+ export function sh({ namespace, }) {
5
+ return {
6
+ PropertyShape: ($identifier, parameters) => {
7
+ // Order of default population matters here.
8
+ const { cardinality: cardinalityParameter, classes: classesParameter, in_: inParameter, path: pathParameter, node: nodeParameter, resolve: resolveParameter, ...otherParameters } = parameters;
9
+ let $identifierTerm;
10
+ switch (typeof $identifier) {
11
+ case "object":
12
+ $identifierTerm = $identifier;
13
+ break;
14
+ case "string":
15
+ $identifierTerm = toIri($identifier, namespace);
16
+ break;
17
+ case "undefined":
18
+ $identifierTerm = dataFactory.blankNode();
19
+ break;
20
+ default:
21
+ throw new RangeError(typeof $identifier);
22
+ }
23
+ let in_;
24
+ // let inConceptScheme: ConceptScheme<any> | undefined;
25
+ // if (inParameter) {
26
+ // if (Array.isArray(inParameter)) {
27
+ // in_ = inParameter;
28
+ // } else {
29
+ // inConceptScheme = inParameter as ConceptScheme<any>;
30
+ // in_ = Object.values(inConceptScheme.concepts).map(
31
+ // (concept) => concept.identifier,
32
+ // );
33
+ // }
34
+ // }
35
+ let path;
36
+ switch (typeof pathParameter) {
37
+ case "object":
38
+ path = pathParameter;
39
+ break;
40
+ case "string":
41
+ path = toIri(pathParameter, namespace);
42
+ break;
43
+ case "undefined":
44
+ if ($identifierTerm.termType === "BlankNode") {
45
+ throw new Error("must specify a path if identifier is a BlankNode/undefined");
46
+ }
47
+ path = $identifierTerm;
48
+ break;
49
+ default:
50
+ throw new RangeError(typeof pathParameter);
51
+ }
52
+ let maxCount;
53
+ let minCount;
54
+ switch (cardinalityParameter) {
55
+ case "optional":
56
+ maxCount = 1n;
57
+ break;
58
+ case "required":
59
+ maxCount = 1n;
60
+ minCount = 1n;
61
+ break;
62
+ case "set":
63
+ break;
64
+ }
65
+ let classes;
66
+ if (parameters.classes) {
67
+ classes = parameters.classes.map((class_) => toIri(class_, namespace));
68
+ }
69
+ // else if (inConceptScheme) {
70
+ // classes = [(namespace as any)(inConceptScheme.className)];
71
+ // }
72
+ const finalParameters = {
73
+ ...otherParameters,
74
+ $identifier: $identifierTerm,
75
+ classes,
76
+ in_,
77
+ maxCount,
78
+ minCount,
79
+ node: nodeParameter ? toIri(nodeParameter, namespace) : undefined,
80
+ path,
81
+ resolve: resolveParameter
82
+ ? toIri(resolveParameter, namespace)
83
+ : undefined,
84
+ };
85
+ return sh_PropertyShape.createUnsafe(finalParameters);
86
+ },
87
+ };
88
+ }
89
+ //# sourceMappingURL=sh.js.map