ldkit 0.0.4 → 0.4.2

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 CHANGED
@@ -1 +1,5 @@
1
- # ldkit
1
+ # LDkit
2
+
3
+ RDF framework for browser, Deno and Node
4
+
5
+ [ldkit.io](https://ldkit.io).
@@ -1,4 +1,4 @@
1
- import { toRdf, DataFactory, literal, } from "./rdf.js";
1
+ import { DataFactory, literal, toRdf, } from "./rdf.js";
2
2
  import { rdf, xsd } from "./namespaces/mod.js";
3
3
  export const encode = (node, schema, context, variableInitCounter = 0) => {
4
4
  return Encoder.encode(node, schema, context, variableInitCounter);
@@ -100,7 +100,7 @@ class Encoder {
100
100
  this.push(nodeId, propertyId, subNodeId);
101
101
  return;
102
102
  }
103
- const propertyType = property["@type"] ?? xsd.string;
103
+ const propertyType = property["@type"] ? property["@type"] : xsd.string;
104
104
  if (typeof val === "string" && this.context.language) {
105
105
  if (propertyType === xsd.string || propertyType === rdf.langString) {
106
106
  this.push(nodeId, propertyId, literal(val, this.context.language));
@@ -108,7 +108,7 @@ class Encoder {
108
108
  }
109
109
  }
110
110
  const rdfValue = toRdf(val, {
111
- datatype: this.df.namedNode(property["@type"] ?? xsd.string),
111
+ datatype: this.df.namedNode(propertyType),
112
112
  });
113
113
  this.push(nodeId, propertyId, rdfValue);
114
114
  });
@@ -1,4 +1,4 @@
1
- import { QueryEngine } from "./comunica/mod.js";
1
+ import { QueryEngine } from "@comunica/query-sparql";
2
2
  import { from, map, switchMap } from "./rxjs.js";
3
3
  import { resolveContext } from "./context.js";
4
4
  import { quadsToGraph } from "./rdf.js";
package/esm/mod.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export { createResource } from "./library/resource/mod.js";
2
2
  export { createNamespace } from "./library/namespaces/namespace.js";
3
- export { createDefaultContext, createContext } from "./library/context.js";
3
+ export { createContext, createDefaultContext, } from "./library/context.js";
@@ -0,0 +1 @@
1
+ export * from "./library/namespaces/mod.js";
package/esm/rdf.js ADDED
@@ -0,0 +1 @@
1
+ export * from "./library/rdf.js";
package/esm/sparql.js ADDED
@@ -0,0 +1 @@
1
+ export * from "./library/sparql.js";
@@ -0,0 +1 @@
1
+ {"main":"../script/namespaces.js","module":"../esm/namespaces.js","types":"../types/namespaces.d.ts"}
package/package.json CHANGED
@@ -3,8 +3,13 @@
3
3
  "main": "./script/mod.js",
4
4
  "types": "./types/mod.d.ts",
5
5
  "name": "ldkit",
6
- "version": "0.0.4",
7
- "description": "LDKit",
6
+ "version": "0.4.2",
7
+ "description": "LDkit, a Linked Data query toolkit for TypeScript developers",
8
+ "homepage": "https://ldkit.io",
9
+ "author": "Karel Klima <karelklima@gmail.com> (https://karelklima.com)",
10
+ "keywords": [
11
+ "linked data, rdf, sparql"
12
+ ],
8
13
  "license": "MIT",
9
14
  "repository": {
10
15
  "type": "git",
@@ -20,33 +25,29 @@
20
25
  "types": "./types/mod.d.ts"
21
26
  },
22
27
  "./namespaces": {
23
- "import": "./esm/library/namespaces/mod.js",
24
- "require": "./script/library/namespaces/mod.js",
25
- "types": "./types/library/namespaces/mod.d.ts"
28
+ "import": "./esm/namespaces.js",
29
+ "require": "./script/namespaces.js",
30
+ "types": "./types/namespaces.d.ts"
26
31
  },
27
32
  "./rdf": {
28
- "import": "./esm/library/rdf.js",
29
- "require": "./script/library/rdf.js",
30
- "types": "./types/library/rdf.d.ts"
33
+ "import": "./esm/rdf.js",
34
+ "require": "./script/rdf.js",
35
+ "types": "./types/rdf.d.ts"
31
36
  },
32
37
  "./sparql": {
33
- "import": "./esm/library/sparql.js",
34
- "require": "./script/library/sparql.js",
35
- "types": "./types/library/sparql.d.ts"
38
+ "import": "./esm/sparql.js",
39
+ "require": "./script/sparql.js",
40
+ "types": "./types/sparql.d.ts"
36
41
  }
37
42
  },
38
43
  "dependencies": {
44
+ "@comunica/query-sparql": "2.4.3",
39
45
  "@comunica/types": "2.4.0",
40
46
  "@tpluscode/rdf-string": "0.2.26",
41
47
  "@tpluscode/sparql-builder": "0.3.23",
42
48
  "rdf-data-factory": "1.1.1",
43
49
  "rdf-js": "4.0.2",
44
50
  "rdf-literal": "1.3.0",
45
- "rxjs": "7.5.6",
46
- "@deno/shim-deno": "~0.9.0",
47
- "undici": "^5.8.0"
48
- },
49
- "devDependencies": {
50
- "@types/node": "16.11.37"
51
+ "rxjs": "7.5.6"
51
52
  }
52
53
  }
@@ -0,0 +1 @@
1
+ {"main":"../script/rdf.js","module":"../esm/rdf.js","types":"../types/rdf.d.ts"}
@@ -104,7 +104,7 @@ class Encoder {
104
104
  this.push(nodeId, propertyId, subNodeId);
105
105
  return;
106
106
  }
107
- const propertyType = property["@type"] ?? mod_js_1.xsd.string;
107
+ const propertyType = property["@type"] ? property["@type"] : mod_js_1.xsd.string;
108
108
  if (typeof val === "string" && this.context.language) {
109
109
  if (propertyType === mod_js_1.xsd.string || propertyType === mod_js_1.rdf.langString) {
110
110
  this.push(nodeId, propertyId, (0, rdf_js_1.literal)(val, this.context.language));
@@ -112,7 +112,7 @@ class Encoder {
112
112
  }
113
113
  }
114
114
  const rdfValue = (0, rdf_js_1.toRdf)(val, {
115
- datatype: this.df.namedNode(property["@type"] ?? mod_js_1.xsd.string),
115
+ datatype: this.df.namedNode(propertyType),
116
116
  });
117
117
  this.push(nodeId, propertyId, rdfValue);
118
118
  });
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateQuery = exports.quadsQuery = exports.bindingsQuery = exports.booleanQuery = void 0;
4
- const mod_js_1 = require("./comunica/mod.js");
4
+ const query_sparql_1 = require("@comunica/query-sparql");
5
5
  const rxjs_js_1 = require("./rxjs.js");
6
6
  const context_js_1 = require("./context.js");
7
7
  const rdf_js_1 = require("./rdf.js");
8
- const engine = new mod_js_1.QueryEngine();
8
+ const engine = new query_sparql_1.QueryEngine();
9
9
  const booleanQuery = (query, context) => (0, rxjs_js_1.from)(engine.queryBoolean(query, (0, context_js_1.resolveContext)(context)));
10
10
  exports.booleanQuery = booleanQuery;
11
11
  const bindingsQuery = (query, context) => (0, rxjs_js_1.from)(engine.queryBindings(query, (0, context_js_1.resolveContext)(context))).pipe((0, rxjs_js_1.switchMap)((stream) => (0, rxjs_js_1.from)(stream.toArray())));
package/script/mod.js CHANGED
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createContext = exports.createDefaultContext = exports.createNamespace = exports.createResource = void 0;
3
+ exports.createDefaultContext = exports.createContext = exports.createNamespace = exports.createResource = void 0;
4
4
  var mod_js_1 = require("./library/resource/mod.js");
5
5
  Object.defineProperty(exports, "createResource", { enumerable: true, get: function () { return mod_js_1.createResource; } });
6
6
  var namespace_js_1 = require("./library/namespaces/namespace.js");
7
7
  Object.defineProperty(exports, "createNamespace", { enumerable: true, get: function () { return namespace_js_1.createNamespace; } });
8
8
  var context_js_1 = require("./library/context.js");
9
- Object.defineProperty(exports, "createDefaultContext", { enumerable: true, get: function () { return context_js_1.createDefaultContext; } });
10
9
  Object.defineProperty(exports, "createContext", { enumerable: true, get: function () { return context_js_1.createContext; } });
10
+ Object.defineProperty(exports, "createDefaultContext", { enumerable: true, get: function () { return context_js_1.createDefaultContext; } });
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./library/namespaces/mod.js"), exports);
package/script/rdf.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./library/rdf.js"), exports);
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./library/sparql.js"), exports);
@@ -0,0 +1 @@
1
+ {"main":"../script/sparql.js","module":"../esm/sparql.js","types":"../types/sparql.d.ts"}
package/types/mod.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { type SchemaInterface } from "./library/schema/mod.js";
2
- export { type Resource, createResource } from "./library/resource/mod.js";
2
+ export { createResource, type Resource } from "./library/resource/mod.js";
3
3
  export { createNamespace } from "./library/namespaces/namespace.js";
4
- export { createDefaultContext, createContext } from "./library/context.js";
4
+ export { type Context, createContext, createDefaultContext, } from "./library/context.js";
@@ -0,0 +1 @@
1
+ export * from "./library/namespaces/mod.js";
package/types/rdf.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./library/rdf.js";
@@ -0,0 +1 @@
1
+ export * from "./library/sparql.js";
package/esm/_dnt.shims.js DELETED
@@ -1,70 +0,0 @@
1
- import { Deno } from "@deno/shim-deno";
2
- export { Deno } from "@deno/shim-deno";
3
- import { fetch, File, FormData, Headers, Request, Response } from "undici";
4
- export { fetch, File, FormData, Headers, Request, Response } from "undici";
5
- const dntGlobals = {
6
- Deno,
7
- fetch,
8
- File,
9
- FormData,
10
- Headers,
11
- Request,
12
- Response,
13
- };
14
- export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
15
- // deno-lint-ignore ban-types
16
- function createMergeProxy(baseObj, extObj) {
17
- return new Proxy(baseObj, {
18
- get(_target, prop, _receiver) {
19
- if (prop in extObj) {
20
- return extObj[prop];
21
- }
22
- else {
23
- return baseObj[prop];
24
- }
25
- },
26
- set(_target, prop, value) {
27
- if (prop in extObj) {
28
- delete extObj[prop];
29
- }
30
- baseObj[prop] = value;
31
- return true;
32
- },
33
- deleteProperty(_target, prop) {
34
- let success = false;
35
- if (prop in extObj) {
36
- delete extObj[prop];
37
- success = true;
38
- }
39
- if (prop in baseObj) {
40
- delete baseObj[prop];
41
- success = true;
42
- }
43
- return success;
44
- },
45
- ownKeys(_target) {
46
- const baseKeys = Reflect.ownKeys(baseObj);
47
- const extKeys = Reflect.ownKeys(extObj);
48
- const extKeysSet = new Set(extKeys);
49
- return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
50
- },
51
- defineProperty(_target, prop, desc) {
52
- if (prop in extObj) {
53
- delete extObj[prop];
54
- }
55
- Reflect.defineProperty(baseObj, prop, desc);
56
- return true;
57
- },
58
- getOwnPropertyDescriptor(_target, prop) {
59
- if (prop in extObj) {
60
- return Reflect.getOwnPropertyDescriptor(extObj, prop);
61
- }
62
- else {
63
- return Reflect.getOwnPropertyDescriptor(baseObj, prop);
64
- }
65
- },
66
- has(_target, prop) {
67
- return prop in extObj || prop in baseObj;
68
- },
69
- });
70
- }