@shaclmate/compiler 4.0.70 → 4.0.71
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/AbstractCollectionType.d.ts +1 -1
- package/dist/generators/ts/AbstractCollectionType.js +6 -6
- package/dist/generators/ts/AbstractContainerType.d.ts +0 -2
- package/dist/generators/ts/AbstractContainerType.js +0 -2
- package/dist/generators/ts/AbstractLazyType.d.ts +1 -2
- package/dist/generators/ts/AbstractLazyType.js +1 -2
- package/dist/generators/ts/AbstractLiteralType.d.ts +0 -7
- package/dist/generators/ts/AbstractPrimitiveType.js +19 -6
- package/dist/generators/ts/AbstractTermType.d.ts +6 -3
- package/dist/generators/ts/AbstractTermType.js +11 -16
- package/dist/generators/ts/AbstractType.d.ts +11 -9
- package/dist/generators/ts/AbstractType.js +51 -2
- package/dist/generators/ts/AbstractTypedLiteralType.d.ts +3 -6
- package/dist/generators/ts/AbstractTypedLiteralType.js +1 -11
- package/dist/generators/ts/BigDecimalType.d.ts +1 -1
- package/dist/generators/ts/BigDecimalType.js +1 -1
- package/dist/generators/ts/BigIntType.d.ts +2 -1
- package/dist/generators/ts/BigIntType.js +11 -5
- package/dist/generators/ts/BooleanType.d.ts +1 -1
- package/dist/generators/ts/BooleanType.js +1 -1
- package/dist/generators/ts/DateTimeType.d.ts +1 -1
- package/dist/generators/ts/DateTimeType.js +1 -1
- package/dist/generators/ts/DateType.d.ts +1 -1
- package/dist/generators/ts/DateType.js +1 -1
- package/dist/generators/ts/DefaultValueType.d.ts +1 -1
- package/dist/generators/ts/DefaultValueType.js +4 -4
- package/dist/generators/ts/DiscriminatedUnionType.d.ts +2 -4
- package/dist/generators/ts/DiscriminatedUnionType.js +20 -56
- package/dist/generators/ts/FloatType.d.ts +1 -1
- package/dist/generators/ts/FloatType.js +1 -1
- package/dist/generators/ts/IntType.d.ts +1 -1
- package/dist/generators/ts/IntType.js +1 -1
- package/dist/generators/ts/IriType.d.ts +2 -0
- package/dist/generators/ts/IriType.js +43 -11
- package/dist/generators/ts/LangStringType.d.ts +1 -1
- package/dist/generators/ts/LangStringType.js +1 -4
- package/dist/generators/ts/LiteralType.d.ts +1 -1
- package/dist/generators/ts/LiteralType.js +1 -4
- package/dist/generators/ts/ObjectDiscriminatedUnionType.d.ts +1 -2
- package/dist/generators/ts/ObjectDiscriminatedUnionType.js +2 -11
- package/dist/generators/ts/ObjectType.d.ts +3 -3
- package/dist/generators/ts/ObjectType.js +134 -124
- package/dist/generators/ts/OptionType.d.ts +1 -1
- package/dist/generators/ts/OptionType.js +6 -6
- package/dist/generators/ts/StringType.d.ts +1 -1
- package/dist/generators/ts/StringType.js +10 -3
- package/dist/generators/ts/TypeFactory.js +7 -29
- package/dist/generators/ts/_ObjectType/ObjectType_identifierTypeDeclarations.d.ts +1 -1
- package/dist/generators/ts/_ObjectType/ObjectType_identifierTypeDeclarations.js +4 -5
- package/package.json +2 -2
|
@@ -40,8 +40,7 @@ import { ObjectType_typeGuardFunctionExpression } from "./_ObjectType/ObjectType
|
|
|
40
40
|
import { ObjectType_valueSparqlConstructTriplesFunctionExpression } from "./_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionExpression.js";
|
|
41
41
|
import { ObjectType_valueSparqlWherePatternsFunctionExpression } from "./_ObjectType/ObjectType_valueSparqlWherePatternsFunctionExpression.js";
|
|
42
42
|
import { AbstractType } from "./AbstractType.js";
|
|
43
|
-
import { arrayOf, code,
|
|
44
|
-
import { tsComment } from "./tsComment.js";
|
|
43
|
+
import { arrayOf, code, joinCode } from "./ts-poet-wrapper.js";
|
|
45
44
|
export class ObjectType extends AbstractType {
|
|
46
45
|
toRdfTypes;
|
|
47
46
|
discriminantProperty;
|
|
@@ -85,141 +84,157 @@ export class ObjectType extends AbstractType {
|
|
|
85
84
|
],
|
|
86
85
|
});
|
|
87
86
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
${this.
|
|
98
|
-
.alt(this.label)
|
|
99
|
-
.map(tsComment)
|
|
100
|
-
.orDefault("")}export type ${name} = ${this.inlineExpression};`);
|
|
101
|
-
}
|
|
102
|
-
let staticModuleDeclarations = [];
|
|
103
|
-
// create
|
|
104
|
-
if (this.configuration.features.has("Object.create")) {
|
|
105
|
-
staticModuleDeclarations.push(code `export const create: (${this.constructorParameters.signature}) => ${this.reusables.imports.Either}<Error, ${this.expression}> = ${ObjectType_createFunctionExpression.call(this)};`, code `export function createUnsafe(${this.constructorParameters.signature}): ${this.expression} {
|
|
87
|
+
staticModuleDeclarations(name) {
|
|
88
|
+
let staticModuleDeclarations = {
|
|
89
|
+
...super.staticModuleDeclarations(name),
|
|
90
|
+
};
|
|
91
|
+
// create
|
|
92
|
+
if (this.configuration.features.has("Object.create")) {
|
|
93
|
+
staticModuleDeclarations["create"] =
|
|
94
|
+
code `export const create: (${this.constructorParameters.signature}) => ${this.reusables.imports.Either}<Error, ${this.expression}> = ${ObjectType_createFunctionExpression.call(this)};`;
|
|
95
|
+
staticModuleDeclarations["createUnsafe"] =
|
|
96
|
+
code `export function createUnsafe(${this.constructorParameters.signature}): ${this.expression} {
|
|
106
97
|
return create(parameters).unsafeCoerce();
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
98
|
+
}`;
|
|
99
|
+
}
|
|
100
|
+
// equals
|
|
101
|
+
if (this.configuration.features.has("Object.equals")) {
|
|
102
|
+
staticModuleDeclarations["equals"] =
|
|
103
|
+
code `export const equals: (left: ${this.expression}, right: ${this.expression}) => ${this.reusables.snippets.EqualsResult} = ${ObjectType_equalsFunctionExpression.call(this)};`;
|
|
104
|
+
}
|
|
105
|
+
// Filter / filter
|
|
106
|
+
if (this.configuration.features.has("Object.filter")) {
|
|
107
|
+
staticModuleDeclarations["Filter"] =
|
|
108
|
+
code `export type Filter = ${ObjectType_filterTypeExpression.call(this)};`;
|
|
109
|
+
staticModuleDeclarations["filter"] =
|
|
110
|
+
code `export const filter: (filter: ${this.filterType}, value: ${this.expression}) => boolean = ${ObjectType_filterFunctionExpression.call(this)};`;
|
|
111
|
+
}
|
|
112
|
+
// GraphQL
|
|
113
|
+
if (this.configuration.features.has("GraphQL") && !this.synthetic) {
|
|
114
|
+
staticModuleDeclarations["GraphQL"] =
|
|
115
|
+
code `export const GraphQL = ${ObjectType_graphqlTypeExpression.call(this)};`;
|
|
116
|
+
}
|
|
117
|
+
// focusSparqlConstructTriples / focusSparqlWherePatterns
|
|
118
|
+
if (this.configuration.features.has("Object.SPARQL")) {
|
|
119
|
+
staticModuleDeclarations["focusSparqlConstructTriples"] =
|
|
120
|
+
code `export const focusSparqlConstructTriples: ${this.reusables.snippets.FocusSparqlConstructTriplesFunction}<${this.filterType}> = ${ObjectType_focusSparqlConstructTriplesFunctionExpression.call(this)};`;
|
|
121
|
+
staticModuleDeclarations["focusSparqlWherePatterns"] =
|
|
122
|
+
code `export const focusSparqlWherePatterns: ${this.reusables.snippets.FocusSparqlWherePatternsFunction}<${this.filterType}> = ${ObjectType_focusSparqlWherePatternsFunctionExpression.call(this)};`;
|
|
123
|
+
}
|
|
124
|
+
// fromJson
|
|
125
|
+
if (this.configuration.features.has("Object.fromJson")) {
|
|
126
|
+
staticModuleDeclarations["fromJson"] =
|
|
127
|
+
code `export const fromJson: (json: ${this.jsonType().expression}) => ${this.reusables.imports.Either}<Error, ${this.expression}> = ${ObjectType_fromJsonFunctionExpression.call(this)};`;
|
|
128
|
+
}
|
|
129
|
+
// fromRdfResource / fromRdfResourceValues
|
|
130
|
+
if (this.configuration.features.has("Object.fromRdf")) {
|
|
131
|
+
staticModuleDeclarations["_fromRdfResource"] =
|
|
132
|
+
code `export const _fromRdfResource: ${this.reusables.snippets._FromRdfResourceFunction}<${this.expression}> = ${ObjectType_fromRdfResourceFunctionExpression.call(this)};`;
|
|
133
|
+
staticModuleDeclarations["fromRdfResource"] =
|
|
134
|
+
code `export const fromRdfResource = ${this.reusables.snippets.wrap_FromRdfResourceFunction}(_fromRdfResource);`;
|
|
135
|
+
staticModuleDeclarations["fromRdfResourceValues"] =
|
|
136
|
+
code `export const fromRdfResourceValues: ${this.reusables.snippets.FromRdfResourceValuesFunction}<${this.expression}, ${this.schemaType}> =
|
|
137
|
+
(values, options) => values.chainMap(value => value.toResource().chain(resource => fromRdfResource(resource, options)));`;
|
|
138
|
+
}
|
|
139
|
+
// hash
|
|
140
|
+
if (this.configuration.features.has("Object.hash")) {
|
|
141
|
+
staticModuleDeclarations["hash"] =
|
|
142
|
+
code `export const hash = ${ObjectType_hashFunctionExpression.call(this)};`;
|
|
143
|
+
}
|
|
144
|
+
// Identifier
|
|
145
|
+
if (this.configuration.features.has("Object.type")) {
|
|
146
|
+
staticModuleDeclarations = {
|
|
147
|
+
...staticModuleDeclarations,
|
|
148
|
+
...ObjectType_identifierTypeDeclarations.call(this),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
// Type guard
|
|
152
|
+
ObjectType_typeGuardFunctionExpression.call(this).ifJust((typeGuardFunctionExpression) => {
|
|
153
|
+
staticModuleDeclarations[`is${name}`] =
|
|
154
|
+
code `export const is${name} = ${typeGuardFunctionExpression};`;
|
|
155
|
+
});
|
|
156
|
+
// type Json
|
|
157
|
+
if (this.configuration.features.has("Object.JSON.type")) {
|
|
158
|
+
staticModuleDeclarations["JsonType"] =
|
|
159
|
+
code `export type Json = ${ObjectType_jsonTypeExpression.call(this)}`;
|
|
160
|
+
}
|
|
161
|
+
// namespace Json
|
|
162
|
+
{
|
|
163
|
+
const jsonModuleDeclarations = [];
|
|
164
|
+
if (this.configuration.features.has("Object.JSON.parse")) {
|
|
165
|
+
jsonModuleDeclarations.push(ObjectType_jsonParseFunctionDeclaration.call(this));
|
|
142
166
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
staticModuleDeclarations.push(code `export const is${name} = ${typeGuardFunctionExpression};`);
|
|
146
|
-
});
|
|
147
|
-
// type Json
|
|
148
|
-
if (this.configuration.features.has("Object.JSON.type")) {
|
|
149
|
-
staticModuleDeclarations.push(code `export type Json = ${ObjectType_jsonTypeExpression.call(this)}`);
|
|
167
|
+
if (this.configuration.features.has("Object.JSON.schema")) {
|
|
168
|
+
jsonModuleDeclarations.push(code `export function schema() { return ${ObjectType_jsonSchemaExpression.call(this)} satisfies ${this.reusables.imports.z}.ZodType<Json>; }`);
|
|
150
169
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const jsonModuleDeclarations = [];
|
|
154
|
-
if (this.configuration.features.has("Object.JSON.parse")) {
|
|
155
|
-
jsonModuleDeclarations.push(ObjectType_jsonParseFunctionDeclaration.call(this));
|
|
156
|
-
}
|
|
157
|
-
if (this.configuration.features.has("Object.JSON.schema")) {
|
|
158
|
-
jsonModuleDeclarations.push(code `export function schema() { return ${ObjectType_jsonSchemaExpression.call(this)} satisfies ${this.reusables.imports.z}.ZodType<Json>; }`);
|
|
159
|
-
}
|
|
160
|
-
if (this.configuration.features.has("Object.JSON.uiSchema")) {
|
|
161
|
-
jsonModuleDeclarations.push(code `export const uiSchema = ${ObjectType_jsonUiSchemaFunctionExpression.call(this)};`);
|
|
162
|
-
}
|
|
163
|
-
if (jsonModuleDeclarations.length > 0) {
|
|
164
|
-
staticModuleDeclarations.push(code `export namespace Json { ${joinCode(jsonModuleDeclarations, { on: "\n\n" })} }`);
|
|
165
|
-
}
|
|
170
|
+
if (this.configuration.features.has("Object.JSON.uiSchema")) {
|
|
171
|
+
jsonModuleDeclarations.push(code `export const uiSchema = ${ObjectType_jsonUiSchemaFunctionExpression.call(this)};`);
|
|
166
172
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
173
|
+
if (jsonModuleDeclarations.length > 0) {
|
|
174
|
+
staticModuleDeclarations["JsonNamespace"] =
|
|
175
|
+
code `export namespace Json { ${joinCode(jsonModuleDeclarations, { on: "\n\n" })} }`;
|
|
170
176
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
177
|
+
}
|
|
178
|
+
// schema / Schema
|
|
179
|
+
if (this.configuration.features.has("Object.schema")) {
|
|
180
|
+
staticModuleDeclarations["schema"] =
|
|
181
|
+
code `export const schema = ${ObjectType_schemaExpression.call(this)};`;
|
|
182
|
+
staticModuleDeclarations["Schema"] =
|
|
183
|
+
code `export type Schema = typeof schema;`;
|
|
184
|
+
}
|
|
185
|
+
// sparqlConstructQuery / sparqlConstructQueryString
|
|
186
|
+
if (this.configuration.features.has("Object.SPARQL")) {
|
|
187
|
+
staticModuleDeclarations["sparqlConstructQuery"] =
|
|
188
|
+
ObjectType_sparqlConstructQueryFunctionDeclaration.call({
|
|
174
189
|
name,
|
|
175
190
|
configuration: this.configuration,
|
|
176
191
|
filterType: this.filterType,
|
|
177
192
|
reusables: this.reusables,
|
|
178
|
-
})
|
|
193
|
+
});
|
|
194
|
+
staticModuleDeclarations["sparqlConstructQueryString"] =
|
|
195
|
+
ObjectType_sparqlConstructQueryStringFunctionDeclaration.call({
|
|
179
196
|
name,
|
|
180
197
|
configuration: this.configuration,
|
|
181
198
|
filterType: this.filterType,
|
|
182
199
|
reusables: this.reusables,
|
|
183
|
-
})
|
|
184
|
-
}
|
|
185
|
-
// toJson
|
|
186
|
-
if (this.configuration.features.has("Object.toJson")) {
|
|
187
|
-
staticModuleDeclarations.push(code `export const toJson: (${this.thisVariable}: ${this.expression}) => ${this.jsonType().expression} = ${ObjectType_toJsonFunctionExpression.call(this)};`);
|
|
188
|
-
}
|
|
189
|
-
// toRdfResource
|
|
190
|
-
if (this.configuration.features.has("Object.toRdf")) {
|
|
191
|
-
staticModuleDeclarations.push(code `export const _toRdfResource: ${this.reusables.snippets._ToRdfResourceFunction}<${this.identifierTypeAlias}, ${this.expression}> = ${ObjectType_toRdfResourceFunctionExpression.call(this)};`, code `export const toRdfResource = ${this.reusables.snippets.wrap_ToRdfResourceFunction}(_toRdfResource);`);
|
|
192
|
-
}
|
|
193
|
-
// toString / toStringRecord
|
|
194
|
-
if (this.configuration.features.has("Object.toString")) {
|
|
195
|
-
staticModuleDeclarations.push(code `export const ${this.configuration.syntheticNamePrefix}toString: (${this.thisVariable}: ${this.expression}) => string = ${ObjectType_toStringFunctionExpression.call(this)};`, code `export const toStringRecord: (${this.thisVariable}: ${this.expression}) => Record<string, string> = ${ObjectType_toStringRecordFunctionExpression.call(this)};`);
|
|
196
|
-
}
|
|
197
|
-
// valueSparqlConstructTriples / valueSparqlWherePatterns
|
|
198
|
-
if (this.configuration.features.has("Object.SPARQL")) {
|
|
199
|
-
staticModuleDeclarations.push(code `export const valueSparqlConstructTriples: ${this.reusables.snippets.ValueSparqlConstructTriplesFunction}<${this.filterType}, ${this.schemaType}> = ${ObjectType_valueSparqlConstructTriplesFunctionExpression.call(this)};`, code `export const valueSparqlWherePatterns: ${this.reusables.snippets.ValueSparqlWherePatternsFunction}<${this.filterType}, ${this.schemaType}> = ${ObjectType_valueSparqlWherePatternsFunctionExpression.call(this)};`);
|
|
200
|
-
}
|
|
201
|
-
if (staticModuleDeclarations.length > 0) {
|
|
202
|
-
declarations.push(code `\
|
|
203
|
-
export namespace ${def(name)} {
|
|
204
|
-
${joinCode(staticModuleDeclarations, { on: "\n\n" })}
|
|
205
|
-
}`);
|
|
206
|
-
}
|
|
200
|
+
});
|
|
207
201
|
}
|
|
208
|
-
|
|
209
|
-
|
|
202
|
+
// toJson
|
|
203
|
+
if (this.configuration.features.has("Object.toJson")) {
|
|
204
|
+
staticModuleDeclarations["toJson"] =
|
|
205
|
+
code `export const toJson: (${this.thisVariable}: ${this.expression}) => ${this.jsonType().expression} = ${ObjectType_toJsonFunctionExpression.call(this)};`;
|
|
206
|
+
}
|
|
207
|
+
// toRdfResource
|
|
208
|
+
if (this.configuration.features.has("Object.toRdf")) {
|
|
209
|
+
staticModuleDeclarations["_toRdfResource"] =
|
|
210
|
+
code `export const _toRdfResource: ${this.reusables.snippets._ToRdfResourceFunction}<${this.identifierTypeAlias}, ${this.expression}> = ${ObjectType_toRdfResourceFunctionExpression.call(this)};`;
|
|
211
|
+
staticModuleDeclarations["toRdfResource"] =
|
|
212
|
+
code `export const toRdfResource = ${this.reusables.snippets.wrap_ToRdfResourceFunction}(_toRdfResource);`;
|
|
210
213
|
}
|
|
211
|
-
|
|
214
|
+
// toString / toStringRecord
|
|
215
|
+
if (this.configuration.features.has("Object.toString")) {
|
|
216
|
+
staticModuleDeclarations[`${this.configuration.syntheticNamePrefix}toString`] =
|
|
217
|
+
code `export const ${this.configuration.syntheticNamePrefix}toString: (${this.thisVariable}: ${this.expression}) => string = ${ObjectType_toStringFunctionExpression.call(this)};`;
|
|
218
|
+
staticModuleDeclarations["toStringRecord"] =
|
|
219
|
+
code `export const toStringRecord: (${this.thisVariable}: ${this.expression}) => Record<string, string> = ${ObjectType_toStringRecordFunctionExpression.call(this)};`;
|
|
220
|
+
}
|
|
221
|
+
// valueSparqlConstructTriples / valueSparqlWherePatterns
|
|
222
|
+
if (this.configuration.features.has("Object.SPARQL")) {
|
|
223
|
+
staticModuleDeclarations["valueSparqlConstructTriples"] =
|
|
224
|
+
code `export const valueSparqlConstructTriples: ${this.reusables.snippets.ValueSparqlConstructTriplesFunction}<${this.filterType}, ${this.schemaType}> = ${ObjectType_valueSparqlConstructTriplesFunctionExpression.call(this)};`;
|
|
225
|
+
staticModuleDeclarations["valueSparqlWherePatterns"] =
|
|
226
|
+
code `export const valueSparqlWherePatterns: ${this.reusables.snippets.ValueSparqlWherePatternsFunction}<${this.filterType}, ${this.schemaType}> = ${ObjectType_valueSparqlWherePatternsFunctionExpression.call(this)};`;
|
|
227
|
+
}
|
|
228
|
+
return staticModuleDeclarations;
|
|
229
|
+
}
|
|
230
|
+
get declaration() {
|
|
231
|
+
return !this.extern ? super.declaration : Maybe.empty();
|
|
212
232
|
}
|
|
213
233
|
get equalsFunction() {
|
|
214
234
|
return this.name
|
|
215
235
|
.map((name) => code `${name}.equals`)
|
|
216
236
|
.orDefaultLazy(() => ObjectType_equalsFunctionExpression.call(this));
|
|
217
237
|
}
|
|
218
|
-
get expression() {
|
|
219
|
-
return this.name
|
|
220
|
-
.map((name) => code `${name}`)
|
|
221
|
-
.orDefaultLazy(() => this.inlineExpression);
|
|
222
|
-
}
|
|
223
238
|
get filterFunction() {
|
|
224
239
|
return this.name
|
|
225
240
|
.map((name) => code `${name}.filter`)
|
|
@@ -279,10 +294,8 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
|
|
|
279
294
|
}
|
|
280
295
|
}));
|
|
281
296
|
}
|
|
282
|
-
get
|
|
283
|
-
return this
|
|
284
|
-
.map((name) => code `${name}.schema`)
|
|
285
|
-
.orDefaultLazy(() => ObjectType_schemaExpression.call(this));
|
|
297
|
+
get schemaExpression() {
|
|
298
|
+
return ObjectType_schemaExpression.call(this);
|
|
286
299
|
}
|
|
287
300
|
get schemaType() {
|
|
288
301
|
return this.name
|
|
@@ -425,9 +438,6 @@ __decorate([
|
|
|
425
438
|
__decorate([
|
|
426
439
|
Memoize()
|
|
427
440
|
], ObjectType.prototype, "equalsFunction", null);
|
|
428
|
-
__decorate([
|
|
429
|
-
Memoize()
|
|
430
|
-
], ObjectType.prototype, "expression", null);
|
|
431
441
|
__decorate([
|
|
432
442
|
Memoize()
|
|
433
443
|
], ObjectType.prototype, "filterFunction", null);
|
|
@@ -463,7 +473,7 @@ __decorate([
|
|
|
463
473
|
], ObjectType.prototype, "referencesNamedType", null);
|
|
464
474
|
__decorate([
|
|
465
475
|
Memoize()
|
|
466
|
-
], ObjectType.prototype, "
|
|
476
|
+
], ObjectType.prototype, "schemaExpression", null);
|
|
467
477
|
__decorate([
|
|
468
478
|
Memoize()
|
|
469
479
|
], ObjectType.prototype, "schemaType", null);
|
|
@@ -11,7 +11,6 @@ export declare class OptionType<ItemTypeT extends OptionType.ItemType> extends A
|
|
|
11
11
|
readonly kind = "Option";
|
|
12
12
|
get conversionFunction(): Maybe<AbstractContainerType.ConversionFunction>;
|
|
13
13
|
get equalsFunction(): Code;
|
|
14
|
-
get expression(): Code;
|
|
15
14
|
get filterFunction(): Code;
|
|
16
15
|
get filterType(): Code;
|
|
17
16
|
get fromRdfResourceValuesFunction(): Code;
|
|
@@ -23,6 +22,7 @@ export declare class OptionType<ItemTypeT extends OptionType.ItemType> extends A
|
|
|
23
22
|
get validationFunction(): Maybe<Code>;
|
|
24
23
|
get valueSparqlConstructTriplesFunction(): Code;
|
|
25
24
|
get valueSparqlWherePatternsFunction(): Code;
|
|
25
|
+
protected get inlineExpression(): Code;
|
|
26
26
|
fromJsonExpression({ variables, }: Parameters<AbstractContainerType<ItemTypeT>["fromJsonExpression"]>[0]): Code;
|
|
27
27
|
graphqlResolveExpression(parameters: Parameters<AbstractContainerType<ItemTypeT>["graphqlResolveExpression"]>[0]): Code;
|
|
28
28
|
jsonSchema(parameters: Parameters<AbstractContainerType<ItemTypeT>["jsonSchema"]>[0]): Code;
|
|
@@ -33,9 +33,6 @@ export class OptionType extends AbstractContainerType {
|
|
|
33
33
|
get equalsFunction() {
|
|
34
34
|
return code `((left, right) => ${this.reusables.snippets.maybeEquals}(left, right, ${this.itemType.equalsFunction}))`;
|
|
35
35
|
}
|
|
36
|
-
get expression() {
|
|
37
|
-
return code `${this.reusables.imports.Maybe}<${this.itemType.expression}>`;
|
|
38
|
-
}
|
|
39
36
|
get filterFunction() {
|
|
40
37
|
return code `${this.reusables.snippets.filterMaybe}<${this.itemType.expression}, ${this.itemType.filterType}>(${this.itemType.filterFunction})`;
|
|
41
38
|
}
|
|
@@ -72,6 +69,9 @@ export class OptionType extends AbstractContainerType {
|
|
|
72
69
|
get valueSparqlWherePatternsFunction() {
|
|
73
70
|
return code `${this.reusables.snippets.maybeSparqlWherePatterns}<${this.itemType.filterType}, ${this.itemType.schemaType}>(${this.itemType.valueSparqlWherePatternsFunction})`;
|
|
74
71
|
}
|
|
72
|
+
get inlineExpression() {
|
|
73
|
+
return code `${this.reusables.imports.Maybe}<${this.itemType.expression}>`;
|
|
74
|
+
}
|
|
75
75
|
fromJsonExpression({ variables, }) {
|
|
76
76
|
const expression = code `${this.reusables.imports.Maybe}.fromNullable(${variables.value})`;
|
|
77
77
|
const itemFromJsonExpression = this.itemType.fromJsonExpression({
|
|
@@ -118,9 +118,6 @@ __decorate([
|
|
|
118
118
|
__decorate([
|
|
119
119
|
Memoize()
|
|
120
120
|
], OptionType.prototype, "equalsFunction", null);
|
|
121
|
-
__decorate([
|
|
122
|
-
Memoize()
|
|
123
|
-
], OptionType.prototype, "expression", null);
|
|
124
121
|
__decorate([
|
|
125
122
|
Memoize()
|
|
126
123
|
], OptionType.prototype, "filterFunction", null);
|
|
@@ -148,6 +145,9 @@ __decorate([
|
|
|
148
145
|
__decorate([
|
|
149
146
|
Memoize()
|
|
150
147
|
], OptionType.prototype, "valueSparqlWherePatternsFunction", null);
|
|
148
|
+
__decorate([
|
|
149
|
+
Memoize()
|
|
150
|
+
], OptionType.prototype, "inlineExpression", null);
|
|
151
151
|
__decorate([
|
|
152
152
|
Memoize()
|
|
153
153
|
], OptionType.prototype, "jsonType", null);
|
|
@@ -19,7 +19,7 @@ export declare class StringType extends AbstractPrimitiveType<string> {
|
|
|
19
19
|
get schemaType(): Code;
|
|
20
20
|
protected get schemaInitializers(): readonly Code[];
|
|
21
21
|
jsonSchema(parameters: Parameters<AbstractPrimitiveType<string>["jsonSchema"]>[0]): Code;
|
|
22
|
-
|
|
22
|
+
valueExpression(literal: Literal | string): Code;
|
|
23
23
|
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractPrimitiveType<string>["toRdfResourceValuesExpression"]>[0]): Code;
|
|
24
24
|
}
|
|
25
25
|
//# sourceMappingURL=StringType.d.ts.map
|
|
@@ -39,12 +39,19 @@ export class StringType extends AbstractPrimitiveType {
|
|
|
39
39
|
return initializers;
|
|
40
40
|
}
|
|
41
41
|
jsonSchema(parameters) {
|
|
42
|
-
if (this.
|
|
43
|
-
|
|
42
|
+
if (this.in_.length > 1) {
|
|
43
|
+
const name = this.name.extract();
|
|
44
|
+
if (name && this.configuration.features.has("Object.schema")) {
|
|
45
|
+
// Reuse the type from schema to cut down code
|
|
46
|
+
return code `${this.reusables.imports.z}.enum(${name}.schema.in)`;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return code `${this.reusables.imports.z}.enum(${arrayOf(...this.in_.map((value) => this.valueExpression(value)))})`;
|
|
50
|
+
}
|
|
44
51
|
}
|
|
45
52
|
return super.jsonSchema(parameters);
|
|
46
53
|
}
|
|
47
|
-
|
|
54
|
+
valueExpression(literal) {
|
|
48
55
|
return code `${literalOf(typeof literal === "string" ? literal : literal.value)}`;
|
|
49
56
|
}
|
|
50
57
|
toRdfResourceValuesExpression({ variables, }) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import TermMap from "@rdfjs/term-map";
|
|
2
2
|
import TermSet from "@rdfjs/term-set";
|
|
3
|
-
import {
|
|
3
|
+
import { literalDatatypeDefinitions } from "@rdfx/literal";
|
|
4
4
|
import base62 from "@sindresorhus/base62";
|
|
5
5
|
import { rdf } from "@tpluscode/rdf-ns-builders";
|
|
6
6
|
import { Maybe } from "purify-ts";
|
|
@@ -341,41 +341,19 @@ export class TypeFactory {
|
|
|
341
341
|
if (datatypeDefinition) {
|
|
342
342
|
switch (datatypeDefinition.kind) {
|
|
343
343
|
case "bigdecimal":
|
|
344
|
-
return new BigDecimalType(
|
|
345
|
-
...typeParameters,
|
|
346
|
-
decodedIn: astType.in_.map((value) => LiteralDecoder.decodeBigDecimalLiteral(value).unsafeCoerce()),
|
|
347
|
-
});
|
|
344
|
+
return new BigDecimalType(typeParameters);
|
|
348
345
|
case "bigint":
|
|
349
|
-
return new BigIntType(
|
|
350
|
-
...typeParameters,
|
|
351
|
-
decodedIn: astType.in_.map((value) => LiteralDecoder.decodeBigIntLiteral(value).unsafeCoerce()),
|
|
352
|
-
});
|
|
346
|
+
return new BigIntType(typeParameters);
|
|
353
347
|
case "boolean":
|
|
354
|
-
return new BooleanType(
|
|
355
|
-
...typeParameters,
|
|
356
|
-
decodedIn: astType.in_.map((value) => LiteralDecoder.decodeBooleanLiteral(value).unsafeCoerce()),
|
|
357
|
-
});
|
|
348
|
+
return new BooleanType(typeParameters);
|
|
358
349
|
case "date":
|
|
359
350
|
case "datetime":
|
|
360
|
-
return new (datatypeDefinition.kind === "date" ? DateType : DateTimeType)(
|
|
361
|
-
...typeParameters,
|
|
362
|
-
decodedIn: astType.in_.map((value) => (datatypeDefinition.kind === "date"
|
|
363
|
-
? LiteralDecoder.decodeDateLiteral
|
|
364
|
-
: LiteralDecoder.decodeDateTimeLiteral)(value).unsafeCoerce()),
|
|
365
|
-
});
|
|
351
|
+
return new (datatypeDefinition.kind === "date" ? DateType : DateTimeType)(typeParameters);
|
|
366
352
|
case "float":
|
|
367
353
|
case "int":
|
|
368
|
-
return new (datatypeDefinition.kind === "float" ? FloatType : IntType)(
|
|
369
|
-
...typeParameters,
|
|
370
|
-
decodedIn: astType.in_.map((value) => (datatypeDefinition.kind === "float"
|
|
371
|
-
? LiteralDecoder.decodeFloatLiteral
|
|
372
|
-
: LiteralDecoder.decodeIntLiteral)(value).unsafeCoerce()),
|
|
373
|
-
});
|
|
354
|
+
return new (datatypeDefinition.kind === "float" ? FloatType : IntType)(typeParameters);
|
|
374
355
|
case "string":
|
|
375
|
-
return new StringType(
|
|
376
|
-
...typeParameters,
|
|
377
|
-
decodedIn: astType.in_.map((value) => LiteralDecoder.decodeStringLiteral(value).unsafeCoerce()),
|
|
378
|
-
});
|
|
356
|
+
return new StringType(typeParameters);
|
|
379
357
|
}
|
|
380
358
|
}
|
|
381
359
|
this.logger.warn("unrecognized literal datatype: %s", datatype.value);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ObjectType } from "../ObjectType.js";
|
|
2
2
|
import { type Code } from "../ts-poet-wrapper.js";
|
|
3
|
-
export declare function ObjectType_identifierTypeDeclarations(this: ObjectType):
|
|
3
|
+
export declare function ObjectType_identifierTypeDeclarations(this: ObjectType): Record<string, Code>;
|
|
4
4
|
//# sourceMappingURL=ObjectType_identifierTypeDeclarations.d.ts.map
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
+
import { singleEntryRecord } from "../singleEntryRecord.js";
|
|
1
2
|
import { code } from "../ts-poet-wrapper.js";
|
|
2
3
|
export function ObjectType_identifierTypeDeclarations() {
|
|
3
4
|
// Bespoke identifier type and associated functions
|
|
4
|
-
return
|
|
5
|
-
|
|
6
|
-
code `\
|
|
5
|
+
return singleEntryRecord("Identifier", code `\
|
|
6
|
+
export type Identifier = ${this.identifierType.expression};
|
|
7
7
|
export namespace Identifier {
|
|
8
8
|
export const parse = ${this.identifierType.parseFunction};
|
|
9
9
|
export const stringify = ${this.identifierType.stringifyFunction};
|
|
10
|
-
}
|
|
11
|
-
];
|
|
10
|
+
}`);
|
|
12
11
|
}
|
|
13
12
|
//# sourceMappingURL=ObjectType_identifierTypeDeclarations.js.map
|
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.71",
|
|
4
4
|
"@rdfjs/dataset": "~2.0.2",
|
|
5
5
|
"@rdfjs/prefix-map": "~0.1.2",
|
|
6
6
|
"@rdfjs/term-map": "~2.0.2",
|
|
@@ -723,5 +723,5 @@
|
|
|
723
723
|
},
|
|
724
724
|
"type": "module",
|
|
725
725
|
"types": "./dist/index.d.ts",
|
|
726
|
-
"version": "4.0.
|
|
726
|
+
"version": "4.0.71"
|
|
727
727
|
}
|