ldkit 0.6.5 → 0.7.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/README.md +15 -15
- package/esm/library/global.js +2 -2
- package/esm/library/{resource/resource.js → lens/lens.js} +17 -2
- package/esm/library/lens/mod.js +1 -0
- package/esm/library/{resource → lens}/query_builder.js +0 -0
- package/esm/library/{resource → lens}/query_helper.js +0 -0
- package/esm/library/{resource → lens}/types.js +0 -0
- package/esm/library/sparql/sparql_query_builders.js +70 -32
- package/esm/library/sparql/sparql_shared_builders.js +42 -36
- package/esm/library/sparql/sparql_update_builders.js +32 -13
- package/esm/mod.js +1 -1
- package/package.json +1 -1
- package/script/library/global.js +2 -2
- package/script/library/{resource/resource.js → lens/lens.js} +20 -4
- package/script/library/lens/mod.js +6 -0
- package/script/library/{resource → lens}/query_builder.js +0 -0
- package/script/library/{resource → lens}/query_helper.js +0 -0
- package/script/library/{resource → lens}/types.js +0 -0
- package/script/library/sparql/sparql_query_builders.js +70 -31
- package/script/library/sparql/sparql_shared_builders.js +46 -41
- package/script/library/sparql/sparql_update_builders.js +32 -12
- package/script/mod.js +3 -2
- package/types/library/{resource/resource.d.ts → lens/lens.d.ts} +17 -2
- package/types/library/lens/mod.d.ts +1 -0
- package/types/library/{resource → lens}/query_builder.d.ts +0 -0
- package/types/library/{resource → lens}/query_helper.d.ts +0 -0
- package/types/library/{resource → lens}/types.d.ts +0 -0
- package/types/library/sparql/sparql_query_builders.d.ts +36 -1175
- package/types/library/sparql/sparql_shared_builders.d.ts +13 -11
- package/types/library/sparql/sparql_update_builders.d.ts +20 -129
- package/types/mod.d.ts +1 -1
- package/esm/library/resource/mod.js +0 -1
- package/script/library/resource/mod.js +0 -6
- package/types/library/resource/mod.d.ts +0 -1
|
@@ -1,47 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.SparqlBuilder = exports.parentheses = exports.braces = void 0;
|
|
4
4
|
const rdf_js_1 = require("../rdf.js");
|
|
5
5
|
const sparql_tag_js_1 = require("./sparql_tag.js");
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
6
|
+
const braces = (keyword, value) => `${keyword} {\n${value}\n}\n`;
|
|
7
|
+
exports.braces = braces;
|
|
8
|
+
const parentheses = (keyword, value) => `${keyword} (${value})\n`;
|
|
9
|
+
exports.parentheses = parentheses;
|
|
10
|
+
const none = (keyword, value) => `${keyword} ${value}\n`;
|
|
11
|
+
class SparqlBuilder {
|
|
12
|
+
constructor() {
|
|
13
|
+
Object.defineProperty(this, "value", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true,
|
|
17
|
+
value: ""
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(this, "dataFactory", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
configurable: true,
|
|
22
|
+
writable: true,
|
|
23
|
+
value: new rdf_js_1.DataFactory()
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
build() {
|
|
27
|
+
return this.value;
|
|
28
|
+
}
|
|
29
|
+
sparql(strings, ...values) {
|
|
30
|
+
return !values || values.length < 1
|
|
31
|
+
? (0, sparql_tag_js_1.sparql)(strings)
|
|
32
|
+
: (0, sparql_tag_js_1.sparql)(strings, ...values);
|
|
33
|
+
}
|
|
34
|
+
template(strings, values, keyword, wrap = none) {
|
|
35
|
+
const inputSparql = this.sparql(strings, ...values);
|
|
36
|
+
this.value += wrap(keyword, inputSparql);
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
namedNode(stringOrNamedNode, keyword, wrap = none) {
|
|
35
40
|
const namedNode = typeof stringOrNamedNode === "string"
|
|
36
|
-
?
|
|
41
|
+
? this.dataFactory.namedNode(stringOrNamedNode)
|
|
37
42
|
: stringOrNamedNode;
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
return
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
exports.
|
|
43
|
+
const inputSparql = this.sparql `${namedNode}`;
|
|
44
|
+
this.value += wrap(keyword, inputSparql);
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
number(number, keyword, wrap = none) {
|
|
48
|
+
this.value += wrap(keyword, number.toString());
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.SparqlBuilder = SparqlBuilder;
|
|
@@ -2,17 +2,37 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WITH = exports.DELETE = exports.INSERT = void 0;
|
|
4
4
|
const sparql_shared_builders_js_1 = require("./sparql_shared_builders.js");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
class SparqlUpdateBuilder extends sparql_shared_builders_js_1.SparqlBuilder {
|
|
6
|
+
WHERE(strings, ...values) {
|
|
7
|
+
return this.template(strings, values, "WHERE", sparql_shared_builders_js_1.braces);
|
|
8
|
+
}
|
|
9
|
+
USING_NAMED(stringOrNamedNode) {
|
|
10
|
+
return this.namedNode(stringOrNamedNode, "USING NAMED");
|
|
11
|
+
}
|
|
12
|
+
USING(stringOrNamedNode) {
|
|
13
|
+
return this.namedNode(stringOrNamedNode, "USING");
|
|
14
|
+
}
|
|
15
|
+
INSERT(strings, ...values) {
|
|
16
|
+
return this.template(strings, values, "INSERT", sparql_shared_builders_js_1.braces);
|
|
17
|
+
}
|
|
18
|
+
INSERT_DATA(strings, ...values) {
|
|
19
|
+
return this.template(strings, values, "INSERT DATA", sparql_shared_builders_js_1.braces);
|
|
20
|
+
}
|
|
21
|
+
DELETE(strings, ...values) {
|
|
22
|
+
return this.template(strings, values, "DELETE", sparql_shared_builders_js_1.braces);
|
|
23
|
+
}
|
|
24
|
+
DELETE_DATA(strings, ...values) {
|
|
25
|
+
return this.template(strings, values, "DELETE DATA", sparql_shared_builders_js_1.braces);
|
|
26
|
+
}
|
|
27
|
+
WITH(stringOrNamedNode) {
|
|
28
|
+
return this.namedNode(stringOrNamedNode, "WITH");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.INSERT = Object.assign((strings, ...values) => new SparqlUpdateBuilder().INSERT(strings, ...values), {
|
|
32
|
+
DATA: (strings, ...values) => new SparqlUpdateBuilder().INSERT_DATA(strings, ...values),
|
|
12
33
|
});
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
exports.DELETE = Object.assign(_DELETE, {
|
|
16
|
-
DATA: _DELETE_DATA,
|
|
34
|
+
exports.DELETE = Object.assign((strings, ...values) => new SparqlUpdateBuilder().DELETE(strings, ...values), {
|
|
35
|
+
DATA: (strings, ...values) => new SparqlUpdateBuilder().DELETE_DATA(strings, ...values),
|
|
17
36
|
});
|
|
18
|
-
|
|
37
|
+
const WITH = (stringOrNamedNode) => new SparqlUpdateBuilder().WITH(stringOrNamedNode);
|
|
38
|
+
exports.WITH = WITH;
|
package/script/mod.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createNamespace = exports.createResource = exports.setDefaultEngine = exports.setDefaultContext = void 0;
|
|
3
|
+
exports.createNamespace = exports.createResource = exports.createLens = exports.setDefaultEngine = exports.setDefaultContext = void 0;
|
|
4
4
|
var global_js_1 = require("./library/global.js");
|
|
5
5
|
Object.defineProperty(exports, "setDefaultContext", { enumerable: true, get: function () { return global_js_1.setDefaultContext; } });
|
|
6
6
|
Object.defineProperty(exports, "setDefaultEngine", { enumerable: true, get: function () { return global_js_1.setDefaultEngine; } });
|
|
7
|
-
var mod_js_1 = require("./library/
|
|
7
|
+
var mod_js_1 = require("./library/lens/mod.js");
|
|
8
|
+
Object.defineProperty(exports, "createLens", { enumerable: true, get: function () { return mod_js_1.createLens; } });
|
|
8
9
|
Object.defineProperty(exports, "createResource", { enumerable: true, get: function () { return mod_js_1.createResource; } });
|
|
9
10
|
var namespace_js_1 = require("./library/namespaces/namespace.js");
|
|
10
11
|
Object.defineProperty(exports, "createNamespace", { enumerable: true, get: function () { return namespace_js_1.createNamespace; } });
|
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
import type { Context, IQueryEngine, Iri, RDF } from "../rdf.js";
|
|
2
2
|
import { type SchemaInterface, type SchemaInterfaceIdentity, type SchemaPrototype } from "../schema/mod.js";
|
|
3
3
|
import type { Entity } from "./types.js";
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Lens lets you query and update RDF data via data schema using TypeScript native data types.
|
|
6
|
+
*
|
|
7
|
+
* https://ldkit.io/docs/components/lens
|
|
8
|
+
*
|
|
9
|
+
* @param schema data schema which extends `SchemaPrototype`
|
|
10
|
+
* @param context optional `Context` - contains LDkit and query engine configuration
|
|
11
|
+
* @param engine optional Query Engine
|
|
12
|
+
* @returns Lens instance
|
|
13
|
+
*/
|
|
14
|
+
export declare const createLens: <T extends SchemaPrototype>(schema: T, context?: Context, engine?: IQueryEngine) => Lens<T, SchemaInterface<T>>;
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated
|
|
17
|
+
* Use `createLens` instead
|
|
18
|
+
*/
|
|
19
|
+
export declare const createResource: <T extends SchemaPrototype>(schema: T, context?: Context, engine?: IQueryEngine) => Lens<T, SchemaInterface<T>>;
|
|
20
|
+
export declare class Lens<S extends SchemaPrototype, I = SchemaInterface<S>> {
|
|
6
21
|
private readonly schema;
|
|
7
22
|
private readonly context;
|
|
8
23
|
private readonly engine;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createLens, createResource, type Lens } from "./lens.js";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|