@shaclmate/compiler 4.0.33 → 4.0.34
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/Compiler.d.ts +0 -3
- package/dist/Compiler.js +0 -2
- package/dist/ShapesGraphToAstTransformer.d.ts +1 -4
- package/dist/ShapesGraphToAstTransformer.js +1 -5
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +1 -3
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.js +4 -7
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +0 -1
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +1 -3
- package/dist/ast/AbstractCompoundType.d.ts +6 -4
- package/dist/ast/AbstractCompoundType.js +4 -37
- package/dist/ast/ObjectType.d.ts +1 -7
- package/dist/ast/ObjectType.js +1 -6
- package/dist/generators/ts/AbstractCollectionType.d.ts +8 -8
- package/dist/generators/ts/AbstractCollectionType.js +28 -111
- package/dist/generators/ts/AbstractContainerType.d.ts +1 -1
- package/dist/generators/ts/AbstractDateType.d.ts +4 -9
- package/dist/generators/ts/AbstractDateType.js +2 -29
- package/dist/generators/ts/AbstractIdentifierType.d.ts +4 -1
- package/dist/generators/ts/AbstractIdentifierType.js +0 -17
- package/dist/generators/ts/AbstractLazyObjectType.d.ts +8 -5
- package/dist/generators/ts/AbstractLazyObjectType.js +21 -21
- package/dist/generators/ts/AbstractLiteralType.d.ts +11 -3
- package/dist/generators/ts/AbstractLiteralType.js +1 -1
- package/dist/generators/ts/AbstractNamedUnionType.d.ts +2 -5
- package/dist/generators/ts/AbstractNamedUnionType.js +27 -58
- package/dist/generators/ts/AbstractNumericType.d.ts +9 -8
- package/dist/generators/ts/AbstractNumericType.js +18 -11
- package/dist/generators/ts/AbstractPrimitiveType.d.ts +8 -4
- package/dist/generators/ts/AbstractPrimitiveType.js +9 -17
- package/dist/generators/ts/AbstractTermType.d.ts +8 -4
- package/dist/generators/ts/AbstractTermType.js +11 -51
- package/dist/generators/ts/AbstractType.d.ts +26 -22
- package/dist/generators/ts/AbstractType.js +4 -2
- package/dist/generators/ts/AbstractUnionType.d.ts +2 -2
- package/dist/generators/ts/AbstractUnionType.js +25 -36
- package/dist/generators/ts/AnonymousUnionType.d.ts +1 -1
- package/dist/generators/ts/AnonymousUnionType.js +3 -3
- package/dist/generators/ts/BigDecimalType.d.ts +5 -3
- package/dist/generators/ts/BigDecimalType.js +15 -42
- package/dist/generators/ts/BigIntType.d.ts +3 -4
- package/dist/generators/ts/BigIntType.js +5 -16
- package/dist/generators/ts/BlankNodeType.d.ts +7 -7
- package/dist/generators/ts/BlankNodeType.js +14 -2
- package/dist/generators/ts/BooleanType.d.ts +6 -8
- package/dist/generators/ts/BooleanType.js +18 -11
- package/dist/generators/ts/DateTimeType.d.ts +5 -1
- package/dist/generators/ts/DateTimeType.js +15 -13
- package/dist/generators/ts/DateType.d.ts +5 -1
- package/dist/generators/ts/DateType.js +16 -14
- package/dist/generators/ts/DefaultValueType.d.ts +5 -6
- package/dist/generators/ts/DefaultValueType.js +30 -64
- package/dist/generators/ts/FloatType.d.ts +3 -3
- package/dist/generators/ts/FloatType.js +5 -5
- package/dist/generators/ts/IdentifierType.d.ts +6 -6
- package/dist/generators/ts/IdentifierType.js +22 -2
- package/dist/generators/ts/IntType.d.ts +3 -3
- package/dist/generators/ts/IntType.js +5 -5
- package/dist/generators/ts/IriType.d.ts +17 -12
- package/dist/generators/ts/IriType.js +39 -29
- package/dist/generators/ts/LazyObjectOptionType.d.ts +2 -1
- package/dist/generators/ts/LazyObjectOptionType.js +23 -44
- package/dist/generators/ts/LazyObjectSetType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectSetType.js +19 -29
- package/dist/generators/ts/LazyObjectType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectType.js +17 -25
- package/dist/generators/ts/LiteralType.d.ts +5 -3
- package/dist/generators/ts/LiteralType.js +25 -12
- package/dist/generators/ts/NamedObjectType.d.ts +6 -9
- package/dist/generators/ts/NamedObjectType.js +33 -29
- package/dist/generators/ts/NamedObjectUnionType.d.ts +3 -1
- package/dist/generators/ts/NamedObjectUnionType.js +21 -14
- package/dist/generators/ts/OptionType.d.ts +4 -4
- package/dist/generators/ts/OptionType.js +22 -45
- package/dist/generators/ts/Reusables.d.ts +3 -1
- package/dist/generators/ts/Reusables.js +2 -1
- package/dist/generators/ts/SetType.d.ts +0 -1
- package/dist/generators/ts/SetType.js +4 -22
- package/dist/generators/ts/SnippetFactory.d.ts +2 -0
- package/dist/generators/ts/Snippets.d.ts +40 -8
- package/dist/generators/ts/Snippets.js +235 -30
- package/dist/generators/ts/StringType.d.ts +6 -9
- package/dist/generators/ts/StringType.js +17 -16
- package/dist/generators/ts/TermType.d.ts +1 -4
- package/dist/generators/ts/TermType.js +14 -8
- package/dist/generators/ts/TsGenerator.d.ts +14 -1
- package/dist/generators/ts/TsGenerator.js +41 -12
- package/dist/generators/ts/TypeFactory.d.ts +8 -4
- package/dist/generators/ts/TypeFactory.js +73 -49
- package/dist/generators/ts/ZodGenerator.js +6 -3
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.d.ts +27 -20
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.js +4 -2
- package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.d.ts +7 -7
- package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.js +9 -9
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.d.ts +6 -6
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.js +35 -39
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.js +34 -31
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js +1 -1
- 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 +7 -16
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +26 -32
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.js +2 -3
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js +6 -8
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.js +1 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_objectSetMethodNames.d.ts +2 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_objectSetMethodNames.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js +14 -18
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.d.ts +7 -7
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.js +22 -30
- package/dist/generators/ts/_snippets/snippets_DefaultValueSchema.js +3 -3
- package/dist/generators/ts/_snippets/snippets_HashFunction.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_HashFunction.js +4 -0
- package/dist/generators/ts/_snippets/snippets_PropertyPath.js +34 -24
- package/dist/generators/ts/_snippets/snippets_convertToBigDecimal.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToBigDecimal.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToBlankNode.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToBlankNode.js +11 -0
- package/dist/generators/ts/_snippets/snippets_convertToBlankNodeIdentifierProperty.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToBlankNodeIdentifierProperty.js +17 -0
- package/dist/generators/ts/_snippets/snippets_convertToBoolean.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToBoolean.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToDate.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToDate.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToDateTime.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToDateTime.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToIdentifier.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToIdentifier.js +13 -0
- package/dist/generators/ts/_snippets/snippets_convertToIdentifierProperty.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToIdentifierProperty.js +21 -0
- package/dist/generators/ts/_snippets/snippets_convertToIri.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToIri.js +11 -0
- package/dist/generators/ts/_snippets/snippets_convertToIriIdentifierProperty.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToIriIdentifierProperty.js +17 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObject.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObject.js +15 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.js +31 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.js +25 -0
- package/dist/generators/ts/_snippets/snippets_convertToLiteral.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToLiteral.js +13 -0
- package/dist/generators/ts/_snippets/snippets_convertToMaybe.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToMaybe.js +19 -0
- package/dist/generators/ts/_snippets/snippets_convertToMutableArray.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToMutableArray.js +14 -0
- package/dist/generators/ts/_snippets/snippets_convertToNumeric.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToNumeric.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToObject.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToObject.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToReadonlyArray.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToReadonlyArray.js +14 -0
- package/dist/generators/ts/_snippets/snippets_convertToString.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToString.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToTerm.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToTerm.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToUnion.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToUnion.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertWithDefaultValue.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertWithDefaultValue.js +11 -0
- package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_hashArray.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashArray.js +11 -0
- package/dist/generators/ts/_snippets/snippets_hashBigDecimal.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashBigDecimal.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashBoolean.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashBoolean.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashDate.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashDate.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashDateTime.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashDateTime.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashMaybe.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashMaybe.js +11 -0
- package/dist/generators/ts/_snippets/snippets_hashNumeric.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashNumeric.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashString.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashString.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashTerm.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashTerm.js +12 -0
- package/dist/generators/ts/_snippets/snippets_toIsoDateString.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_toIsoDateString.js +6 -0
- package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +1 -1
- package/dist/generators/ts/graphqlSchemaVariableStatement.js +7 -4
- package/dist/generators/ts/objectSetDeclarations.js +4 -34
- package/dist/generators/ts/objectSetInterfaceDeclaration.js +1 -1
- package/dist/generators/ts/objectSetMethodSignatures.js +2 -2
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +2 -2
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +2 -2
- package/dist/input/ShapesGraph.d.ts +5 -8
- package/dist/input/ShapesGraph.js +5 -6
- package/dist/input/generated.d.ts +171 -226
- package/dist/input/generated.js +563 -2082
- package/package.json +2 -2
- package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.d.ts +0 -6
- package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.js +0 -67
- package/dist/generators/ts/_snippets/snippets_isReadonlyBigIntArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_isReadonlyBigIntArray.js +0 -6
- package/dist/generators/ts/_snippets/snippets_isReadonlyBooleanArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_isReadonlyBooleanArray.js +0 -6
- package/dist/generators/ts/_snippets/snippets_isReadonlyNumberArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_isReadonlyNumberArray.js +0 -6
- package/dist/generators/ts/_snippets/snippets_isReadonlyObjectArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_isReadonlyObjectArray.js +0 -6
- package/dist/generators/ts/_snippets/snippets_isReadonlyStringArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_isReadonlyStringArray.js +0 -6
- package/dist/generators/ts/syntheticNamePrefix.d.ts +0 -2
- package/dist/generators/ts/syntheticNamePrefix.js +0 -2
package/dist/Compiler.d.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import type { Either } from "purify-ts";
|
|
2
2
|
import type { Logger } from "ts-log";
|
|
3
3
|
import type { Generator } from "./generators/Generator.js";
|
|
4
|
-
import type { TsFeature } from "./generators/ts/TsFeature.js";
|
|
5
4
|
import type { ShapesGraph } from "./input/ShapesGraph.js";
|
|
6
5
|
export declare class Compiler {
|
|
7
6
|
private readonly generator;
|
|
8
7
|
private readonly logger;
|
|
9
|
-
private readonly tsFeaturesDefault?;
|
|
10
8
|
constructor({ generator, logger, }: {
|
|
11
9
|
generator: Generator;
|
|
12
10
|
logger: Logger;
|
|
13
|
-
tsFeaturesDefault?: ReadonlySet<TsFeature>;
|
|
14
11
|
});
|
|
15
12
|
compile(shapesGraph: ShapesGraph): Either<Error, string>;
|
|
16
13
|
}
|
package/dist/Compiler.js
CHANGED
|
@@ -2,7 +2,6 @@ import { ShapesGraphToAstTransformer } from "./ShapesGraphToAstTransformer.js";
|
|
|
2
2
|
export class Compiler {
|
|
3
3
|
generator;
|
|
4
4
|
logger;
|
|
5
|
-
tsFeaturesDefault;
|
|
6
5
|
constructor({ generator, logger, }) {
|
|
7
6
|
this.generator = generator;
|
|
8
7
|
this.logger = logger;
|
|
@@ -11,7 +10,6 @@ export class Compiler {
|
|
|
11
10
|
return new ShapesGraphToAstTransformer({
|
|
12
11
|
logger: this.logger,
|
|
13
12
|
shapesGraph,
|
|
14
|
-
tsFeaturesDefault: this.tsFeaturesDefault,
|
|
15
13
|
})
|
|
16
14
|
.transform()
|
|
17
15
|
.map((ast) => this.generator.generate(ast));
|
|
@@ -3,7 +3,6 @@ import type { BlankNode, NamedNode } from "@rdfjs/types";
|
|
|
3
3
|
import { Either } from "purify-ts";
|
|
4
4
|
import type { Logger } from "ts-log";
|
|
5
5
|
import type * as ast from "./ast/index.js";
|
|
6
|
-
import type { TsFeature } from "./generators/ts/TsFeature.js";
|
|
7
6
|
import type * as input from "./input/index.js";
|
|
8
7
|
interface RelatedNodeShapes {
|
|
9
8
|
readonly ancestors: input.NodeShape[];
|
|
@@ -16,11 +15,9 @@ export declare class ShapesGraphToAstTransformer {
|
|
|
16
15
|
protected readonly logger: Logger;
|
|
17
16
|
protected readonly shapesGraph: input.ShapesGraph;
|
|
18
17
|
protected readonly relatedNodeShapesByIdentifier: TermMap<BlankNode | NamedNode, RelatedNodeShapes>;
|
|
19
|
-
|
|
20
|
-
constructor({ logger, shapesGraph, tsFeaturesDefault, }: {
|
|
18
|
+
constructor({ logger, shapesGraph, }: {
|
|
21
19
|
logger: Logger;
|
|
22
20
|
shapesGraph: input.ShapesGraph;
|
|
23
|
-
tsFeaturesDefault?: ReadonlySet<TsFeature>;
|
|
24
21
|
});
|
|
25
22
|
transform(): Either<Error, ast.Ast>;
|
|
26
23
|
}
|
|
@@ -77,17 +77,13 @@ export class ShapesGraphToAstTransformer {
|
|
|
77
77
|
logger;
|
|
78
78
|
shapesGraph;
|
|
79
79
|
relatedNodeShapesByIdentifier = new TermMap();
|
|
80
|
-
|
|
81
|
-
constructor({ logger, shapesGraph, tsFeaturesDefault, }) {
|
|
80
|
+
constructor({ logger, shapesGraph, }) {
|
|
82
81
|
this.logger = logger;
|
|
83
82
|
this.relatedNodeShapesByIdentifier = relatedNodeShapes({
|
|
84
83
|
logger: this.logger,
|
|
85
84
|
shapesGraph,
|
|
86
85
|
});
|
|
87
86
|
this.shapesGraph = shapesGraph;
|
|
88
|
-
this.tsFeaturesDefault =
|
|
89
|
-
tsFeaturesDefault ??
|
|
90
|
-
new Set(["create", "equals", "hash", "json", "rdf"]);
|
|
91
87
|
}
|
|
92
88
|
transform() {
|
|
93
89
|
const astNamedIntersectionTypes = [];
|
|
@@ -6,7 +6,7 @@ import * as ast from "../ast/index.js";
|
|
|
6
6
|
import { Eithers } from "../Eithers.js";
|
|
7
7
|
import { ShapeStack } from "./ShapeStack.js";
|
|
8
8
|
import { transformShapeToAstType } from "./transformShapeToAstType.js";
|
|
9
|
-
function synthesizePartialAstObjectType({ identifierType,
|
|
9
|
+
function synthesizePartialAstObjectType({ identifierType, }) {
|
|
10
10
|
let syntheticName;
|
|
11
11
|
switch (identifierType.kind) {
|
|
12
12
|
case "BlankNodeType":
|
|
@@ -28,7 +28,6 @@ function synthesizePartialAstObjectType({ identifierType, tsFeatures, }) {
|
|
|
28
28
|
shapeIdentifier: dataFactory.namedNode(`urn:shaclmate:synthetic:${syntheticName}`),
|
|
29
29
|
synthetic: true,
|
|
30
30
|
toRdfTypes: [],
|
|
31
|
-
tsFeatures,
|
|
32
31
|
tsImports: [],
|
|
33
32
|
});
|
|
34
33
|
}
|
|
@@ -179,7 +178,6 @@ export function transformPropertyShapeToAstObjectTypeProperty({ objectType, prop
|
|
|
179
178
|
case "IriType":
|
|
180
179
|
astPartialItemType = synthesizePartialAstObjectType({
|
|
181
180
|
identifierType: astItemType,
|
|
182
|
-
tsFeatures: astResolveItemType.tsFeatures,
|
|
183
181
|
});
|
|
184
182
|
break;
|
|
185
183
|
case "ObjectType":
|
|
@@ -2,7 +2,6 @@ import { Either, Left, Maybe } from "purify-ts";
|
|
|
2
2
|
import { invariant } from "ts-invariant";
|
|
3
3
|
import * as ast from "../ast/index.js";
|
|
4
4
|
import { Eithers } from "../Eithers.js";
|
|
5
|
-
import { nodeShapeTsFeatures } from "./nodeShapeTsFeatures.js";
|
|
6
5
|
import { shapeAstTypeName } from "./shapeAstTypeName.js";
|
|
7
6
|
import { transformShapeToAstType } from "./transformShapeToAstType.js";
|
|
8
7
|
/**
|
|
@@ -11,13 +10,11 @@ import { transformShapeToAstType } from "./transformShapeToAstType.js";
|
|
|
11
10
|
export function transformShapeToAstCompoundType(shape, shapeStack) {
|
|
12
11
|
shapeStack.push(shape);
|
|
13
12
|
try {
|
|
14
|
-
return Eithers.
|
|
13
|
+
return Eithers.chain2(Either.sequence(shape.and
|
|
15
14
|
.orDefault([])
|
|
16
|
-
.map((shapeIdentifier) => this.shapesGraph.shape(shapeIdentifier))), shape
|
|
17
|
-
? nodeShapeTsFeatures.call(this, shape)
|
|
18
|
-
: Either.of(new Set()), Either.sequence(shape.xone
|
|
15
|
+
.map((shapeIdentifier) => this.shapesGraph.shape(shapeIdentifier))), Either.sequence(shape.xone
|
|
19
16
|
.orDefault([])
|
|
20
|
-
.map((shapeIdentifier) => this.shapesGraph.shape(shapeIdentifier)))).chain(([andConstraintShapes,
|
|
17
|
+
.map((shapeIdentifier) => this.shapesGraph.shape(shapeIdentifier)))).chain(([andConstraintShapes, xoneConstraintShapes]) => {
|
|
21
18
|
let compoundTypeKind;
|
|
22
19
|
// Distinguish constraints that take arbitrary shapes from those that only take node shapes
|
|
23
20
|
// With the latter we'll do special transformations.
|
|
@@ -42,7 +39,7 @@ export function transformShapeToAstCompoundType(shape, shapeStack) {
|
|
|
42
39
|
label: shape.label,
|
|
43
40
|
name: shapeAstTypeName(shape),
|
|
44
41
|
shapeIdentifier: shape.$identifier(),
|
|
45
|
-
|
|
42
|
+
synthetic: false,
|
|
46
43
|
});
|
|
47
44
|
if (memberShapes.length === 1) {
|
|
48
45
|
return transformShapeToAstType
|
|
@@ -4,7 +4,6 @@ import { invariant } from "ts-invariant";
|
|
|
4
4
|
import * as ast from "../ast/index.js";
|
|
5
5
|
import { Eithers } from "../Eithers.js";
|
|
6
6
|
import { defaultNodeShapeNodeKinds } from "./defaultNodeShapeNodeKinds.js";
|
|
7
|
-
import { nodeShapeTsFeatures } from "./nodeShapeTsFeatures.js";
|
|
8
7
|
import { ShapeStack } from "./ShapeStack.js";
|
|
9
8
|
import { shapeAstTypeName } from "./shapeAstTypeName.js";
|
|
10
9
|
import { shapeNodeKinds } from "./shapeNodeKinds.js";
|
|
@@ -60,7 +59,7 @@ export function transformShapeToAstObjectType(shape, shapeStack) {
|
|
|
60
59
|
if (nodeShape.$identifier().termType !== "NamedNode") {
|
|
61
60
|
return Either.of(Maybe.empty());
|
|
62
61
|
}
|
|
63
|
-
return Eithers.
|
|
62
|
+
return Eithers.chain2(shapeNodeKinds.call(this, nodeShape, { defaultNodeShapeNodeKinds }), Either.sequence(nodeShape.properties.map((propertyShapeIdentifier) => this.shapesGraph.propertyShape(propertyShapeIdentifier)))).chain(([nodeKinds, propertyShapes]) => {
|
|
64
63
|
const nodeShapeIdentifier = nodeShape.$identifier();
|
|
65
64
|
const { ancestors: ancestorNodeShapes, descendants: descendantNodeShapes, children: childNodeShapes, parents: parentNodeShapes, } = this.relatedNodeShapesByIdentifier.get(nodeShapeIdentifier);
|
|
66
65
|
const isClass = nodeShape.subClassOf.length > 0 ||
|
|
@@ -128,7 +127,6 @@ export function transformShapeToAstObjectType(shape, shapeStack) {
|
|
|
128
127
|
shapeIdentifier: nodeShape.$identifier(),
|
|
129
128
|
synthetic: false,
|
|
130
129
|
toRdfTypes,
|
|
131
|
-
tsFeatures,
|
|
132
130
|
tsImports: nodeShape.tsImports,
|
|
133
131
|
});
|
|
134
132
|
this.cachedAstTypesByShapeIdentifier.set(nodeShape.$identifier(), objectType);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { NodeKind } from "@shaclmate/shacl-ast";
|
|
2
|
-
import type { TsFeature } from "../generators/ts/TsFeature.js";
|
|
3
2
|
import { AbstractType } from "./AbstractType.js";
|
|
4
3
|
import type { BlankNodeType } from "./BlankNodeType.js";
|
|
5
4
|
import type { IdentifierType } from "./IdentifierType.js";
|
|
@@ -22,13 +21,16 @@ export declare abstract class AbstractCompoundType<MemberT extends AbstractCompo
|
|
|
22
21
|
* Type discriminant
|
|
23
22
|
*/
|
|
24
23
|
abstract readonly kind: "IntersectionType" | "UnionType";
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Was this type synthesized or did it come from SHACL?
|
|
26
|
+
*/
|
|
27
|
+
readonly synthetic: boolean;
|
|
28
|
+
constructor({ synthetic, ...superParameters }: {
|
|
29
|
+
synthetic: boolean;
|
|
27
30
|
} & ConstructorParameters<typeof AbstractType>[0]);
|
|
28
31
|
get members(): readonly MemberT[];
|
|
29
32
|
get nodeKinds(): ReadonlySet<NodeKind>;
|
|
30
33
|
get recursive(): boolean;
|
|
31
|
-
get tsFeatures(): ReadonlySet<TsFeature>;
|
|
32
34
|
addMember(member: MemberT): void;
|
|
33
35
|
equals(other: AbstractCompoundType<MemberT, MemberTypeT>): boolean;
|
|
34
36
|
}
|
|
@@ -20,12 +20,12 @@ export class AbstractCompoundType extends AbstractType {
|
|
|
20
20
|
*/
|
|
21
21
|
#members = [];
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Was this type synthesized or did it come from SHACL?
|
|
24
24
|
*/
|
|
25
|
-
|
|
26
|
-
constructor({
|
|
25
|
+
synthetic;
|
|
26
|
+
constructor({ synthetic, ...superParameters }) {
|
|
27
27
|
super(superParameters);
|
|
28
|
-
this
|
|
28
|
+
this.synthetic = synthetic;
|
|
29
29
|
}
|
|
30
30
|
get members() {
|
|
31
31
|
return this.#members;
|
|
@@ -42,36 +42,6 @@ export class AbstractCompoundType extends AbstractType {
|
|
|
42
42
|
get recursive() {
|
|
43
43
|
return this.members.some((member) => member.type.recursive);
|
|
44
44
|
}
|
|
45
|
-
get tsFeatures() {
|
|
46
|
-
// Members of the compound type must have the same tsFeatures.
|
|
47
|
-
// They must also have distinct RDF types or no RDF types at all.
|
|
48
|
-
const mergedMemberTsFeatures = new Set();
|
|
49
|
-
for (let memberI = 0; memberI < this.members.length; memberI++) {
|
|
50
|
-
const member = this.members[memberI];
|
|
51
|
-
switch (member.type.kind) {
|
|
52
|
-
case "IntersectionType":
|
|
53
|
-
case "ObjectType":
|
|
54
|
-
case "UnionType":
|
|
55
|
-
break;
|
|
56
|
-
default:
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
if (memberI === 0) {
|
|
60
|
-
for (const tsFeature of member.type.tsFeatures) {
|
|
61
|
-
mergedMemberTsFeatures.add(tsFeature);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (member.type.tsFeatures.size !== mergedMemberTsFeatures.size) {
|
|
65
|
-
throw new Error(`${this} has a member (${member}) with different tsFeatures than the other members`);
|
|
66
|
-
}
|
|
67
|
-
for (const tsFeature of member.type.tsFeatures) {
|
|
68
|
-
if (!mergedMemberTsFeatures.has(tsFeature)) {
|
|
69
|
-
throw new Error(`${this} has a member (${member}) with different tsFeatures than the other members`);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return this.#tsFeatures;
|
|
74
|
-
}
|
|
75
45
|
addMember(member) {
|
|
76
46
|
this.#members.push(member);
|
|
77
47
|
}
|
|
@@ -84,9 +54,6 @@ export class AbstractCompoundType extends AbstractType {
|
|
|
84
54
|
__decorate([
|
|
85
55
|
Memoize()
|
|
86
56
|
], AbstractCompoundType.prototype, "nodeKinds", null);
|
|
87
|
-
__decorate([
|
|
88
|
-
Memoize()
|
|
89
|
-
], AbstractCompoundType.prototype, "tsFeatures", null);
|
|
90
57
|
(function (AbstractCompoundType) {
|
|
91
58
|
function isMemberType(type) {
|
|
92
59
|
switch (type.kind) {
|
package/dist/ast/ObjectType.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type { BlankNode, NamedNode } from "@rdfjs/types";
|
|
|
2
2
|
import { PropertyPath } from "@rdfx/resource";
|
|
3
3
|
import type { NodeKind } from "@shaclmate/shacl-ast";
|
|
4
4
|
import type { Maybe } from "purify-ts";
|
|
5
|
-
import type { TsFeature } from "../generators/ts/TsFeature.js";
|
|
6
5
|
import { AbstractType } from "./AbstractType.js";
|
|
7
6
|
import type { BlankNodeType } from "./BlankNodeType.js";
|
|
8
7
|
import type { IdentifierType } from "./IdentifierType.js";
|
|
@@ -43,10 +42,6 @@ export declare class ObjectType extends AbstractType {
|
|
|
43
42
|
* class targets).
|
|
44
43
|
*/
|
|
45
44
|
readonly toRdfTypes: readonly NamedNode[];
|
|
46
|
-
/**
|
|
47
|
-
* TypeScript features to generate.
|
|
48
|
-
*/
|
|
49
|
-
readonly tsFeatures: ReadonlySet<TsFeature>;
|
|
50
45
|
/**
|
|
51
46
|
* TypeScript imports to add to generated code.
|
|
52
47
|
*
|
|
@@ -56,13 +51,12 @@ export declare class ObjectType extends AbstractType {
|
|
|
56
51
|
* import { MyType } from "./MyType.js"
|
|
57
52
|
*/
|
|
58
53
|
readonly tsImports: readonly string[];
|
|
59
|
-
constructor({ extern, fromRdfType, identifierType, synthetic, toRdfTypes,
|
|
54
|
+
constructor({ extern, fromRdfType, identifierType, synthetic, toRdfTypes, tsImports, ...superParameters }: {
|
|
60
55
|
extern: boolean;
|
|
61
56
|
fromRdfType: Maybe<NamedNode>;
|
|
62
57
|
identifierType: BlankNodeType | IdentifierType | IriType;
|
|
63
58
|
synthetic: boolean;
|
|
64
59
|
toRdfTypes: readonly NamedNode[];
|
|
65
|
-
tsFeatures: ReadonlySet<TsFeature>;
|
|
66
60
|
tsImports: readonly string[];
|
|
67
61
|
} & ConstructorParameters<typeof AbstractType>[0]);
|
|
68
62
|
get ancestorObjectTypes(): readonly ObjectType[];
|
package/dist/ast/ObjectType.js
CHANGED
|
@@ -76,10 +76,6 @@ export class ObjectType extends AbstractType {
|
|
|
76
76
|
* class targets).
|
|
77
77
|
*/
|
|
78
78
|
toRdfTypes;
|
|
79
|
-
/**
|
|
80
|
-
* TypeScript features to generate.
|
|
81
|
-
*/
|
|
82
|
-
tsFeatures;
|
|
83
79
|
/**
|
|
84
80
|
* TypeScript imports to add to generated code.
|
|
85
81
|
*
|
|
@@ -89,14 +85,13 @@ export class ObjectType extends AbstractType {
|
|
|
89
85
|
* import { MyType } from "./MyType.js"
|
|
90
86
|
*/
|
|
91
87
|
tsImports;
|
|
92
|
-
constructor({ extern, fromRdfType, identifierType, synthetic, toRdfTypes,
|
|
88
|
+
constructor({ extern, fromRdfType, identifierType, synthetic, toRdfTypes, tsImports, ...superParameters }) {
|
|
93
89
|
super(superParameters);
|
|
94
90
|
this.extern = extern;
|
|
95
91
|
this.fromRdfType = fromRdfType;
|
|
96
92
|
this.identifierType = identifierType;
|
|
97
93
|
this.synthetic = synthetic;
|
|
98
94
|
this.toRdfTypes = toRdfTypes;
|
|
99
|
-
this.tsFeatures = tsFeatures;
|
|
100
95
|
this.tsImports = tsImports;
|
|
101
96
|
}
|
|
102
97
|
get ancestorObjectTypes() {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Maybe
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
2
|
import { AbstractContainerType } from "./AbstractContainerType.js";
|
|
3
|
+
import type { AbstractType } from "./AbstractType.js";
|
|
3
4
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
4
5
|
/**
|
|
5
6
|
* Abstract base class for ListType and SetType.
|
|
@@ -9,16 +10,17 @@ export declare abstract class AbstractCollectionType<ItemTypeT extends AbstractC
|
|
|
9
10
|
protected readonly minCount: bigint;
|
|
10
11
|
readonly discriminantProperty: Maybe<AbstractContainerType.DiscriminantProperty>;
|
|
11
12
|
readonly graphqlArgs: AbstractContainerType<ItemTypeT>["graphqlArgs"];
|
|
12
|
-
readonly typeofs:
|
|
13
|
+
readonly typeofs: "object"[];
|
|
13
14
|
constructor({ minCount, mutable, ...superParameters }: {
|
|
14
15
|
minCount: bigint;
|
|
15
16
|
mutable: boolean;
|
|
16
17
|
} & ConstructorParameters<typeof AbstractContainerType<ItemTypeT>>[0]);
|
|
17
|
-
get
|
|
18
|
+
get conversionFunction(): AbstractType.ConversionFunction;
|
|
18
19
|
get equalsFunction(): Code;
|
|
19
20
|
get filterFunction(): Code;
|
|
20
21
|
get filterType(): Code;
|
|
21
22
|
get graphqlType(): AbstractContainerType.GraphqlType;
|
|
23
|
+
get hashFunction(): Code;
|
|
22
24
|
get mutable(): boolean;
|
|
23
25
|
get name(): Code;
|
|
24
26
|
get schemaType(): Code;
|
|
@@ -29,19 +31,17 @@ export declare abstract class AbstractCollectionType<ItemTypeT extends AbstractC
|
|
|
29
31
|
};
|
|
30
32
|
fromJsonExpression({ variables, }: Parameters<AbstractContainerType<ItemTypeT>["fromJsonExpression"]>[0]): Code;
|
|
31
33
|
graphqlResolveExpression({ variables, }: Parameters<AbstractContainerType<ItemTypeT>["graphqlResolveExpression"]>[0]): Code;
|
|
32
|
-
hashStatements({ depth, variables, }: Parameters<AbstractContainerType<ItemTypeT>["hashStatements"]>[0]): readonly Code[];
|
|
33
|
-
jsonUiSchemaElement(parameters: Parameters<AbstractContainerType<ItemTypeT>["jsonUiSchemaElement"]>[0]): Maybe<Code>;
|
|
34
34
|
jsonSchema(parameters: Parameters<AbstractContainerType<ItemTypeT>["jsonSchema"]>[0]): Code;
|
|
35
|
+
jsonUiSchemaElement(parameters: Parameters<AbstractContainerType<ItemTypeT>["jsonUiSchemaElement"]>[0]): Maybe<Code>;
|
|
35
36
|
toJsonExpression({ variables, }: Parameters<AbstractContainerType<ItemTypeT>["toJsonExpression"]>[0]): Code;
|
|
36
37
|
}
|
|
37
38
|
export declare namespace AbstractCollectionType {
|
|
38
|
-
type Conversion = AbstractContainerType.Conversion;
|
|
39
39
|
type DiscriminantProperty = AbstractContainerType.DiscriminantProperty;
|
|
40
|
-
const GraphqlType: typeof
|
|
40
|
+
const GraphqlType: typeof AbstractType.GraphqlType;
|
|
41
41
|
type GraphqlType = AbstractContainerType.GraphqlType;
|
|
42
42
|
const isItemType: typeof AbstractContainerType.isItemType;
|
|
43
43
|
type ItemType = AbstractContainerType.ItemType;
|
|
44
|
-
const JsonType: typeof
|
|
44
|
+
const JsonType: typeof AbstractType.JsonType;
|
|
45
45
|
type JsonType = AbstractContainerType.JsonType;
|
|
46
46
|
}
|
|
47
47
|
//# sourceMappingURL=AbstractCollectionType.d.ts.map
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { Maybe
|
|
7
|
+
import { Maybe } from "purify-ts";
|
|
8
8
|
import { invariant } from "ts-invariant";
|
|
9
9
|
import { Memoize } from "typescript-memoize";
|
|
10
10
|
import { AbstractContainerType } from "./AbstractContainerType.js";
|
|
@@ -18,7 +18,7 @@ export class AbstractCollectionType extends AbstractContainerType {
|
|
|
18
18
|
minCount;
|
|
19
19
|
discriminantProperty = Maybe.empty();
|
|
20
20
|
graphqlArgs = Maybe.empty();
|
|
21
|
-
typeofs =
|
|
21
|
+
typeofs = ["object"];
|
|
22
22
|
constructor({ minCount, mutable, ...superParameters }) {
|
|
23
23
|
super(superParameters);
|
|
24
24
|
this.minCount = minCount;
|
|
@@ -28,91 +28,24 @@ export class AbstractCollectionType extends AbstractContainerType {
|
|
|
28
28
|
invariant(this.minCount === 0n);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
get
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// array.every(item => typeof item === "string")
|
|
40
|
-
const itemTypeConversionsByTypeof = {};
|
|
41
|
-
if (this.itemType.typeofs.length === 1) {
|
|
42
|
-
itemTypeConversionsByTypeof[this.itemType.typeofs[0]] = {
|
|
43
|
-
conversionExpression: (value) => value,
|
|
44
|
-
sourceTypeCheckExpression: (value) => code `typeof ${value} === ${this.itemType.typeofs[0]}`,
|
|
45
|
-
sourceTypeName: this.itemType.name,
|
|
46
|
-
sourceTypeof: this.itemType.typeofs[0],
|
|
47
|
-
};
|
|
48
|
-
for (const itemTypeConversion of this.itemType.conversions) {
|
|
49
|
-
if (!itemTypeConversionsByTypeof[itemTypeConversion.sourceTypeof]) {
|
|
50
|
-
itemTypeConversionsByTypeof[itemTypeConversion.sourceTypeof] =
|
|
51
|
-
itemTypeConversion;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
31
|
+
get conversionFunction() {
|
|
32
|
+
const itemConversionFunction = this.itemType.conversionFunction;
|
|
33
|
+
const sourceTypes = [
|
|
34
|
+
{
|
|
35
|
+
name: code `readonly (${joinCode(itemConversionFunction.sourceTypes.map((itemSourceType) => code `${itemSourceType.name}`), { on: " | " })})[]`,
|
|
36
|
+
typeof: "object",
|
|
37
|
+
},
|
|
38
|
+
];
|
|
55
39
|
if (this.minCount === 0n) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
conversions.push({
|
|
60
|
-
conversionExpression: (value) =>
|
|
61
|
-
// Defensive copy
|
|
62
|
-
code `${value}${this.mutable ? ".concat()" : ""}`,
|
|
63
|
-
sourceTypeCheckExpression: (value) => code `typeof ${value} === "object"`,
|
|
64
|
-
sourceTypeName: code `readonly (${this.itemType.name})[]`,
|
|
65
|
-
sourceTypeof: "object",
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
// There were additional conversions with different item typeof's.
|
|
70
|
-
// We do .every (per above) to discriminate array types with different item typeof's and .map to convert the array at runtime.
|
|
71
|
-
for (const [itemTypeof, itemTypeofConversion] of Object.entries(itemTypeConversionsByTypeof)) {
|
|
72
|
-
const itemVariable = code `item`;
|
|
73
|
-
conversions.push({
|
|
74
|
-
conversionExpression: (value) => {
|
|
75
|
-
const itemTypeConversionExpression = itemTypeofConversion.conversionExpression(itemVariable);
|
|
76
|
-
return !codeEquals(itemTypeConversionExpression, itemVariable)
|
|
77
|
-
? code `${value}.map(item => ${itemTypeConversionExpression})`
|
|
78
|
-
: // Defensive copy
|
|
79
|
-
code `${value}${this.mutable ? ".concat()" : ""}`;
|
|
80
|
-
},
|
|
81
|
-
sourceTypeCheckExpression: (value) => {
|
|
82
|
-
switch (itemTypeof) {
|
|
83
|
-
case "bigint":
|
|
84
|
-
return code `${this.reusables.snippets.isReadonlyBigIntArray}(${value})`;
|
|
85
|
-
case "boolean":
|
|
86
|
-
return code `${this.reusables.snippets.isReadonlyBooleanArray}(${value})`;
|
|
87
|
-
case "number":
|
|
88
|
-
return code `${this.reusables.snippets.isReadonlyNumberArray}(${value})`;
|
|
89
|
-
case "object":
|
|
90
|
-
return code `${this.reusables.snippets.isReadonlyObjectArray}(${value})`;
|
|
91
|
-
case "string":
|
|
92
|
-
return code `${this.reusables.snippets.isReadonlyStringArray}(${value})`;
|
|
93
|
-
case "function":
|
|
94
|
-
case "symbol":
|
|
95
|
-
case "undefined":
|
|
96
|
-
throw new Error(`source type check on ${itemTypeof} not implemented`);
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
sourceTypeName: code `readonly (${itemTypeofConversion.sourceTypeName})[]`,
|
|
100
|
-
sourceTypeof: itemTypeofConversion.sourceTypeof,
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
// minCount > 0
|
|
107
|
-
// Don't try to do any item type conversions here (yet).
|
|
108
|
-
conversions.push({
|
|
109
|
-
conversionExpression: (value) => value,
|
|
110
|
-
sourceTypeCheckExpression: (value) => code `${this.reusables.imports.NonEmptyList}.isNonEmpty(${value})`,
|
|
111
|
-
sourceTypeName: this.name,
|
|
112
|
-
sourceTypeof: "object",
|
|
40
|
+
sourceTypes.push({
|
|
41
|
+
name: "undefined",
|
|
42
|
+
typeof: "undefined",
|
|
113
43
|
});
|
|
114
44
|
}
|
|
115
|
-
return
|
|
45
|
+
return {
|
|
46
|
+
code: code `${this._mutable ? this.reusables.snippets.convertToMutableArray : this.reusables.snippets.convertToReadonlyArray}(${itemConversionFunction.code})`,
|
|
47
|
+
sourceTypes,
|
|
48
|
+
};
|
|
116
49
|
}
|
|
117
50
|
get equalsFunction() {
|
|
118
51
|
return code `((left, right) => ${this.reusables.snippets.arrayEquals}(left, right, ${this.itemType.equalsFunction}))`;
|
|
@@ -126,17 +59,14 @@ export class AbstractCollectionType extends AbstractContainerType {
|
|
|
126
59
|
get graphqlType() {
|
|
127
60
|
return new AbstractContainerType.GraphqlType(code `new ${this.reusables.imports.GraphQLList}(${this.itemType.graphqlType.name})`, this.reusables);
|
|
128
61
|
}
|
|
62
|
+
get hashFunction() {
|
|
63
|
+
return code `${this.reusables.snippets.hashArray}(${this.itemType.hashFunction})`;
|
|
64
|
+
}
|
|
129
65
|
get mutable() {
|
|
130
66
|
return this._mutable || this.itemType.mutable;
|
|
131
67
|
}
|
|
132
68
|
get name() {
|
|
133
|
-
|
|
134
|
-
return code `(${this.itemType.name})[]`;
|
|
135
|
-
}
|
|
136
|
-
if (this.minCount === 0n) {
|
|
137
|
-
return code `readonly (${this.itemType.name})[]`;
|
|
138
|
-
}
|
|
139
|
-
return code `${this.reusables.imports.NonEmptyList}<${this.itemType.name}>`;
|
|
69
|
+
return code `${!this._mutable ? "readonly " : ""}(${this.itemType.name})[]`;
|
|
140
70
|
}
|
|
141
71
|
get schemaType() {
|
|
142
72
|
return code `${this.reusables.snippets.CollectionSchema}<${this.itemType.schemaType}>`;
|
|
@@ -149,9 +79,6 @@ export class AbstractCollectionType extends AbstractContainerType {
|
|
|
149
79
|
}
|
|
150
80
|
fromJsonExpression({ variables, }) {
|
|
151
81
|
let expression = variables.value;
|
|
152
|
-
if (!this._mutable && this.minCount > 0n) {
|
|
153
|
-
expression = code `${this.reusables.imports.NonEmptyList}.fromArray(${expression}).unsafeCoerce()`;
|
|
154
|
-
}
|
|
155
82
|
if (this.minCount === 0n) {
|
|
156
83
|
expression = code `(${expression} ?? [])`;
|
|
157
84
|
}
|
|
@@ -166,22 +93,6 @@ export class AbstractCollectionType extends AbstractContainerType {
|
|
|
166
93
|
graphqlResolveExpression({ variables, }) {
|
|
167
94
|
return variables.value;
|
|
168
95
|
}
|
|
169
|
-
hashStatements({ depth, variables, }) {
|
|
170
|
-
return [
|
|
171
|
-
code `for (const item${depth} of ${variables.value}) { ${joinCode(this.itemType
|
|
172
|
-
.hashStatements({
|
|
173
|
-
depth: depth + 1,
|
|
174
|
-
variables: {
|
|
175
|
-
hasher: variables.hasher,
|
|
176
|
-
value: code `item${depth}`,
|
|
177
|
-
},
|
|
178
|
-
})
|
|
179
|
-
.concat())} }`,
|
|
180
|
-
];
|
|
181
|
-
}
|
|
182
|
-
jsonUiSchemaElement(parameters) {
|
|
183
|
-
return this.itemType.jsonUiSchemaElement(parameters);
|
|
184
|
-
}
|
|
185
96
|
jsonSchema(parameters) {
|
|
186
97
|
let schema = code `${this.itemType.jsonSchema(parameters)}.array()`;
|
|
187
98
|
if (this.minCount > 0n) {
|
|
@@ -195,13 +106,16 @@ export class AbstractCollectionType extends AbstractContainerType {
|
|
|
195
106
|
}
|
|
196
107
|
return schema;
|
|
197
108
|
}
|
|
109
|
+
jsonUiSchemaElement(parameters) {
|
|
110
|
+
return this.itemType.jsonUiSchemaElement(parameters);
|
|
111
|
+
}
|
|
198
112
|
toJsonExpression({ variables, }) {
|
|
199
113
|
return code `${variables.value}.map(item => (${this.itemType.toJsonExpression({ variables: { value: code `item` } })}))`;
|
|
200
114
|
}
|
|
201
115
|
}
|
|
202
116
|
__decorate([
|
|
203
117
|
Memoize()
|
|
204
|
-
], AbstractCollectionType.prototype, "
|
|
118
|
+
], AbstractCollectionType.prototype, "conversionFunction", null);
|
|
205
119
|
__decorate([
|
|
206
120
|
Memoize()
|
|
207
121
|
], AbstractCollectionType.prototype, "equalsFunction", null);
|
|
@@ -214,6 +128,9 @@ __decorate([
|
|
|
214
128
|
__decorate([
|
|
215
129
|
Memoize()
|
|
216
130
|
], AbstractCollectionType.prototype, "graphqlType", null);
|
|
131
|
+
__decorate([
|
|
132
|
+
Memoize()
|
|
133
|
+
], AbstractCollectionType.prototype, "hashFunction", null);
|
|
217
134
|
__decorate([
|
|
218
135
|
Memoize()
|
|
219
136
|
], AbstractCollectionType.prototype, "name", null);
|
|
@@ -44,7 +44,7 @@ export declare abstract class AbstractContainerType<ItemTypeT extends AbstractCo
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
export declare namespace AbstractContainerType {
|
|
47
|
-
type
|
|
47
|
+
type ConversionFunction = AbstractType.ConversionFunction;
|
|
48
48
|
type DiscriminantProperty = AbstractType.DiscriminantProperty;
|
|
49
49
|
const GraphqlType: typeof AbstractType.GraphqlType;
|
|
50
50
|
type GraphqlType = AbstractType.GraphqlType;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { NonEmptyList } from "purify-ts";
|
|
2
1
|
import { AbstractPrimitiveType } from "./AbstractPrimitiveType.js";
|
|
3
2
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
4
3
|
export declare abstract class AbstractDateType extends AbstractPrimitiveType<Date> {
|
|
@@ -10,15 +9,8 @@ export declare abstract class AbstractDateType extends AbstractPrimitiveType<Dat
|
|
|
10
9
|
readonly name = "Date";
|
|
11
10
|
readonly schemaType: Code;
|
|
12
11
|
readonly valueSparqlWherePatternsFunction: Code;
|
|
13
|
-
readonly typeofs:
|
|
14
|
-
get conversions(): readonly AbstractPrimitiveType.Conversion[];
|
|
15
|
-
protected get schemaObject(): {
|
|
16
|
-
in: Code[] | undefined;
|
|
17
|
-
languageIn: import("ts-poet/build/Node.js").Node[] | undefined;
|
|
18
|
-
kind: Code;
|
|
19
|
-
};
|
|
12
|
+
readonly typeofs: "object"[];
|
|
20
13
|
fromJsonExpression({ variables, }: Parameters<AbstractPrimitiveType<Date>["fromJsonExpression"]>[0]): Code;
|
|
21
|
-
hashStatements({ variables, }: Parameters<AbstractPrimitiveType<Date>["hashStatements"]>[0]): readonly Code[];
|
|
22
14
|
jsonType(): AbstractPrimitiveType.JsonType;
|
|
23
15
|
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractPrimitiveType<Date>["toRdfResourceValuesExpression"]>[0]): Code;
|
|
24
16
|
protected fromRdfExpressionChain({ variables, }: Parameters<AbstractPrimitiveType<Date>["fromRdfExpressionChain"]>[0]): ReturnType<AbstractPrimitiveType<Date>["fromRdfExpressionChain"]>;
|
|
@@ -28,4 +20,7 @@ export declare abstract class AbstractDateType extends AbstractPrimitiveType<Dat
|
|
|
28
20
|
};
|
|
29
21
|
}): Code;
|
|
30
22
|
}
|
|
23
|
+
export declare namespace AbstractDateType {
|
|
24
|
+
type ConversionFunction = AbstractPrimitiveType.ConversionFunction;
|
|
25
|
+
}
|
|
31
26
|
//# sourceMappingURL=AbstractDateType.d.ts.map
|