@comake/skl-js-engine 1.3.8 → 1.3.10
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/dist/JsExecutor/PermissionBuilder.d.ts +1 -0
- package/dist/JsExecutor/PermissionBuilder.d.ts.map +1 -0
- package/dist/JsExecutor/PermissionBuilder.js.map +1 -1
- package/dist/JsExecutor/constants.d.ts +1 -0
- package/dist/JsExecutor/constants.d.ts.map +1 -0
- package/dist/JsExecutor/constants.js.map +1 -1
- package/dist/JsExecutor/denoUtils.d.ts +1 -0
- package/dist/JsExecutor/denoUtils.d.ts.map +1 -0
- package/dist/JsExecutor/denoUtils.js.map +1 -1
- package/dist/JsExecutor/errors.d.ts +1 -0
- package/dist/JsExecutor/errors.d.ts.map +1 -0
- package/dist/JsExecutor/errors.js.map +1 -1
- package/dist/JsExecutor/examples/basic/index.d.ts +1 -0
- package/dist/JsExecutor/examples/basic/index.d.ts.map +1 -0
- package/dist/JsExecutor/examples/basic/index.js.map +1 -1
- package/dist/JsExecutor/examples/basic/process.d.ts +1 -0
- package/dist/JsExecutor/examples/basic/process.d.ts.map +1 -0
- package/dist/JsExecutor/examples/basic/process.js.map +1 -1
- package/dist/JsExecutor/examples/jsExecutor/index.d.ts +1 -0
- package/dist/JsExecutor/examples/jsExecutor/index.d.ts.map +1 -0
- package/dist/JsExecutor/examples/jsExecutor/index.js.map +1 -1
- package/dist/JsExecutor/examples/jsExecutor/process.d.ts +1 -0
- package/dist/JsExecutor/examples/jsExecutor/process.d.ts.map +1 -0
- package/dist/JsExecutor/examples/jsExecutor/process.js.map +1 -1
- package/dist/JsExecutor/index.d.ts +1 -0
- package/dist/JsExecutor/index.d.ts.map +1 -0
- package/dist/JsExecutor/index.js.map +1 -1
- package/dist/JsExecutor/jsExecutor.d.ts +1 -0
- package/dist/JsExecutor/jsExecutor.d.ts.map +1 -0
- package/dist/JsExecutor/jsExecutor.js.map +1 -1
- package/dist/JsExecutor/jsonRpc/JsonRpcClient.d.ts +1 -0
- package/dist/JsExecutor/jsonRpc/JsonRpcClient.d.ts.map +1 -0
- package/dist/JsExecutor/jsonRpc/JsonRpcClient.js.map +1 -1
- package/dist/JsExecutor/jsonRpc/JsonRpcServer.d.ts +1 -0
- package/dist/JsExecutor/jsonRpc/JsonRpcServer.d.ts.map +1 -0
- package/dist/JsExecutor/jsonRpc/JsonRpcServer.js.map +1 -1
- package/dist/JsExecutor/jsonRpc/index.d.ts +1 -0
- package/dist/JsExecutor/jsonRpc/index.d.ts.map +1 -0
- package/dist/JsExecutor/jsonRpc/index.js.map +1 -1
- package/dist/JsExecutor/jsonRpc/types.d.ts +1 -0
- package/dist/JsExecutor/jsonRpc/types.d.ts.map +1 -0
- package/dist/JsExecutor/jsonRpc/types.js.map +1 -1
- package/dist/JsExecutor/transport/Transport.d.ts +1 -0
- package/dist/JsExecutor/transport/Transport.d.ts.map +1 -0
- package/dist/JsExecutor/transport/Transport.js.map +1 -1
- package/dist/JsExecutor/transport/base/BaseTransport.d.ts +1 -0
- package/dist/JsExecutor/transport/base/BaseTransport.d.ts.map +1 -0
- package/dist/JsExecutor/transport/base/BaseTransport.js.map +1 -1
- package/dist/JsExecutor/transport/index.d.ts +1 -0
- package/dist/JsExecutor/transport/index.d.ts.map +1 -0
- package/dist/JsExecutor/transport/index.js.map +1 -1
- package/dist/JsExecutor/transport/process/ProcessManager.d.ts +1 -0
- package/dist/JsExecutor/transport/process/ProcessManager.d.ts.map +1 -0
- package/dist/JsExecutor/transport/process/ProcessManager.js.map +1 -1
- package/dist/JsExecutor/transport/stdio/ChildStdioTransport.d.ts +1 -0
- package/dist/JsExecutor/transport/stdio/ChildStdioTransport.d.ts.map +1 -0
- package/dist/JsExecutor/transport/stdio/ChildStdioTransport.js.map +1 -1
- package/dist/JsExecutor/transport/stdio/ParentStdioTransport.d.ts +1 -0
- package/dist/JsExecutor/transport/stdio/ParentStdioTransport.d.ts.map +1 -0
- package/dist/JsExecutor/transport/stdio/ParentStdioTransport.js.map +1 -1
- package/dist/JsExecutor/transport/utils/MessageUtils.d.ts +1 -0
- package/dist/JsExecutor/transport/utils/MessageUtils.d.ts.map +1 -0
- package/dist/JsExecutor/transport/utils/MessageUtils.js.map +1 -1
- package/dist/JsExecutor/transport/utils/PollingUtils.d.ts +1 -0
- package/dist/JsExecutor/transport/utils/PollingUtils.d.ts.map +1 -0
- package/dist/JsExecutor/transport/utils/PollingUtils.js.map +1 -1
- package/dist/JsExecutor/types.d.ts +1 -0
- package/dist/JsExecutor/types.d.ts.map +1 -0
- package/dist/JsExecutor/types.js.map +1 -1
- package/dist/SklEngine.d.ts +1 -0
- package/dist/SklEngine.d.ts.map +1 -0
- package/dist/SklEngine.js.map +1 -1
- package/dist/SklEngineOptions.d.ts +1 -0
- package/dist/SklEngineOptions.d.ts.map +1 -0
- package/dist/SklEngineOptions.js.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/customCapabilities.d.ts +1 -0
- package/dist/customCapabilities.d.ts.map +1 -0
- package/dist/customCapabilities.js.map +1 -1
- package/dist/examples/customCapabilitiesExample.d.ts +1 -0
- package/dist/examples/customCapabilitiesExample.d.ts.map +1 -0
- package/dist/examples/customCapabilitiesExample.js.map +1 -1
- package/dist/hooks/globalHooks.d.ts +1 -0
- package/dist/hooks/globalHooks.d.ts.map +1 -0
- package/dist/hooks/globalHooks.js.map +1 -1
- package/dist/hooks/types.d.ts +1 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +1 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js.map +1 -1
- package/dist/mapping/Mapper.d.ts +1 -0
- package/dist/mapping/Mapper.d.ts.map +1 -0
- package/dist/mapping/Mapper.js.map +1 -1
- package/dist/storage/FindOperator.d.ts +1 -0
- package/dist/storage/FindOperator.d.ts.map +1 -0
- package/dist/storage/FindOperator.js.map +1 -1
- package/dist/storage/FindOptionsTypes.d.ts +1 -0
- package/dist/storage/FindOptionsTypes.d.ts.map +1 -0
- package/dist/storage/FindOptionsTypes.js.map +1 -1
- package/dist/storage/GroupOptionTypes.d.ts +1 -0
- package/dist/storage/GroupOptionTypes.d.ts.map +1 -0
- package/dist/storage/GroupOptionTypes.js.map +1 -1
- package/dist/storage/operator/And.d.ts +1 -0
- package/dist/storage/operator/And.d.ts.map +1 -0
- package/dist/storage/operator/And.js.map +1 -1
- package/dist/storage/operator/Contains.d.ts +1 -0
- package/dist/storage/operator/Contains.d.ts.map +1 -0
- package/dist/storage/operator/Contains.js.map +1 -1
- package/dist/storage/operator/Equal.d.ts +1 -0
- package/dist/storage/operator/Equal.d.ts.map +1 -0
- package/dist/storage/operator/Equal.js.map +1 -1
- package/dist/storage/operator/Exists.d.ts +1 -0
- package/dist/storage/operator/Exists.d.ts.map +1 -0
- package/dist/storage/operator/Exists.js.map +1 -1
- package/dist/storage/operator/GreaterThan.d.ts +1 -0
- package/dist/storage/operator/GreaterThan.d.ts.map +1 -0
- package/dist/storage/operator/GreaterThan.js.map +1 -1
- package/dist/storage/operator/GreaterThanOrEqual.d.ts +1 -0
- package/dist/storage/operator/GreaterThanOrEqual.d.ts.map +1 -0
- package/dist/storage/operator/GreaterThanOrEqual.js.map +1 -1
- package/dist/storage/operator/In.d.ts +1 -0
- package/dist/storage/operator/In.d.ts.map +1 -0
- package/dist/storage/operator/In.js.map +1 -1
- package/dist/storage/operator/Inverse.d.ts +1 -0
- package/dist/storage/operator/Inverse.d.ts.map +1 -0
- package/dist/storage/operator/Inverse.js.map +1 -1
- package/dist/storage/operator/InversePath.d.ts +1 -0
- package/dist/storage/operator/InversePath.d.ts.map +1 -0
- package/dist/storage/operator/InversePath.js.map +1 -1
- package/dist/storage/operator/InverseRelation.d.ts +1 -0
- package/dist/storage/operator/InverseRelation.d.ts.map +1 -0
- package/dist/storage/operator/InverseRelation.js.map +1 -1
- package/dist/storage/operator/InverseRelationOrder.d.ts +1 -0
- package/dist/storage/operator/InverseRelationOrder.d.ts.map +1 -0
- package/dist/storage/operator/InverseRelationOrder.js.map +1 -1
- package/dist/storage/operator/LessThan.d.ts +1 -0
- package/dist/storage/operator/LessThan.d.ts.map +1 -0
- package/dist/storage/operator/LessThan.js.map +1 -1
- package/dist/storage/operator/LessThanOrEqual.d.ts +1 -0
- package/dist/storage/operator/LessThanOrEqual.d.ts.map +1 -0
- package/dist/storage/operator/LessThanOrEqual.js.map +1 -1
- package/dist/storage/operator/Not.d.ts +1 -0
- package/dist/storage/operator/Not.d.ts.map +1 -0
- package/dist/storage/operator/Not.js.map +1 -1
- package/dist/storage/operator/OneOrMorePath.d.ts +1 -0
- package/dist/storage/operator/OneOrMorePath.d.ts.map +1 -0
- package/dist/storage/operator/OneOrMorePath.js.map +1 -1
- package/dist/storage/operator/Sequence.d.ts +1 -0
- package/dist/storage/operator/Sequence.d.ts.map +1 -0
- package/dist/storage/operator/Sequence.js.map +1 -1
- package/dist/storage/operator/SequencePath.d.ts +1 -0
- package/dist/storage/operator/SequencePath.d.ts.map +1 -0
- package/dist/storage/operator/SequencePath.js.map +1 -1
- package/dist/storage/operator/ZeroOrMorePath.d.ts +1 -0
- package/dist/storage/operator/ZeroOrMorePath.d.ts.map +1 -0
- package/dist/storage/operator/ZeroOrMorePath.js.map +1 -1
- package/dist/storage/query-adapter/QueryAdapter.d.ts +1 -0
- package/dist/storage/query-adapter/QueryAdapter.d.ts.map +1 -0
- package/dist/storage/query-adapter/QueryAdapter.js.map +1 -1
- package/dist/storage/query-adapter/sparql/SparqlQueryAdapter.d.ts +1 -0
- package/dist/storage/query-adapter/sparql/SparqlQueryAdapter.d.ts.map +1 -0
- package/dist/storage/query-adapter/sparql/SparqlQueryAdapter.js +28 -4
- package/dist/storage/query-adapter/sparql/SparqlQueryAdapter.js.map +1 -1
- package/dist/storage/query-adapter/sparql/SparqlQueryAdapterOptions.d.ts +1 -0
- package/dist/storage/query-adapter/sparql/SparqlQueryAdapterOptions.d.ts.map +1 -0
- package/dist/storage/query-adapter/sparql/SparqlQueryAdapterOptions.js.map +1 -1
- package/dist/storage/query-adapter/sparql/SparqlQueryBuilder.d.ts +1 -0
- package/dist/storage/query-adapter/sparql/SparqlQueryBuilder.d.ts.map +1 -0
- package/dist/storage/query-adapter/sparql/SparqlQueryBuilder.js +7 -21
- package/dist/storage/query-adapter/sparql/SparqlQueryBuilder.js.map +1 -1
- package/dist/storage/query-adapter/sparql/SparqlUpdateBuilder.d.ts +1 -0
- package/dist/storage/query-adapter/sparql/SparqlUpdateBuilder.d.ts.map +1 -0
- package/dist/storage/query-adapter/sparql/SparqlUpdateBuilder.js.map +1 -1
- package/dist/storage/query-adapter/sparql/VariableGenerator.d.ts +1 -0
- package/dist/storage/query-adapter/sparql/VariableGenerator.d.ts.map +1 -0
- package/dist/storage/query-adapter/sparql/VariableGenerator.js.map +1 -1
- package/dist/storage/query-adapter/sparql/query-executor/InMemorySparqlQueryExecutor.d.ts +1 -0
- package/dist/storage/query-adapter/sparql/query-executor/InMemorySparqlQueryExecutor.d.ts.map +1 -0
- package/dist/storage/query-adapter/sparql/query-executor/InMemorySparqlQueryExecutor.js.map +1 -1
- package/dist/storage/query-adapter/sparql/query-executor/SparqlEndpointQueryExecutor.d.ts +1 -0
- package/dist/storage/query-adapter/sparql/query-executor/SparqlEndpointQueryExecutor.d.ts.map +1 -0
- package/dist/storage/query-adapter/sparql/query-executor/SparqlEndpointQueryExecutor.js.map +1 -1
- package/dist/storage/query-adapter/sparql/query-executor/SparqlQueryExecutor.d.ts +1 -0
- package/dist/storage/query-adapter/sparql/query-executor/SparqlQueryExecutor.d.ts.map +1 -0
- package/dist/storage/query-adapter/sparql/query-executor/SparqlQueryExecutor.js.map +1 -1
- package/dist/util/PerformanceLogger.d.ts +1 -0
- package/dist/util/PerformanceLogger.d.ts.map +1 -0
- package/dist/util/PerformanceLogger.js.map +1 -1
- package/dist/util/SparqlUtil.d.ts +1 -0
- package/dist/util/SparqlUtil.d.ts.map +1 -0
- package/dist/util/SparqlUtil.js.map +1 -1
- package/dist/util/TripleUtil.d.ts +1 -0
- package/dist/util/TripleUtil.d.ts.map +1 -0
- package/dist/util/TripleUtil.js +10 -0
- package/dist/util/TripleUtil.js.map +1 -1
- package/dist/util/Types.d.ts +1 -0
- package/dist/util/Types.d.ts.map +1 -0
- package/dist/util/Types.js.map +1 -1
- package/dist/util/Util.d.ts +1 -0
- package/dist/util/Util.d.ts.map +1 -0
- package/dist/util/Util.js.map +1 -1
- package/dist/util/Vocabularies/Shared.d.ts +1 -0
- package/dist/util/Vocabularies/Shared.d.ts.map +1 -0
- package/dist/util/Vocabularies/Shared.js.map +1 -1
- package/dist/util/Vocabularies/helper.d.ts +1 -0
- package/dist/util/Vocabularies/helper.d.ts.map +1 -0
- package/dist/util/Vocabularies/helper.js.map +1 -1
- package/dist/util/Vocabularies/index.d.ts +1 -0
- package/dist/util/Vocabularies/index.d.ts.map +1 -0
- package/dist/util/Vocabularies/index.js.map +1 -1
- package/dist/util/safeJsonStringify.d.ts +1 -0
- package/dist/util/safeJsonStringify.d.ts.map +1 -0
- package/dist/util/safeJsonStringify.js.map +1 -1
- package/package.json +6 -3
- package/src/JsExecutor/PermissionBuilder.ts +60 -0
- package/src/JsExecutor/constants.ts +27 -0
- package/src/JsExecutor/denoUtils.ts +20 -0
- package/src/JsExecutor/errors.ts +63 -0
- package/src/JsExecutor/examples/basic/index.ts +54 -0
- package/src/JsExecutor/examples/basic/process.ts +39 -0
- package/src/JsExecutor/examples/jsExecutor/README.md +3 -0
- package/src/JsExecutor/examples/jsExecutor/index.ts +50 -0
- package/src/JsExecutor/examples/jsExecutor/process.ts +79 -0
- package/src/JsExecutor/index.ts +19 -0
- package/src/JsExecutor/jsExecutor.ts +194 -0
- package/src/JsExecutor/jsonRpc/JsonRpcClient.ts +422 -0
- package/src/JsExecutor/jsonRpc/JsonRpcServer.ts +454 -0
- package/src/JsExecutor/jsonRpc/index.ts +4 -0
- package/src/JsExecutor/jsonRpc/types.ts +231 -0
- package/src/JsExecutor/transport/README.md +67 -0
- package/src/JsExecutor/transport/Transport.ts +106 -0
- package/src/JsExecutor/transport/base/BaseTransport.ts +83 -0
- package/src/JsExecutor/transport/index.ts +56 -0
- package/src/JsExecutor/transport/process/ProcessManager.ts +281 -0
- package/src/JsExecutor/transport/stdio/ChildStdioTransport.ts +251 -0
- package/src/JsExecutor/transport/stdio/ParentStdioTransport.ts +308 -0
- package/src/JsExecutor/transport/utils/MessageUtils.ts +139 -0
- package/src/JsExecutor/transport/utils/PollingUtils.ts +114 -0
- package/src/JsExecutor/types.ts +130 -0
- package/src/SklEngine.ts +1828 -0
- package/src/SklEngineOptions.ts +28 -0
- package/src/constants.ts +120 -0
- package/src/customCapabilities.ts +65 -0
- package/src/examples/customCapabilitiesExample.ts +77 -0
- package/src/hooks/globalHooks.ts +238 -0
- package/src/hooks/types.ts +7 -0
- package/src/index.ts +45 -0
- package/src/logger.ts +144 -0
- package/src/mapping/Mapper.ts +52 -0
- package/src/storage/FindOperator.ts +55 -0
- package/src/storage/FindOptionsTypes.ts +107 -0
- package/src/storage/GroupOptionTypes.ts +32 -0
- package/src/storage/operator/And.ts +10 -0
- package/src/storage/operator/Contains.ts +9 -0
- package/src/storage/operator/Equal.ts +13 -0
- package/src/storage/operator/Exists.ts +6 -0
- package/src/storage/operator/GreaterThan.ts +12 -0
- package/src/storage/operator/GreaterThanOrEqual.ts +12 -0
- package/src/storage/operator/In.ts +12 -0
- package/src/storage/operator/Inverse.ts +11 -0
- package/src/storage/operator/InversePath.ts +17 -0
- package/src/storage/operator/InverseRelation.ts +18 -0
- package/src/storage/operator/InverseRelationOrder.ts +17 -0
- package/src/storage/operator/LessThan.ts +12 -0
- package/src/storage/operator/LessThanOrEqual.ts +12 -0
- package/src/storage/operator/Not.ts +11 -0
- package/src/storage/operator/OneOrMorePath.ts +17 -0
- package/src/storage/operator/Sequence.ts +11 -0
- package/src/storage/operator/SequencePath.ts +17 -0
- package/src/storage/operator/ZeroOrMorePath.ts +17 -0
- package/src/storage/query-adapter/QueryAdapter.ts +110 -0
- package/src/storage/query-adapter/sparql/SparqlQueryAdapter.ts +400 -0
- package/src/storage/query-adapter/sparql/SparqlQueryAdapterOptions.ts +38 -0
- package/src/storage/query-adapter/sparql/SparqlQueryBuilder.ts +1524 -0
- package/src/storage/query-adapter/sparql/SparqlUpdateBuilder.ts +347 -0
- package/src/storage/query-adapter/sparql/VariableGenerator.ts +8 -0
- package/src/storage/query-adapter/sparql/query-executor/InMemorySparqlQueryExecutor.ts +135 -0
- package/src/storage/query-adapter/sparql/query-executor/SparqlEndpointQueryExecutor.ts +146 -0
- package/src/storage/query-adapter/sparql/query-executor/SparqlQueryExecutor.ts +51 -0
- package/src/util/PerformanceLogger.ts +286 -0
- package/src/util/SparqlUtil.ts +516 -0
- package/src/util/TripleUtil.ts +412 -0
- package/src/util/Types.ts +399 -0
- package/src/util/Util.ts +116 -0
- package/src/util/Vocabularies/Shared.ts +99 -0
- package/src/util/Vocabularies/helper.ts +14 -0
- package/src/util/Vocabularies/index.ts +108 -0
- package/src/util/safeJsonStringify.ts +19 -0
- package/dist/JsExecutor/transport/StdioTransport.d.ts +0 -0
- package/dist/JsExecutor/transport/StdioTransport.js +0 -641
- package/dist/JsExecutor/transport/StdioTransport.js.map +0 -1
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
import type { ReferenceNodeObject, TriplesMap } from '@comake/rmlmapper-js';
|
|
3
|
+
import type {
|
|
4
|
+
GraphObject,
|
|
5
|
+
IdMap,
|
|
6
|
+
IncludedBlock,
|
|
7
|
+
IndexMap,
|
|
8
|
+
LanguageMap,
|
|
9
|
+
ListObject,
|
|
10
|
+
NodeObject,
|
|
11
|
+
SetObject,
|
|
12
|
+
TypeMap
|
|
13
|
+
} from 'jsonld';
|
|
14
|
+
import type { Frame } from 'jsonld/jsonld-spec';
|
|
15
|
+
import type { EngineConstants } from '../constants';
|
|
16
|
+
import type { FindAllOptions, FindOneOptions, FindOptionsWhere } from '../storage/FindOptionsTypes';
|
|
17
|
+
import type { GroupByOptions, GroupByResponse } from '../storage/GroupOptionTypes';
|
|
18
|
+
import type { RawQueryResult } from '../storage/query-adapter/QueryAdapter';
|
|
19
|
+
import type { RDF, SHACL } from './Vocabularies';
|
|
20
|
+
|
|
21
|
+
export type JSONPrimitive = string | number | boolean | null;
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style
|
|
23
|
+
export interface JSONObject {
|
|
24
|
+
[key: string]: JSONValue | undefined;
|
|
25
|
+
}
|
|
26
|
+
export interface JSONArray extends Array<JSONValue> {}
|
|
27
|
+
|
|
28
|
+
export type JSONValue = JSONPrimitive | JSONObject | JSONValue[];
|
|
29
|
+
|
|
30
|
+
export interface RdfList<T> {
|
|
31
|
+
[RDF.first]: T;
|
|
32
|
+
[RDF.rest]?: RdfList<T> | typeof RDF.nil | ReferenceNodeObject;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface ValueObject<T extends string | boolean | number | JSONObject | JSONArray> {
|
|
36
|
+
['@type']: string;
|
|
37
|
+
['@value']: T;
|
|
38
|
+
['@language']?: string;
|
|
39
|
+
['@direction']?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type IRIObject<T extends string = string> = { '@id': T };
|
|
43
|
+
|
|
44
|
+
export type ShaclIRI = string | IRIObject;
|
|
45
|
+
export type ShaclIRIOrLiteral = ShaclIRI | ValueObject<any>;
|
|
46
|
+
|
|
47
|
+
export type NodeKindValues =
|
|
48
|
+
| typeof SHACL.Literal
|
|
49
|
+
| typeof SHACL.IRI
|
|
50
|
+
| typeof SHACL.BlankNode
|
|
51
|
+
| typeof SHACL.BlankNodeOrIRI
|
|
52
|
+
| typeof SHACL.BlankNodeOrLiteral
|
|
53
|
+
| typeof SHACL.IRIOrLiteral;
|
|
54
|
+
|
|
55
|
+
export type BaseShape = NodeObject & {
|
|
56
|
+
[SHACL.targetNode]?: ShaclIRIOrLiteral;
|
|
57
|
+
[SHACL.targetClass]?: ShaclIRI;
|
|
58
|
+
[SHACL.targetSubjectsOf]?: ShaclIRI;
|
|
59
|
+
[SHACL.targetObjectOf]?: ShaclIRI;
|
|
60
|
+
[SHACL.severity]?: ShaclIRI;
|
|
61
|
+
[SHACL.message]?: OrArray<ValueObject<string>>;
|
|
62
|
+
[SHACL.deactivated]?: ValueObject<boolean>;
|
|
63
|
+
[SHACL.and]?: ShapesListShape;
|
|
64
|
+
[SHACL.class]?: OrArray<ShaclIRI>;
|
|
65
|
+
[SHACL.closed]?: ValueObject<boolean>;
|
|
66
|
+
[SHACL.ignoredProperties]?: ShaclIRI[];
|
|
67
|
+
[SHACL.disjoint]?: OrArray<ShaclIRI>;
|
|
68
|
+
[SHACL.equals]?: OrArray<ShaclIRI>;
|
|
69
|
+
[SHACL.in]?: ListObject;
|
|
70
|
+
[SHACL.languageIn]?: string[];
|
|
71
|
+
[SHACL.maxExclusive]?: ValueObject<number>;
|
|
72
|
+
[SHACL.maxInclusive]?: ValueObject<number>;
|
|
73
|
+
[SHACL.maxLength]?: ValueObject<number>;
|
|
74
|
+
[SHACL.minExclusive]?: ValueObject<number>;
|
|
75
|
+
[SHACL.minInclusive]?: ValueObject<number>;
|
|
76
|
+
[SHACL.minLength]?: ValueObject<number>;
|
|
77
|
+
[SHACL.nodeKind]?: IRIObject<NodeKindValues>;
|
|
78
|
+
[SHACL.or]?: ShapesListShape;
|
|
79
|
+
[SHACL.pattern]?: ValueObject<string>;
|
|
80
|
+
[SHACL.flags]?: ValueObject<string>;
|
|
81
|
+
[SHACL.xone]?: ShapesListShape;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export type ShapesListShape = (PropertyShape | NodeShape)[];
|
|
85
|
+
|
|
86
|
+
export interface PropertyShape extends BaseShape {
|
|
87
|
+
[SHACL.path]: PathTypes;
|
|
88
|
+
[SHACL.datatype]?: ShaclIRI;
|
|
89
|
+
[SHACL.node]?: OrArray<NodeShape>;
|
|
90
|
+
[SHACL.name]?: ValueObject<string>;
|
|
91
|
+
[SHACL.description]?: ValueObject<string>;
|
|
92
|
+
[SHACL.minCount]?: ValueObject<number>;
|
|
93
|
+
[SHACL.maxCount]?: ValueObject<number>;
|
|
94
|
+
[SHACL.lessThanOrEquals]?: OrArray<ShaclIRI>;
|
|
95
|
+
[SHACL.lessThan]?: OrArray<ShaclIRI>;
|
|
96
|
+
[SHACL.qualifiedValueShape]?: OrArray<BaseShape>;
|
|
97
|
+
[SHACL.qualifiedMaxCount]?: ValueObject<number>;
|
|
98
|
+
[SHACL.qualifiedMinCount]?: ValueObject<number>;
|
|
99
|
+
[SHACL.qualifiedValueShapesDisjoint]?: ValueObject<boolean>;
|
|
100
|
+
[SHACL.uniqueLang]?: ValueObject<boolean>;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface NodeShape extends BaseShape {
|
|
104
|
+
'@type': typeof SHACL.NodeShape;
|
|
105
|
+
[EngineConstants.prop.label]?: ValueObject<string>;
|
|
106
|
+
[SHACL.property]: OrArray<PropertyShape>;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface InverseShaclPath extends NodeObject {
|
|
110
|
+
[SHACL.inversePath]: PathShape;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface ZeroOrMoreShaclPath extends NodeObject {
|
|
114
|
+
[SHACL.zeroOrMorePath]: PathShape;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface OneOrMoreShaclPath extends NodeObject {
|
|
118
|
+
[SHACL.oneOrMorePath]: PathShape;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface ZeroOrOneShaclPath extends NodeObject {
|
|
122
|
+
[SHACL.zeroOrOnePath]: PathShape;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface AlternativeShaclPath extends NodeObject {
|
|
126
|
+
[SHACL.alternativePath]: PathTypes[];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export type PathTypes =
|
|
130
|
+
| ShaclIRI
|
|
131
|
+
| AlternativeShaclPath
|
|
132
|
+
| ZeroOrMoreShaclPath
|
|
133
|
+
| OneOrMoreShaclPath
|
|
134
|
+
| ZeroOrOneShaclPath
|
|
135
|
+
| InverseShaclPath;
|
|
136
|
+
|
|
137
|
+
export type PathShape = OrArray<PathTypes>;
|
|
138
|
+
|
|
139
|
+
export type Mapping = NodeObject & {
|
|
140
|
+
[EngineConstants.prop.preProcessingMapping]?: OrArray<TriplesMap>;
|
|
141
|
+
[EngineConstants.prop.preProcessingMappingFrame]?: ValueObject<JSONObject>;
|
|
142
|
+
[EngineConstants.prop.inputsMapping]?: OrArray<TriplesMap>;
|
|
143
|
+
[EngineConstants.prop.inputsMappingFrame]?: ValueObject<JSONObject>;
|
|
144
|
+
[EngineConstants.prop.inputsMappingRef]?: string | ValueObject<string>;
|
|
145
|
+
[EngineConstants.prop.operationId]?: ValueObject<string>;
|
|
146
|
+
[EngineConstants.prop.operationMapping]?: TriplesMap;
|
|
147
|
+
[EngineConstants.prop.capability]?: ReferenceNodeObject;
|
|
148
|
+
[EngineConstants.prop.outputsMapping]?: OrArray<TriplesMap>;
|
|
149
|
+
[EngineConstants.prop.outputsMappingFrame]?: ValueObject<JSONObject>;
|
|
150
|
+
[EngineConstants.prop.series]?: { '@list': CapabilityMapping[] } | (RdfList<CapabilityMapping> & NodeObject);
|
|
151
|
+
[EngineConstants.prop.parallel]?: OrArray<CapabilityMapping>;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export type Capability = NodeObject & {
|
|
155
|
+
'@id': string;
|
|
156
|
+
'@type': typeof EngineConstants.spec.capability;
|
|
157
|
+
[EngineConstants.prop.label]?: ValueObject<string>;
|
|
158
|
+
[EngineConstants.prop.inputsContext]?: ValueObject<JSONObject>;
|
|
159
|
+
[EngineConstants.prop.inputs]?: NodeShape | ReferenceNodeObject;
|
|
160
|
+
[EngineConstants.prop.outputsContext]?: ValueObject<JSONObject>;
|
|
161
|
+
[EngineConstants.prop.outputs]?: NodeShape | ReferenceNodeObject;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export type CapabilityMapping = Mapping & {
|
|
165
|
+
[EngineConstants.prop.capability]: ReferenceNodeObject;
|
|
166
|
+
[EngineConstants.prop.object]?: ReferenceNodeObject;
|
|
167
|
+
[EngineConstants.prop.integration]?: ReferenceNodeObject;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export type MappingWithInputs = CapabilityMapping &
|
|
171
|
+
Required<Pick<CapabilityMapping, typeof EngineConstants.prop.inputs | typeof EngineConstants.prop.inputsMapping>>;
|
|
172
|
+
|
|
173
|
+
export type MappingWithInputsReference = CapabilityMapping &
|
|
174
|
+
Required<Pick<CapabilityMapping, typeof EngineConstants.prop.inputsReference>>;
|
|
175
|
+
|
|
176
|
+
export type MappingWithOutputsMapping = CapabilityMapping &
|
|
177
|
+
Required<
|
|
178
|
+
Pick<
|
|
179
|
+
CapabilityMapping,
|
|
180
|
+
typeof EngineConstants.prop.outputsMapping | typeof EngineConstants.prop.outputsMappingFrame
|
|
181
|
+
>
|
|
182
|
+
>;
|
|
183
|
+
|
|
184
|
+
export type MappingWithSeries = CapabilityMapping &
|
|
185
|
+
Required<Pick<CapabilityMapping, typeof EngineConstants.prop.series>>;
|
|
186
|
+
|
|
187
|
+
export type MappingWithParallel = CapabilityMapping &
|
|
188
|
+
Required<Pick<CapabilityMapping, typeof EngineConstants.prop.parallel>>;
|
|
189
|
+
|
|
190
|
+
export interface SeriesCapabilityArgs extends JSONObject {
|
|
191
|
+
originalCapabilityParameters: JSONObject;
|
|
192
|
+
previousCapabilityReturnValue: JSONObject;
|
|
193
|
+
allStepsResults: JSONObject[];
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export type TriggerMapping = Mapping & {
|
|
197
|
+
[EngineConstants.prop.integration]: ReferenceNodeObject;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
export type PossibleArrayFieldValues =
|
|
201
|
+
| boolean
|
|
202
|
+
| number
|
|
203
|
+
| string
|
|
204
|
+
| NodeObject
|
|
205
|
+
| GraphObject
|
|
206
|
+
| ValueObject<any>
|
|
207
|
+
| ListObject
|
|
208
|
+
| SetObject;
|
|
209
|
+
|
|
210
|
+
export type EntityFieldSingularValue =
|
|
211
|
+
| boolean
|
|
212
|
+
| number
|
|
213
|
+
| string
|
|
214
|
+
| NodeObject
|
|
215
|
+
| GraphObject
|
|
216
|
+
| ValueObject<any>
|
|
217
|
+
| ListObject
|
|
218
|
+
| SetObject;
|
|
219
|
+
|
|
220
|
+
export type EntityFieldValue =
|
|
221
|
+
| OrArray<EntityFieldSingularValue>
|
|
222
|
+
| LanguageMap
|
|
223
|
+
| IndexMap
|
|
224
|
+
| IncludedBlock
|
|
225
|
+
| IdMap
|
|
226
|
+
| TypeMap
|
|
227
|
+
| NodeObject[keyof NodeObject];
|
|
228
|
+
|
|
229
|
+
export interface Entity {
|
|
230
|
+
'@id': string;
|
|
231
|
+
'@type': OrArray<string>;
|
|
232
|
+
[key: string]: EntityFieldValue;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export type OrArray<T> = T | T[];
|
|
236
|
+
|
|
237
|
+
export interface OperationResponse extends JSONObject {
|
|
238
|
+
data: JSONObject;
|
|
239
|
+
operationParameters: JSONObject;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export interface CapabilityConfig {
|
|
243
|
+
/**
|
|
244
|
+
* Callbacks to execute upon events.
|
|
245
|
+
* If global callbacks are provided, both are executed.
|
|
246
|
+
*/
|
|
247
|
+
callbacks?: Callbacks;
|
|
248
|
+
/**
|
|
249
|
+
* When true, disables validation of capability parameters and
|
|
250
|
+
* return values according to schemas. Overrides the global setting.
|
|
251
|
+
*/
|
|
252
|
+
readonly disableValidation?: boolean;
|
|
253
|
+
/**
|
|
254
|
+
* An object containing files keyed on their title that can be used in mappings.
|
|
255
|
+
* Merged with the global setting. The capability config taking prededence in the case of overlapping names.
|
|
256
|
+
*/
|
|
257
|
+
readonly inputFiles?: Record<string, string>;
|
|
258
|
+
/**
|
|
259
|
+
* Manually defined functions which can be used in mappings.
|
|
260
|
+
* Merged with the global setting. The capability config taking prededence in the case of overlapping names.
|
|
261
|
+
*/
|
|
262
|
+
readonly functions?: Record<string, (args: any | any[]) => any>;
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* When true, the operation will be streamed.
|
|
266
|
+
*/
|
|
267
|
+
readonly stream?: boolean;
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* When true, the operation will be buffered.
|
|
271
|
+
*/
|
|
272
|
+
readonly buffer?: boolean;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export interface Callbacks {
|
|
276
|
+
/**
|
|
277
|
+
* Callback run when a Capability starts being executed
|
|
278
|
+
*/
|
|
279
|
+
onCapabilityStart?: (capability: string, args: Record<string, any>) => void;
|
|
280
|
+
/**
|
|
281
|
+
* Callback run when a Capability is finished being executed
|
|
282
|
+
*/
|
|
283
|
+
onCapabilityEnd?: (capability: string, returnValue: Record<string, any>) => void;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export interface SKLEngineInterface {
|
|
287
|
+
/**
|
|
288
|
+
* Finds the first entity by the given find options
|
|
289
|
+
*/
|
|
290
|
+
find: (options?: FindOneOptions) => Promise<Entity>;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Finds the first entity that matches the given where condition
|
|
294
|
+
*/
|
|
295
|
+
findBy: (where: FindOptionsWhere, notFoundErrorMessage?: string) => Promise<Entity>;
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Finds the first entity that matches the given where condition, or undefined if not found
|
|
299
|
+
*/
|
|
300
|
+
findByIfExists: (options: FindOptionsWhere) => Promise<Entity | undefined>;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Finds entities that match the given find options
|
|
304
|
+
*/
|
|
305
|
+
findAll: (options?: FindAllOptions) => Promise<Entity[]>;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Groups entities by the given options
|
|
309
|
+
*/
|
|
310
|
+
groupBy: (options: GroupByOptions) => Promise<GroupByResponse>;
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Finds entities that match the given where condition
|
|
314
|
+
*/
|
|
315
|
+
findAllBy: (where: FindOptionsWhere) => Promise<Entity[]>;
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Determines if an entity matching the given options exists
|
|
319
|
+
*/
|
|
320
|
+
exists: (options?: FindAllOptions) => Promise<boolean>;
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Returns a count of entities matching the given options
|
|
324
|
+
*/
|
|
325
|
+
count: (options?: FindAllOptions) => Promise<number>;
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Saves a given entity or entities
|
|
329
|
+
*/
|
|
330
|
+
save: ((entity: Entity) => Promise<Entity>) & ((entities: Entity[]) => Promise<Entity[]>);
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Updates an entity or entities partially
|
|
334
|
+
*/
|
|
335
|
+
update: ((id: string, attributes: Partial<Entity>) => Promise<void>) &
|
|
336
|
+
((ids: string[], attributes: Partial<Entity>) => Promise<void>);
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Removes an entity or entities from the database by id
|
|
340
|
+
*/
|
|
341
|
+
delete: ((id: string) => Promise<void>) & ((ids: string[]) => Promise<void>);
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Removes a given entity or entities from the database
|
|
345
|
+
*/
|
|
346
|
+
destroy: ((entity: Entity) => Promise<Entity>) & ((entities: Entity[]) => Promise<Entity[]>);
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Performs a mapping operation
|
|
350
|
+
*/
|
|
351
|
+
performMapping: (
|
|
352
|
+
args: JSONValue,
|
|
353
|
+
mapping: OrArray<NodeObject>,
|
|
354
|
+
frame?: Record<string, any>,
|
|
355
|
+
capabilityConfig?: CapabilityConfig,
|
|
356
|
+
) => Promise<NodeObject>;
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Executes a raw query
|
|
360
|
+
*/
|
|
361
|
+
executeRawQuery: <T extends RawQueryResult>(query: string) => Promise<T[]>;
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Executes a raw update query
|
|
365
|
+
*/
|
|
366
|
+
executeRawUpdate: (query: string) => Promise<void>;
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Executes a raw construct query
|
|
370
|
+
*/
|
|
371
|
+
executeRawConstructQuery: (query: string, frame?: Frame) => Promise<GraphObject>;
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Record of capability handlers by name
|
|
375
|
+
*/
|
|
376
|
+
capability: Record<string, (params: JSONObject, capabilityConfig?: CapabilityConfig) => Promise<any>>;
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Finds and executes a capability
|
|
380
|
+
*/
|
|
381
|
+
findAndExecuteCapability: (
|
|
382
|
+
capabilityId: string,
|
|
383
|
+
args: JSONObject,
|
|
384
|
+
capabilityConfig?: CapabilityConfig,
|
|
385
|
+
) => Promise<OrArray<NodeObject>>;
|
|
386
|
+
|
|
387
|
+
executeCapability: (
|
|
388
|
+
capability: Capability,
|
|
389
|
+
capabilityArgs: JSONObject,
|
|
390
|
+
capabilityConfig?: CapabilityConfig,
|
|
391
|
+
) => Promise<OrArray<NodeObject>>;
|
|
392
|
+
|
|
393
|
+
executeMapping: (
|
|
394
|
+
mapping: Mapping,
|
|
395
|
+
args: JSONObject,
|
|
396
|
+
capabilityConfig?: CapabilityConfig,
|
|
397
|
+
account?: Entity,
|
|
398
|
+
) => Promise<OrArray<NodeObject>>;
|
|
399
|
+
}
|
package/src/util/Util.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { ReferenceNodeObject } from '@comake/rmlmapper-js';
|
|
2
|
+
import { getIdFromNodeObjectIfDefined } from '@comake/rmlmapper-js';
|
|
3
|
+
import * as jsonld from 'jsonld';
|
|
4
|
+
import type { NodeObject, ValueObject } from 'jsonld';
|
|
5
|
+
import { Parser, Store } from 'n3';
|
|
6
|
+
import type { EntityFieldSingularValue, EntityFieldValue, JSONObject, RdfList } from './Types';
|
|
7
|
+
import { RDF, XSD } from './Vocabularies';
|
|
8
|
+
|
|
9
|
+
export async function convertJsonLdToQuads(jsonldDoc: any): Promise<Store> {
|
|
10
|
+
const nquads = (await jsonld.toRDF(jsonldDoc, { format: 'application/n-quads' })) as unknown as string;
|
|
11
|
+
const turtleParser = new Parser({ format: 'application/n-quads' });
|
|
12
|
+
const store = new Store();
|
|
13
|
+
turtleParser.parse(nquads).forEach((quad): void => {
|
|
14
|
+
store.addQuad(quad);
|
|
15
|
+
});
|
|
16
|
+
return store;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function toJSON(jsonLd: NodeObject, convertBeyondFirstLevel = true): JSONObject {
|
|
20
|
+
[ '@context', '@id', '@type' ].forEach((key): void => {
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
22
|
+
delete jsonLd[key];
|
|
23
|
+
});
|
|
24
|
+
if (convertBeyondFirstLevel) {
|
|
25
|
+
Object.keys(jsonLd).forEach((key): void => {
|
|
26
|
+
if (Array.isArray(jsonLd[key])) {
|
|
27
|
+
(jsonLd[key] as any[])!.forEach((item, index): void => {
|
|
28
|
+
if (typeof item === 'object') {
|
|
29
|
+
(jsonLd[key] as any[])[index] = toJSON(item);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
} else if (typeof jsonLd[key] === 'object') {
|
|
33
|
+
jsonLd[key] = toJSON(jsonLd[key] as NodeObject);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return jsonLd as JSONObject;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function ensureArray<T>(arrayable: T | T[]): T[] {
|
|
41
|
+
if (arrayable !== null && arrayable !== undefined) {
|
|
42
|
+
return Array.isArray(arrayable) ? arrayable : [ arrayable ];
|
|
43
|
+
}
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function getValueIfDefined<T>(fieldValue?: EntityFieldValue): T | undefined {
|
|
48
|
+
if (fieldValue && Array.isArray(fieldValue)) {
|
|
49
|
+
return fieldValue.map(
|
|
50
|
+
(valueItem): EntityFieldSingularValue => getValueIfDefined<EntityFieldSingularValue>(valueItem)!
|
|
51
|
+
) as unknown as T;
|
|
52
|
+
}
|
|
53
|
+
if (fieldValue && typeof fieldValue === 'object') {
|
|
54
|
+
return (fieldValue as ValueObject)['@value'] as unknown as T;
|
|
55
|
+
}
|
|
56
|
+
if (fieldValue !== undefined && fieldValue !== null) {
|
|
57
|
+
return fieldValue as unknown as T;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function isUrl(value: any): boolean {
|
|
62
|
+
if (typeof value !== 'string') {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
// eslint-disable-next-line no-new
|
|
67
|
+
new URL(value);
|
|
68
|
+
return true;
|
|
69
|
+
} catch {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
75
|
+
export function rdfListToArray<T extends NodeObject>(list: { '@list': T[] } | RdfList<T>): T[] {
|
|
76
|
+
if (!('@list' in list)) {
|
|
77
|
+
return [
|
|
78
|
+
list[RDF.first],
|
|
79
|
+
...getIdFromNodeObjectIfDefined(list[RDF.rest] as ReferenceNodeObject) === RDF.nil
|
|
80
|
+
? []
|
|
81
|
+
: rdfListToArray(list[RDF.rest] as RdfList<T>)
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
return list['@list'];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function parseJSONOrDefault<T>(json: string, defaultValue: T): T {
|
|
88
|
+
try {
|
|
89
|
+
return JSON.parse(json);
|
|
90
|
+
} catch {
|
|
91
|
+
return defaultValue;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export const dataTypeMapping = {
|
|
96
|
+
string: XSD.string,
|
|
97
|
+
boolean: XSD.boolean,
|
|
98
|
+
integer: XSD.integer,
|
|
99
|
+
float: XSD.float,
|
|
100
|
+
double: XSD.double,
|
|
101
|
+
dateTime: XSD.dateTime,
|
|
102
|
+
json: RDF.JSON
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export function getEntityValue<T>(
|
|
106
|
+
value: T,
|
|
107
|
+
dataType: keyof typeof dataTypeMapping = 'string'
|
|
108
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
109
|
+
): { '@type': string; '@value': T } {
|
|
110
|
+
return {
|
|
111
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
112
|
+
'@type': dataTypeMapping[dataType],
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
114
|
+
'@value': value
|
|
115
|
+
};
|
|
116
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { createNamespace } from './helper';
|
|
2
|
+
|
|
3
|
+
export const XSD_NAMESPACE = 'http://www.w3.org/2001/XMLSchema#';
|
|
4
|
+
export const RDF_NAMESPACE = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#';
|
|
5
|
+
export const RDFS_NAMESPACE = 'http://www.w3.org/2000/01/rdf-schema#';
|
|
6
|
+
export const R2RML_NAMESPACE = 'http://www.w3.org/ns/r2rml#';
|
|
7
|
+
export const OWL_NAMESPACE = 'https://www.w3.org/2002/07/owl#';
|
|
8
|
+
export const SHACL_NAMESPACE = 'http://www.w3.org/ns/shacl#';
|
|
9
|
+
|
|
10
|
+
export const RDF = createNamespace(RDF_NAMESPACE, [ 'Property', 'type', 'datatype', 'JSON', 'first', 'rest', 'nil' ]);
|
|
11
|
+
|
|
12
|
+
export const RDFS = createNamespace(RDFS_NAMESPACE, [ 'subClassOf', 'label', 'range', 'domain' ]);
|
|
13
|
+
|
|
14
|
+
export const R2RML = createNamespace(R2RML_NAMESPACE, [ 'TriplesMap' ]);
|
|
15
|
+
|
|
16
|
+
export const XSD = createNamespace(XSD_NAMESPACE, [
|
|
17
|
+
'boolean',
|
|
18
|
+
'integer',
|
|
19
|
+
'double',
|
|
20
|
+
'decimal',
|
|
21
|
+
'string',
|
|
22
|
+
'float',
|
|
23
|
+
'positiveInteger',
|
|
24
|
+
'negativeInteger',
|
|
25
|
+
'int',
|
|
26
|
+
'date',
|
|
27
|
+
'time',
|
|
28
|
+
'dateTime',
|
|
29
|
+
'label'
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
export const OWL = createNamespace(OWL_NAMESPACE, [
|
|
33
|
+
'Restriction',
|
|
34
|
+
'onProperty',
|
|
35
|
+
'allValuesFrom',
|
|
36
|
+
'Class',
|
|
37
|
+
'intersectionOf',
|
|
38
|
+
'someValuesFrom',
|
|
39
|
+
'ObjectProperty'
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
export const SHACL = createNamespace(SHACL_NAMESPACE, [
|
|
43
|
+
'NodeShape',
|
|
44
|
+
'PropertyShape',
|
|
45
|
+
'Literal',
|
|
46
|
+
'IRI',
|
|
47
|
+
'BlankNode',
|
|
48
|
+
'BlankNodeOrIRI',
|
|
49
|
+
'BlankNodeOrLiteral',
|
|
50
|
+
'IRIOrLiteral',
|
|
51
|
+
'property',
|
|
52
|
+
'path',
|
|
53
|
+
'name',
|
|
54
|
+
'description',
|
|
55
|
+
'minCount',
|
|
56
|
+
'maxCount',
|
|
57
|
+
'targetNode',
|
|
58
|
+
'targetClass',
|
|
59
|
+
'targetSubjectsOf',
|
|
60
|
+
'targetObjectOf',
|
|
61
|
+
'severity',
|
|
62
|
+
'message',
|
|
63
|
+
'deactivated',
|
|
64
|
+
'and',
|
|
65
|
+
'or',
|
|
66
|
+
'class',
|
|
67
|
+
'closed',
|
|
68
|
+
'ignoredProperties',
|
|
69
|
+
'datatype',
|
|
70
|
+
'disjoint',
|
|
71
|
+
'equals',
|
|
72
|
+
'in',
|
|
73
|
+
'languageIn',
|
|
74
|
+
'lessThan',
|
|
75
|
+
'lessThanOrEquals',
|
|
76
|
+
'maxCount',
|
|
77
|
+
'maxExclusive',
|
|
78
|
+
'maxInclusive',
|
|
79
|
+
'maxLength',
|
|
80
|
+
'minCount',
|
|
81
|
+
'minExclusive',
|
|
82
|
+
'minInclusive',
|
|
83
|
+
'minLength',
|
|
84
|
+
'nodeKind',
|
|
85
|
+
'pattern',
|
|
86
|
+
'flags',
|
|
87
|
+
'qualifiedMaxCount',
|
|
88
|
+
'qualifiedMinCount',
|
|
89
|
+
'qualifiedValueShape',
|
|
90
|
+
'qualifiedValueShapesDisjoint',
|
|
91
|
+
'uniqueLang',
|
|
92
|
+
'xone',
|
|
93
|
+
'inversePath',
|
|
94
|
+
'zeroOrMorePath',
|
|
95
|
+
'oneOrMorePath',
|
|
96
|
+
'zeroOrOnePath',
|
|
97
|
+
'alternativePath',
|
|
98
|
+
'node'
|
|
99
|
+
]);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type Namespace<T extends string, TBase extends string> = {
|
|
2
|
+
[key in T]: `${TBase}${key}`;
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
export function createNamespace<T extends string, TBase extends string>(
|
|
6
|
+
baseUri: TBase,
|
|
7
|
+
localNames: T[]
|
|
8
|
+
): Namespace<T, TBase> {
|
|
9
|
+
return localNames.reduce(
|
|
10
|
+
(obj: Namespace<T, TBase>, localName): Namespace<T, TBase> => ({ ...obj, [localName]: `${baseUri}${localName}` }),
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/prefer-reduce-type-parameter
|
|
12
|
+
{} as Namespace<T, TBase>
|
|
13
|
+
);
|
|
14
|
+
}
|