@shaclmate/compiler 4.0.6 → 4.0.7
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/generators/ts/ObjectType.js +17 -4
- package/dist/generators/ts/ObjectUnionType.js +21 -9
- package/dist/generators/ts/ZodGenerator.d.ts +7 -0
- package/dist/generators/ts/ZodGenerator.js +37 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclarations.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/{ObjectType_jsonFunctionDeclarations.js → ObjectType_fromJsonFunctionDeclarations.js} +8 -64
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfFunctionDeclaration.js +27 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.js +14 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.js +18 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonZodSchemaFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonZodSchemaFunctionDeclaration.js +30 -0
- package/dist/generators/ts/_ObjectType/ObjectType_propertiesFromRdfFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/{ObjectType_rdfFunctionDeclarations.js → ObjectType_propertiesFromRdfFunctionDeclaration.js} +5 -37
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.d.ts +4 -1
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js +6 -2
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts +4 -1
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js +6 -2
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructTriplesFunctionDeclaration.js +57 -0
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlWherePatternsFunctionDeclarations.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlWherePatternsFunctionDeclarations.js +106 -0
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromJsonFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromJsonFunctionDeclaration.js +19 -0
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromRdfFunctionDeclarations.d.ts +5 -0
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromRdfFunctionDeclarations.js +20 -0
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonZodSchemaFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonZodSchemaFunctionDeclaration.js +14 -0
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlConstructTriplesFunctionDeclaration.js +15 -0
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlWherePatternsFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlWherePatternsFunctionDeclaration.js +35 -0
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_toJsonFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_toJsonFunctionDeclaration.js +26 -0
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_toRdfFunctionDeclarations.d.ts +5 -0
- package/dist/generators/ts/_ObjectUnionType/{ObjectUnionType_rdfFunctionDeclarations.js → ObjectUnionType_toRdfFunctionDeclarations.js} +6 -23
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +2 -2
- package/dist/generators/ts/_ObjectType/ObjectType_jsonFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_rdfFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlFunctionDeclarations.js +0 -140
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonFunctionDeclarations.js +0 -50
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_rdfFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlFunctionDeclarations.js +0 -44
|
@@ -16,17 +16,26 @@ import { ObjectType_createFunctionDeclaration } from "./_ObjectType/ObjectType_c
|
|
|
16
16
|
import { ObjectType_equalsFunctionOrMethodDeclaration } from "./_ObjectType/ObjectType_equalsFunctionOrMethodDeclaration.js";
|
|
17
17
|
import { ObjectType_filterFunctionDeclaration } from "./_ObjectType/ObjectType_filterFunctionDeclaration.js";
|
|
18
18
|
import { ObjectType_filterTypeDeclaration } from "./_ObjectType/ObjectType_filterTypeDeclaration.js";
|
|
19
|
+
import { ObjectType_fromJsonFunctionDeclarations } from "./_ObjectType/ObjectType_fromJsonFunctionDeclarations.js";
|
|
20
|
+
import { ObjectType_fromRdfFunctionDeclaration } from "./_ObjectType/ObjectType_fromRdfFunctionDeclaration.js";
|
|
19
21
|
import { ObjectType_fromRdfTypeVariableStatement } from "./_ObjectType/ObjectType_fromRdfTypeVariableStatement.js";
|
|
20
22
|
import { ObjectType_graphqlTypeVariableStatement } from "./_ObjectType/ObjectType_graphqlTypeVariableStatement.js";
|
|
21
23
|
import { ObjectType_hashFunctionOrMethodDeclarations } from "./_ObjectType/ObjectType_hashFunctionOrMethodDeclarations.js";
|
|
22
24
|
import { ObjectType_interfaceDeclaration } from "./_ObjectType/ObjectType_interfaceDeclaration.js";
|
|
23
25
|
import { ObjectType_isTypeFunctionDeclaration } from "./_ObjectType/ObjectType_isTypeFunctionDeclaration.js";
|
|
24
|
-
import {
|
|
26
|
+
import { ObjectType_jsonSchemaFunctionDeclaration } from "./_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.js";
|
|
25
27
|
import { ObjectType_jsonTypeAliasDeclaration } from "./_ObjectType/ObjectType_jsonTypeAliasDeclaration.js";
|
|
28
|
+
import { ObjectType_jsonUiSchemaFunctionDeclaration } from "./_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.js";
|
|
29
|
+
import { ObjectType_jsonZodSchemaFunctionDeclaration } from "./_ObjectType/ObjectType_jsonZodSchemaFunctionDeclaration.js";
|
|
26
30
|
import { ObjectType_objectSetMethodNames } from "./_ObjectType/ObjectType_objectSetMethodNames.js";
|
|
27
|
-
import {
|
|
31
|
+
import { ObjectType_propertiesFromRdfFunctionDeclaration } from "./_ObjectType/ObjectType_propertiesFromRdfFunctionDeclaration.js";
|
|
28
32
|
import { ObjectType_schemaVariableStatement } from "./_ObjectType/ObjectType_schemaVariableStatement.js";
|
|
29
|
-
import {
|
|
33
|
+
import { ObjectType_sparqlConstructQueryFunctionDeclaration } from "./_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js";
|
|
34
|
+
import { ObjectType_sparqlConstructQueryStringFunctionDeclaration } from "./_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js";
|
|
35
|
+
import { ObjectType_sparqlConstructTriplesFunctionDeclaration } from "./_ObjectType/ObjectType_sparqlConstructTriplesFunctionDeclaration.js";
|
|
36
|
+
import { ObjectType_sparqlWherePatternsFunctionDeclaration } from "./_ObjectType/ObjectType_sparqlWherePatternsFunctionDeclarations.js";
|
|
37
|
+
import { ObjectType_toJsonFunctionOrMethodDeclaration } from "./_ObjectType/ObjectType_toJsonFunctionOrMethodDeclaration.js";
|
|
38
|
+
import { ObjectType_toRdfFunctionOrMethodDeclaration } from "./_ObjectType/ObjectType_toRdfFunctionOrMethodDeclaration.js";
|
|
30
39
|
import { ShaclProperty as _ShaclProperty } from "./_ObjectType/ShaclProperty.js";
|
|
31
40
|
import { TypeDiscriminantProperty as _TypeDiscriminantProperty } from "./_ObjectType/TypeDiscriminantProperty.js";
|
|
32
41
|
import { AbstractDeclaredType } from "./AbstractDeclaredType.js";
|
|
@@ -108,7 +117,11 @@ export class ObjectType extends AbstractDeclaredType {
|
|
|
108
117
|
break;
|
|
109
118
|
}
|
|
110
119
|
}
|
|
111
|
-
staticModuleDeclarations.push(ObjectType_filterFunctionDeclaration.bind(this)(), ObjectType_filterTypeDeclaration.bind(this)(), ...ObjectType_fromRdfTypeVariableStatement.bind(this)().toList(), ...
|
|
120
|
+
staticModuleDeclarations.push(...ObjectType_graphqlTypeVariableStatement.bind(this)().toList(), ...identifierTypeDeclarations.bind(this)(), ...ObjectType_jsonTypeAliasDeclaration.bind(this)().toList(), ObjectType_filterFunctionDeclaration.bind(this)(), ObjectType_filterTypeDeclaration.bind(this)(), ...ObjectType_fromJsonFunctionDeclarations.bind(this)(), ...ObjectType_fromRdfFunctionDeclaration.bind(this)().toList(), ...ObjectType_fromRdfTypeVariableStatement.bind(this)().toList(), ObjectType_isTypeFunctionDeclaration.bind(this)(), ...ObjectType_jsonSchemaFunctionDeclaration.bind(this)().toList(), ...ObjectType_jsonUiSchemaFunctionDeclaration.bind(this)().toList(), ...ObjectType_jsonZodSchemaFunctionDeclaration.bind(this)().toList(), ...ObjectType_propertiesFromRdfFunctionDeclaration.bind(this)().toList(), ObjectType_schemaVariableStatement.bind(this)(), ...ObjectType_sparqlConstructQueryFunctionDeclaration.bind(this)().toList(), ...ObjectType_sparqlConstructQueryStringFunctionDeclaration.bind(this)().toList(), ...ObjectType_sparqlConstructTriplesFunctionDeclaration.bind(this)().toList(), ...ObjectType_sparqlWherePatternsFunctionDeclaration.bind(this)().toList(), ...(this.declarationType === "interface"
|
|
121
|
+
? ObjectType_toJsonFunctionOrMethodDeclaration.bind(this)().toList()
|
|
122
|
+
: []), ...(this.declarationType === "interface"
|
|
123
|
+
? ObjectType_toRdfFunctionOrMethodDeclaration.bind(this)().toList()
|
|
124
|
+
: []));
|
|
112
125
|
if (staticModuleDeclarations.length > 0) {
|
|
113
126
|
declarations.push(code `\
|
|
114
127
|
export namespace ${def(this.staticModuleName)} {
|
|
@@ -9,19 +9,25 @@ import { Maybe, NonEmptyList } from "purify-ts";
|
|
|
9
9
|
import { invariant } from "ts-invariant";
|
|
10
10
|
import { Memoize } from "typescript-memoize";
|
|
11
11
|
import { ObjectType_objectSetMethodNames } from "./_ObjectType/ObjectType_objectSetMethodNames.js";
|
|
12
|
+
import { ObjectType_sparqlConstructQueryFunctionDeclaration } from "./_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js";
|
|
13
|
+
import { ObjectType_sparqlConstructQueryStringFunctionDeclaration } from "./_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js";
|
|
12
14
|
import { MemberType } from "./_ObjectUnionType/MemberType.js";
|
|
13
15
|
import { ObjectUnionType_equalsFunctionDeclaration } from "./_ObjectUnionType/ObjectUnionType_equalsFunctionDeclaration.js";
|
|
14
16
|
import { ObjectUnionType_filterFunctionDeclaration } from "./_ObjectUnionType/ObjectUnionType_filterFunctionDeclaration.js";
|
|
15
17
|
import { ObjectUnionType_filterTypeDeclaration } from "./_ObjectUnionType/ObjectUnionType_filterTypeDeclaration.js";
|
|
18
|
+
import { ObjectUnionType_fromJsonFunctionDeclaration } from "./_ObjectUnionType/ObjectUnionType_fromJsonFunctionDeclaration.js";
|
|
19
|
+
import { ObjectUnionType_fromRdfFunctionDeclaration } from "./_ObjectUnionType/ObjectUnionType_fromRdfFunctionDeclarations.js";
|
|
16
20
|
import { ObjectUnionType_graphqlTypeVariableStatement } from "./_ObjectUnionType/ObjectUnionType_graphqlTypeVariableStatement.js";
|
|
17
21
|
import { ObjectUnionType_hashFunctionDeclaration } from "./_ObjectUnionType/ObjectUnionType_hashFunctionDeclaration.js";
|
|
18
22
|
import { ObjectUnionType_identifierTypeDeclarations } from "./_ObjectUnionType/ObjectUnionType_identifierTypeDeclarations.js";
|
|
19
23
|
import { ObjectUnionType_isTypeFunctionDeclaration } from "./_ObjectUnionType/ObjectUnionType_isTypeFunctionDeclaration.js";
|
|
20
|
-
import { jsonFunctionDeclarations } from "./_ObjectUnionType/ObjectUnionType_jsonFunctionDeclarations.js";
|
|
21
24
|
import { ObjectUnionType_jsonTypeAliasDeclaration } from "./_ObjectUnionType/ObjectUnionType_jsonTypeAliasDeclaration.js";
|
|
22
|
-
import {
|
|
25
|
+
import { ObjectUnionType_jsonZodSchemaFunctionDeclaration } from "./_ObjectUnionType/ObjectUnionType_jsonZodSchemaFunctionDeclaration.js";
|
|
23
26
|
import { ObjectUnionType_schemaVariableStatement } from "./_ObjectUnionType/ObjectUnionType_schemaVariableStatement.js";
|
|
24
|
-
import {
|
|
27
|
+
import { ObjectUnionType_sparqlConstructTriplesFunctionDeclaration } from "./_ObjectUnionType/ObjectUnionType_sparqlConstructTriplesFunctionDeclaration.js";
|
|
28
|
+
import { ObjectUnionType_sparqlWherePatternsFunctionDeclaration } from "./_ObjectUnionType/ObjectUnionType_sparqlWherePatternsFunctionDeclaration.js";
|
|
29
|
+
import { ObjectUnionType_toJsonFunctionDeclaration } from "./_ObjectUnionType/ObjectUnionType_toJsonFunctionDeclaration.js";
|
|
30
|
+
import { ObjectUnionType_toRdfFunctionDeclaration } from "./_ObjectUnionType/ObjectUnionType_toRdfFunctionDeclarations.js";
|
|
25
31
|
import { ObjectUnionType_typeAliasDeclaration } from "./_ObjectUnionType/ObjectUnionType_typeAliasDeclaration.js";
|
|
26
32
|
import { AbstractDeclaredType } from "./AbstractDeclaredType.js";
|
|
27
33
|
import { imports } from "./imports.js";
|
|
@@ -68,18 +74,24 @@ export class ObjectUnionType extends AbstractDeclaredType {
|
|
|
68
74
|
ObjectUnionType_typeAliasDeclaration.bind(this)(),
|
|
69
75
|
];
|
|
70
76
|
const staticModuleDeclarations = [
|
|
77
|
+
...ObjectUnionType_graphqlTypeVariableStatement.bind(this)().toList(),
|
|
78
|
+
...ObjectUnionType_identifierTypeDeclarations.bind(this)(),
|
|
79
|
+
...ObjectUnionType_jsonTypeAliasDeclaration.bind(this)().toList(),
|
|
71
80
|
...ObjectUnionType_equalsFunctionDeclaration.bind(this)().toList(),
|
|
72
81
|
ObjectUnionType_filterFunctionDeclaration.bind(this)(),
|
|
73
82
|
ObjectUnionType_filterTypeDeclaration.bind(this)(),
|
|
74
|
-
...ObjectUnionType_graphqlTypeVariableStatement.bind(this)().toList(),
|
|
75
83
|
...ObjectUnionType_hashFunctionDeclaration.bind(this)().toList(),
|
|
76
|
-
...
|
|
77
|
-
...
|
|
78
|
-
...ObjectUnionType_jsonTypeAliasDeclaration.bind(this)().toList(),
|
|
84
|
+
...ObjectUnionType_fromJsonFunctionDeclaration.bind(this)().toList(),
|
|
85
|
+
...ObjectUnionType_fromRdfFunctionDeclaration.bind(this)().toList(),
|
|
79
86
|
...ObjectUnionType_isTypeFunctionDeclaration.bind(this)().toList(),
|
|
87
|
+
...ObjectUnionType_jsonZodSchemaFunctionDeclaration.bind(this)().toList(),
|
|
80
88
|
ObjectUnionType_schemaVariableStatement.bind(this)(),
|
|
81
|
-
...
|
|
82
|
-
...
|
|
89
|
+
...ObjectType_sparqlConstructQueryFunctionDeclaration.bind(this)().toList(),
|
|
90
|
+
...ObjectType_sparqlConstructQueryStringFunctionDeclaration.bind(this)().toList(),
|
|
91
|
+
...ObjectUnionType_sparqlConstructTriplesFunctionDeclaration.bind(this)().toList(),
|
|
92
|
+
...ObjectUnionType_sparqlWherePatternsFunctionDeclaration.bind(this)().toList(),
|
|
93
|
+
...ObjectUnionType_toJsonFunctionDeclaration.bind(this)().toList(),
|
|
94
|
+
...ObjectUnionType_toRdfFunctionDeclaration.bind(this)().toList(),
|
|
83
95
|
];
|
|
84
96
|
if (staticModuleDeclarations.length > 0) {
|
|
85
97
|
declarations.push(code `\
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as ast from "../../ast/index.js";
|
|
2
|
+
import type { Generator } from "../Generator.js";
|
|
3
|
+
export declare class ZodGenerator implements Generator {
|
|
4
|
+
private readonly typeFactory;
|
|
5
|
+
generate(ast_: ast.Ast): string;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=ZodGenerator.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as ast from "../../ast/index.js";
|
|
2
|
+
import { ObjectType_jsonTypeAliasDeclaration } from "./_ObjectType/ObjectType_jsonTypeAliasDeclaration.js";
|
|
3
|
+
import { ObjectType_jsonZodSchemaFunctionDeclaration } from "./_ObjectType/ObjectType_jsonZodSchemaFunctionDeclaration.js";
|
|
4
|
+
import { ObjectUnionType_jsonTypeAliasDeclaration } from "./_ObjectUnionType/ObjectUnionType_jsonTypeAliasDeclaration.js";
|
|
5
|
+
import { ObjectUnionType_jsonZodSchemaFunctionDeclaration } from "./_ObjectUnionType/ObjectUnionType_jsonZodSchemaFunctionDeclaration.js";
|
|
6
|
+
import { snippets } from "./snippets.js";
|
|
7
|
+
import { TypeFactory } from "./TypeFactory.js";
|
|
8
|
+
import { code, joinCode } from "./ts-poet-wrapper.js";
|
|
9
|
+
export class ZodGenerator {
|
|
10
|
+
typeFactory = new TypeFactory();
|
|
11
|
+
generate(ast_) {
|
|
12
|
+
const declarations = [];
|
|
13
|
+
for (const objectType of ast.ObjectType.toposort(ast_.objectTypes).map((astObjectType) => this.typeFactory.createObjectType(astObjectType))) {
|
|
14
|
+
declarations.push(code `\
|
|
15
|
+
export namespace ${objectType.staticModuleName} {
|
|
16
|
+
${joinCode([
|
|
17
|
+
...ObjectType_jsonTypeAliasDeclaration.bind(objectType)().toList(),
|
|
18
|
+
...ObjectType_jsonZodSchemaFunctionDeclaration.bind(objectType)().toList(),
|
|
19
|
+
], { on: "\n\n" })}
|
|
20
|
+
}`);
|
|
21
|
+
}
|
|
22
|
+
for (const objectUnionType of ast_.objectUnionTypes.map((astObjectUnionType) => this.typeFactory.createObjectUnionType(astObjectUnionType))) {
|
|
23
|
+
declarations.push(code `\
|
|
24
|
+
export namespace ${objectUnionType.staticModuleName} {
|
|
25
|
+
${joinCode([
|
|
26
|
+
...ObjectUnionType_jsonTypeAliasDeclaration.bind(objectUnionType)().toList(),
|
|
27
|
+
...ObjectUnionType_jsonZodSchemaFunctionDeclaration.bind(objectUnionType)().toList(),
|
|
28
|
+
], { on: "\n\n" })}
|
|
29
|
+
}`);
|
|
30
|
+
}
|
|
31
|
+
declarations.splice(0, 0, joinCode(Object.values(snippets)
|
|
32
|
+
.sort((left, right) => left.usageSiteName.localeCompare(right.usageSiteName))
|
|
33
|
+
.map((snippet) => code `${snippet.ifUsed}`), { on: "\n\n" }));
|
|
34
|
+
return joinCode(declarations, { on: "\n\n" }).toString({});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=ZodGenerator.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ObjectType } from "../ObjectType.js";
|
|
2
|
+
import { type Code } from "../ts-poet-wrapper.js";
|
|
3
|
+
export declare function ObjectType_fromJsonFunctionDeclarations(this: ObjectType): readonly Code[];
|
|
4
|
+
//# sourceMappingURL=ObjectType_fromJsonFunctionDeclarations.d.ts.map
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { Maybe } from "purify-ts";
|
|
2
1
|
import { imports } from "../imports.js";
|
|
3
2
|
import { snippets } from "../snippets.js";
|
|
4
3
|
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
5
4
|
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const variables = {
|
|
6
|
+
jsonObject: code `${syntheticNamePrefix}jsonObject`,
|
|
7
|
+
};
|
|
8
|
+
export function ObjectType_fromJsonFunctionDeclarations() {
|
|
9
|
+
if (!this.features.has("json")) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
8
12
|
const initializers = [];
|
|
9
13
|
const propertiesFromJsonReturnType = [];
|
|
10
14
|
const propertiesFromJsonStatements = [];
|
|
@@ -59,64 +63,4 @@ export function ${syntheticNamePrefix}fromJson(json: unknown): ${imports.Either}
|
|
|
59
63
|
}`);
|
|
60
64
|
return functionDeclarations;
|
|
61
65
|
}
|
|
62
|
-
|
|
63
|
-
return code `\
|
|
64
|
-
export function ${syntheticNamePrefix}jsonSchema() {
|
|
65
|
-
return ${imports.z}.toJSONSchema(${syntheticNamePrefix}jsonZodSchema());
|
|
66
|
-
}`;
|
|
67
|
-
}
|
|
68
|
-
function ObjectType_jsonUiSchemaFunctionDeclaration() {
|
|
69
|
-
const variables = { scopePrefix: code `scopePrefix` };
|
|
70
|
-
const elements = this.parentObjectTypes
|
|
71
|
-
.map((parentObjectType) => code `${parentObjectType.staticModuleName}.${syntheticNamePrefix}jsonUiSchema({ scopePrefix })`)
|
|
72
|
-
.concat(this.ownProperties.flatMap((property) => property.jsonUiSchemaElement({ variables }).toList()));
|
|
73
|
-
return code `\
|
|
74
|
-
export function ${syntheticNamePrefix}jsonUiSchema(parameters?: { scopePrefix?: string }): any {
|
|
75
|
-
const scopePrefix = parameters?.scopePrefix ?? "#";
|
|
76
|
-
return { "elements": [ ${joinCode(elements, { on: "," })} ], label: "${this.label.orDefault(this.name)}", type: "Group" };
|
|
77
|
-
}`;
|
|
78
|
-
}
|
|
79
|
-
function ObjectType_jsonZodSchemaFunctionDeclaration() {
|
|
80
|
-
const mergeZodObjectSchemas = [];
|
|
81
|
-
for (const parentObjectType of this.parentObjectTypes) {
|
|
82
|
-
mergeZodObjectSchemas.push(parentObjectType.jsonZodSchema({ context: "type" }));
|
|
83
|
-
}
|
|
84
|
-
if (this.properties.length > 0) {
|
|
85
|
-
mergeZodObjectSchemas.push(code `${imports.z}.object({ ${joinCode(this.properties
|
|
86
|
-
.flatMap((property) => property.jsonZodSchema.toList())
|
|
87
|
-
.map(({ key, schema }) => code `"${key}": ${schema}`), { on: "," })} })`);
|
|
88
|
-
}
|
|
89
|
-
return code `\
|
|
90
|
-
export function ${syntheticNamePrefix}jsonZodSchema() {
|
|
91
|
-
return ${mergeZodObjectSchemas.length > 0
|
|
92
|
-
? mergeZodObjectSchemas.reduce((merged, zodObjectSchema) => {
|
|
93
|
-
if (merged === null) {
|
|
94
|
-
return zodObjectSchema;
|
|
95
|
-
}
|
|
96
|
-
return code `${merged}.merge(${zodObjectSchema})`;
|
|
97
|
-
}, null)
|
|
98
|
-
: `${imports.z}.object()`} satisfies ${imports.z}.ZodType<${syntheticNamePrefix}Json>;
|
|
99
|
-
}`;
|
|
100
|
-
}
|
|
101
|
-
function ObjectType_toJsonFunctionDeclaration() {
|
|
102
|
-
if (this.declarationType !== "interface") {
|
|
103
|
-
return Maybe.empty();
|
|
104
|
-
}
|
|
105
|
-
return ObjectType_toJsonFunctionOrMethodDeclaration.bind(this)();
|
|
106
|
-
}
|
|
107
|
-
export function ObjectType_jsonFunctionDeclarations() {
|
|
108
|
-
if (!this.features.has("json")) {
|
|
109
|
-
return [];
|
|
110
|
-
}
|
|
111
|
-
return [
|
|
112
|
-
...ObjectType_fromJsonFunctionDeclarations.bind(this)(),
|
|
113
|
-
ObjectType_jsonSchemaFunctionDeclaration.bind(this)(),
|
|
114
|
-
ObjectType_jsonUiSchemaFunctionDeclaration.bind(this)(),
|
|
115
|
-
...ObjectType_toJsonFunctionDeclaration.bind(this)().toList(),
|
|
116
|
-
ObjectType_jsonZodSchemaFunctionDeclaration.bind(this)(),
|
|
117
|
-
];
|
|
118
|
-
}
|
|
119
|
-
const variables = {
|
|
120
|
-
jsonObject: code `${syntheticNamePrefix}jsonObject`,
|
|
121
|
-
};
|
|
122
|
-
//# sourceMappingURL=ObjectType_jsonFunctionDeclarations.js.map
|
|
66
|
+
//# sourceMappingURL=ObjectType_fromJsonFunctionDeclarations.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import type { ObjectType } from "../ObjectType.js";
|
|
3
|
+
import { type Code } from "../ts-poet-wrapper.js";
|
|
4
|
+
export declare function ObjectType_fromRdfFunctionDeclaration(this: ObjectType): Maybe<Code>;
|
|
5
|
+
//# sourceMappingURL=ObjectType_fromRdfFunctionDeclaration.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import { imports } from "../imports.js";
|
|
3
|
+
import { snippets } from "../snippets.js";
|
|
4
|
+
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
5
|
+
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
6
|
+
export function ObjectType_fromRdfFunctionDeclaration() {
|
|
7
|
+
if (!this.features.has("rdf")) {
|
|
8
|
+
return Maybe.empty();
|
|
9
|
+
}
|
|
10
|
+
if (this.abstract) {
|
|
11
|
+
return Maybe.empty();
|
|
12
|
+
}
|
|
13
|
+
const statements = [
|
|
14
|
+
code `let { context, ignoreRdfType = false, objectSet, preferredLanguages } = (options ?? {});`,
|
|
15
|
+
code `if (!objectSet) { objectSet = new ${syntheticNamePrefix}RdfjsDatasetObjectSet(resource.dataset); }`,
|
|
16
|
+
];
|
|
17
|
+
let propertiesFromRdfExpression = code `${this.staticModuleName}.${syntheticNamePrefix}propertiesFromRdf({ context, ignoreRdfType, objectSet, preferredLanguages, resource })`;
|
|
18
|
+
if (this.declarationType === "class") {
|
|
19
|
+
propertiesFromRdfExpression = code `${propertiesFromRdfExpression}.map(properties => new ${this.name}(properties))`;
|
|
20
|
+
}
|
|
21
|
+
statements.push(code `return ${propertiesFromRdfExpression};`);
|
|
22
|
+
return Maybe.of(code `\
|
|
23
|
+
export function ${syntheticNamePrefix}fromRdf(resource: ${imports.Resource}, options?: ${snippets.FromRdfOptions}): ${imports.Either}<Error, ${this.name}> {
|
|
24
|
+
${joinCode(statements)}
|
|
25
|
+
}`);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=ObjectType_fromRdfFunctionDeclaration.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import type { ObjectType } from "../ObjectType.js";
|
|
3
|
+
import { type Code } from "../ts-poet-wrapper.js";
|
|
4
|
+
export declare function ObjectType_jsonSchemaFunctionDeclaration(this: ObjectType): Maybe<Code>;
|
|
5
|
+
//# sourceMappingURL=ObjectType_jsonSchemaFunctionDeclaration.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import { imports } from "../imports.js";
|
|
3
|
+
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
4
|
+
import { code } from "../ts-poet-wrapper.js";
|
|
5
|
+
export function ObjectType_jsonSchemaFunctionDeclaration() {
|
|
6
|
+
if (!this.features.has("json")) {
|
|
7
|
+
return Maybe.empty();
|
|
8
|
+
}
|
|
9
|
+
return Maybe.of(code `\
|
|
10
|
+
export function ${syntheticNamePrefix}jsonSchema() {
|
|
11
|
+
return ${imports.z}.toJSONSchema(${syntheticNamePrefix}jsonZodSchema());
|
|
12
|
+
}`);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=ObjectType_jsonSchemaFunctionDeclaration.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import type { ObjectType } from "../ObjectType.js";
|
|
3
|
+
import { type Code } from "../ts-poet-wrapper.js";
|
|
4
|
+
export declare function ObjectType_jsonUiSchemaFunctionDeclaration(this: ObjectType): Maybe<Code>;
|
|
5
|
+
//# sourceMappingURL=ObjectType_jsonUiSchemaFunctionDeclaration.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
3
|
+
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
4
|
+
export function ObjectType_jsonUiSchemaFunctionDeclaration() {
|
|
5
|
+
if (!this.features.has("json")) {
|
|
6
|
+
return Maybe.empty();
|
|
7
|
+
}
|
|
8
|
+
const variables = { scopePrefix: code `scopePrefix` };
|
|
9
|
+
const elements = this.parentObjectTypes
|
|
10
|
+
.map((parentObjectType) => code `${parentObjectType.staticModuleName}.${syntheticNamePrefix}jsonUiSchema({ scopePrefix })`)
|
|
11
|
+
.concat(this.ownProperties.flatMap((property) => property.jsonUiSchemaElement({ variables }).toList()));
|
|
12
|
+
return Maybe.of(code `\
|
|
13
|
+
export function ${syntheticNamePrefix}jsonUiSchema(parameters?: { scopePrefix?: string }): any {
|
|
14
|
+
const scopePrefix = parameters?.scopePrefix ?? "#";
|
|
15
|
+
return { "elements": [ ${joinCode(elements, { on: "," })} ], label: "${this.label.orDefault(this.name)}", type: "Group" };
|
|
16
|
+
}`);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=ObjectType_jsonUiSchemaFunctionDeclaration.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import type { ObjectType } from "../ObjectType.js";
|
|
3
|
+
import { type Code } from "../ts-poet-wrapper.js";
|
|
4
|
+
export declare function ObjectType_jsonZodSchemaFunctionDeclaration(this: ObjectType): Maybe<Code>;
|
|
5
|
+
//# sourceMappingURL=ObjectType_jsonZodSchemaFunctionDeclaration.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import { imports } from "../imports.js";
|
|
3
|
+
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
4
|
+
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
5
|
+
export function ObjectType_jsonZodSchemaFunctionDeclaration() {
|
|
6
|
+
if (!this.features.has("json")) {
|
|
7
|
+
return Maybe.empty();
|
|
8
|
+
}
|
|
9
|
+
const mergeZodObjectSchemas = [];
|
|
10
|
+
for (const parentObjectType of this.parentObjectTypes) {
|
|
11
|
+
mergeZodObjectSchemas.push(parentObjectType.jsonZodSchema({ context: "type" }));
|
|
12
|
+
}
|
|
13
|
+
if (this.properties.length > 0) {
|
|
14
|
+
mergeZodObjectSchemas.push(code `${imports.z}.object({ ${joinCode(this.properties
|
|
15
|
+
.flatMap((property) => property.jsonZodSchema.toList())
|
|
16
|
+
.map(({ key, schema }) => code `"${key}": ${schema}`), { on: "," })} })`);
|
|
17
|
+
}
|
|
18
|
+
return Maybe.of(code `\
|
|
19
|
+
export function ${syntheticNamePrefix}jsonZodSchema() {
|
|
20
|
+
return ${mergeZodObjectSchemas.length > 0
|
|
21
|
+
? mergeZodObjectSchemas.reduce((merged, zodObjectSchema) => {
|
|
22
|
+
if (merged === null) {
|
|
23
|
+
return zodObjectSchema;
|
|
24
|
+
}
|
|
25
|
+
return code `${merged}.merge(${zodObjectSchema})`;
|
|
26
|
+
}, null)
|
|
27
|
+
: `${imports.z}.object()`} satisfies ${imports.z}.ZodType<${syntheticNamePrefix}Json>;
|
|
28
|
+
}`);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=ObjectType_jsonZodSchemaFunctionDeclaration.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import type { ObjectType } from "../ObjectType.js";
|
|
3
|
+
import { type Code } from "../ts-poet-wrapper.js";
|
|
4
|
+
export declare function ObjectType_propertiesFromRdfFunctionDeclaration(this: ObjectType): Maybe<Code>;
|
|
5
|
+
//# sourceMappingURL=ObjectType_propertiesFromRdfFunctionDeclaration.d.ts.map
|
|
@@ -5,26 +5,10 @@ import { rdfjsTermExpression } from "../rdfjsTermExpression.js";
|
|
|
5
5
|
import { snippets } from "../snippets.js";
|
|
6
6
|
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
7
7
|
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (this.abstract) {
|
|
8
|
+
export function ObjectType_propertiesFromRdfFunctionDeclaration() {
|
|
9
|
+
if (!this.features.has("rdf")) {
|
|
11
10
|
return Maybe.empty();
|
|
12
11
|
}
|
|
13
|
-
const statements = [
|
|
14
|
-
code `let { context, ignoreRdfType = false, objectSet, preferredLanguages } = (options ?? {});`,
|
|
15
|
-
code `if (!objectSet) { objectSet = new ${syntheticNamePrefix}RdfjsDatasetObjectSet(resource.dataset); }`,
|
|
16
|
-
];
|
|
17
|
-
let propertiesFromRdfExpression = code `${this.staticModuleName}.${syntheticNamePrefix}propertiesFromRdf({ context, ignoreRdfType, objectSet, preferredLanguages, resource })`;
|
|
18
|
-
if (this.declarationType === "class") {
|
|
19
|
-
propertiesFromRdfExpression = code `${propertiesFromRdfExpression}.map(properties => new ${this.name}(properties))`;
|
|
20
|
-
}
|
|
21
|
-
statements.push(code `return ${propertiesFromRdfExpression};`);
|
|
22
|
-
return Maybe.of(code `\
|
|
23
|
-
export function ${syntheticNamePrefix}fromRdf(resource: ${imports.Resource}, options?: ${snippets.FromRdfOptions}): ${imports.Either}<Error, ${this.name}> {
|
|
24
|
-
${joinCode(statements)}
|
|
25
|
-
}`);
|
|
26
|
-
}
|
|
27
|
-
function ObjectType_propertiesFromRdfFunctionDeclaration() {
|
|
28
12
|
const chains = [];
|
|
29
13
|
const initializers = [];
|
|
30
14
|
const propertySignatures = [];
|
|
@@ -108,25 +92,9 @@ function ObjectType_propertiesFromRdfFunctionDeclaration() {
|
|
|
108
92
|
if (propertySignatures.length > 0) {
|
|
109
93
|
returnType.splice(0, 0, code `{ ${joinCode(propertySignatures, { on: " " })} }`);
|
|
110
94
|
}
|
|
111
|
-
return code `\
|
|
95
|
+
return Maybe.of(code `\
|
|
112
96
|
export function ${syntheticNamePrefix}propertiesFromRdf(${syntheticNamePrefix}parameters: ${snippets.PropertiesFromRdfParameters}): ${imports.Either}<Error, ${joinCode(returnType, { on: " & " })}> {
|
|
113
97
|
${joinCode(statements)}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
export function ObjectType_rdfFunctionDeclarations() {
|
|
117
|
-
if (!this.features.has("rdf")) {
|
|
118
|
-
return [];
|
|
119
|
-
}
|
|
120
|
-
return [
|
|
121
|
-
...ObjectType_fromRdfFunctionDeclaration.bind(this)().toList(),
|
|
122
|
-
ObjectType_propertiesFromRdfFunctionDeclaration.bind(this)(),
|
|
123
|
-
...ObjectType_toRdfFunctionDeclaration.bind(this)().toList(),
|
|
124
|
-
];
|
|
125
|
-
}
|
|
126
|
-
function ObjectType_toRdfFunctionDeclaration() {
|
|
127
|
-
if (this.declarationType !== "interface") {
|
|
128
|
-
return Maybe.empty();
|
|
129
|
-
}
|
|
130
|
-
return ObjectType_toRdfFunctionOrMethodDeclaration.bind(this)();
|
|
98
|
+
}`);
|
|
131
99
|
}
|
|
132
|
-
//# sourceMappingURL=
|
|
100
|
+
//# sourceMappingURL=ObjectType_propertiesFromRdfFunctionDeclaration.js.map
|
package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import type { TsFeature } from "../../../enums/TsFeature.js";
|
|
1
3
|
import { type Code } from "../ts-poet-wrapper.js";
|
|
2
4
|
export declare function ObjectType_sparqlConstructQueryFunctionDeclaration(this: {
|
|
5
|
+
readonly features: ReadonlySet<TsFeature>;
|
|
3
6
|
readonly filterType: Code;
|
|
4
7
|
readonly name: string;
|
|
5
8
|
readonly staticModuleName: string;
|
|
6
|
-
}): Code
|
|
9
|
+
}): Maybe<Code>;
|
|
7
10
|
//# sourceMappingURL=ObjectType_sparqlConstructQueryFunctionDeclaration.d.ts.map
|
package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { camelCase } from "change-case";
|
|
2
|
+
import { Maybe } from "purify-ts";
|
|
2
3
|
import { imports } from "../imports.js";
|
|
3
4
|
import { snippets } from "../snippets.js";
|
|
4
5
|
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
5
6
|
import { code } from "../ts-poet-wrapper.js";
|
|
6
7
|
export function ObjectType_sparqlConstructQueryFunctionDeclaration() {
|
|
7
|
-
|
|
8
|
+
if (!this.features.has("sparql")) {
|
|
9
|
+
return Maybe.empty();
|
|
10
|
+
}
|
|
11
|
+
return Maybe.of(code `\
|
|
8
12
|
export function ${syntheticNamePrefix}sparqlConstructQuery({ filter, ignoreRdfType, preferredLanguages, prefixes, subject, ...queryParameters }: { filter?: ${this.filterType}; ignoreRdfType?: boolean; prefixes?: { [prefix: string]: string }; preferredLanguages?: readonly string[]; subject: ${imports.NamedNode} | ${imports.Variable} } & Omit<${imports.sparqljs}.ConstructQuery, "prefixes" | "queryType" | "type">): ${imports.sparqljs}.ConstructQuery {
|
|
9
13
|
const variablePrefix = subject.termType === "Variable" ? subject.value : "${camelCase(this.name)}";
|
|
10
14
|
|
|
@@ -33,6 +37,6 @@ export function ${syntheticNamePrefix}sparqlConstructQuery({ filter, ignoreRdfTy
|
|
|
33
37
|
)
|
|
34
38
|
)
|
|
35
39
|
};
|
|
36
|
-
}
|
|
40
|
+
}`);
|
|
37
41
|
}
|
|
38
42
|
//# sourceMappingURL=ObjectType_sparqlConstructQueryFunctionDeclaration.js.map
|
package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import type { TsFeature } from "../../../enums/TsFeature.js";
|
|
1
3
|
import { type Code } from "../ts-poet-wrapper.js";
|
|
2
4
|
export declare function ObjectType_sparqlConstructQueryStringFunctionDeclaration(this: {
|
|
5
|
+
readonly features: ReadonlySet<TsFeature>;
|
|
3
6
|
readonly filterType: Code;
|
|
4
7
|
readonly staticModuleName: string;
|
|
5
|
-
}): Code
|
|
8
|
+
}): Maybe<Code>;
|
|
6
9
|
//# sourceMappingURL=ObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts.map
|
package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
1
2
|
import { imports } from "../imports.js";
|
|
2
3
|
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
3
4
|
import { code } from "../ts-poet-wrapper.js";
|
|
4
5
|
export function ObjectType_sparqlConstructQueryStringFunctionDeclaration() {
|
|
5
|
-
|
|
6
|
+
if (!this.features.has("sparql")) {
|
|
7
|
+
return Maybe.empty();
|
|
8
|
+
}
|
|
9
|
+
return Maybe.of(code `\
|
|
6
10
|
export function ${syntheticNamePrefix}sparqlConstructQueryString(parameters: Parameters<typeof ${this.staticModuleName}.${syntheticNamePrefix}sparqlConstructQuery>[0] & ${imports.sparqljs}.GeneratorOptions): string {
|
|
7
11
|
return new ${imports.sparqljs}.Generator(parameters).stringify(${this.staticModuleName}.${syntheticNamePrefix}sparqlConstructQuery(parameters));
|
|
8
|
-
}
|
|
12
|
+
}`);
|
|
9
13
|
}
|
|
10
14
|
//# sourceMappingURL=ObjectType_sparqlConstructQueryStringFunctionDeclaration.js.map
|
package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructTriplesFunctionDeclaration.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import type { ObjectType } from "../ObjectType.js";
|
|
3
|
+
import { type Code } from "../ts-poet-wrapper.js";
|
|
4
|
+
export declare function ObjectType_sparqlConstructTriplesFunctionDeclaration(this: ObjectType): Maybe<Code>;
|
|
5
|
+
//# sourceMappingURL=ObjectType_sparqlConstructTriplesFunctionDeclaration.d.ts.map
|
package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructTriplesFunctionDeclaration.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { rdf, rdfs } from "@tpluscode/rdf-ns-builders";
|
|
2
|
+
import { Maybe } from "purify-ts";
|
|
3
|
+
import { imports } from "../imports.js";
|
|
4
|
+
import { rdfjsTermExpression } from "../rdfjsTermExpression.js";
|
|
5
|
+
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
6
|
+
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
7
|
+
const variables = {
|
|
8
|
+
filter: code `parameters.filter`,
|
|
9
|
+
focusIdentifier: code `parameters.focusIdentifier`,
|
|
10
|
+
variablePrefix: code `parameters.variablePrefix`,
|
|
11
|
+
};
|
|
12
|
+
export function ObjectType_sparqlConstructTriplesFunctionDeclaration() {
|
|
13
|
+
if (!this.features.has("sparql")) {
|
|
14
|
+
return Maybe.empty();
|
|
15
|
+
}
|
|
16
|
+
const rdfClassVariable = code `${imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfClass\`)`;
|
|
17
|
+
const rdfTypeVariable = code `${imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfType\`)`;
|
|
18
|
+
let triplesVariableDeclarationKeyword = "const";
|
|
19
|
+
const statements = [];
|
|
20
|
+
for (const parentObjectType of this.parentObjectTypes) {
|
|
21
|
+
statements.push(code `triples = triples.concat(${parentObjectType.staticModuleName}.${syntheticNamePrefix}sparqlConstructTriples(${{ filter: variables.filter, focusIdentifier: variables.focusIdentifier, ignoreRdfType: true, variablePrefix: variables.variablePrefix }}));`);
|
|
22
|
+
triplesVariableDeclarationKeyword = "let";
|
|
23
|
+
}
|
|
24
|
+
if (this.fromRdfType.isJust()) {
|
|
25
|
+
statements.push(code `\
|
|
26
|
+
if (!parameters?.ignoreRdfType) {
|
|
27
|
+
triples.push(
|
|
28
|
+
{ subject: ${variables.focusIdentifier}, predicate: ${rdfjsTermExpression(rdf.type)}, object: ${rdfTypeVariable} },
|
|
29
|
+
{ subject: ${rdfTypeVariable}, predicate: ${rdfjsTermExpression(rdfs.subClassOf)}, object: ${rdfClassVariable} }
|
|
30
|
+
);
|
|
31
|
+
}`);
|
|
32
|
+
}
|
|
33
|
+
for (const property of this.ownProperties) {
|
|
34
|
+
if (property.recursive) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
property
|
|
38
|
+
.sparqlConstructTriplesExpression({
|
|
39
|
+
variables,
|
|
40
|
+
})
|
|
41
|
+
.ifJust((propertyTriples) => {
|
|
42
|
+
statements.push(code `triples = triples.concat(${propertyTriples});`);
|
|
43
|
+
triplesVariableDeclarationKeyword = "let";
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return Maybe.of(code `\
|
|
47
|
+
export function ${syntheticNamePrefix}sparqlConstructTriples(${statements.length === 0 ? "_" : ""}parameters: { filter: ${this.filterType} | undefined; focusIdentifier: ${imports.NamedNode} | ${imports.Variable}; ignoreRdfType: boolean; variablePrefix: string }): readonly ${imports.sparqljs}.Triple[] {
|
|
48
|
+
${statements.length > 0
|
|
49
|
+
? joinCode([
|
|
50
|
+
code `${triplesVariableDeclarationKeyword} triples: ${imports.sparqljs}.Triple[] = [];`,
|
|
51
|
+
...statements,
|
|
52
|
+
code `return triples;`,
|
|
53
|
+
])
|
|
54
|
+
: "return [];"}
|
|
55
|
+
}`);
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=ObjectType_sparqlConstructTriplesFunctionDeclaration.js.map
|
package/dist/generators/ts/_ObjectType/ObjectType_sparqlWherePatternsFunctionDeclarations.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import type { ObjectType } from "../ObjectType.js";
|
|
3
|
+
import { type Code } from "../ts-poet-wrapper.js";
|
|
4
|
+
export declare function ObjectType_sparqlWherePatternsFunctionDeclaration(this: ObjectType): Maybe<Code>;
|
|
5
|
+
//# sourceMappingURL=ObjectType_sparqlWherePatternsFunctionDeclarations.d.ts.map
|