@shaclmate/compiler 4.0.22 → 4.0.24
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/ShapesGraphToAstTransformer.js +16 -16
- package/dist/_ShapesGraphToAstTransformer/shapeAstTypeName.js +6 -5
- package/dist/_ShapesGraphToAstTransformer/shapeNodeKinds.js +1 -1
- package/dist/_ShapesGraphToAstTransformer/shapeOntology.js +4 -3
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +12 -11
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.js +3 -3
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +6 -9
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +11 -12
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +1 -1
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.js +3 -3
- package/dist/ast/AbstractLazyObjectType.d.ts +0 -2
- package/dist/ast/ListType.d.ts +1 -8
- package/dist/ast/ListType.js +1 -6
- package/dist/ast/ObjectType.d.ts +7 -9
- package/dist/ast/ObjectType.js +7 -8
- package/dist/generators/ts/AbstractLazyObjectType.d.ts +1 -0
- package/dist/generators/ts/AbstractLazyObjectType.js +7 -0
- package/dist/generators/ts/AbstractNamedUnionType.d.ts +3 -2
- package/dist/generators/ts/AbstractNamedUnionType.js +23 -9
- package/dist/generators/ts/AbstractTermType.d.ts +1 -0
- package/dist/generators/ts/AbstractTermType.js +3 -0
- package/dist/generators/ts/AbstractType.d.ts +12 -4
- package/dist/generators/ts/AbstractUnionType.d.ts +1 -0
- package/dist/generators/ts/AbstractUnionType.js +11 -1
- package/dist/generators/ts/AnonymousUnionType.d.ts +2 -1
- package/dist/generators/ts/AnonymousUnionType.js +6 -3
- package/dist/generators/ts/DefaultValueType.d.ts +2 -1
- package/dist/generators/ts/DefaultValueType.js +6 -3
- package/dist/generators/ts/ListType.d.ts +2 -5
- package/dist/generators/ts/ListType.js +11 -27
- package/dist/generators/ts/NamedObjectType.d.ts +2 -9
- package/dist/generators/ts/NamedObjectType.js +12 -29
- package/dist/generators/ts/NamedObjectUnionType.js +1 -1
- package/dist/generators/ts/OptionType.d.ts +1 -0
- package/dist/generators/ts/OptionType.js +3 -0
- package/dist/generators/ts/SetType.d.ts +1 -0
- package/dist/generators/ts/SetType.js +3 -0
- package/dist/generators/ts/TypeFactory.js +9 -46
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.d.ts +23 -15
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.js +6 -0
- package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.d.ts +3 -4
- package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.js +26 -11
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.d.ts +5 -14
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.js +34 -201
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_classDeclaration.js +3 -11
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionOrMethodDeclaration.js +10 -9
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterFunctionDeclaration.js +4 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js +1 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +5 -10
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionOrMethodDeclarations.js +13 -9
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_interfaceDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js +11 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionOrMethodDeclaration.js +8 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.js +4 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionOrMethodDeclaration.d.ts +4 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionOrMethodDeclaration.js +66 -0
- package/dist/generators/ts/_NamedObjectType/Property.d.ts +1 -2
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.d.ts +6 -5
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.js +26 -20
- package/dist/generators/ts/_snippets/snippets_LazyObject.js +2 -2
- package/dist/generators/ts/_snippets/snippets_LazyObjectOption.js +2 -2
- package/dist/generators/ts/_snippets/snippets_LazyObjectSet.js +2 -2
- package/dist/generators/ts/_snippets/snippets_PropertyPath.js +5 -3
- package/dist/generators/ts/_snippets/snippets_compactRecord.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_compactRecord.js +16 -0
- package/dist/generators/ts/_snippets/{parseIri.d.ts → snippets_parseIri.d.ts} +1 -1
- package/dist/generators/ts/_snippets/{parseIri.js → snippets_parseIri.js} +1 -1
- package/dist/generators/ts/imports.d.ts +1 -3
- package/dist/generators/ts/imports.js +1 -3
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +2 -2
- package/dist/generators/ts/snippets.d.ts +1 -0
- package/dist/generators/ts/snippets.js +3 -1
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +1 -1
- package/dist/input/generated.d.ts +104 -50
- package/dist/input/generated.js +284 -171
- package/package.json +2 -2
- package/dist/_ShapesGraphToAstTransformer/nodeShapeIdentifierMintingStrategy.d.ts +0 -6
- package/dist/_ShapesGraphToAstTransformer/nodeShapeIdentifierMintingStrategy.js +0 -32
- package/dist/enums/IdentifierMintingStrategy.d.ts +0 -9
- package/dist/enums/IdentifierMintingStrategy.js +0 -18
- package/dist/generators/ts/_NamedObjectType/IdentifierPrefixProperty.d.ts +0 -32
- package/dist/generators/ts/_NamedObjectType/IdentifierPrefixProperty.js +0 -89
package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionOrMethodDeclaration.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { NamedObjectType } from "../NamedObjectType.js";
|
|
2
|
+
import { type Code } from "../ts-poet-wrapper.js";
|
|
3
|
+
export declare function NamedObjectType_toStringFunctionOrMethodDeclarations(this: NamedObjectType): readonly Code[];
|
|
4
|
+
//# sourceMappingURL=NamedObjectType_toStringFunctionOrMethodDeclaration.d.ts.map
|
package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionOrMethodDeclaration.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { snippets } from "../snippets.js";
|
|
2
|
+
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
3
|
+
import { code, joinCode, literalOf } from "../ts-poet-wrapper.js";
|
|
4
|
+
export function NamedObjectType_toStringFunctionOrMethodDeclarations() {
|
|
5
|
+
const propertiesToStringRecordProperties = [];
|
|
6
|
+
if (this.parentObjectTypes.length > 0) {
|
|
7
|
+
switch (this.declarationType) {
|
|
8
|
+
case "class": {
|
|
9
|
+
propertiesToStringRecordProperties.push(code `...super.${syntheticNamePrefix}propertiesToStrings()`);
|
|
10
|
+
break;
|
|
11
|
+
}
|
|
12
|
+
case "interface": {
|
|
13
|
+
for (const parentObjectType of this.parentObjectTypes) {
|
|
14
|
+
propertiesToStringRecordProperties.push(code `...${parentObjectType.staticModuleName}.${syntheticNamePrefix}propertiesToStrings(${this.thisVariable})`);
|
|
15
|
+
}
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
for (const property of this.properties) {
|
|
21
|
+
property
|
|
22
|
+
.toStringExpression({
|
|
23
|
+
variables: {
|
|
24
|
+
value: property.accessExpression({
|
|
25
|
+
variables: { object: this.thisVariable },
|
|
26
|
+
}),
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
.ifJust((propertyToStringExpression) => {
|
|
30
|
+
propertiesToStringRecordProperties.push(code `${literalOf(property.name)}: ${propertyToStringExpression}`);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const propertiesToStringsReturnExpression = code `${snippets.compactRecord}({${joinCode(propertiesToStringRecordProperties, { on: "," })}})`;
|
|
34
|
+
const toStringReturnExpression = (propertiesToStrings) => code `\`${this.name}(\${JSON.stringify(${propertiesToStrings})})\``;
|
|
35
|
+
switch (this.declarationType) {
|
|
36
|
+
case "class": {
|
|
37
|
+
let propertiesToStringsPreamble = "";
|
|
38
|
+
let toStringPreamble = "";
|
|
39
|
+
if (this.parentObjectTypes.length > 0) {
|
|
40
|
+
propertiesToStringsPreamble = "override ";
|
|
41
|
+
toStringPreamble = "override ";
|
|
42
|
+
}
|
|
43
|
+
propertiesToStringsPreamble = `protected ${propertiesToStringsPreamble}`;
|
|
44
|
+
return [
|
|
45
|
+
code `${propertiesToStringsPreamble}${syntheticNamePrefix}propertiesToStrings(): Record<string, string> { return ${propertiesToStringsReturnExpression}; }`,
|
|
46
|
+
code `${toStringPreamble}toString(): string { return ${toStringReturnExpression(code `this.${syntheticNamePrefix}propertiesToStrings()`)}; }`,
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
case "interface": {
|
|
50
|
+
return [
|
|
51
|
+
// Use overloads to allow the function to be attached to an instance or used freestanding
|
|
52
|
+
code `\
|
|
53
|
+
export function ${syntheticNamePrefix}propertiesToStrings(${this.thisVariable}: ${this.name}): Record<string, string> {
|
|
54
|
+
return ${propertiesToStringsReturnExpression};
|
|
55
|
+
}`,
|
|
56
|
+
code `\
|
|
57
|
+
export function ${syntheticNamePrefix}toString(this: ${this.name}): string;
|
|
58
|
+
export function ${syntheticNamePrefix}toString(${this.thisVariable}: ${this.name}): string;
|
|
59
|
+
export function ${syntheticNamePrefix}toString(this: ${this.name} | undefined, ${this.thisVariable}?: ${this.name}): string {
|
|
60
|
+
return ${toStringReturnExpression(code `${syntheticNamePrefix}propertiesToStrings((${this.thisVariable} ?? this)!)`)};
|
|
61
|
+
}`,
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=NamedObjectType_toStringFunctionOrMethodDeclaration.js.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Type } from "../Type.js";
|
|
2
2
|
import type { DiscriminantProperty } from "./DiscriminantProperty.js";
|
|
3
|
-
import type { IdentifierPrefixProperty } from "./IdentifierPrefixProperty.js";
|
|
4
3
|
import type { IdentifierProperty } from "./IdentifierProperty.js";
|
|
5
4
|
import type { ShaclProperty } from "./ShaclProperty.js";
|
|
6
|
-
export type Property = IdentifierProperty |
|
|
5
|
+
export type Property = IdentifierProperty | ShaclProperty<Type> | DiscriminantProperty;
|
|
7
6
|
//# sourceMappingURL=Property.d.ts.map
|
|
@@ -6,30 +6,30 @@ import { AbstractProperty } from "./AbstractProperty.js";
|
|
|
6
6
|
export declare class ShaclProperty<TypeT extends Type> extends AbstractProperty<TypeT> {
|
|
7
7
|
private readonly comment;
|
|
8
8
|
private readonly description;
|
|
9
|
+
private readonly display;
|
|
9
10
|
private readonly label;
|
|
10
11
|
readonly kind = "ShaclProperty";
|
|
11
12
|
readonly mutable: boolean;
|
|
12
13
|
readonly path: PropertyPath;
|
|
13
14
|
readonly recursive: boolean;
|
|
14
|
-
constructor({ comment, description, label, mutable, path, recursive, ...superParameters }: {
|
|
15
|
+
constructor({ comment, description, display, label, mutable, path, recursive, ...superParameters }: {
|
|
15
16
|
comment: Maybe<string>;
|
|
16
17
|
description: Maybe<string>;
|
|
18
|
+
display: boolean;
|
|
17
19
|
label: Maybe<string>;
|
|
18
20
|
mutable: boolean;
|
|
19
21
|
path: PropertyPath;
|
|
20
22
|
recursive: boolean;
|
|
21
23
|
} & ConstructorParameters<typeof AbstractProperty<TypeT>>[0]);
|
|
22
24
|
get constructorParametersSignature(): Maybe<Code>;
|
|
23
|
-
get declaration():
|
|
24
|
-
get equalsFunction(): Maybe<Code>;
|
|
25
|
+
get declaration(): Code;
|
|
25
26
|
get filterProperty(): Maybe<{
|
|
26
27
|
name: string;
|
|
27
28
|
type: Code;
|
|
28
29
|
}>;
|
|
29
|
-
get getAccessorDeclaration(): Maybe<Code>;
|
|
30
30
|
get graphqlField(): AbstractProperty<TypeT>["graphqlField"];
|
|
31
|
+
get jsonSchema(): AbstractProperty<TypeT>["jsonSchema"];
|
|
31
32
|
get jsonSignature(): Maybe<Code>;
|
|
32
|
-
get jsonZchema(): AbstractProperty<TypeT>["jsonZchema"];
|
|
33
33
|
protected get schemaObject(): {
|
|
34
34
|
path: Code | undefined;
|
|
35
35
|
kind: Code;
|
|
@@ -44,6 +44,7 @@ export declare class ShaclProperty<TypeT extends Type> extends AbstractProperty<
|
|
|
44
44
|
sparqlWherePatternsExpression({ variables, }: Parameters<AbstractProperty<TypeT>["sparqlWherePatternsExpression"]>[0]): ReturnType<AbstractProperty<TypeT>["sparqlWherePatternsExpression"]>;
|
|
45
45
|
toJsonObjectMemberExpression(parameters: Parameters<AbstractProperty<TypeT>["toJsonObjectMemberExpression"]>[0]): Maybe<Code>;
|
|
46
46
|
toRdfRdfResourceValuesStatements({ variables, }: Parameters<AbstractProperty<TypeT>["toRdfRdfResourceValuesStatements"]>[0]): readonly Code[];
|
|
47
|
+
toStringExpression(parameters: Parameters<AbstractProperty<TypeT>["toStringExpression"]>[0]): Maybe<Code>;
|
|
47
48
|
private propertyPathToCode;
|
|
48
49
|
}
|
|
49
50
|
//# sourceMappingURL=ShaclProperty.d.ts.map
|
|
@@ -16,15 +16,17 @@ import { AbstractProperty } from "./AbstractProperty.js";
|
|
|
16
16
|
export class ShaclProperty extends AbstractProperty {
|
|
17
17
|
comment;
|
|
18
18
|
description;
|
|
19
|
+
display;
|
|
19
20
|
label;
|
|
20
21
|
kind = "ShaclProperty";
|
|
21
22
|
mutable;
|
|
22
23
|
path;
|
|
23
24
|
recursive;
|
|
24
|
-
constructor({ comment, description, label, mutable, path, recursive, ...superParameters }) {
|
|
25
|
+
constructor({ comment, description, display, label, mutable, path, recursive, ...superParameters }) {
|
|
25
26
|
super(superParameters);
|
|
26
27
|
this.comment = comment;
|
|
27
28
|
this.description = description;
|
|
29
|
+
this.display = display;
|
|
28
30
|
this.label = label;
|
|
29
31
|
this.mutable = mutable;
|
|
30
32
|
this.path = path;
|
|
@@ -53,14 +55,11 @@ export class ShaclProperty extends AbstractProperty {
|
|
|
53
55
|
lhs.push(code `readonly`);
|
|
54
56
|
}
|
|
55
57
|
lhs.push(code `${this.name}`);
|
|
56
|
-
return
|
|
58
|
+
return code `${this.comment
|
|
57
59
|
.alt(this.description)
|
|
58
60
|
.alt(this.label)
|
|
59
61
|
.map(tsComment)
|
|
60
|
-
.orDefault("")}${joinCode(lhs, { on: " " })}: ${this.type.name}
|
|
61
|
-
}
|
|
62
|
-
get equalsFunction() {
|
|
63
|
-
return Maybe.of(this.type.equalsFunction);
|
|
62
|
+
.orDefault("")}${joinCode(lhs, { on: " " })}: ${this.type.name};`;
|
|
64
63
|
}
|
|
65
64
|
get filterProperty() {
|
|
66
65
|
if (this.visibility !== "public") {
|
|
@@ -71,9 +70,6 @@ export class ShaclProperty extends AbstractProperty {
|
|
|
71
70
|
type: this.type.filterType,
|
|
72
71
|
});
|
|
73
72
|
}
|
|
74
|
-
get getAccessorDeclaration() {
|
|
75
|
-
return Maybe.empty();
|
|
76
|
-
}
|
|
77
73
|
get graphqlField() {
|
|
78
74
|
const args = this.type.graphqlArgs;
|
|
79
75
|
const argsVariable = args.isJust() ? code `args` : code `_args`;
|
|
@@ -85,22 +81,29 @@ export class ShaclProperty extends AbstractProperty {
|
|
|
85
81
|
type: this.type.graphqlType.name,
|
|
86
82
|
});
|
|
87
83
|
}
|
|
88
|
-
get
|
|
89
|
-
const typeJsonType = this.type.jsonType();
|
|
90
|
-
return Maybe.of(code `${!this.mutable ? "readonly " : ""}${this.name}${typeJsonType.optional ? "?" : ""}: ${typeJsonType.requiredName}`);
|
|
91
|
-
}
|
|
92
|
-
get jsonZchema() {
|
|
84
|
+
get jsonSchema() {
|
|
93
85
|
let schema = this.type.jsonSchema({
|
|
94
86
|
context: "property",
|
|
95
87
|
});
|
|
88
|
+
const meta = {
|
|
89
|
+
id: `${this.namedObjectType.name}-${this.name}`, // id's must be unique
|
|
90
|
+
};
|
|
96
91
|
this.comment.alt(this.description).ifJust((description) => {
|
|
97
|
-
|
|
92
|
+
meta["description"] = description;
|
|
93
|
+
});
|
|
94
|
+
this.label.ifJust((label) => {
|
|
95
|
+
meta["title"] = label;
|
|
98
96
|
});
|
|
97
|
+
schema = code `${schema}.meta(${meta})`;
|
|
99
98
|
return Maybe.of({
|
|
100
99
|
key: this.name,
|
|
101
100
|
schema,
|
|
102
101
|
});
|
|
103
102
|
}
|
|
103
|
+
get jsonSignature() {
|
|
104
|
+
const typeJsonType = this.type.jsonType();
|
|
105
|
+
return Maybe.of(code `${!this.mutable ? "readonly " : ""}${this.name}${typeJsonType.optional ? "?" : ""}: ${typeJsonType.requiredName}`);
|
|
106
|
+
}
|
|
104
107
|
get schemaObject() {
|
|
105
108
|
return {
|
|
106
109
|
...super.schemaObject,
|
|
@@ -228,6 +231,12 @@ export class ShaclProperty extends AbstractProperty {
|
|
|
228
231
|
})}, ${variables.graph});`,
|
|
229
232
|
];
|
|
230
233
|
}
|
|
234
|
+
toStringExpression(parameters) {
|
|
235
|
+
if (!this.display) {
|
|
236
|
+
return Maybe.empty();
|
|
237
|
+
}
|
|
238
|
+
return Maybe.of(this.type.toStringExpression(parameters));
|
|
239
|
+
}
|
|
231
240
|
propertyPathToCode(propertyPath) {
|
|
232
241
|
switch (propertyPath.termType) {
|
|
233
242
|
case "AlternativePath":
|
|
@@ -249,9 +258,6 @@ __decorate([
|
|
|
249
258
|
__decorate([
|
|
250
259
|
Memoize()
|
|
251
260
|
], ShaclProperty.prototype, "declaration", null);
|
|
252
|
-
__decorate([
|
|
253
|
-
Memoize()
|
|
254
|
-
], ShaclProperty.prototype, "equalsFunction", null);
|
|
255
261
|
__decorate([
|
|
256
262
|
Memoize()
|
|
257
263
|
], ShaclProperty.prototype, "filterProperty", null);
|
|
@@ -260,8 +266,8 @@ __decorate([
|
|
|
260
266
|
], ShaclProperty.prototype, "graphqlField", null);
|
|
261
267
|
__decorate([
|
|
262
268
|
Memoize()
|
|
263
|
-
], ShaclProperty.prototype, "
|
|
269
|
+
], ShaclProperty.prototype, "jsonSchema", null);
|
|
264
270
|
__decorate([
|
|
265
271
|
Memoize()
|
|
266
|
-
], ShaclProperty.prototype, "
|
|
272
|
+
], ShaclProperty.prototype, "jsonSignature", null);
|
|
267
273
|
//# sourceMappingURL=ShaclProperty.js.map
|
|
@@ -5,7 +5,7 @@ export const snippets_LazyObject = conditionalOutput(`${syntheticNamePrefix}Lazy
|
|
|
5
5
|
/**
|
|
6
6
|
* Type of lazy properties that return a single required object. This is a class instead of an interface so it can be instanceof'd elsewhere.
|
|
7
7
|
*/
|
|
8
|
-
export class ${syntheticNamePrefix}LazyObject<ObjectIdentifierT extends ${imports.BlankNode} | ${imports.NamedNode}, PartialObjectT extends { ${syntheticNamePrefix}identifier: ObjectIdentifierT }, ResolvedObjectT extends { ${syntheticNamePrefix}identifier: ObjectIdentifierT }> {
|
|
8
|
+
export class ${syntheticNamePrefix}LazyObject<ObjectIdentifierT extends ${imports.BlankNode} | ${imports.NamedNode}, PartialObjectT extends { ${syntheticNamePrefix}identifier: () => ObjectIdentifierT }, ResolvedObjectT extends { ${syntheticNamePrefix}identifier: () => ObjectIdentifierT }> {
|
|
9
9
|
readonly partial: PartialObjectT;
|
|
10
10
|
private readonly resolver: (identifier: ObjectIdentifierT, options?: { preferredLanguages?: readonly string[] }) => Promise<${imports.Either}<Error, ResolvedObjectT>>;
|
|
11
11
|
|
|
@@ -18,7 +18,7 @@ export class ${syntheticNamePrefix}LazyObject<ObjectIdentifierT extends ${import
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
resolve(options?: { preferredLanguages?: readonly string[] }): Promise<${imports.Either}<Error, ResolvedObjectT>> {
|
|
21
|
-
return this.resolver(this.partial.${syntheticNamePrefix}identifier, options);
|
|
21
|
+
return this.resolver(this.partial.${syntheticNamePrefix}identifier(), options);
|
|
22
22
|
}
|
|
23
23
|
}`);
|
|
24
24
|
//# sourceMappingURL=snippets_LazyObject.js.map
|
|
@@ -5,7 +5,7 @@ export const snippets_LazyObjectOption = conditionalOutput(`${syntheticNamePrefi
|
|
|
5
5
|
/**
|
|
6
6
|
* Type of lazy properties that return a single optional object. This is a class instead of an interface so it can be instanceof'd elsewhere.
|
|
7
7
|
*/
|
|
8
|
-
export class ${syntheticNamePrefix}LazyObjectOption<ObjectIdentifierT extends ${imports.BlankNode} | ${imports.NamedNode}, PartialObjectT extends { ${syntheticNamePrefix}identifier: ObjectIdentifierT }, ResolvedObjectT extends { ${syntheticNamePrefix}identifier: ObjectIdentifierT }> {
|
|
8
|
+
export class ${syntheticNamePrefix}LazyObjectOption<ObjectIdentifierT extends ${imports.BlankNode} | ${imports.NamedNode}, PartialObjectT extends { ${syntheticNamePrefix}identifier: () => ObjectIdentifierT }, ResolvedObjectT extends { ${syntheticNamePrefix}identifier: () => ObjectIdentifierT }> {
|
|
9
9
|
readonly partial: ${imports.Maybe}<PartialObjectT>;
|
|
10
10
|
private readonly resolver: (identifier: ObjectIdentifierT, options?: { preferredLanguages?: readonly string[] }) => Promise<${imports.Either}<Error, ResolvedObjectT>>;
|
|
11
11
|
|
|
@@ -21,7 +21,7 @@ export class ${syntheticNamePrefix}LazyObjectOption<ObjectIdentifierT extends ${
|
|
|
21
21
|
if (this.partial.isNothing()) {
|
|
22
22
|
return ${imports.Right}(${imports.Maybe}.empty());
|
|
23
23
|
}
|
|
24
|
-
return (await this.resolver(this.partial.unsafeCoerce().${syntheticNamePrefix}identifier, options)).map(${imports.Maybe}.of);
|
|
24
|
+
return (await this.resolver(this.partial.unsafeCoerce().${syntheticNamePrefix}identifier(), options)).map(${imports.Maybe}.of);
|
|
25
25
|
}
|
|
26
26
|
}`);
|
|
27
27
|
//# sourceMappingURL=snippets_LazyObjectOption.js.map
|
|
@@ -5,7 +5,7 @@ export const snippets_LazyObjectSet = conditionalOutput(`${syntheticNamePrefix}L
|
|
|
5
5
|
/**
|
|
6
6
|
* Type of lazy properties that return a set of objects. This is a class instead of an interface so it can be instanceof'd elsewhere.
|
|
7
7
|
*/
|
|
8
|
-
export class ${syntheticNamePrefix}LazyObjectSet<ObjectIdentifierT extends ${imports.BlankNode} | ${imports.NamedNode}, PartialObjectT extends { ${syntheticNamePrefix}identifier: ObjectIdentifierT }, ResolvedObjectT extends { ${syntheticNamePrefix}identifier: ObjectIdentifierT }> {
|
|
8
|
+
export class ${syntheticNamePrefix}LazyObjectSet<ObjectIdentifierT extends ${imports.BlankNode} | ${imports.NamedNode}, PartialObjectT extends { ${syntheticNamePrefix}identifier: () => ObjectIdentifierT }, ResolvedObjectT extends { ${syntheticNamePrefix}identifier: () => ObjectIdentifierT }> {
|
|
9
9
|
readonly partials: readonly PartialObjectT[];
|
|
10
10
|
private readonly resolver: (identifiers: readonly ObjectIdentifierT[], options?: { preferredLanguages?: readonly string[] }) => Promise<${imports.Either}<Error, readonly ResolvedObjectT[]>>;
|
|
11
11
|
|
|
@@ -36,7 +36,7 @@ export class ${syntheticNamePrefix}LazyObjectSet<ObjectIdentifierT extends ${imp
|
|
|
36
36
|
offset = 0;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
return await this.resolver(this.partials.slice(offset, offset + limit).map(partial => partial.${syntheticNamePrefix}identifier), { preferredLanguages: options?.preferredLanguages });
|
|
39
|
+
return await this.resolver(this.partials.slice(offset, offset + limit).map(partial => partial.${syntheticNamePrefix}identifier()), { preferredLanguages: options?.preferredLanguages });
|
|
40
40
|
}
|
|
41
41
|
}`);
|
|
42
42
|
//# sourceMappingURL=snippets_LazyObjectSet.js.map
|
|
@@ -8,7 +8,7 @@ import { snippets_ToRdfResourceFunction } from "./snippets_ToRdfResourceFunction
|
|
|
8
8
|
* Adapter between generated code and the rdfjs-resource PropertyPath.
|
|
9
9
|
*/
|
|
10
10
|
export const snippets_PropertyPath = conditionalOutput(`${syntheticNamePrefix}PropertyPath`, code `\
|
|
11
|
-
export type ${syntheticNamePrefix}PropertyPath = ${imports.
|
|
11
|
+
export type ${syntheticNamePrefix}PropertyPath = ${imports.RdfxResourcePropertyPath};
|
|
12
12
|
|
|
13
13
|
export namespace ${syntheticNamePrefix}PropertyPath {
|
|
14
14
|
export type $Filter = object;
|
|
@@ -17,7 +17,7 @@ export namespace ${syntheticNamePrefix}PropertyPath {
|
|
|
17
17
|
return true;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export const ${syntheticNamePrefix}fromRdfResource: ${snippets_FromRdfResourceFunction}<${syntheticNamePrefix}PropertyPath> = ${imports.
|
|
20
|
+
export const ${syntheticNamePrefix}fromRdfResource: ${snippets_FromRdfResourceFunction}<${syntheticNamePrefix}PropertyPath> = ${imports.RdfxResourcePropertyPath}.fromResource;
|
|
21
21
|
|
|
22
22
|
export const $fromRdfResourceValues: ${snippets_FromRdfResourceValuesFunction}<${syntheticNamePrefix}PropertyPath> = (values, options) =>
|
|
23
23
|
values.chain((values) =>
|
|
@@ -30,6 +30,8 @@ export namespace ${syntheticNamePrefix}PropertyPath {
|
|
|
30
30
|
|
|
31
31
|
export const $schema: Readonly<object> = {};
|
|
32
32
|
|
|
33
|
-
export const ${syntheticNamePrefix}toRdfResource: ${snippets_ToRdfResourceFunction}<${syntheticNamePrefix}PropertyPath> = ${imports.
|
|
33
|
+
export const ${syntheticNamePrefix}toRdfResource: ${snippets_ToRdfResourceFunction}<${syntheticNamePrefix}PropertyPath> = ${imports.RdfxResourcePropertyPath}.toResource;
|
|
34
|
+
|
|
35
|
+
export const ${syntheticNamePrefix}toString = ${imports.RdfxResourcePropertyPath}.toString;
|
|
34
36
|
}`);
|
|
35
37
|
//# sourceMappingURL=snippets_PropertyPath.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
2
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
3
|
+
export const snippets_compactRecord = conditionalOutput(`${syntheticNamePrefix}compactRecord`, code `\
|
|
4
|
+
/**
|
|
5
|
+
* Remove undefined values from a record.
|
|
6
|
+
*/
|
|
7
|
+
function ${syntheticNamePrefix}compactRecord<KeyT extends string, ValueT extends {}>(record: Record<KeyT, ValueT | undefined>): Record<KeyT, ValueT> {
|
|
8
|
+
return \
|
|
9
|
+
Object.entries(record).reduce((definedProperties, [propertyName, propertyValue]) => {
|
|
10
|
+
if (propertyValue !== undefined) {
|
|
11
|
+
definedProperties[propertyName as KeyT] = propertyValue as ValueT;
|
|
12
|
+
}
|
|
13
|
+
return definedProperties;
|
|
14
|
+
}, {} as Record<KeyT, ValueT>);
|
|
15
|
+
}`);
|
|
16
|
+
//# sourceMappingURL=snippets_compactRecord.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const snippets_parseIri: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=snippets_parseIri.d.ts.map
|
|
@@ -9,4 +9,4 @@ export function ${syntheticNamePrefix}parseIri(identifier: string): ${imports.Ei
|
|
|
9
9
|
.chain((identifier) => (identifier.termType === "NamedNode") ? ${imports.Right}(identifier) : ${imports.Left}(new Error("expected identifier to be NamedNode"))) \
|
|
10
10
|
as ${imports.Either}<Error, ${imports.NamedNode}>;
|
|
11
11
|
}`);
|
|
12
|
-
//# sourceMappingURL=
|
|
12
|
+
//# sourceMappingURL=snippets_parseIri.js.map
|
|
@@ -29,13 +29,11 @@ export declare const imports: {
|
|
|
29
29
|
readonly NTriplesTerm: import("ts-poet/build/Import.js").Import;
|
|
30
30
|
readonly Quad: import("ts-poet/build/Import.js").Import;
|
|
31
31
|
readonly Quad_Graph: import("ts-poet/build/Import.js").Import;
|
|
32
|
-
readonly
|
|
32
|
+
readonly RdfxResourcePropertyPath: import("ts-poet/build/Import.js").Import;
|
|
33
33
|
readonly Resource: import("ts-poet/build/Import.js").Import;
|
|
34
34
|
readonly ResourceSet: import("ts-poet/build/Import.js").Import;
|
|
35
35
|
readonly Right: import("ts-poet/build/Import.js").Import;
|
|
36
|
-
readonly sha256: import("ts-poet/build/Import.js").Import;
|
|
37
36
|
readonly sparqljs: import("ts-poet/build/Import.js").Import;
|
|
38
|
-
readonly uuid: import("ts-poet/build/Import.js").Import;
|
|
39
37
|
readonly Variable: import("ts-poet/build/Import.js").Import;
|
|
40
38
|
readonly z: import("ts-poet/build/Import.js").Import;
|
|
41
39
|
};
|
|
@@ -30,13 +30,11 @@ export const imports = {
|
|
|
30
30
|
NTriplesTerm: imp("NTriplesTerm@@rdfx/string"),
|
|
31
31
|
Quad: imp("Quad@@rdfjs/types"),
|
|
32
32
|
Quad_Graph: imp("Quad_Graph@@rdfjs/types"),
|
|
33
|
-
|
|
33
|
+
RdfxResourcePropertyPath: imp("PropertyPath:RdfxResourcePropertyPath@@rdfx/resource"),
|
|
34
34
|
Resource: imp("Resource@@rdfx/resource"),
|
|
35
35
|
ResourceSet: imp("ResourceSet@@rdfx/resource"),
|
|
36
36
|
Right: imp("Right@purify-ts"),
|
|
37
|
-
sha256: imp("sha256@js-sha256"),
|
|
38
37
|
sparqljs: imp("sparqljs*sparqljs"),
|
|
39
|
-
uuid: imp("uuid*uuid"),
|
|
40
38
|
Variable: imp("Variable@@rdfjs/types"),
|
|
41
39
|
z: imp("z@zod"),
|
|
42
40
|
};
|
|
@@ -15,7 +15,7 @@ export function rdfjsDatasetObjectSetClassDeclaration({ namedObjectTypes, namedO
|
|
|
15
15
|
query: `query?: ${syntheticNamePrefix}ObjectSet.Query<ObjectFilterT, ObjectIdentifierT>`,
|
|
16
16
|
};
|
|
17
17
|
const typeParameters = {
|
|
18
|
-
ObjectT: code `ObjectT extends { readonly $identifier: ObjectIdentifierT }`,
|
|
18
|
+
ObjectT: code `ObjectT extends { readonly $identifier: () => ObjectIdentifierT }`,
|
|
19
19
|
ObjectFilterT: code `ObjectFilterT`,
|
|
20
20
|
ObjectIdentifierT: code `ObjectIdentifierT extends ${imports.BlankNode} | ${imports.NamedNode}`,
|
|
21
21
|
};
|
|
@@ -79,7 +79,7 @@ async ${methodSignatures.objectIdentifiers.name}(${methodSignatures.objectIdenti
|
|
|
79
79
|
// objectIdentifiersSync
|
|
80
80
|
code `\
|
|
81
81
|
${methodSignatures.objectIdentifiers.name}Sync(${methodSignatures.objectIdentifiers.parameters}): ${imports.Either}<Error, readonly ${namedObjectType.identifierTypeAlias}[]> {
|
|
82
|
-
return this.${methodSignatures.objects.name}Sync(query).map(objects => objects.map(object => object.${syntheticNamePrefix}identifier));
|
|
82
|
+
return this.${methodSignatures.objects.name}Sync(query).map(objects => objects.map(object => object.${syntheticNamePrefix}identifier()));
|
|
83
83
|
}`,
|
|
84
84
|
// objects
|
|
85
85
|
code `\
|
|
@@ -12,6 +12,7 @@ export declare const snippets: {
|
|
|
12
12
|
booleanSparqlWherePatterns: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
13
13
|
CollectionFilter: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
14
14
|
CollectionSchema: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
15
|
+
compactRecord: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
15
16
|
dateEquals: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
16
17
|
DateFilter: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
17
18
|
DateSchema: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { snippets_parseIri } from "./_snippets/parseIri.js";
|
|
2
1
|
import { snippets_arrayEquals } from "./_snippets/snippets_arrayEquals.js";
|
|
3
2
|
import { snippets_arrayIntersection } from "./_snippets/snippets_arrayIntersection.js";
|
|
4
3
|
import { snippets_BlankNodeFilter } from "./_snippets/snippets_BlankNodeFilter.js";
|
|
@@ -12,6 +11,7 @@ import { snippets_booleanEquals } from "./_snippets/snippets_booleanEquals.js";
|
|
|
12
11
|
import { snippets_booleanSparqlWherePatterns } from "./_snippets/snippets_booleanSparqlWherePatterns.js";
|
|
13
12
|
import { snippets_CollectionFilter } from "./_snippets/snippets_CollectionFilter.js";
|
|
14
13
|
import { snippets_CollectionSchema } from "./_snippets/snippets_CollectionSchema.js";
|
|
14
|
+
import { snippets_compactRecord } from "./_snippets/snippets_compactRecord.js";
|
|
15
15
|
import { snippets_DateFilter } from "./_snippets/snippets_DateFilter.js";
|
|
16
16
|
import { snippets_DateSchema } from "./_snippets/snippets_DateSchema.js";
|
|
17
17
|
import { snippets_DefaultValueSchema } from "./_snippets/snippets_DefaultValueSchema.js";
|
|
@@ -76,6 +76,7 @@ import { snippets_PropertiesFromRdfResourceFunction } from "./_snippets/snippets
|
|
|
76
76
|
import { snippets_PropertyPath } from "./_snippets/snippets_PropertyPath.js";
|
|
77
77
|
import { snippets_parseBlankNode } from "./_snippets/snippets_parseBlankNode.js";
|
|
78
78
|
import { snippets_parseIdentifier } from "./_snippets/snippets_parseIdentifier.js";
|
|
79
|
+
import { snippets_parseIri } from "./_snippets/snippets_parseIri.js";
|
|
79
80
|
import { snippets_RdfVocabularies } from "./_snippets/snippets_RdfVocabularies.js";
|
|
80
81
|
import { snippets_ShaclPropertySchema } from "./_snippets/snippets_ShaclPropertySchema.js";
|
|
81
82
|
import { snippets_SparqlFilterPattern } from "./_snippets/snippets_SparqlFilterPattern.js";
|
|
@@ -118,6 +119,7 @@ export const snippets = {
|
|
|
118
119
|
booleanSparqlWherePatterns: snippets_booleanSparqlWherePatterns,
|
|
119
120
|
CollectionFilter: snippets_CollectionFilter,
|
|
120
121
|
CollectionSchema: snippets_CollectionSchema,
|
|
122
|
+
compactRecord: snippets_compactRecord,
|
|
121
123
|
dateEquals: snippets_dateEquals,
|
|
122
124
|
DateFilter: snippets_DateFilter,
|
|
123
125
|
DateSchema: snippets_DateSchema,
|
|
@@ -15,7 +15,7 @@ export function sparqlObjectSetClassDeclaration({ namedObjectTypes, namedObjectU
|
|
|
15
15
|
selectObjectTypeType: code `namedObjectType: { ${syntheticNamePrefix}focusSparqlWherePatterns: ${snippets.FocusSparqlWherePatternsFunction}<ObjectFilterT> }`,
|
|
16
16
|
};
|
|
17
17
|
const typeParameters = {
|
|
18
|
-
ObjectT: code `ObjectT extends { readonly $identifier: ObjectIdentifierT }`,
|
|
18
|
+
ObjectT: code `ObjectT extends { readonly $identifier: () => ObjectIdentifierT }`,
|
|
19
19
|
ObjectFilterT: code `ObjectFilterT`,
|
|
20
20
|
ObjectIdentifierT: code `ObjectIdentifierT extends ${imports.BlankNode} | ${imports.NamedNode}`,
|
|
21
21
|
};
|