@shaclmate/compiler 4.0.23 → 4.0.25
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 +1 -1
- package/dist/ShapesGraphToAstTransformer.d.ts +1 -1
- package/dist/ShapesGraphToAstTransformer.js +16 -16
- package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.d.ts +1 -1
- package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.js +5 -2
- 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 +11 -17
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.js +3 -3
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +6 -11
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +21 -40
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +1 -1
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.js +3 -3
- package/dist/ast/AbstractCompoundType.d.ts +1 -1
- 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 +3 -30
- package/dist/ast/ObjectType.js +2 -26
- package/dist/generators/ts/AbstractContainerType.d.ts +0 -1
- package/dist/generators/ts/AbstractContainerType.js +0 -1
- package/dist/generators/ts/AbstractLazyObjectType.d.ts +0 -1
- package/dist/generators/ts/AbstractLazyObjectType.js +2 -2
- package/dist/generators/ts/AbstractNamedUnionType.d.ts +1 -2
- package/dist/generators/ts/AbstractNamedUnionType.js +16 -19
- package/dist/generators/ts/AbstractTermType.d.ts +0 -1
- package/dist/generators/ts/AbstractTermType.js +0 -1
- package/dist/generators/ts/AbstractType.d.ts +0 -4
- package/dist/generators/ts/AbstractUnionType.d.ts +1 -10
- package/dist/generators/ts/AbstractUnionType.js +27 -40
- package/dist/generators/ts/LazyObjectOptionType.js +3 -2
- package/dist/generators/ts/LazyObjectSetType.js +2 -1
- package/dist/generators/ts/LazyObjectType.js +2 -1
- package/dist/generators/ts/ListType.d.ts +1 -5
- package/dist/generators/ts/ListType.js +8 -27
- package/dist/generators/ts/NamedObjectType.d.ts +2 -21
- package/dist/generators/ts/NamedObjectType.js +33 -132
- package/dist/generators/ts/NamedObjectUnionType.js +14 -25
- package/dist/generators/ts/TypeFactory.js +11 -67
- package/dist/generators/ts/ZodGenerator.js +2 -2
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.d.ts +11 -17
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.js +7 -6
- package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.d.ts +1 -4
- package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.js +19 -34
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.d.ts +5 -15
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.js +31 -212
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js +25 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterFunctionDeclaration.js +4 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterTypeDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js +1 -8
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +5 -13
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js +1 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.d.ts +4 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js +49 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_interfaceDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js +0 -3
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromJsonFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromRdfResourceFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts +1 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.js +41 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_NamedObjectType/{NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.js → NamedObjectType_toRdfResourceFunctionDeclaration.js} +8 -27
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.d.ts +4 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js +40 -0
- 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/Property.d.ts +1 -2
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.d.ts +1 -3
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.js +8 -39
- 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/imports.d.ts +0 -2
- package/dist/generators/ts/imports.js +0 -2
- package/dist/generators/ts/objectSetDeclarations.js +1 -3
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +4 -6
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +2 -2
- package/dist/input/ShapesGraph.d.ts +1 -1
- package/dist/input/generated.d.ts +10 -181
- package/dist/input/generated.js +116 -392
- package/package.json +2 -4
- 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/enums/TsObjectDeclarationType.d.ts +0 -9
- package/dist/enums/TsObjectDeclarationType.js +0 -16
- package/dist/enums/Visibility.d.ts +0 -6
- package/dist/enums/Visibility.js +0 -18
- package/dist/generators/ts/_NamedObjectType/IdentifierPrefixProperty.d.ts +0 -33
- package/dist/generators/ts/_NamedObjectType/IdentifierPrefixProperty.js +0 -92
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_classDeclaration.d.ts +0 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_classDeclaration.js +0 -62
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionOrMethodDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionOrMethodDeclaration.js +0 -51
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionOrMethodDeclarations.d.ts +0 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionOrMethodDeclarations.js +0 -73
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionOrMethodDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionOrMethodDeclaration.js +0 -59
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionOrMethodDeclaration.d.ts +0 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionOrMethodDeclaration.js +0 -62
- /package/dist/{enums → generators/ts}/TsFeature.d.ts +0 -0
- /package/dist/{enums → generators/ts}/TsFeature.js +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
-
"@shaclmate/shacl-ast": "4.0.
|
|
3
|
+
"@shaclmate/shacl-ast": "4.0.25",
|
|
4
4
|
"@rdfjs/dataset": "~2.0.2",
|
|
5
5
|
"@rdfjs/prefix-map": "~0.1.2",
|
|
6
6
|
"@rdfjs/term-map": "~2.0.2",
|
|
@@ -37,8 +37,6 @@
|
|
|
37
37
|
"dist/_ShapesGraphToAstTransformer/*.js",
|
|
38
38
|
"dist/ast/*.d.ts",
|
|
39
39
|
"dist/ast/*.js",
|
|
40
|
-
"dist/enums/*.d.ts",
|
|
41
|
-
"dist/enums/*.js",
|
|
42
40
|
"dist/generators/*.d.ts",
|
|
43
41
|
"dist/generators/*.js",
|
|
44
42
|
"dist/generators/ts/*.d.ts",
|
|
@@ -70,5 +68,5 @@
|
|
|
70
68
|
},
|
|
71
69
|
"type": "module",
|
|
72
70
|
"types": "./dist/index.d.ts",
|
|
73
|
-
"version": "4.0.
|
|
71
|
+
"version": "4.0.25"
|
|
74
72
|
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Either, Maybe } from "purify-ts";
|
|
2
|
-
import { IdentifierMintingStrategy } from "../enums/IdentifierMintingStrategy.js";
|
|
3
|
-
import type * as input from "../input/index.js";
|
|
4
|
-
import type { ShapesGraphToAstTransformer } from "../ShapesGraphToAstTransformer.js";
|
|
5
|
-
export declare function nodeShapeIdentifierMintingStrategy(this: ShapesGraphToAstTransformer, nodeShape: input.NodeShape): Either<Error, Maybe<IdentifierMintingStrategy>>;
|
|
6
|
-
//# sourceMappingURL=nodeShapeIdentifierMintingStrategy.d.ts.map
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Either, Left, Maybe } from "purify-ts";
|
|
2
|
-
import { IdentifierMintingStrategy } from "../enums/IdentifierMintingStrategy.js";
|
|
3
|
-
import { shapeNodeKinds } from "./shapeNodeKinds.js";
|
|
4
|
-
const defaultNodeShapeNodeKinds = new Set([
|
|
5
|
-
"BlankNode",
|
|
6
|
-
"IRI",
|
|
7
|
-
]);
|
|
8
|
-
export function nodeShapeIdentifierMintingStrategy(nodeShape) {
|
|
9
|
-
if (nodeShape.identifierMintingStrategy.isJust()) {
|
|
10
|
-
if (nodeShape.in_.filter((_) => _.length > 0).isJust()) {
|
|
11
|
-
return Left(new Error(`${nodeShape} cannot have an identifier minting strategy and sh:in`));
|
|
12
|
-
}
|
|
13
|
-
return Either.of(nodeShape.identifierMintingStrategy.map(IdentifierMintingStrategy.fromIri));
|
|
14
|
-
}
|
|
15
|
-
// Recurse into parents
|
|
16
|
-
for (const parentNodeShape of this.relatedNodeShapesByIdentifier.get(nodeShape.$identifier).parents) {
|
|
17
|
-
const parentNodeShapeIdentifierMintingStrategy = nodeShapeIdentifierMintingStrategy.call(this, parentNodeShape);
|
|
18
|
-
if (parentNodeShapeIdentifierMintingStrategy.isRight() &&
|
|
19
|
-
parentNodeShapeIdentifierMintingStrategy.extract().isJust()) {
|
|
20
|
-
return parentNodeShapeIdentifierMintingStrategy;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return shapeNodeKinds
|
|
24
|
-
.call(this, nodeShape, { defaultNodeShapeNodeKinds })
|
|
25
|
-
.map((nodeKinds) => {
|
|
26
|
-
if (nodeKinds.has("BlankNode")) {
|
|
27
|
-
return Maybe.of("blankNode");
|
|
28
|
-
}
|
|
29
|
-
return Maybe.empty();
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=nodeShapeIdentifierMintingStrategy.js.map
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { NamedNode } from "@rdfjs/types";
|
|
2
|
-
/**
|
|
3
|
-
* TypeScript enum corresponding to shaclmate:identifierMintingStrategy, for simpler manipulation.
|
|
4
|
-
*/
|
|
5
|
-
export type IdentifierMintingStrategy = "blankNode" | "sha256" | "uuidv4";
|
|
6
|
-
export declare namespace IdentifierMintingStrategy {
|
|
7
|
-
function fromIri(iri: NamedNode<"http://purl.org/shaclmate/ontology#_IdentifierMintingStrategy_BlankNode" | "http://purl.org/shaclmate/ontology#_IdentifierMintingStrategy_SHA256" | "http://purl.org/shaclmate/ontology#_IdentifierMintingStrategy_UUIDv4">): IdentifierMintingStrategy;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=IdentifierMintingStrategy.d.ts.map
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export var IdentifierMintingStrategy;
|
|
2
|
-
(function (IdentifierMintingStrategy) {
|
|
3
|
-
function fromIri(iri) {
|
|
4
|
-
switch (iri.value) {
|
|
5
|
-
case "http://purl.org/shaclmate/ontology#_IdentifierMintingStrategy_BlankNode":
|
|
6
|
-
return "blankNode";
|
|
7
|
-
case "http://purl.org/shaclmate/ontology#_IdentifierMintingStrategy_SHA256":
|
|
8
|
-
return "sha256";
|
|
9
|
-
case "http://purl.org/shaclmate/ontology#_IdentifierMintingStrategy_UUIDv4":
|
|
10
|
-
return "uuidv4";
|
|
11
|
-
default:
|
|
12
|
-
iri.value;
|
|
13
|
-
throw new RangeError(iri.value);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
IdentifierMintingStrategy.fromIri = fromIri;
|
|
17
|
-
})(IdentifierMintingStrategy || (IdentifierMintingStrategy = {}));
|
|
18
|
-
//# sourceMappingURL=IdentifierMintingStrategy.js.map
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { NamedNode } from "@rdfjs/types";
|
|
2
|
-
/**
|
|
3
|
-
* TypeScript enum corresponding to shaclmate:tsObjectDeclarationType, for simpler manipulation.
|
|
4
|
-
*/
|
|
5
|
-
export type TsObjectDeclarationType = "class" | "interface";
|
|
6
|
-
export declare namespace TsObjectDeclarationType {
|
|
7
|
-
function fromIri(iri: NamedNode<"http://purl.org/shaclmate/ontology#_TsObjectDeclarationType_Class" | "http://purl.org/shaclmate/ontology#_TsObjectDeclarationType_Interface">): TsObjectDeclarationType;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=TsObjectDeclarationType.d.ts.map
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export var TsObjectDeclarationType;
|
|
2
|
-
(function (TsObjectDeclarationType) {
|
|
3
|
-
function fromIri(iri) {
|
|
4
|
-
switch (iri.value) {
|
|
5
|
-
case "http://purl.org/shaclmate/ontology#_TsObjectDeclarationType_Class":
|
|
6
|
-
return "class";
|
|
7
|
-
case "http://purl.org/shaclmate/ontology#_TsObjectDeclarationType_Interface":
|
|
8
|
-
return "interface";
|
|
9
|
-
default:
|
|
10
|
-
iri.value;
|
|
11
|
-
throw new RangeError(iri.value);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
TsObjectDeclarationType.fromIri = fromIri;
|
|
15
|
-
})(TsObjectDeclarationType || (TsObjectDeclarationType = {}));
|
|
16
|
-
//# sourceMappingURL=TsObjectDeclarationType.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { NamedNode } from "@rdfjs/types";
|
|
2
|
-
export type Visibility = "private" | "protected" | "public";
|
|
3
|
-
export declare namespace Visibility {
|
|
4
|
-
function fromIri(iri: NamedNode<"http://purl.org/shaclmate/ontology#_Visibility_Private" | "http://purl.org/shaclmate/ontology#_Visibility_Protected" | "http://purl.org/shaclmate/ontology#_Visibility_Public">): Visibility;
|
|
5
|
-
}
|
|
6
|
-
//# sourceMappingURL=Visibility.d.ts.map
|
package/dist/enums/Visibility.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export var Visibility;
|
|
2
|
-
(function (Visibility) {
|
|
3
|
-
function fromIri(iri) {
|
|
4
|
-
switch (iri.value) {
|
|
5
|
-
case "http://purl.org/shaclmate/ontology#_Visibility_Private":
|
|
6
|
-
return "private";
|
|
7
|
-
case "http://purl.org/shaclmate/ontology#_Visibility_Protected":
|
|
8
|
-
return "protected";
|
|
9
|
-
case "http://purl.org/shaclmate/ontology#_Visibility_Public":
|
|
10
|
-
return "public";
|
|
11
|
-
default:
|
|
12
|
-
iri.value;
|
|
13
|
-
throw new RangeError(iri.value);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
Visibility.fromIri = fromIri;
|
|
17
|
-
})(Visibility || (Visibility = {}));
|
|
18
|
-
//# sourceMappingURL=Visibility.js.map
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Maybe } from "purify-ts";
|
|
2
|
-
import type { StringType } from "../StringType.js";
|
|
3
|
-
import { type Code } from "../ts-poet-wrapper.js";
|
|
4
|
-
import { AbstractProperty } from "./AbstractProperty.js";
|
|
5
|
-
export declare class IdentifierPrefixProperty extends AbstractProperty<StringType> {
|
|
6
|
-
private readonly own;
|
|
7
|
-
readonly filterProperty: AbstractProperty<StringType>["filterProperty"];
|
|
8
|
-
readonly graphqlField: AbstractProperty<StringType>["graphqlField"];
|
|
9
|
-
readonly jsonSchema: AbstractProperty<StringType>["jsonSchema"];
|
|
10
|
-
readonly jsonSignature: Maybe<Code>;
|
|
11
|
-
readonly kind = "IdentifierPrefixProperty";
|
|
12
|
-
readonly mutable = false;
|
|
13
|
-
readonly recursive = false;
|
|
14
|
-
constructor({ own, ...superParameters }: {
|
|
15
|
-
own: boolean;
|
|
16
|
-
type: StringType;
|
|
17
|
-
} & ConstructorParameters<typeof AbstractProperty>[0]);
|
|
18
|
-
get constructorParametersSignature(): Maybe<Code>;
|
|
19
|
-
get declaration(): Maybe<Code>;
|
|
20
|
-
get equalsFunction(): Maybe<Code>;
|
|
21
|
-
get getAccessorDeclaration(): Maybe<Code>;
|
|
22
|
-
constructorStatements({ variables, }: Parameters<AbstractProperty<StringType>["constructorStatements"]>[0]): readonly Code[];
|
|
23
|
-
fromJsonStatements(): readonly Code[];
|
|
24
|
-
fromRdfResourceValuesExpression(): Maybe<Code>;
|
|
25
|
-
hashStatements(): readonly Code[];
|
|
26
|
-
jsonUiSchemaElement(): Maybe<Code>;
|
|
27
|
-
sparqlConstructTriplesExpression(): Maybe<Code>;
|
|
28
|
-
sparqlWherePatternsExpression(): ReturnType<AbstractProperty<StringType>["sparqlWherePatternsExpression"]>;
|
|
29
|
-
toJsonObjectMemberExpression(): Maybe<Code>;
|
|
30
|
-
toRdfRdfResourceValuesStatements(): readonly Code[];
|
|
31
|
-
toStringExpression(): Maybe<Code>;
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=IdentifierPrefixProperty.d.ts.map
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { Maybe } from "purify-ts";
|
|
8
|
-
import { invariant } from "ts-invariant";
|
|
9
|
-
import { Memoize } from "typescript-memoize";
|
|
10
|
-
import { snippets } from "../snippets.js";
|
|
11
|
-
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
12
|
-
import { code } from "../ts-poet-wrapper.js";
|
|
13
|
-
import { AbstractProperty } from "./AbstractProperty.js";
|
|
14
|
-
export class IdentifierPrefixProperty extends AbstractProperty {
|
|
15
|
-
own;
|
|
16
|
-
filterProperty = Maybe.empty();
|
|
17
|
-
graphqlField = Maybe.empty();
|
|
18
|
-
jsonSchema = Maybe.empty();
|
|
19
|
-
jsonSignature = Maybe.empty();
|
|
20
|
-
kind = "IdentifierPrefixProperty";
|
|
21
|
-
mutable = false;
|
|
22
|
-
recursive = false;
|
|
23
|
-
constructor({ own, ...superParameters }) {
|
|
24
|
-
super(superParameters);
|
|
25
|
-
invariant(this.visibility === "protected");
|
|
26
|
-
this.own = own;
|
|
27
|
-
}
|
|
28
|
-
get constructorParametersSignature() {
|
|
29
|
-
return Maybe.of(code `readonly ${this.name}?: ${this.type.name};`);
|
|
30
|
-
}
|
|
31
|
-
get declaration() {
|
|
32
|
-
if (this.namedObjectType.declarationType === "interface") {
|
|
33
|
-
return Maybe.empty();
|
|
34
|
-
}
|
|
35
|
-
if (!this.own) {
|
|
36
|
-
return Maybe.empty();
|
|
37
|
-
}
|
|
38
|
-
return Maybe.of(code `protected readonly _${this.name}?: ${this.type.name};`);
|
|
39
|
-
}
|
|
40
|
-
get equalsFunction() {
|
|
41
|
-
return this.namedObjectType.declarationType === "class"
|
|
42
|
-
? Maybe.of(code `${snippets.strictEquals}`)
|
|
43
|
-
: Maybe.empty();
|
|
44
|
-
}
|
|
45
|
-
get getAccessorDeclaration() {
|
|
46
|
-
return Maybe.of(code `\
|
|
47
|
-
protected ${!this.own ? "override " : ""} get ${this.name}(): ${this.type.name} {
|
|
48
|
-
return (this._${this.name} !== undefined) ? this._${this.name} : \`urn:shaclmate:\${this.${syntheticNamePrefix}type}:\`;
|
|
49
|
-
}`);
|
|
50
|
-
}
|
|
51
|
-
constructorStatements({ variables, }) {
|
|
52
|
-
switch (this.namedObjectType.declarationType) {
|
|
53
|
-
case "class":
|
|
54
|
-
return this.declaration
|
|
55
|
-
.map(() => [code `this._${this.name} = ${variables.parameter};`])
|
|
56
|
-
.orDefault([]);
|
|
57
|
-
case "interface":
|
|
58
|
-
return [];
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
fromJsonStatements() {
|
|
62
|
-
return [];
|
|
63
|
-
}
|
|
64
|
-
fromRdfResourceValuesExpression() {
|
|
65
|
-
return Maybe.empty();
|
|
66
|
-
}
|
|
67
|
-
hashStatements() {
|
|
68
|
-
return [];
|
|
69
|
-
}
|
|
70
|
-
jsonUiSchemaElement() {
|
|
71
|
-
return Maybe.empty();
|
|
72
|
-
}
|
|
73
|
-
sparqlConstructTriplesExpression() {
|
|
74
|
-
return Maybe.empty();
|
|
75
|
-
}
|
|
76
|
-
sparqlWherePatternsExpression() {
|
|
77
|
-
return Maybe.empty();
|
|
78
|
-
}
|
|
79
|
-
toJsonObjectMemberExpression() {
|
|
80
|
-
return Maybe.empty();
|
|
81
|
-
}
|
|
82
|
-
toRdfRdfResourceValuesStatements() {
|
|
83
|
-
return [];
|
|
84
|
-
}
|
|
85
|
-
toStringExpression() {
|
|
86
|
-
return Maybe.empty();
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
__decorate([
|
|
90
|
-
Memoize()
|
|
91
|
-
], IdentifierPrefixProperty.prototype, "equalsFunction", null);
|
|
92
|
-
//# sourceMappingURL=IdentifierPrefixProperty.js.map
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { code, def, joinCode } from "../ts-poet-wrapper.js";
|
|
2
|
-
import { tsComment } from "../tsComment.js";
|
|
3
|
-
import { NamedObjectType_equalsFunctionOrMethodDeclaration } from "./NamedObjectType_equalsFunctionOrMethodDeclaration.js";
|
|
4
|
-
import { NamedObjectType_hashFunctionOrMethodDeclarations } from "./NamedObjectType_hashFunctionOrMethodDeclarations.js";
|
|
5
|
-
import { NamedObjectType_toJsonFunctionOrMethodDeclaration } from "./NamedObjectType_toJsonFunctionOrMethodDeclaration.js";
|
|
6
|
-
import { NamedObjectType_toRdfResourceFunctionOrMethodDeclaration } from "./NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.js";
|
|
7
|
-
import { NamedObjectType_toStringFunctionOrMethodDeclarations } from "./NamedObjectType_toStringFunctionOrMethodDeclaration.js";
|
|
8
|
-
function NamedObjectType_constructorDeclaration() {
|
|
9
|
-
const parametersPropertySignatures = this.properties.flatMap((property) => property.constructorParametersSignature.toList());
|
|
10
|
-
const parametersType = [];
|
|
11
|
-
if (parametersPropertySignatures.length > 0) {
|
|
12
|
-
parametersType.push(code `{ ${joinCode(parametersPropertySignatures)} }`);
|
|
13
|
-
}
|
|
14
|
-
if (this.parentObjectTypes.length > 0) {
|
|
15
|
-
// Pass up parameters
|
|
16
|
-
parametersType.push(code `ConstructorParameters<typeof ${this.parentObjectTypes[0].name}>[0]`);
|
|
17
|
-
}
|
|
18
|
-
if (parametersType.length === 0) {
|
|
19
|
-
parametersType.push(code `object`);
|
|
20
|
-
}
|
|
21
|
-
const statements = [];
|
|
22
|
-
if (this.parentObjectTypes.length > 0) {
|
|
23
|
-
// An ancestor object type may be extern so we always have a constructor and always pass up parameters instead
|
|
24
|
-
// of trying to sense whether we need to or not.
|
|
25
|
-
statements.push(code `super(parameters);`);
|
|
26
|
-
}
|
|
27
|
-
const parametersHasQuestionToken = this.parentObjectTypes.length === 0 &&
|
|
28
|
-
parametersPropertySignatures.every((propertySignature) => propertySignature.toCodeString([]).indexOf("?:") !== -1);
|
|
29
|
-
const parametersVariable = code `parameters${parametersHasQuestionToken ? "?" : ""}`;
|
|
30
|
-
const propertyStatements = this.properties.flatMap((property) => property.constructorStatements({
|
|
31
|
-
variables: {
|
|
32
|
-
parameter: code `${parametersVariable}.${property.name}`,
|
|
33
|
-
parameters: parametersVariable,
|
|
34
|
-
},
|
|
35
|
-
}));
|
|
36
|
-
statements.push(...propertyStatements);
|
|
37
|
-
return code `\
|
|
38
|
-
${propertyStatements.length === 0 ? "// biome-ignore lint/complexity/noUselessConstructor: Always have a constructor" : ""}
|
|
39
|
-
constructor(${statements.length > 0 ? "parameters" : "_parameters"}${parametersHasQuestionToken ? "?" : ""}: ${joinCode(parametersType, { on: " & " })}) {
|
|
40
|
-
${joinCode(statements)}
|
|
41
|
-
}`;
|
|
42
|
-
}
|
|
43
|
-
export function NamedObjectType_classDeclaration() {
|
|
44
|
-
this.ensureAtMostOneSuperObjectType();
|
|
45
|
-
return code `\
|
|
46
|
-
${this.comment
|
|
47
|
-
.alt(this.label)
|
|
48
|
-
.map(tsComment)
|
|
49
|
-
.orDefault("")}export ${this.abstract ? "abstract " : ""}class ${def(this.name)}${this.parentObjectTypes.length > 0 ? ` extends ${this.parentObjectTypes[0].name}` : ""} {
|
|
50
|
-
${joinCode([
|
|
51
|
-
...this.properties.flatMap((property) => property.declaration.toList()),
|
|
52
|
-
NamedObjectType_constructorDeclaration.call(this),
|
|
53
|
-
...this.properties.flatMap((property) => property.getAccessorDeclaration.toList()),
|
|
54
|
-
...NamedObjectType_equalsFunctionOrMethodDeclaration.call(this).toList(),
|
|
55
|
-
...NamedObjectType_hashFunctionOrMethodDeclarations.call(this),
|
|
56
|
-
...NamedObjectType_toJsonFunctionOrMethodDeclaration.call(this).toList(),
|
|
57
|
-
...NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.call(this).toList(),
|
|
58
|
-
...NamedObjectType_toStringFunctionOrMethodDeclarations.call(this),
|
|
59
|
-
], { on: "\n\n" })}
|
|
60
|
-
}`;
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=NamedObjectType_classDeclaration.js.map
|
package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionOrMethodDeclaration.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Maybe } from "purify-ts";
|
|
2
|
-
import type { NamedObjectType } from "../NamedObjectType.js";
|
|
3
|
-
import { type Code } from "../ts-poet-wrapper.js";
|
|
4
|
-
export declare function NamedObjectType_equalsFunctionOrMethodDeclaration(this: NamedObjectType): Maybe<Code>;
|
|
5
|
-
//# sourceMappingURL=NamedObjectType_equalsFunctionOrMethodDeclaration.d.ts.map
|
package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionOrMethodDeclaration.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { Maybe } from "purify-ts";
|
|
2
|
-
import { snippets } from "../snippets.js";
|
|
3
|
-
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
4
|
-
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
5
|
-
export function NamedObjectType_equalsFunctionOrMethodDeclaration() {
|
|
6
|
-
if (!this.features.has("equals")) {
|
|
7
|
-
return Maybe.empty();
|
|
8
|
-
}
|
|
9
|
-
const chain = [];
|
|
10
|
-
let leftVariable;
|
|
11
|
-
let parameters;
|
|
12
|
-
let preamble;
|
|
13
|
-
let rightVariable;
|
|
14
|
-
switch (this.declarationType) {
|
|
15
|
-
case "class":
|
|
16
|
-
if (this.ownProperties.length === 0) {
|
|
17
|
-
// If there's a parent class and no properties in this class, can skip overriding equals
|
|
18
|
-
return Maybe.empty();
|
|
19
|
-
}
|
|
20
|
-
leftVariable = "this";
|
|
21
|
-
parameters = code `other: ${this.name}`;
|
|
22
|
-
if (this.parentObjectTypes.length > 0) {
|
|
23
|
-
chain.push(code `super.${syntheticNamePrefix}equals(other)`);
|
|
24
|
-
preamble = "override ";
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
preamble = "";
|
|
28
|
-
}
|
|
29
|
-
rightVariable = "other";
|
|
30
|
-
break;
|
|
31
|
-
case "interface":
|
|
32
|
-
// For every parent, find the nearest equals implementation
|
|
33
|
-
for (const parentObjectType of this.parentObjectTypes) {
|
|
34
|
-
chain.push(code `${parentObjectType.staticModuleName}.${syntheticNamePrefix}equals(left, right)`);
|
|
35
|
-
}
|
|
36
|
-
leftVariable = "left";
|
|
37
|
-
parameters = code `left: ${this.name}, right: ${this.name}`;
|
|
38
|
-
preamble = "export function ";
|
|
39
|
-
rightVariable = "right";
|
|
40
|
-
}
|
|
41
|
-
for (const property of this.ownProperties) {
|
|
42
|
-
property.equalsFunction.ifJust((equalsFunction) => {
|
|
43
|
-
chain.push(code `(${equalsFunction})(${leftVariable}.${property.name}, ${rightVariable}.${property.name}).mapLeft(propertyValuesUnequal => ({ left: ${leftVariable}, right: ${rightVariable}, propertyName: "${property.name}", propertyValuesUnequal, type: "property" as const }))`);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
return Maybe.of(code `\
|
|
47
|
-
${preamble}${syntheticNamePrefix}equals(${parameters}): ${snippets.EqualsResult} {
|
|
48
|
-
return ${joinCode(chain.map((chainPart, chainPartI) => chainPartI === 0 ? chainPart : code `chain(() => ${chainPart})`), { on: "." })}
|
|
49
|
-
}`);
|
|
50
|
-
}
|
|
51
|
-
//# sourceMappingURL=NamedObjectType_equalsFunctionOrMethodDeclaration.js.map
|
package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionOrMethodDeclarations.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { NamedObjectType } from "../NamedObjectType.js";
|
|
2
|
-
import { type Code } from "../ts-poet-wrapper.js";
|
|
3
|
-
export declare function NamedObjectType_hashFunctionOrMethodDeclarations(this: NamedObjectType): readonly Code[];
|
|
4
|
-
//# sourceMappingURL=NamedObjectType_hashFunctionOrMethodDeclarations.d.ts.map
|
package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionOrMethodDeclarations.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { snippets } from "../snippets.js";
|
|
2
|
-
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
3
|
-
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
4
|
-
const hasherVariable = code `_hasher`;
|
|
5
|
-
export function NamedObjectType_hashFunctionOrMethodDeclarations() {
|
|
6
|
-
if (!this.features.has("hash")) {
|
|
7
|
-
return [];
|
|
8
|
-
}
|
|
9
|
-
const hashOwnShaclPropertiesStatements = this.ownShaclProperties.flatMap((property) => property.hashStatements({
|
|
10
|
-
depth: 0,
|
|
11
|
-
variables: {
|
|
12
|
-
hasher: hasherVariable,
|
|
13
|
-
value: code `${this.thisVariable}.${property.name}`,
|
|
14
|
-
},
|
|
15
|
-
}));
|
|
16
|
-
if (this.declarationType === "class" &&
|
|
17
|
-
this.parentObjectTypes.length > 0 &&
|
|
18
|
-
hashOwnShaclPropertiesStatements.length === 0) {
|
|
19
|
-
// If there's a parent class and no hash statements in this class, can skip overriding hash
|
|
20
|
-
return [];
|
|
21
|
-
}
|
|
22
|
-
const hashShaclPropertiesStatements = [];
|
|
23
|
-
const hashStatements = [];
|
|
24
|
-
const parameters = []; // Same between the two functions
|
|
25
|
-
let hashPreamble = "";
|
|
26
|
-
let hashShaclPropertiesPreamble = "";
|
|
27
|
-
switch (this.declarationType) {
|
|
28
|
-
case "class": {
|
|
29
|
-
if (this.parentObjectTypes.length > 0) {
|
|
30
|
-
hashShaclPropertiesStatements.push(code `super.${syntheticNamePrefix}hashShaclProperties(${hasherVariable});`);
|
|
31
|
-
hashShaclPropertiesPreamble = "override ";
|
|
32
|
-
hashPreamble = "override ";
|
|
33
|
-
}
|
|
34
|
-
hashShaclPropertiesPreamble = `protected ${hashShaclPropertiesPreamble}`;
|
|
35
|
-
hashStatements.push(code `this.${syntheticNamePrefix}hashShaclProperties(${hasherVariable});`);
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
case "interface": {
|
|
39
|
-
for (const parentObjectType of this.parentObjectTypes) {
|
|
40
|
-
hashShaclPropertiesStatements.push(code `${parentObjectType.staticModuleName}.${syntheticNamePrefix}hashShaclProperties(${this.thisVariable}, ${hasherVariable});`);
|
|
41
|
-
}
|
|
42
|
-
parameters.push(code `${this.thisVariable}: ${this.name}`);
|
|
43
|
-
hashPreamble = hashShaclPropertiesPreamble = "export function ";
|
|
44
|
-
hashStatements.push(code `${this.staticModuleName}.${syntheticNamePrefix}hashShaclProperties(${this.thisVariable}, ${hasherVariable});`);
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
parameters.push(code `${hasherVariable}: HasherT`);
|
|
49
|
-
const parametersCode = joinCode(parameters, { on: "," });
|
|
50
|
-
hashShaclPropertiesStatements.push(...hashOwnShaclPropertiesStatements);
|
|
51
|
-
hashShaclPropertiesStatements.push(code `return ${hasherVariable};`);
|
|
52
|
-
hashStatements.push(...this.ownProperties
|
|
53
|
-
.filter((property) => property.kind !== "ShaclProperty")
|
|
54
|
-
.flatMap((property) => property.hashStatements({
|
|
55
|
-
depth: 0,
|
|
56
|
-
variables: {
|
|
57
|
-
hasher: hasherVariable,
|
|
58
|
-
value: code `${this.thisVariable}.${property.name}`,
|
|
59
|
-
},
|
|
60
|
-
})));
|
|
61
|
-
hashStatements.push(code `return ${hasherVariable};`);
|
|
62
|
-
return [
|
|
63
|
-
code `\
|
|
64
|
-
${hashPreamble}${syntheticNamePrefix}hash<HasherT extends ${snippets.Hasher}>(${parametersCode}): HasherT {
|
|
65
|
-
${joinCode(hashStatements)}
|
|
66
|
-
}`,
|
|
67
|
-
code `\
|
|
68
|
-
${hashShaclPropertiesPreamble}${syntheticNamePrefix}hashShaclProperties<HasherT extends ${snippets.Hasher}>(${parametersCode}): HasherT {
|
|
69
|
-
${joinCode(hashShaclPropertiesStatements)}
|
|
70
|
-
}`,
|
|
71
|
-
];
|
|
72
|
-
}
|
|
73
|
-
//# sourceMappingURL=NamedObjectType_hashFunctionOrMethodDeclarations.js.map
|
package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionOrMethodDeclaration.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Maybe } from "purify-ts";
|
|
2
|
-
import type { NamedObjectType } from "../NamedObjectType.js";
|
|
3
|
-
import { type Code } from "../ts-poet-wrapper.js";
|
|
4
|
-
export declare function NamedObjectType_toJsonFunctionOrMethodDeclaration(this: NamedObjectType): Maybe<Code>;
|
|
5
|
-
//# sourceMappingURL=NamedObjectType_toJsonFunctionOrMethodDeclaration.d.ts.map
|
package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionOrMethodDeclaration.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { Maybe } from "purify-ts";
|
|
2
|
-
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
3
|
-
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
4
|
-
export function NamedObjectType_toJsonFunctionOrMethodDeclaration() {
|
|
5
|
-
if (!this.features.has("json")) {
|
|
6
|
-
return Maybe.empty();
|
|
7
|
-
}
|
|
8
|
-
if (this.declarationType === "class" &&
|
|
9
|
-
this.ownProperties.length === 0 &&
|
|
10
|
-
this.parentObjectTypes.length > 0) {
|
|
11
|
-
return Maybe.empty();
|
|
12
|
-
}
|
|
13
|
-
const jsonObjectMembers = [];
|
|
14
|
-
const parameters = [];
|
|
15
|
-
let preamble;
|
|
16
|
-
switch (this.declarationType) {
|
|
17
|
-
case "class":
|
|
18
|
-
if (this.parentObjectTypes.length > 0) {
|
|
19
|
-
jsonObjectMembers.push(code `...super.${syntheticNamePrefix}toJson()`);
|
|
20
|
-
preamble = "override ";
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
preamble = "";
|
|
24
|
-
}
|
|
25
|
-
break;
|
|
26
|
-
case "interface":
|
|
27
|
-
for (const parentObjectType of this.parentObjectTypes) {
|
|
28
|
-
jsonObjectMembers.push(code `...${parentObjectType.staticModuleName}.${syntheticNamePrefix}toJson(${this.thisVariable})`);
|
|
29
|
-
}
|
|
30
|
-
parameters.push(code `${this.thisVariable}: ${this.name}`);
|
|
31
|
-
preamble = "export function ";
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
if (this.ownProperties.length > 0) {
|
|
35
|
-
jsonObjectMembers.push(...this.ownProperties.flatMap((property) => property
|
|
36
|
-
.toJsonObjectMemberExpression({
|
|
37
|
-
variables: { value: code `${this.thisVariable}.${property.name}` },
|
|
38
|
-
})
|
|
39
|
-
.toList()));
|
|
40
|
-
}
|
|
41
|
-
// 20241220: don't add @type until we're doing JSON-LD
|
|
42
|
-
// switch (this.toRdfTypes.length) {
|
|
43
|
-
// case 0:
|
|
44
|
-
// break;
|
|
45
|
-
// case 1:
|
|
46
|
-
// jsonObjectMembers.push(`"@type": "${this.toRdfTypes[0].value}"`);
|
|
47
|
-
// break;
|
|
48
|
-
// default:
|
|
49
|
-
// jsonObjectMembers.push(
|
|
50
|
-
// `"@type": ${JSON.stringify(this.toRdfTypes.map((rdfType) => rdfType.value))}`,
|
|
51
|
-
// );
|
|
52
|
-
// break;
|
|
53
|
-
// }
|
|
54
|
-
return Maybe.of(code `\
|
|
55
|
-
${preamble}${syntheticNamePrefix}toJson(${joinCode(parameters, { on: ", " })}): ${this.jsonType().name} {
|
|
56
|
-
return JSON.parse(JSON.stringify({ ${joinCode(jsonObjectMembers, { on: "," })} } satisfies ${this.jsonType().name}));
|
|
57
|
-
}`);
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=NamedObjectType_toJsonFunctionOrMethodDeclaration.js.map
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Maybe } from "purify-ts";
|
|
2
|
-
import type { NamedObjectType } from "../NamedObjectType.js";
|
|
3
|
-
import { type Code } from "../ts-poet-wrapper.js";
|
|
4
|
-
export declare function NamedObjectType_toRdfResourceFunctionOrMethodDeclaration(this: NamedObjectType): Maybe<Code>;
|
|
5
|
-
//# sourceMappingURL=NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.d.ts.map
|
package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionOrMethodDeclaration.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
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 ownProperty of this.ownProperties) {
|
|
21
|
-
ownProperty
|
|
22
|
-
.toStringExpression({
|
|
23
|
-
variables: { value: code `${this.thisVariable}.${ownProperty.name}` },
|
|
24
|
-
})
|
|
25
|
-
.ifJust((ownPropertyToStringExpression) => {
|
|
26
|
-
propertiesToStringRecordProperties.push(code `${literalOf(ownProperty.name)}: ${ownPropertyToStringExpression}`);
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
const propertiesToStringsReturnExpression = code `${snippets.compactRecord}({${joinCode(propertiesToStringRecordProperties, { on: "," })}})`;
|
|
30
|
-
const toStringReturnExpression = (propertiesToStrings) => code `\`${this.name}(\${JSON.stringify(${propertiesToStrings})})\``;
|
|
31
|
-
switch (this.declarationType) {
|
|
32
|
-
case "class": {
|
|
33
|
-
let propertiesToStringsPreamble = "";
|
|
34
|
-
let toStringPreamble = "";
|
|
35
|
-
if (this.parentObjectTypes.length > 0) {
|
|
36
|
-
propertiesToStringsPreamble = "override ";
|
|
37
|
-
toStringPreamble = "override ";
|
|
38
|
-
}
|
|
39
|
-
propertiesToStringsPreamble = `protected ${propertiesToStringsPreamble}`;
|
|
40
|
-
return [
|
|
41
|
-
code `${propertiesToStringsPreamble}${syntheticNamePrefix}propertiesToStrings(): Record<string, string> { return ${propertiesToStringsReturnExpression}; }`,
|
|
42
|
-
code `${toStringPreamble}toString(): string { return ${toStringReturnExpression(code `this.${syntheticNamePrefix}propertiesToStrings()`)}; }`,
|
|
43
|
-
];
|
|
44
|
-
}
|
|
45
|
-
case "interface": {
|
|
46
|
-
return [
|
|
47
|
-
// Use overloads to allow the function to be attached to an instance or used freestanding
|
|
48
|
-
code `\
|
|
49
|
-
export function ${syntheticNamePrefix}propertiesToStrings(${this.thisVariable}: ${this.name}): Record<string, string> {
|
|
50
|
-
return ${propertiesToStringsReturnExpression};
|
|
51
|
-
}`,
|
|
52
|
-
code `\
|
|
53
|
-
export function ${syntheticNamePrefix}toString(this: ${this.name}): string;
|
|
54
|
-
export function ${syntheticNamePrefix}toString(${this.thisVariable}: ${this.name}): string;
|
|
55
|
-
export function ${syntheticNamePrefix}toString(this: ${this.name} | undefined, ${this.thisVariable}?: ${this.name}): string {
|
|
56
|
-
return ${toStringReturnExpression(code `${syntheticNamePrefix}propertiesToStrings((${this.thisVariable} ?? this)!)`)};
|
|
57
|
-
}`,
|
|
58
|
-
];
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=NamedObjectType_toStringFunctionOrMethodDeclaration.js.map
|
|
File without changes
|
|
File without changes
|