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.
@@ -1,5 +1,5 @@
1
1
  export { fromRdf, toRdf } from "rdf-literal";
2
- import { DataFactory, DefaultGraph, } from "rdf-data-factory";
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.7.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": "./esm/mod.js",
27
- "require": "./script/mod.js",
28
- "types": "./types/mod.d.ts"
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": "./esm/namespaces.js",
32
- "require": "./script/namespaces.js",
33
- "types": "./types/namespaces.d.ts"
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": "./esm/rdf.js",
37
- "require": "./script/rdf.js",
38
- "types": "./types/rdf.d.ts"
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": "./esm/sparql.js",
42
- "require": "./script/sparql.js",
43
- "types": "./types/sparql.d.ts"
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.4.0",
48
- "asynciterator": "3.7.0",
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.0"
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
- declare type TreeNode<T> = {
3
+ type TreeNode<T> = {
4
4
  [property: string]: T[] | TreeNode<T>;
5
5
  };
6
- export declare type Tree<T> = T[] | TreeNode<T>;
7
- declare type Subtree<T> = {
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
- declare type DecodedNode = Record<string, unknown>;
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
- declare type DecodedNode = Record<string, unknown>;
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
- declare type QueryResponseFormat = {
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 declare type Entity<T extends unknown = Record<string, unknown>> = DeepPartial<T> & SchemaInterfaceIdentity;
3
- export declare type DeepPartial<T> = T extends Record<string, unknown> ? {
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
- declare type NamespacePrototype = {
1
+ type NamespacePrototype = {
2
2
  iri: string;
3
3
  prefix: string;
4
4
  terms: readonly string[];
5
5
  };
6
- declare type NamespacePrefix<Namespace extends NamespacePrototype> = Namespace["prefix"];
7
- declare type NamespaceIri<Namespace extends NamespacePrototype> = Namespace["iri"];
8
- declare type NamespaceObject<Namespace extends NamespacePrototype> = {
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 & {
@@ -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 declare type LDkitContext = {
7
+ export type LDkitContext = {
8
8
  graph?: string;
9
9
  language?: string;
10
10
  };
11
- export declare type Context = LDkitContext & RDF.QueryStringContext & RDF.QuerySourceContext<IDataSource> & IQueryContextCommon;
12
- export declare type IQueryEngine = RDF.StringSparqlQueryable<RDF.SparqlResultSupport, Context>;
13
- export declare type Iri = string;
14
- export declare type Node = Map<Iri, RDF.Term[]>;
15
- export declare type Graph = Map<Iri, Node>;
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 declare type SupportedDataTypes = typeof SupportedDataTypesPrototype;
38
- export declare type SupportedNativeTypes = SupportedDataTypes[keyof SupportedDataTypes];
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
- declare type IsOptional<Property extends PropertyPrototype> = Property extends {
3
+ type IsOptional<Property extends PropertyPrototype> = Property extends {
4
4
  "@optional": true;
5
5
  } ? true : false;
6
- declare type IsArray<Property extends PropertyPrototype> = Property extends {
6
+ type IsArray<Property extends PropertyPrototype> = Property extends {
7
7
  "@array": true;
8
8
  } ? true : false;
9
- declare type IsMultilang<Property extends PropertyPrototype> = Property extends {
9
+ type IsMultilang<Property extends PropertyPrototype> = Property extends {
10
10
  "@multilang": true;
11
11
  } ? true : false;
12
- declare type ValidPropertyDefinition = PropertyPrototype | string;
13
- declare type ConvertPropertyType<T extends PropertyPrototype> = T extends {
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
- declare type ConvertPropertyOptional<T extends PropertyPrototype> = IsOptional<T> extends true ? ConvertPropertyType<T> | undefined : ConvertPropertyType<T>;
19
- declare type ConvertPropertyArray<T extends PropertyPrototype> = IsArray<T> extends true ? ConvertPropertyType<T>[] : ConvertPropertyOptional<T>;
20
- declare type ConvertPropertyMultilang<T extends PropertyPrototype> = IsMultilang<T> extends true ? IsArray<T> extends true ? Record<string, ConvertPropertyType<T>[]> : Record<string, ConvertPropertyType<T>> : ConvertPropertyArray<T>;
21
- declare type ConvertPropertyObject<T extends PropertyPrototype> = ConvertPropertyMultilang<T>;
22
- declare type ConvertProperty<T extends ValidPropertyDefinition> = T extends PropertyPrototype ? ConvertPropertyObject<T> : string;
23
- export declare type SchemaInterfaceIdentity = {
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 declare type SchemaInterfaceType = {
26
+ export type SchemaInterfaceType = {
27
27
  $type: string[];
28
28
  };
29
- export declare type SchemaInterface<T extends SchemaPrototype> = {
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
- declare type PropertyType = keyof SupportedDataTypes;
3
- export declare type PropertyPrototype = {
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 declare type SchemaPrototypeProperties = {
11
+ export type SchemaPrototypeProperties = {
12
12
  [key: string]: PropertyPrototype | string | readonly string[];
13
13
  };
14
- export declare type SchemaPrototypeType = {
14
+ export type SchemaPrototypeType = {
15
15
  "@type": string | readonly string[];
16
16
  };
17
- export declare type SchemaPrototype = SchemaPrototypeProperties & SchemaPrototypeType;
18
- export declare type Property = {
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 declare type Schema = {
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
- declare type Builders<T extends keyof SparqlQueryBuilder> = Pick<SparqlQueryBuilder, T>;
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
- declare type Wrap = (keyword: string, value: string) => string;
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 declare type SparqlValue = RDF.Term | string | number | boolean | Date | Iterable<SparqlValue> | null | undefined;
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
- declare type Builders<T extends keyof SparqlUpdateBuilder> = Pick<SparqlUpdateBuilder, T>;
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">;