@shaclmate/compiler 4.0.24 → 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/nodeShapeTsFeatures.d.ts +1 -1
- package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.js +5 -2
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +0 -6
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +0 -2
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +14 -32
- package/dist/ast/AbstractCompoundType.d.ts +1 -1
- package/dist/ast/ObjectType.d.ts +3 -23
- package/dist/ast/ObjectType.js +2 -20
- 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 +26 -39
- 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/NamedObjectType.d.ts +2 -13
- package/dist/generators/ts/NamedObjectType.js +33 -104
- package/dist/generators/ts/NamedObjectUnionType.js +13 -24
- package/dist/generators/ts/TypeFactory.js +10 -28
- package/dist/generators/ts/ZodGenerator.js +2 -2
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.d.ts +1 -7
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.js +1 -6
- package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.d.ts +0 -1
- package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.js +4 -31
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.js +6 -17
- 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_filterTypeDeclaration.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 +1 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +1 -4
- 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_jsonParseFunctionDeclaration.js +0 -3
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js +1 -1
- 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 +1 -1
- 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_toJsonFunctionOrMethodDeclaration.js → NamedObjectType_toJsonFunctionDeclaration.js} +5 -27
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_NamedObjectType/{NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.js → NamedObjectType_toRdfResourceFunctionDeclaration.js} +4 -25
- 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/ShaclProperty.js +6 -28
- package/dist/generators/ts/objectSetDeclarations.js +1 -3
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +2 -4
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +1 -1
- package/dist/input/ShapesGraph.d.ts +1 -1
- package/dist/input/generated.d.ts +0 -134
- package/dist/input/generated.js +12 -239
- package/package.json +2 -4
- 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/NamedObjectType_classDeclaration.d.ts +0 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_classDeclaration.js +0 -61
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionOrMethodDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionOrMethodDeclaration.js +0 -52
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionOrMethodDeclarations.d.ts +0 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionOrMethodDeclarations.js +0 -77
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionOrMethodDeclaration.d.ts +0 -5
- 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 -66
- /package/dist/{enums → generators/ts}/TsFeature.d.ts +0 -0
- /package/dist/{enums → generators/ts}/TsFeature.js +0 -0
|
@@ -30,13 +30,13 @@ export class NamedObjectUnionType extends AbstractNamedUnionType {
|
|
|
30
30
|
return new AbstractType.GraphqlType(code `${this._name}.${syntheticNamePrefix}GraphQL`);
|
|
31
31
|
}
|
|
32
32
|
get identifierTypeAlias() {
|
|
33
|
-
return code `${this.
|
|
33
|
+
return code `${this.name}.${syntheticNamePrefix}Identifier`;
|
|
34
34
|
}
|
|
35
35
|
get objectSetMethodNames() {
|
|
36
36
|
return NamedObjectType_objectSetMethodNames.call(this);
|
|
37
37
|
}
|
|
38
38
|
get schema() {
|
|
39
|
-
return code `${this.
|
|
39
|
+
return code `${this.name}.${syntheticNamePrefix}schema`;
|
|
40
40
|
}
|
|
41
41
|
get schemaType() {
|
|
42
42
|
return code `typeof ${this.schema}`;
|
|
@@ -66,7 +66,7 @@ export class NamedObjectUnionType extends AbstractNamedUnionType {
|
|
|
66
66
|
}
|
|
67
67
|
return singleEntryRecord(`${syntheticNamePrefix}focusSparqlConstructTriples`, code `\
|
|
68
68
|
export function ${syntheticNamePrefix}focusSparqlConstructTriples({ filter, focusIdentifier, variablePrefix }: { filter: ${this.filterType} | undefined; focusIdentifier: ${imports.NamedNode} | ${imports.Variable}; ignoreRdfType: boolean; variablePrefix: string }): readonly ${imports.sparqljs}.Triple[] {
|
|
69
|
-
return [${joinCode(this.
|
|
69
|
+
return [${joinCode(this.members.map((member) => code `...${member.type.name}.${syntheticNamePrefix}focusSparqlConstructTriples({ filter: filter?.on?.${member.type.name}, focusIdentifier, ignoreRdfType: false, variablePrefix: \`\${variablePrefix}${pascalCase(member.type.name)}\` }).concat()`), { on: ", " })}];
|
|
70
70
|
}`);
|
|
71
71
|
}
|
|
72
72
|
get focusSparqlWherePatternsFunctionDeclaration() {
|
|
@@ -89,8 +89,8 @@ if (focusIdentifier.termType === "Variable") {
|
|
|
89
89
|
variablePrefix,
|
|
90
90
|
}));
|
|
91
91
|
}`,
|
|
92
|
-
code `patterns.push({ patterns: [${joinCode(this.
|
|
93
|
-
patterns: code `${member.type.
|
|
92
|
+
code `patterns.push({ patterns: [${joinCode(this.members.map((member) => code `${{
|
|
93
|
+
patterns: code `${member.type.name}.${syntheticNamePrefix}focusSparqlWherePatterns({ filter: filter?.on?.${member.type.name}, focusIdentifier, ignoreRdfType: false, preferredLanguages, variablePrefix: \`\${variablePrefix}${pascalCase(member.type.name)}\` }).concat()`,
|
|
94
94
|
type: literalOf("group"),
|
|
95
95
|
}}`), { on: ", " })}], type: "union" });`,
|
|
96
96
|
code `return patterns;`,
|
|
@@ -103,8 +103,8 @@ if (focusIdentifier.termType === "Variable") {
|
|
|
103
103
|
}
|
|
104
104
|
return singleEntryRecord(`${syntheticNamePrefix}fromRdfResource`, code `\
|
|
105
105
|
export const ${syntheticNamePrefix}fromRdfResource: ${snippets.FromRdfResourceFunction}<${this.name}> = (resource, options) =>
|
|
106
|
-
${this.
|
|
107
|
-
const memberTypeExpression = code `(${member.type.
|
|
106
|
+
${this.members.reduce((expression, member) => {
|
|
107
|
+
const memberTypeExpression = code `(${member.type.name}.${syntheticNamePrefix}fromRdfResource(resource, { ...options, ignoreRdfType: false }) as ${imports.Either}<Error, ${this.name}>)`;
|
|
108
108
|
return expression !== null
|
|
109
109
|
? code `${expression}.altLazy(() => ${memberTypeExpression})`
|
|
110
110
|
: memberTypeExpression;
|
|
@@ -119,7 +119,7 @@ export const ${syntheticNamePrefix}GraphQL = new ${imports.GraphQLUnionType}(${{
|
|
|
119
119
|
description: this.comment.map(JSON.stringify).extract(),
|
|
120
120
|
name: this.name,
|
|
121
121
|
resolveType: code `(value: ${this.name}) => value.${syntheticNamePrefix}type`,
|
|
122
|
-
types: code `[${joinCode(this.
|
|
122
|
+
types: code `[${joinCode(this.members.map((member) => member.type.graphqlType.nullableName), { on: ", " })}]`,
|
|
123
123
|
}});`);
|
|
124
124
|
}
|
|
125
125
|
get identifierTypeDeclarations() {
|
|
@@ -136,12 +136,12 @@ export namespace ${syntheticNamePrefix}Identifier {
|
|
|
136
136
|
}
|
|
137
137
|
return singleEntryRecord(`is${this._name}`, code `\
|
|
138
138
|
export function is${this._name}(object: ${syntheticNamePrefix}Object): object is ${this.name} {
|
|
139
|
-
return ${joinCode(this.
|
|
139
|
+
return ${joinCode(this.members.map((member) => code `${member.type.name}.is${member.type.name}(object)`), { on: " || " })};
|
|
140
140
|
}`);
|
|
141
141
|
}
|
|
142
142
|
get schemaVariableStatement() {
|
|
143
143
|
const commonPropertiesByName = {};
|
|
144
|
-
this.
|
|
144
|
+
this.members.forEach((member, memberI) => {
|
|
145
145
|
for (const memberTypeProperty of member.type.properties.concat(member.type.ancestorObjectTypes.flatMap((ancestorObjectType) => ancestorObjectType.properties))) {
|
|
146
146
|
if (memberTypeProperty.kind !== "ShaclProperty") {
|
|
147
147
|
continue;
|
|
@@ -154,7 +154,7 @@ export namespace ${syntheticNamePrefix}Identifier {
|
|
|
154
154
|
}
|
|
155
155
|
else {
|
|
156
156
|
commonPropertiesByName[memberTypeProperty.name] = commonProperty = {
|
|
157
|
-
memberTypesWithProperty: new Array(this.
|
|
157
|
+
memberTypesWithProperty: new Array(this.members.length).fill(false),
|
|
158
158
|
property: memberTypeProperty,
|
|
159
159
|
};
|
|
160
160
|
commonProperty.memberTypesWithProperty[memberI] = true;
|
|
@@ -182,19 +182,8 @@ ${{
|
|
|
182
182
|
}
|
|
183
183
|
return singleEntryRecord(`${syntheticNamePrefix}toRdfResource`, code `\
|
|
184
184
|
export const ${syntheticNamePrefix}toRdfResource: ${snippets.ToRdfResourceFunction}<${this.name}> = (value, options) => {
|
|
185
|
-
${joinCode(this.
|
|
186
|
-
.map((member) => {
|
|
187
|
-
let returnExpression;
|
|
188
|
-
switch (member.type.declarationType) {
|
|
189
|
-
case "class":
|
|
190
|
-
returnExpression = code `value.${syntheticNamePrefix}toRdfResource(options)`;
|
|
191
|
-
break;
|
|
192
|
-
case "interface":
|
|
193
|
-
returnExpression = code `${member.type.staticModuleName}.${syntheticNamePrefix}toRdfResource(value, options)`;
|
|
194
|
-
break;
|
|
195
|
-
}
|
|
196
|
-
return code `if (${member.type.staticModuleName}.is${member.type.name}(value)) { return ${returnExpression}; }`;
|
|
197
|
-
})
|
|
185
|
+
${joinCode(this.members
|
|
186
|
+
.map((member) => code `if (${member.type.name}.is${member.type.name}(value)) { return ${member.type.name}.${syntheticNamePrefix}toRdfResource(value, options); }`)
|
|
198
187
|
.concat(code `throw new Error("unrecognized type");`))}
|
|
199
188
|
};`);
|
|
200
189
|
}
|
|
@@ -75,11 +75,8 @@ export class TypeFactory {
|
|
|
75
75
|
const name = tsName(astType.name.unsafeCoerce(), {
|
|
76
76
|
synthetic: astType.synthetic,
|
|
77
77
|
});
|
|
78
|
-
const staticModuleName = astType.childObjectTypes.length > 0 ? `${name}Static` : name;
|
|
79
78
|
const namedObjectType = new NamedObjectType({
|
|
80
|
-
abstract: astType.abstract,
|
|
81
79
|
comment: astType.comment,
|
|
82
|
-
declarationType: astType.tsObjectDeclarationType,
|
|
83
80
|
extern: astType.extern,
|
|
84
81
|
features: astType.tsFeatures,
|
|
85
82
|
fromRdfType: astType.fromRdfType,
|
|
@@ -91,14 +88,9 @@ export class TypeFactory {
|
|
|
91
88
|
lazyDescendantObjectTypes: () => astType.descendantObjectTypes.map((astType) => this.createNamedObjectType(astType)),
|
|
92
89
|
lazyDiscriminantProperty: (namedObjectType) => {
|
|
93
90
|
// Discriminant property
|
|
94
|
-
const discriminantOwnValue = !astType.abstract
|
|
95
|
-
? namedObjectType.discriminantValue
|
|
96
|
-
: undefined;
|
|
97
91
|
const discriminantDescendantValues = new Set();
|
|
98
92
|
for (const descendantObjectType of namedObjectType.descendantObjectTypes) {
|
|
99
|
-
|
|
100
|
-
discriminantDescendantValues.add(descendantObjectType.discriminantValue);
|
|
101
|
-
}
|
|
93
|
+
discriminantDescendantValues.add(descendantObjectType.discriminantValue);
|
|
102
94
|
}
|
|
103
95
|
return new NamedObjectType.DiscriminantProperty({
|
|
104
96
|
logger: this.logger,
|
|
@@ -107,9 +99,8 @@ export class TypeFactory {
|
|
|
107
99
|
type: new NamedObjectType.DiscriminantProperty.Type({
|
|
108
100
|
descendantValues: [...discriminantDescendantValues].sort(),
|
|
109
101
|
mutable: false,
|
|
110
|
-
ownValues:
|
|
102
|
+
ownValues: [namedObjectType.discriminantValue],
|
|
111
103
|
}),
|
|
112
|
-
visibility: "public",
|
|
113
104
|
});
|
|
114
105
|
},
|
|
115
106
|
lazyParentObjectTypes: () => astType.parentObjectTypes.map((astType) => this.createNamedObjectType(astType)),
|
|
@@ -128,27 +119,19 @@ export class TypeFactory {
|
|
|
128
119
|
astObjectTypeProperty: astProperty,
|
|
129
120
|
namedObjectType,
|
|
130
121
|
}));
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
name: `${syntheticNamePrefix}identifier`,
|
|
140
|
-
namedObjectType,
|
|
141
|
-
type: identifierType,
|
|
142
|
-
typeAlias: code `${staticModuleName}.${syntheticNamePrefix}Identifier`,
|
|
143
|
-
visibility: "public",
|
|
144
|
-
}));
|
|
145
|
-
}
|
|
122
|
+
properties.splice(0, 0, namedObjectType._discriminantProperty);
|
|
123
|
+
properties.splice(0, 0, new NamedObjectType.IdentifierProperty({
|
|
124
|
+
logger: this.logger,
|
|
125
|
+
name: `${syntheticNamePrefix}identifier`,
|
|
126
|
+
namedObjectType,
|
|
127
|
+
type: identifierType,
|
|
128
|
+
typeAlias: code `${name}.${syntheticNamePrefix}Identifier`,
|
|
129
|
+
}));
|
|
146
130
|
return properties;
|
|
147
131
|
},
|
|
148
132
|
logger: this.logger,
|
|
149
133
|
name,
|
|
150
134
|
recursive: astType.recursive,
|
|
151
|
-
staticModuleName,
|
|
152
135
|
synthetic: astType.synthetic,
|
|
153
136
|
toRdfTypes: astType.toRdfTypes,
|
|
154
137
|
});
|
|
@@ -442,7 +425,6 @@ export class TypeFactory {
|
|
|
442
425
|
path: astObjectTypeProperty.path,
|
|
443
426
|
recursive: !!astObjectTypeProperty.recursive,
|
|
444
427
|
type: this.createType(astObjectTypeProperty.type),
|
|
445
|
-
visibility: astObjectTypeProperty.visibility,
|
|
446
428
|
});
|
|
447
429
|
this.cachedObjectTypePropertiesByShapeIdentifier.set(astObjectTypeProperty.shapeIdentifier, property);
|
|
448
430
|
return property;
|
|
@@ -15,7 +15,7 @@ export class ZodGenerator {
|
|
|
15
15
|
const declarations = [];
|
|
16
16
|
for (const namedObjectType of ast.ObjectType.toposort(ast_.namedObjectTypes).map((astObjectType) => this.typeFactory.createNamedObjectType(astObjectType))) {
|
|
17
17
|
declarations.push(code `\
|
|
18
|
-
export namespace ${namedObjectType.
|
|
18
|
+
export namespace ${namedObjectType.name} {
|
|
19
19
|
${joinCode(NamedObjectType_jsonTypeAliasDeclaration.bind(namedObjectType)().toList())}
|
|
20
20
|
|
|
21
21
|
export namespace ${syntheticNamePrefix}Json {
|
|
@@ -26,7 +26,7 @@ export namespace ${namedObjectType.staticModuleName} {
|
|
|
26
26
|
for (const astNamedUnionType of ast_.namedUnionTypes.map((astNamedUnionType) => this.typeFactory.createUnionType(astNamedUnionType))) {
|
|
27
27
|
invariant(astNamedUnionType.kind !== "AnonymousUnionType");
|
|
28
28
|
declarations.push(code `\
|
|
29
|
-
export namespace ${astNamedUnionType.
|
|
29
|
+
export namespace ${astNamedUnionType.name} {
|
|
30
30
|
${astNamedUnionType.jsonTypeAliasDeclaration}
|
|
31
31
|
export namespace ${syntheticNamePrefix}Json {
|
|
32
32
|
${astNamedUnionType.jsonSchemaFunctionDeclaration}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Maybe } from "purify-ts";
|
|
2
2
|
import type { Logger } from "ts-log";
|
|
3
|
-
import type { Visibility } from "../../../enums/Visibility.js";
|
|
4
3
|
import type { NamedObjectType } from "../NamedObjectType.js";
|
|
5
4
|
import type { Type } from "../Type.js";
|
|
6
5
|
import { type Code } from "../ts-poet-wrapper.js";
|
|
@@ -65,16 +64,11 @@ export declare abstract class AbstractProperty<TypeT extends Pick<Type, "filterF
|
|
|
65
64
|
* Property type
|
|
66
65
|
. */
|
|
67
66
|
readonly type: TypeT;
|
|
68
|
-
|
|
69
|
-
* Property visibility: private, protected, public.
|
|
70
|
-
*/
|
|
71
|
-
readonly visibility: Visibility;
|
|
72
|
-
constructor({ logger, name, namedObjectType, type, visibility, }: {
|
|
67
|
+
constructor({ logger, name, namedObjectType, type, }: {
|
|
73
68
|
logger: Logger;
|
|
74
69
|
name: string;
|
|
75
70
|
namedObjectType: NamedObjectType;
|
|
76
71
|
type: TypeT;
|
|
77
|
-
visibility: Visibility;
|
|
78
72
|
});
|
|
79
73
|
/**
|
|
80
74
|
* TypeScript object describing this type, for runtime use.
|
|
@@ -19,16 +19,11 @@ export class AbstractProperty {
|
|
|
19
19
|
* Property type
|
|
20
20
|
. */
|
|
21
21
|
type;
|
|
22
|
-
|
|
23
|
-
* Property visibility: private, protected, public.
|
|
24
|
-
*/
|
|
25
|
-
visibility;
|
|
26
|
-
constructor({ logger, name, namedObjectType, type, visibility, }) {
|
|
22
|
+
constructor({ logger, name, namedObjectType, type, }) {
|
|
27
23
|
this.logger = logger;
|
|
28
24
|
this.name = name;
|
|
29
25
|
this.namedObjectType = namedObjectType;
|
|
30
26
|
this.type = type;
|
|
31
|
-
this.visibility = visibility;
|
|
32
27
|
}
|
|
33
28
|
/**
|
|
34
29
|
* TypeScript object describing this type, for runtime use.
|
|
@@ -14,7 +14,6 @@ export declare class DiscriminantProperty extends AbstractProperty<DiscriminantP
|
|
|
14
14
|
get declaration(): Code;
|
|
15
15
|
get jsonSchema(): AbstractProperty<DiscriminantProperty.Type>["jsonSchema"];
|
|
16
16
|
get jsonSignature(): Maybe<Code>;
|
|
17
|
-
private get abstract();
|
|
18
17
|
private get initializer();
|
|
19
18
|
private get override();
|
|
20
19
|
constructorStatements(): readonly Code[];
|
|
@@ -5,7 +5,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { Maybe } from "purify-ts";
|
|
8
|
-
import { invariant } from "ts-invariant";
|
|
9
8
|
import { Memoize } from "typescript-memoize";
|
|
10
9
|
import { imports } from "../imports.js";
|
|
11
10
|
import { removeUndefined } from "../removeUndefined.js";
|
|
@@ -20,18 +19,9 @@ export class DiscriminantProperty extends AbstractProperty {
|
|
|
20
19
|
recursive = false;
|
|
21
20
|
constructor({ type, ...superParameters }) {
|
|
22
21
|
super({ ...superParameters, type });
|
|
23
|
-
invariant(this.visibility === "public");
|
|
24
22
|
}
|
|
25
23
|
get declaration() {
|
|
26
|
-
|
|
27
|
-
case "class":
|
|
28
|
-
return code `${this.abstract ? "abstract " : ""}${this.override ? "override " : ""}readonly ${this.name}: ${this.type.name}${!this.abstract ? code ` = ${this.initializer};` : ";"}`;
|
|
29
|
-
case "interface":
|
|
30
|
-
return code `readonly ${this.name}: ${this.type.name};`;
|
|
31
|
-
default:
|
|
32
|
-
this.namedObjectType.declarationType;
|
|
33
|
-
throw new Error("should never reach this point");
|
|
34
|
-
}
|
|
24
|
+
return code `readonly ${this.name}: ${this.type.name};`;
|
|
35
25
|
}
|
|
36
26
|
get jsonSchema() {
|
|
37
27
|
if (this.override) {
|
|
@@ -50,9 +40,6 @@ export class DiscriminantProperty extends AbstractProperty {
|
|
|
50
40
|
}
|
|
51
41
|
return Maybe.of(code `readonly ${this.name}: ${this.type.name}`);
|
|
52
42
|
}
|
|
53
|
-
get abstract() {
|
|
54
|
-
return this.namedObjectType.abstract;
|
|
55
|
-
}
|
|
56
43
|
get initializer() {
|
|
57
44
|
return code `${literalOf(this.namedObjectType.discriminantValue)} as const`;
|
|
58
45
|
}
|
|
@@ -60,27 +47,13 @@ export class DiscriminantProperty extends AbstractProperty {
|
|
|
60
47
|
return this.namedObjectType.parentObjectTypes.length > 0;
|
|
61
48
|
}
|
|
62
49
|
constructorStatements() {
|
|
63
|
-
|
|
64
|
-
case "class":
|
|
65
|
-
return [];
|
|
66
|
-
case "interface":
|
|
67
|
-
if (this.abstract) {
|
|
68
|
-
return [];
|
|
69
|
-
}
|
|
70
|
-
return [code `const ${this.name} = ${this.initializer};`];
|
|
71
|
-
}
|
|
50
|
+
return [code `const ${this.name} = ${this.initializer};`];
|
|
72
51
|
}
|
|
73
52
|
fromJsonStatements() {
|
|
74
|
-
return
|
|
75
|
-
this.namedObjectType.declarationType === "interface"
|
|
76
|
-
? [code `const ${this.name} = ${this.initializer};`]
|
|
77
|
-
: [];
|
|
53
|
+
return [code `const ${this.name} = ${this.initializer};`];
|
|
78
54
|
}
|
|
79
55
|
fromRdfResourceValuesExpression() {
|
|
80
|
-
return
|
|
81
|
-
this.namedObjectType.declarationType === "interface"
|
|
82
|
-
? Maybe.of(code `${imports.Right}<${literalOf(this.namedObjectType.discriminantValue)}>(${this.initializer})`)
|
|
83
|
-
: Maybe.empty();
|
|
56
|
+
return Maybe.of(code `${imports.Right}<${literalOf(this.namedObjectType.discriminantValue)}>(${this.initializer})`);
|
|
84
57
|
}
|
|
85
58
|
hashStatements({ variables, }) {
|
|
86
59
|
if (this.override) {
|
|
@@ -22,7 +22,6 @@ export class IdentifierProperty extends AbstractProperty {
|
|
|
22
22
|
recursive = false;
|
|
23
23
|
constructor({ typeAlias, ...superParameters }) {
|
|
24
24
|
super(superParameters);
|
|
25
|
-
invariant(this.visibility === "public");
|
|
26
25
|
this.typeAlias = typeAlias;
|
|
27
26
|
}
|
|
28
27
|
get constructorParametersSignature() {
|
|
@@ -80,36 +79,26 @@ export class IdentifierProperty extends AbstractProperty {
|
|
|
80
79
|
return code `${variables.object}.${this.name}()`;
|
|
81
80
|
}
|
|
82
81
|
constructorStatements({ variables, }) {
|
|
83
|
-
let lhs;
|
|
84
82
|
const parameterVariable = code `${this.name}Parameter`;
|
|
85
83
|
const statements = [
|
|
86
84
|
// Pull out the parameter so the function can capture it if necessary.
|
|
87
85
|
code `const ${parameterVariable} = ${variables.parameter};`,
|
|
86
|
+
code `let ${this.name}: () => ${this.typeAlias};`,
|
|
88
87
|
];
|
|
89
88
|
const typeConversions = this.type.conversions;
|
|
90
|
-
switch (this.namedObjectType.declarationType) {
|
|
91
|
-
case "class": {
|
|
92
|
-
lhs = `this.${this.name}`;
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
case "interface":
|
|
96
|
-
lhs = this.name;
|
|
97
|
-
statements.push(code `let ${this.name}: () => ${this.typeAlias};`);
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
89
|
const conversionBranches = [
|
|
101
|
-
code `if (typeof ${parameterVariable} === "function") { ${
|
|
90
|
+
code `if (typeof ${parameterVariable} === "function") { ${this.name} = ${parameterVariable}; }`,
|
|
102
91
|
];
|
|
103
92
|
for (const conversion of typeConversions) {
|
|
104
93
|
invariant(conversion.sourceTypeof !== "function");
|
|
105
94
|
invariant(conversion.sourceTypeof !== "undefined");
|
|
106
|
-
conversionBranches.push(code `if (${conversion.sourceTypeCheckExpression(parameterVariable)}) { ${
|
|
95
|
+
conversionBranches.push(code `if (${conversion.sourceTypeCheckExpression(parameterVariable)}) { ${this.name} = () => ${conversion.conversionExpression(parameterVariable)}; }`);
|
|
107
96
|
}
|
|
108
97
|
if (this.type.nodeKinds.has("BlankNode")) {
|
|
109
|
-
conversionBranches.push(code `if (${parameterVariable} === undefined) { const ${syntheticNamePrefix}eagerIdentifier = ${imports.dataFactory}.blankNode(); ${
|
|
98
|
+
conversionBranches.push(code `if (${parameterVariable} === undefined) { const ${syntheticNamePrefix}eagerIdentifier = ${imports.dataFactory}.blankNode(); ${this.name} = () => ${syntheticNamePrefix}eagerIdentifier; }`);
|
|
110
99
|
}
|
|
111
100
|
// We shouldn't need this else, since the parameter now has the never type, but have to add it to appease the TypeScript compiler
|
|
112
|
-
conversionBranches.push(code `{ ${
|
|
101
|
+
conversionBranches.push(code `{ ${this.name} = (${parameterVariable}) satisfies never;\n }`);
|
|
113
102
|
statements.push(joinCode(conversionBranches, { on: " else " }));
|
|
114
103
|
return statements;
|
|
115
104
|
}
|
|
@@ -146,7 +135,7 @@ export class IdentifierProperty extends AbstractProperty {
|
|
|
146
135
|
ignoreRdfType: true, // Unused
|
|
147
136
|
preferredLanguages: variables.preferredLanguages,
|
|
148
137
|
propertyPatterns: code `[]`,
|
|
149
|
-
schema: code `${this.namedObjectType.
|
|
138
|
+
schema: code `${this.namedObjectType.name}.${syntheticNamePrefix}schema.properties.${this.name}.type()`,
|
|
150
139
|
valueVariable: variables.focusIdentifier,
|
|
151
140
|
variablePrefix: variables.variablePrefix, // Unused
|
|
152
141
|
}})`,
|
|
@@ -12,7 +12,7 @@ export function NamedObjectType_createFunctionDeclaration() {
|
|
|
12
12
|
parametersType.push(code `{ ${joinCode(parametersPropertySignatures)} }`);
|
|
13
13
|
}
|
|
14
14
|
for (const parentObjectType of this.parentObjectTypes) {
|
|
15
|
-
parametersType.push(code `Parameters<typeof ${parentObjectType.
|
|
15
|
+
parametersType.push(code `Parameters<typeof ${parentObjectType.name}.${syntheticNamePrefix}create>[0]`);
|
|
16
16
|
}
|
|
17
17
|
if (parametersType.length === 0) {
|
|
18
18
|
parametersType.push(code `object`);
|
|
@@ -21,7 +21,7 @@ export function NamedObjectType_createFunctionDeclaration() {
|
|
|
21
21
|
const omitPropertyNames = [];
|
|
22
22
|
const propertyStatements = [];
|
|
23
23
|
for (const parentObjectType of this.parentObjectTypes) {
|
|
24
|
-
propertyInitializers.push(`...${parentObjectType.
|
|
24
|
+
propertyInitializers.push(`...${parentObjectType.name}.${syntheticNamePrefix}create(parameters)`);
|
|
25
25
|
}
|
|
26
26
|
const parametersHasQuestionToken = this.parentObjectTypes.length === 0 &&
|
|
27
27
|
parametersPropertySignatures.every((propertySignature) => propertySignature.toCodeString([]).indexOf("?:") !== -1);
|
|
@@ -0,0 +1,5 @@
|
|
|
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_equalsFunctionDeclaration(this: NamedObjectType): Maybe<Code>;
|
|
5
|
+
//# sourceMappingURL=NamedObjectType_equalsFunctionDeclaration.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
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_equalsFunctionDeclaration() {
|
|
6
|
+
if (!this.features.has("equals")) {
|
|
7
|
+
return Maybe.empty();
|
|
8
|
+
}
|
|
9
|
+
const chain = [];
|
|
10
|
+
// For every parent, find the nearest equals implementation
|
|
11
|
+
for (const parentObjectType of this.parentObjectTypes) {
|
|
12
|
+
chain.push(code `${parentObjectType.name}.${syntheticNamePrefix}equals(left, right)`);
|
|
13
|
+
}
|
|
14
|
+
for (const property of this.properties) {
|
|
15
|
+
if (property.kind === "DiscriminantProperty") {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
chain.push(code `(${property.type.equalsFunction})(${property.accessExpression({ variables: { object: code `left` } })}, ${property.accessExpression({ variables: { object: code `right` } })}).mapLeft(propertyValuesUnequal => ({ left, right, propertyName: "${property.name}", propertyValuesUnequal, type: "property" as const }))`);
|
|
19
|
+
}
|
|
20
|
+
return Maybe.of(code `\
|
|
21
|
+
export function ${syntheticNamePrefix}equals(left: ${this.name}, right: ${this.name}): ${snippets.EqualsResult} {
|
|
22
|
+
return ${joinCode(chain.map((chainPart, chainPartI) => chainPartI === 0 ? chainPart : code `chain(() => ${chainPart})`), { on: "." })}
|
|
23
|
+
}`);
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=NamedObjectType_equalsFunctionDeclaration.js.map
|
|
@@ -14,7 +14,7 @@ export function NamedObjectType_filterTypeDeclaration() {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
for (const parentObjectType of this.parentObjectTypes) {
|
|
17
|
-
members.push(code `${parentObjectType.
|
|
17
|
+
members.push(code `${parentObjectType.name}.${syntheticNamePrefix}Filter`);
|
|
18
18
|
}
|
|
19
19
|
return code `\
|
|
20
20
|
export type ${syntheticNamePrefix}Filter = ${members.length > 0 ? joinCode(members, { on: " & " }) : "object"};`;
|
|
@@ -19,7 +19,7 @@ export function NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration()
|
|
|
19
19
|
let triplesVariableDeclarationKeyword = "const";
|
|
20
20
|
const statements = [];
|
|
21
21
|
for (const parentObjectType of this.parentObjectTypes) {
|
|
22
|
-
statements.push(code `triples = triples.concat(${parentObjectType.
|
|
22
|
+
statements.push(code `triples = triples.concat(${parentObjectType.name}.${syntheticNamePrefix}focusSparqlConstructTriples(${{ filter: variables.filter, focusIdentifier: variables.focusIdentifier, ignoreRdfType: true, variablePrefix: variables.variablePrefix }}));`);
|
|
23
23
|
triplesVariableDeclarationKeyword = "let";
|
|
24
24
|
}
|
|
25
25
|
if (this.fromRdfType.isJust()) {
|
|
@@ -21,7 +21,7 @@ export function NamedObjectType_focusSparqlWherePatternsFunctionDeclaration() {
|
|
|
21
21
|
const statements = [];
|
|
22
22
|
for (const parentObjectType of this.parentObjectTypes) {
|
|
23
23
|
statements.push(code `\
|
|
24
|
-
patterns = patterns.concat(${parentObjectType.
|
|
24
|
+
patterns = patterns.concat(${parentObjectType.name}.${syntheticNamePrefix}focusSparqlWherePatterns(${{ filter: variables.filter, focusIdentifier: variables.focusIdentifier, ignoreRdfType: true, preferredLanguages: variables.preferredLanguages, variablePrefix: variables.variablePrefix }}));`);
|
|
25
25
|
patternsVariableDeclarationKeyword = "let";
|
|
26
26
|
}
|
|
27
27
|
if (this.fromRdfType.isJust()) {
|
|
@@ -5,12 +5,9 @@ export function NamedObjectType_fromJsonFunctionDeclaration() {
|
|
|
5
5
|
if (!this.features.has("json")) {
|
|
6
6
|
return Maybe.empty();
|
|
7
7
|
}
|
|
8
|
-
if (this.abstract) {
|
|
9
|
-
return Maybe.empty();
|
|
10
|
-
}
|
|
11
8
|
return Maybe.of(code `\
|
|
12
9
|
export function ${syntheticNamePrefix}fromJson(json: ${this.jsonType().name}): ${this.name} {
|
|
13
|
-
return ${
|
|
10
|
+
return ${syntheticNamePrefix}create(${syntheticNamePrefix}propertiesFromJson(json));
|
|
14
11
|
}`);
|
|
15
12
|
}
|
|
16
13
|
//# sourceMappingURL=NamedObjectType_fromJsonFunctionDeclaration.js.map
|
package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js
CHANGED
|
@@ -6,15 +6,12 @@ export function NamedObjectType_fromRdfResourceFunctionDeclaration() {
|
|
|
6
6
|
if (!this.features.has("rdf")) {
|
|
7
7
|
return Maybe.empty();
|
|
8
8
|
}
|
|
9
|
-
if (this.abstract) {
|
|
10
|
-
return Maybe.empty();
|
|
11
|
-
}
|
|
12
9
|
return Maybe.of(code `\
|
|
13
10
|
export const ${syntheticNamePrefix}fromRdfResource: ${snippets.FromRdfResourceFunction}<${this.name}> = (resource, options) => {
|
|
14
11
|
${joinCode([
|
|
15
12
|
code `let { context, graph, ignoreRdfType = false, objectSet, preferredLanguages } = (options ?? {});`,
|
|
16
13
|
code `if (!objectSet) { objectSet = new ${syntheticNamePrefix}RdfjsDatasetObjectSet(resource.dataset); }`,
|
|
17
|
-
code `return ${code `${this.
|
|
14
|
+
code `return ${code `${this.name}.${syntheticNamePrefix}propertiesFromRdfResource(resource, { context, graph, ignoreRdfType, objectSet, preferredLanguages }).map(${syntheticNamePrefix}create)`};`,
|
|
18
15
|
])}
|
|
19
16
|
};`);
|
|
20
17
|
}
|
|
@@ -6,14 +6,11 @@ export function NamedObjectType_fromRdfResourceValuesFunctionDeclaration() {
|
|
|
6
6
|
if (!this.features.has("rdf")) {
|
|
7
7
|
return Maybe.empty();
|
|
8
8
|
}
|
|
9
|
-
if (this.abstract) {
|
|
10
|
-
return Maybe.empty();
|
|
11
|
-
}
|
|
12
9
|
return Maybe.of(code `\
|
|
13
10
|
export const ${syntheticNamePrefix}fromRdfResourceValues: ${snippets.FromRdfResourceValuesFunction}<${this.name}> = (values, options) =>
|
|
14
11
|
values.chain(
|
|
15
12
|
values => values.chainMap(
|
|
16
|
-
value => value.toResource().chain(resource => ${this.
|
|
13
|
+
value => value.toResource().chain(resource => ${this.name}.${syntheticNamePrefix}fromRdfResource(resource, options))
|
|
17
14
|
)
|
|
18
15
|
);`);
|
|
19
16
|
}
|
|
@@ -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_hashFunctionDeclarations(this: NamedObjectType): readonly Code[];
|
|
4
|
+
//# sourceMappingURL=NamedObjectType_hashFunctionDeclarations.d.ts.map
|
|
@@ -0,0 +1,49 @@
|
|
|
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_hashFunctionDeclarations() {
|
|
6
|
+
if (!this.features.has("hash")) {
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
const hashOwnShaclPropertiesStatements = this.properties.flatMap((property) => property.kind === "ShaclProperty"
|
|
10
|
+
? property.hashStatements({
|
|
11
|
+
depth: 0,
|
|
12
|
+
variables: {
|
|
13
|
+
hasher: hasherVariable,
|
|
14
|
+
value: property.accessExpression({
|
|
15
|
+
variables: { object: this.thisVariable },
|
|
16
|
+
}),
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
: []);
|
|
20
|
+
const hashShaclPropertiesStatements = [];
|
|
21
|
+
const hashStatements = [];
|
|
22
|
+
for (const parentObjectType of this.parentObjectTypes) {
|
|
23
|
+
hashShaclPropertiesStatements.push(code `${parentObjectType.name}.${syntheticNamePrefix}hashShaclProperties(${this.thisVariable}, ${hasherVariable});`);
|
|
24
|
+
}
|
|
25
|
+
hashStatements.push(code `${this.name}.${syntheticNamePrefix}hashShaclProperties(${this.thisVariable}, ${hasherVariable});`);
|
|
26
|
+
hashShaclPropertiesStatements.push(...hashOwnShaclPropertiesStatements);
|
|
27
|
+
hashShaclPropertiesStatements.push(code `return ${hasherVariable};`);
|
|
28
|
+
hashStatements.push(...this.properties
|
|
29
|
+
.filter((property) => property.kind !== "ShaclProperty")
|
|
30
|
+
.flatMap((property) => property.hashStatements({
|
|
31
|
+
depth: 0,
|
|
32
|
+
variables: {
|
|
33
|
+
hasher: hasherVariable,
|
|
34
|
+
value: code `${property.accessExpression({ variables: { object: this.thisVariable } })}`,
|
|
35
|
+
},
|
|
36
|
+
})));
|
|
37
|
+
hashStatements.push(code `return ${hasherVariable};`);
|
|
38
|
+
return [
|
|
39
|
+
code `\
|
|
40
|
+
export function ${syntheticNamePrefix}hash<HasherT extends ${snippets.Hasher}>(${this.thisVariable}: ${this.name}, ${hasherVariable}: HasherT): HasherT {
|
|
41
|
+
${joinCode(hashStatements)}
|
|
42
|
+
}`,
|
|
43
|
+
code `\
|
|
44
|
+
export function ${syntheticNamePrefix}hashShaclProperties<HasherT extends ${snippets.Hasher}>(${this.thisVariable}: ${this.name}, ${hasherVariable}: HasherT): HasherT {
|
|
45
|
+
${joinCode(hashShaclPropertiesStatements)}
|
|
46
|
+
}`,
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=NamedObjectType_hashFunctionDeclarations.js.map
|
|
@@ -6,9 +6,6 @@ export function NamedObjectType_jsonParseFunctionDeclaration() {
|
|
|
6
6
|
if (!this.features.has("json")) {
|
|
7
7
|
return Maybe.empty();
|
|
8
8
|
}
|
|
9
|
-
if (this.abstract) {
|
|
10
|
-
return Maybe.empty();
|
|
11
|
-
}
|
|
12
9
|
return Maybe.of(code `\
|
|
13
10
|
export function parse(json: unknown): ${imports.Either}<Error, ${syntheticNamePrefix}Json> {
|
|
14
11
|
const jsonSafeParseResult = schema().safeParse(json);
|
package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js
CHANGED
|
@@ -16,7 +16,7 @@ export function NamedObjectType_jsonSchemaFunctionDeclaration() {
|
|
|
16
16
|
.map(({ key, schema }) => code `"${key}": ${schema}`));
|
|
17
17
|
}
|
|
18
18
|
const meta = {
|
|
19
|
-
|
|
19
|
+
// id: this.name,
|
|
20
20
|
};
|
|
21
21
|
this.comment.ifJust((description) => {
|
|
22
22
|
meta["description"] = description;
|
package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js
CHANGED
|
@@ -7,7 +7,7 @@ export function NamedObjectType_jsonUiSchemaFunctionDeclaration() {
|
|
|
7
7
|
}
|
|
8
8
|
const variables = { scopePrefix: code `scopePrefix` };
|
|
9
9
|
const elements = this.parentObjectTypes
|
|
10
|
-
.map((parentObjectType) => code `${parentObjectType.
|
|
10
|
+
.map((parentObjectType) => code `${parentObjectType.name}.${syntheticNamePrefix}Json.uiSchema({ scopePrefix })`)
|
|
11
11
|
.concat(this.properties.flatMap((property) => property.jsonUiSchemaElement({ variables }).toList()));
|
|
12
12
|
return Maybe.of(code `\
|
|
13
13
|
export function uiSchema(parameters?: { scopePrefix?: string }): any {
|
package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromJsonFunctionDeclaration.js
CHANGED
|
@@ -13,8 +13,8 @@ export function NamedObjectType_propertiesFromJsonFunctionDeclaration() {
|
|
|
13
13
|
const propertyReturnTypeSignatures = [];
|
|
14
14
|
const returnType = [];
|
|
15
15
|
this.parentObjectTypes.forEach((parentObjectType) => {
|
|
16
|
-
initializers.push(code `...${parentObjectType.
|
|
17
|
-
returnType.push(code `ReturnType<typeof ${parentObjectType.
|
|
16
|
+
initializers.push(code `...${parentObjectType.name}.${syntheticNamePrefix}propertiesFromJson(${variables.jsonObject})`);
|
|
17
|
+
returnType.push(code `ReturnType<typeof ${parentObjectType.name}.${syntheticNamePrefix}propertiesFromJson>`);
|
|
18
18
|
});
|
|
19
19
|
for (const property of this.properties) {
|
|
20
20
|
const propertyFromJsonStatements = property.fromJsonStatements({
|
|
@@ -24,11 +24,11 @@ export function NamedObjectType_propertiesFromRdfResourceFunctionDeclaration() {
|
|
|
24
24
|
const returnType = [];
|
|
25
25
|
this.parentObjectTypes.forEach((parentObjectType, parentObjectTypeI) => {
|
|
26
26
|
chains.push({
|
|
27
|
-
expression: code `${parentObjectType.
|
|
27
|
+
expression: code `${parentObjectType.name}.${syntheticNamePrefix}propertiesFromRdfResource(${variables.resource}, { ...${optionsVariable}, ignoreRdfType: true })`,
|
|
28
28
|
variable: `${syntheticNamePrefix}super${parentObjectTypeI}`,
|
|
29
29
|
});
|
|
30
30
|
initializers.push(code `...${syntheticNamePrefix}super${parentObjectTypeI}`);
|
|
31
|
-
returnType.push(code `${snippets.UnwrapR}<ReturnType<typeof ${parentObjectType.
|
|
31
|
+
returnType.push(code `${snippets.UnwrapR}<ReturnType<typeof ${parentObjectType.name}.${syntheticNamePrefix}propertiesFromRdfResource>>`);
|
|
32
32
|
});
|
|
33
33
|
this.fromRdfType.ifJust((fromRdfType) => {
|
|
34
34
|
const fromRdfTypeVariable = this.fromRdfTypeVariable.unsafeCoerce();
|