ldkit 0.7.0 → 0.8.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/esm/library/rdf.js +1 -1
- package/package.json +36 -16
- package/types/library/asynciterator.d.ts +3 -3
- package/types/library/decoder.d.ts +1 -1
- package/types/library/encoder.d.ts +1 -1
- package/types/library/engine/query_engine.d.ts +1 -1
- package/types/library/lens/types.d.ts +2 -2
- package/types/library/namespaces/namespace.d.ts +4 -4
- package/types/library/rdf.d.ts +6 -6
- package/types/library/schema/data_types.d.ts +2 -2
- package/types/library/schema/interface.d.ts +13 -13
- package/types/library/schema/schema.d.ts +7 -7
- package/types/library/sparql/sparql_query_builders.d.ts +1 -1
- package/types/library/sparql/sparql_shared_builders.d.ts +1 -1
- package/types/library/sparql/sparql_tag.d.ts +1 -1
- package/types/library/sparql/sparql_update_builders.d.ts +1 -1
package/esm/library/rdf.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { fromRdf, toRdf } from "rdf-literal";
|
|
2
|
-
import { DataFactory, DefaultGraph
|
|
2
|
+
import { DataFactory, DefaultGraph } from "rdf-data-factory";
|
|
3
3
|
export { DataFactory, DefaultGraph };
|
|
4
4
|
export const quadsToGraph = (quads) => {
|
|
5
5
|
const graph = new Map();
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"main": "./script/mod.js",
|
|
4
4
|
"types": "./types/mod.d.ts",
|
|
5
5
|
"name": "ldkit",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.8.0",
|
|
7
7
|
"description": "LDkit, a Linked Data query toolkit for TypeScript developers",
|
|
8
8
|
"homepage": "https://ldkit.io",
|
|
9
9
|
"author": "Karel Klima <karelklima@gmail.com> (https://karelklima.com)",
|
|
@@ -23,31 +23,51 @@
|
|
|
23
23
|
},
|
|
24
24
|
"exports": {
|
|
25
25
|
".": {
|
|
26
|
-
"import":
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
"import": {
|
|
27
|
+
"types": "./types/mod.d.ts",
|
|
28
|
+
"default": "./esm/mod.js"
|
|
29
|
+
},
|
|
30
|
+
"require": {
|
|
31
|
+
"types": "./types/mod.d.ts",
|
|
32
|
+
"default": "./script/mod.js"
|
|
33
|
+
}
|
|
29
34
|
},
|
|
30
35
|
"./namespaces": {
|
|
31
|
-
"import":
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
"import": {
|
|
37
|
+
"types": "./types/namespaces.d.ts",
|
|
38
|
+
"default": "./esm/namespaces.js"
|
|
39
|
+
},
|
|
40
|
+
"require": {
|
|
41
|
+
"types": "./types/namespaces.d.ts",
|
|
42
|
+
"default": "./script/namespaces.js"
|
|
43
|
+
}
|
|
34
44
|
},
|
|
35
45
|
"./rdf": {
|
|
36
|
-
"import":
|
|
37
|
-
|
|
38
|
-
|
|
46
|
+
"import": {
|
|
47
|
+
"types": "./types/rdf.d.ts",
|
|
48
|
+
"default": "./esm/rdf.js"
|
|
49
|
+
},
|
|
50
|
+
"require": {
|
|
51
|
+
"types": "./types/rdf.d.ts",
|
|
52
|
+
"default": "./script/rdf.js"
|
|
53
|
+
}
|
|
39
54
|
},
|
|
40
55
|
"./sparql": {
|
|
41
|
-
"import":
|
|
42
|
-
|
|
43
|
-
|
|
56
|
+
"import": {
|
|
57
|
+
"types": "./types/sparql.d.ts",
|
|
58
|
+
"default": "./esm/sparql.js"
|
|
59
|
+
},
|
|
60
|
+
"require": {
|
|
61
|
+
"types": "./types/sparql.d.ts",
|
|
62
|
+
"default": "./script/sparql.js"
|
|
63
|
+
}
|
|
44
64
|
}
|
|
45
65
|
},
|
|
46
66
|
"dependencies": {
|
|
47
|
-
"@comunica/types": "2.
|
|
48
|
-
"asynciterator": "3.
|
|
67
|
+
"@comunica/types": "2.6.8",
|
|
68
|
+
"asynciterator": "3.8.0",
|
|
49
69
|
"rdf-data-factory": "1.1.1",
|
|
50
70
|
"rdf-js": "4.0.2",
|
|
51
|
-
"rdf-literal": "1.3.
|
|
71
|
+
"rdf-literal": "1.3.1"
|
|
52
72
|
}
|
|
53
73
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { AsyncIterator } from "asynciterator";
|
|
2
2
|
export { ArrayIterator, type AsyncIterator, MappingIterator, } from "asynciterator";
|
|
3
|
-
|
|
3
|
+
type TreeNode<T> = {
|
|
4
4
|
[property: string]: T[] | TreeNode<T>;
|
|
5
5
|
};
|
|
6
|
-
export
|
|
7
|
-
|
|
6
|
+
export type Tree<T> = T[] | TreeNode<T>;
|
|
7
|
+
type Subtree<T> = {
|
|
8
8
|
type: "node";
|
|
9
9
|
tree: TreeNode<T>;
|
|
10
10
|
parent?: Subtree<T>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Context, Graph } from "./rdf.js";
|
|
2
2
|
import type { Schema } from "./schema/mod.js";
|
|
3
|
-
|
|
3
|
+
type DecodedNode = Record<string, unknown>;
|
|
4
4
|
export declare const decode: (graph: Graph, schema: Schema, context: Context) => DecodedNode[];
|
|
5
5
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Context, type RDF } from "./rdf.js";
|
|
2
2
|
import type { Schema } from "./schema/mod.js";
|
|
3
|
-
|
|
3
|
+
type DecodedNode = Record<string, unknown>;
|
|
4
4
|
export declare const encode: (node: DecodedNode, schema: Schema, context: Context, variableInitCounter?: number) => RDF.Quad[];
|
|
5
5
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Context, type IQueryEngine, type RDF, RDFJSON } from "../rdf.js";
|
|
2
|
-
|
|
2
|
+
type QueryResponseFormat = {
|
|
3
3
|
"application/sparql-results+json": RDFJSON.SparqlResultsJsonFormat;
|
|
4
4
|
"application/rdf+json": RDFJSON.RdfJsonFormat;
|
|
5
5
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SchemaInterfaceIdentity } from "../schema/mod.js";
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type Entity<T extends unknown = Record<string, unknown>> = DeepPartial<T> & SchemaInterfaceIdentity;
|
|
3
|
+
export type DeepPartial<T> = T extends Record<string, unknown> ? {
|
|
4
4
|
[P in keyof T]?: DeepPartial<T[P]>;
|
|
5
5
|
} : T;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
type NamespacePrototype = {
|
|
2
2
|
iri: string;
|
|
3
3
|
prefix: string;
|
|
4
4
|
terms: readonly string[];
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
type NamespacePrefix<Namespace extends NamespacePrototype> = Namespace["prefix"];
|
|
7
|
+
type NamespaceIri<Namespace extends NamespacePrototype> = Namespace["iri"];
|
|
8
|
+
type NamespaceObject<Namespace extends NamespacePrototype> = {
|
|
9
9
|
[Term in Namespace["terms"][number]]: `${NamespacePrefix<Namespace>}${Term}`;
|
|
10
10
|
};
|
|
11
11
|
export declare const createNamespace: <N extends NamespacePrototype, I = NamespaceIri<N>, P = NamespacePrefix<N>, O = NamespaceObject<N>>(namespaceSpec: N) => O & {
|
package/types/library/rdf.d.ts
CHANGED
|
@@ -4,15 +4,15 @@ export { fromRdf, toRdf } from "rdf-literal";
|
|
|
4
4
|
import { DataFactory, DefaultGraph } from "rdf-data-factory";
|
|
5
5
|
export { DataFactory, DefaultGraph };
|
|
6
6
|
import type { IDataSource, IQueryContextCommon } from "@comunica/types";
|
|
7
|
-
export
|
|
7
|
+
export type LDkitContext = {
|
|
8
8
|
graph?: string;
|
|
9
9
|
language?: string;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
11
|
+
export type Context = LDkitContext & RDF.QueryStringContext & RDF.QuerySourceContext<IDataSource> & IQueryContextCommon;
|
|
12
|
+
export type IQueryEngine = RDF.StringSparqlQueryable<RDF.SparqlResultSupport, Context>;
|
|
13
|
+
export type Iri = string;
|
|
14
|
+
export type Node = Map<Iri, RDF.Term[]>;
|
|
15
|
+
export type Graph = Map<Iri, Node>;
|
|
16
16
|
export declare const quadsToGraph: (quads: RDF.Quad[]) => Graph;
|
|
17
17
|
export declare namespace RDFJSON {
|
|
18
18
|
type Term = {
|
|
@@ -34,6 +34,6 @@ declare const SupportedDataTypesPrototype: {
|
|
|
34
34
|
"xsd:hexBinary": string;
|
|
35
35
|
"rdf:langString": string;
|
|
36
36
|
};
|
|
37
|
-
export
|
|
38
|
-
export
|
|
37
|
+
export type SupportedDataTypes = typeof SupportedDataTypesPrototype;
|
|
38
|
+
export type SupportedNativeTypes = SupportedDataTypes[keyof SupportedDataTypes];
|
|
39
39
|
export {};
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import type { SupportedDataTypes } from "./data_types.js";
|
|
2
2
|
import type { PropertyPrototype, SchemaPrototype } from "./schema.js";
|
|
3
|
-
|
|
3
|
+
type IsOptional<Property extends PropertyPrototype> = Property extends {
|
|
4
4
|
"@optional": true;
|
|
5
5
|
} ? true : false;
|
|
6
|
-
|
|
6
|
+
type IsArray<Property extends PropertyPrototype> = Property extends {
|
|
7
7
|
"@array": true;
|
|
8
8
|
} ? true : false;
|
|
9
|
-
|
|
9
|
+
type IsMultilang<Property extends PropertyPrototype> = Property extends {
|
|
10
10
|
"@multilang": true;
|
|
11
11
|
} ? true : false;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
type ValidPropertyDefinition = PropertyPrototype | string;
|
|
13
|
+
type ConvertPropertyType<T extends PropertyPrototype> = T extends {
|
|
14
14
|
"@context": SchemaPrototype;
|
|
15
15
|
} ? SchemaInterface<T["@context"]> : T extends {
|
|
16
16
|
"@type": unknown;
|
|
17
17
|
} ? T["@type"] extends keyof SupportedDataTypes ? SupportedDataTypes[T["@type"]] : never : string;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export
|
|
18
|
+
type ConvertPropertyOptional<T extends PropertyPrototype> = IsOptional<T> extends true ? ConvertPropertyType<T> | undefined : ConvertPropertyType<T>;
|
|
19
|
+
type ConvertPropertyArray<T extends PropertyPrototype> = IsArray<T> extends true ? ConvertPropertyType<T>[] : ConvertPropertyOptional<T>;
|
|
20
|
+
type ConvertPropertyMultilang<T extends PropertyPrototype> = IsMultilang<T> extends true ? IsArray<T> extends true ? Record<string, ConvertPropertyType<T>[]> : Record<string, ConvertPropertyType<T>> : ConvertPropertyArray<T>;
|
|
21
|
+
type ConvertPropertyObject<T extends PropertyPrototype> = ConvertPropertyMultilang<T>;
|
|
22
|
+
type ConvertProperty<T extends ValidPropertyDefinition> = T extends PropertyPrototype ? ConvertPropertyObject<T> : string;
|
|
23
|
+
export type SchemaInterfaceIdentity = {
|
|
24
24
|
$id: string;
|
|
25
25
|
};
|
|
26
|
-
export
|
|
26
|
+
export type SchemaInterfaceType = {
|
|
27
27
|
$type: string[];
|
|
28
28
|
};
|
|
29
|
-
export
|
|
29
|
+
export type SchemaInterface<T extends SchemaPrototype> = {
|
|
30
30
|
[X in Exclude<keyof T, "@type">]: T[X] extends ValidPropertyDefinition ? ConvertProperty<T[X]> : never;
|
|
31
31
|
} & SchemaInterfaceIdentity & SchemaInterfaceType;
|
|
32
32
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SupportedDataTypes } from "./data_types.js";
|
|
2
|
-
|
|
3
|
-
export
|
|
2
|
+
type PropertyType = keyof SupportedDataTypes;
|
|
3
|
+
export type PropertyPrototype = {
|
|
4
4
|
"@id": string;
|
|
5
5
|
"@type"?: PropertyType;
|
|
6
6
|
"@context"?: SchemaPrototype;
|
|
@@ -8,14 +8,14 @@ export declare type PropertyPrototype = {
|
|
|
8
8
|
"@array"?: true;
|
|
9
9
|
"@multilang"?: true;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export type SchemaPrototypeProperties = {
|
|
12
12
|
[key: string]: PropertyPrototype | string | readonly string[];
|
|
13
13
|
};
|
|
14
|
-
export
|
|
14
|
+
export type SchemaPrototypeType = {
|
|
15
15
|
"@type": string | readonly string[];
|
|
16
16
|
};
|
|
17
|
-
export
|
|
18
|
-
export
|
|
17
|
+
export type SchemaPrototype = SchemaPrototypeProperties & SchemaPrototypeType;
|
|
18
|
+
export type Property = {
|
|
19
19
|
"@id": string;
|
|
20
20
|
"@type"?: PropertyType;
|
|
21
21
|
"@context"?: Schema;
|
|
@@ -23,7 +23,7 @@ export declare type Property = {
|
|
|
23
23
|
"@array"?: true;
|
|
24
24
|
"@multilang"?: true;
|
|
25
25
|
};
|
|
26
|
-
export
|
|
26
|
+
export type Schema = {
|
|
27
27
|
[key: string]: Property | string[];
|
|
28
28
|
"@type": string[];
|
|
29
29
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SparqlBuilder } from "./sparql_shared_builders.js";
|
|
2
2
|
import { type RDF } from "../rdf.js";
|
|
3
3
|
import { type SparqlValue } from "./sparql_tag.js";
|
|
4
|
-
|
|
4
|
+
type Builders<T extends keyof SparqlQueryBuilder> = Pick<SparqlQueryBuilder, T>;
|
|
5
5
|
declare class SparqlQueryBuilder extends SparqlBuilder {
|
|
6
6
|
OFFSET(number: number): Builders<"build">;
|
|
7
7
|
LIMIT(number: number): Builders<"build" | "OFFSET">;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DataFactory, RDF } from "../rdf.js";
|
|
2
2
|
import { type SparqlValue } from "./sparql_tag.js";
|
|
3
|
-
|
|
3
|
+
type Wrap = (keyword: string, value: string) => string;
|
|
4
4
|
export declare const braces: Wrap;
|
|
5
5
|
export declare const parentheses: Wrap;
|
|
6
6
|
export declare abstract class SparqlBuilder {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type RDF } from "../rdf.js";
|
|
2
|
-
export
|
|
2
|
+
export type SparqlValue = RDF.Term | string | number | boolean | Date | Iterable<SparqlValue> | null | undefined;
|
|
3
3
|
export declare const sparql: (strings: TemplateStringsArray, ...values: SparqlValue[]) => string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SparqlBuilder } from "./sparql_shared_builders.js";
|
|
2
2
|
import { type RDF } from "../rdf.js";
|
|
3
3
|
import { type SparqlValue } from "./sparql_tag.js";
|
|
4
|
-
|
|
4
|
+
type Builders<T extends keyof SparqlUpdateBuilder> = Pick<SparqlUpdateBuilder, T>;
|
|
5
5
|
declare class SparqlUpdateBuilder extends SparqlBuilder {
|
|
6
6
|
WHERE(strings: TemplateStringsArray, ...values: SparqlValue[]): Builders<"build">;
|
|
7
7
|
USING_NAMED(stringOrNamedNode: string | RDF.NamedNode<string>): Builders<"USING_NAMED" | "WHERE">;
|