@shaclmate/compiler 4.0.34 → 4.0.35
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 +2 -1
- package/dist/generators/ts/AbstractCollectionType.js +14 -13
- package/dist/generators/ts/AbstractContainerType.d.ts +2 -0
- package/dist/generators/ts/AbstractContainerType.js +20 -0
- package/dist/generators/ts/AbstractDateType.d.ts +1 -1
- package/dist/generators/ts/AbstractDateType.js +3 -3
- package/dist/generators/ts/AbstractLazyObjectType.d.ts +1 -0
- package/dist/generators/ts/AbstractLazyObjectType.js +1 -0
- package/dist/generators/ts/AbstractLiteralType.d.ts +1 -1
- package/dist/generators/ts/AbstractLiteralType.js +2 -2
- package/dist/generators/ts/AbstractNumericType.d.ts +1 -8
- package/dist/generators/ts/AbstractNumericType.js +2 -16
- package/dist/generators/ts/AbstractPrimitiveType.d.ts +1 -0
- package/dist/generators/ts/AbstractPrimitiveType.js +2 -1
- package/dist/generators/ts/AbstractTermType.d.ts +2 -1
- package/dist/generators/ts/AbstractTermType.js +3 -2
- package/dist/generators/ts/AbstractType.d.ts +19 -8
- package/dist/generators/ts/AbstractUnionType.d.ts +3 -2
- package/dist/generators/ts/AbstractUnionType.js +14 -13
- package/dist/generators/ts/BigDecimalType.d.ts +3 -2
- package/dist/generators/ts/BigDecimalType.js +5 -12
- package/dist/generators/ts/BigIntType.js +1 -1
- package/dist/generators/ts/BlankNodeType.d.ts +3 -2
- package/dist/generators/ts/BlankNodeType.js +6 -5
- package/dist/generators/ts/BooleanType.d.ts +1 -2
- package/dist/generators/ts/BooleanType.js +2 -16
- package/dist/generators/ts/DateTimeType.d.ts +0 -1
- package/dist/generators/ts/DateTimeType.js +0 -9
- package/dist/generators/ts/DateType.d.ts +0 -1
- package/dist/generators/ts/DateType.js +0 -9
- package/dist/generators/ts/DefaultValueType.d.ts +2 -1
- package/dist/generators/ts/DefaultValueType.js +5 -4
- package/dist/generators/ts/IdentifierType.d.ts +3 -2
- package/dist/generators/ts/IdentifierType.js +6 -5
- package/dist/generators/ts/IriType.d.ts +3 -11
- package/dist/generators/ts/IriType.js +6 -5
- package/dist/generators/ts/LazyObjectOptionType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectOptionType.js +3 -3
- package/dist/generators/ts/LazyObjectSetType.d.ts +2 -1
- package/dist/generators/ts/LazyObjectSetType.js +3 -3
- package/dist/generators/ts/LazyObjectType.d.ts +2 -1
- package/dist/generators/ts/LazyObjectType.js +3 -3
- package/dist/generators/ts/LiteralType.d.ts +2 -1
- package/dist/generators/ts/LiteralType.js +4 -3
- package/dist/generators/ts/NamedObjectType.d.ts +2 -1
- package/dist/generators/ts/NamedObjectType.js +2 -14
- package/dist/generators/ts/OptionType.d.ts +4 -3
- package/dist/generators/ts/OptionType.js +20 -17
- package/dist/generators/ts/Snippets.d.ts +7 -11
- package/dist/generators/ts/Snippets.js +46 -74
- package/dist/generators/ts/StringType.d.ts +1 -2
- package/dist/generators/ts/StringType.js +2 -16
- package/dist/generators/ts/TermType.d.ts +2 -1
- package/dist/generators/ts/TermType.js +6 -16
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.js +2 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js +29 -8
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +5 -5
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.js +22 -2
- package/dist/generators/ts/_snippets/snippets_ConversionFunction.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_ConversionFunction.js +4 -0
- package/dist/generators/ts/_snippets/snippets_ValidationFunction.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_ValidationFunction.js +4 -0
- package/dist/generators/ts/_snippets/snippets_convertToArray.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToArray.js +8 -0
- package/dist/generators/ts/_snippets/snippets_convertToBlankNode.js +2 -2
- package/dist/generators/ts/_snippets/snippets_convertToIdentifier.js +2 -2
- package/dist/generators/ts/_snippets/snippets_convertToIri.js +2 -2
- package/dist/generators/ts/_snippets/snippets_convertToLazyObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.js +1 -1
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.js +1 -1
- package/dist/generators/ts/_snippets/snippets_convertToLiteral.js +1 -1
- package/dist/generators/ts/_snippets/snippets_convertToMaybe.js +3 -3
- package/dist/generators/ts/_snippets/snippets_convertWithDefaultValue.js +4 -4
- package/dist/generators/ts/_snippets/snippets_identityConversionFunction.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_identityConversionFunction.js +6 -0
- package/dist/generators/ts/_snippets/snippets_identityValidationFunction.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_identityValidationFunction.js +6 -0
- package/dist/generators/ts/_snippets/snippets_validateArray.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_validateArray.js +13 -0
- package/dist/generators/ts/_snippets/snippets_validateMaybe.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_validateMaybe.js +7 -0
- package/dist/input/generated.d.ts +8 -8
- package/dist/input/generated.js +110 -113
- package/package.json +2 -2
- package/dist/generators/ts/_snippets/snippets_convertToBigDecimal.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToBigDecimal.js +0 -6
- package/dist/generators/ts/_snippets/snippets_convertToBoolean.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToBoolean.js +0 -6
- package/dist/generators/ts/_snippets/snippets_convertToDate.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToDate.js +0 -6
- package/dist/generators/ts/_snippets/snippets_convertToDateTime.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToDateTime.js +0 -6
- package/dist/generators/ts/_snippets/snippets_convertToMutableArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToMutableArray.js +0 -14
- package/dist/generators/ts/_snippets/snippets_convertToNumeric.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToNumeric.js +0 -6
- package/dist/generators/ts/_snippets/snippets_convertToObject.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToObject.js +0 -6
- package/dist/generators/ts/_snippets/snippets_convertToReadonlyArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToReadonlyArray.js +0 -14
- package/dist/generators/ts/_snippets/snippets_convertToString.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToString.js +0 -6
- package/dist/generators/ts/_snippets/snippets_convertToTerm.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToTerm.js +0 -6
- package/dist/generators/ts/_snippets/snippets_convertToUnion.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToUnion.js +0 -6
|
@@ -29,9 +29,13 @@ export class ShaclProperty extends AbstractProperty {
|
|
|
29
29
|
this.recursive = recursive;
|
|
30
30
|
}
|
|
31
31
|
get constructorParameter() {
|
|
32
|
+
const conversionFunction = this.type.conversionFunction.extract();
|
|
33
|
+
if (!conversionFunction) {
|
|
34
|
+
return Maybe.of(code `readonly ${this.name}: ${this.type.name};`);
|
|
35
|
+
}
|
|
32
36
|
let hasQuestionToken = false;
|
|
33
37
|
const typeNames = [];
|
|
34
|
-
for (const type of
|
|
38
|
+
for (const type of conversionFunction.sourceTypes) {
|
|
35
39
|
if (type.typeof === "undefined") {
|
|
36
40
|
hasQuestionToken = true;
|
|
37
41
|
}
|
|
@@ -111,7 +115,23 @@ export class ShaclProperty extends AbstractProperty {
|
|
|
111
115
|
};
|
|
112
116
|
}
|
|
113
117
|
constructorInitializer({ variables, }) {
|
|
114
|
-
|
|
118
|
+
const parameterVariable = code `${variables.parameters}.${this.name}`;
|
|
119
|
+
const conversionFunction = this.type.conversionFunction.extract()?.code;
|
|
120
|
+
const validationFunction = this.type.validationFunction.extract();
|
|
121
|
+
let rhs;
|
|
122
|
+
if (conversionFunction && validationFunction) {
|
|
123
|
+
rhs = code `${conversionFunction}(${parameterVariable}).chain(value => ${validationFunction}(${this.namedObjectType.name}.schema.properties.${this.name}.type(), value))`;
|
|
124
|
+
}
|
|
125
|
+
else if (conversionFunction) {
|
|
126
|
+
rhs = code `${conversionFunction}(${parameterVariable})`;
|
|
127
|
+
}
|
|
128
|
+
else if (validationFunction) {
|
|
129
|
+
rhs = code `${validationFunction}(${this.namedObjectType.name}.schema.properties.${this.name}.type(), ${parameterVariable})`;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
rhs = code `${this.reusables.imports.Either}.of(${parameterVariable})`;
|
|
133
|
+
}
|
|
134
|
+
return Maybe.of(code `${this.name}: ${rhs}`);
|
|
115
135
|
}
|
|
116
136
|
fromJsonInitializer({ variables, }) {
|
|
117
137
|
return Maybe.of(code `${this.name}: ${this.type.fromJsonExpression({
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_ConversionFunction = ({ imports, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}ConversionFunction`, code `\
|
|
3
|
+
type ${syntheticNamePrefix}ConversionFunction<SourceT, TargetT> = (source: SourceT) => ${imports.Either}<Error, TargetT>;`);
|
|
4
|
+
//# sourceMappingURL=snippets_ConversionFunction.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_ValidationFunction = ({ imports, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}ValidationFunction`, code `\
|
|
3
|
+
type ${syntheticNamePrefix}ValidationFunction<SchemaT, ValueT> = (schema: SchemaT, value: ValueT) => ${imports.Either}<Error, ValueT>;`);
|
|
4
|
+
//# sourceMappingURL=snippets_ValidationFunction.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_convertToArray = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToArray`, code `\
|
|
3
|
+
function ${syntheticNamePrefix}convertToArray<ItemSourceT, ItemTargetT, Readonly extends boolean>(convertToItem: ${snippets.ConversionFunction}<ItemSourceT, ItemTargetT>, _readonly: Readonly) {
|
|
4
|
+
type EitherR = Readonly extends true ? ReadonlyArray<ItemTargetT> : Array<ItemTargetT>;
|
|
5
|
+
return (value: readonly ItemSourceT[] | undefined): ${imports.Either}<Error, EitherR> =>
|
|
6
|
+
(typeof value === "undefined" ? ${imports.Either}.of([]) : ${imports.Either}.sequence(value.map(convertToItem))) as ${imports.Either}<Error, EitherR>;
|
|
7
|
+
}`);
|
|
8
|
+
//# sourceMappingURL=snippets_convertToArray.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
-
export const snippets_convertToBlankNode = ({ imports,
|
|
3
|
-
function ${syntheticNamePrefix}convertToBlankNode(
|
|
2
|
+
export const snippets_convertToBlankNode = ({ imports, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToBlankNode`, code `\
|
|
3
|
+
function ${syntheticNamePrefix}convertToBlankNode(value: ${imports.BlankNode} | undefined): ${imports.Either}<Error, ${imports.BlankNode}> {
|
|
4
4
|
switch (typeof value) {
|
|
5
5
|
case "object":
|
|
6
6
|
return ${imports.Either}.of(value);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
-
export const snippets_convertToIdentifier = ({ imports,
|
|
3
|
-
function ${syntheticNamePrefix}convertToIdentifier(
|
|
2
|
+
export const snippets_convertToIdentifier = ({ imports, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToIdentifier`, code `\
|
|
3
|
+
function ${syntheticNamePrefix}convertToIdentifier(value: ${imports.BlankNode} | ${imports.NamedNode} | string | undefined): ${imports.Either}<Error, ${imports.BlankNode} | ${imports.NamedNode}> {
|
|
4
4
|
switch (typeof value) {
|
|
5
5
|
case "object":
|
|
6
6
|
return ${imports.Either}.of(value);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
-
export const snippets_convertToIri = ({ imports,
|
|
3
|
-
function ${syntheticNamePrefix}convertToIri<IriT extends string = string>(
|
|
2
|
+
export const snippets_convertToIri = ({ imports, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToIri`, code `\
|
|
3
|
+
function ${syntheticNamePrefix}convertToIri<IriT extends string = string>(value: IriT | ${imports.NamedNode}<IriT>): ${imports.Either}<Error, ${imports.NamedNode}<IriT>> {
|
|
4
4
|
switch (typeof value) {
|
|
5
5
|
case "object":
|
|
6
6
|
return ${imports.Either}.of(value);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_convertToLazyObject = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToLazyObject`, code `\
|
|
3
3
|
function ${syntheticNamePrefix}convertToLazyObject<ObjectIdentifierT extends ${imports.BlankNode} | ${imports.NamedNode}, PartialObjectT extends { ${syntheticNamePrefix}identifier: () => ObjectIdentifierT }, ResolvedObjectT extends { ${syntheticNamePrefix}identifier: () => ObjectIdentifierT }>(resolvedToPartial: (resolved: ResolvedObjectT) => PartialObjectT) {
|
|
4
|
-
return (
|
|
4
|
+
return (value: ${snippets.LazyObject}<ObjectIdentifierT, PartialObjectT, ResolvedObjectT> | ResolvedObjectT): ${imports.Either}<Error, ${snippets.LazyObject}<ObjectIdentifierT, PartialObjectT, ResolvedObjectT>> => {
|
|
5
5
|
if (value instanceof ${snippets.LazyObject}) {
|
|
6
6
|
return ${imports.Either}.of(value);
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_convertToLazyObjectOption = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToLazyObjectOption`, code `\
|
|
3
3
|
function ${syntheticNamePrefix}convertToLazyObjectOption<ObjectIdentifierT extends ${imports.BlankNode} | ${imports.NamedNode}, PartialObjectT extends { ${syntheticNamePrefix}identifier: () => ObjectIdentifierT }, ResolvedObjectT extends { ${syntheticNamePrefix}identifier: () => ObjectIdentifierT }>(resolvedToPartial: (resolved: ResolvedObjectT) => PartialObjectT) {
|
|
4
|
-
return (
|
|
4
|
+
return (value: ${snippets.LazyObjectOption}<ObjectIdentifierT, PartialObjectT, ResolvedObjectT> | ${imports.Maybe}<ResolvedObjectT> | ResolvedObjectT | undefined): ${imports.Either}<Error, ${snippets.LazyObjectOption}<ObjectIdentifierT, PartialObjectT, ResolvedObjectT>> => {
|
|
5
5
|
switch (typeof value) {
|
|
6
6
|
case "object": {
|
|
7
7
|
if (value instanceof ${snippets.LazyObjectOption}) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_convertToLazyObjectSet = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToLazyObjectSet`, code `\
|
|
3
3
|
function ${syntheticNamePrefix}convertToLazyObjectSet<ObjectIdentifierT extends ${imports.BlankNode} | ${imports.NamedNode}, PartialObjectT extends { ${syntheticNamePrefix}identifier: () => ObjectIdentifierT }, ResolvedObjectT extends { ${syntheticNamePrefix}identifier: () => ObjectIdentifierT }>(resolvedToPartial: (resolved: ResolvedObjectT) => PartialObjectT) {
|
|
4
|
-
return (
|
|
4
|
+
return (value: ${snippets.LazyObjectSet}<ObjectIdentifierT, PartialObjectT, ResolvedObjectT> | readonly ResolvedObjectT[] | undefined): ${imports.Either}<Error, ${snippets.LazyObjectSet}<ObjectIdentifierT, PartialObjectT, ResolvedObjectT>> => {
|
|
5
5
|
switch (typeof value) {
|
|
6
6
|
case "object": {
|
|
7
7
|
if (value instanceof ${snippets.LazyObjectSet}) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_convertToLiteral = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToLiteral`, code `\
|
|
3
|
-
function ${syntheticNamePrefix}convertToLiteral(
|
|
3
|
+
function ${syntheticNamePrefix}convertToLiteral(value: bigint | boolean | Date | number | string | ${imports.Literal}): ${imports.Either}<Error, ${imports.Literal}> {
|
|
4
4
|
if (typeof value === "object") {
|
|
5
5
|
if (value instanceof Date) {
|
|
6
6
|
return ${imports.Either}.of(${snippets.literalFactory}.date(value));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_convertToMaybe = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToMaybe`, code `\
|
|
3
|
-
function ${syntheticNamePrefix}convertToMaybe<
|
|
4
|
-
return (
|
|
3
|
+
function ${syntheticNamePrefix}convertToMaybe<ItemSourceT, ItemTargetT>(convertToItem: ${snippets.ConversionFunction}<ItemSourceT, ItemTargetT>) {
|
|
4
|
+
return (value: ItemSourceT | ${imports.Maybe}<ItemTargetT> | undefined): ${imports.Either}<Error, ${imports.Maybe}<ItemTargetT>> => {
|
|
5
5
|
switch (typeof value) {
|
|
6
6
|
case "object": {
|
|
7
7
|
if (${imports.Maybe}.isMaybe(value)) {
|
|
@@ -13,7 +13,7 @@ function ${syntheticNamePrefix}convertToMaybe<ItemSchemaT, ItemSourceT, ItemTarg
|
|
|
13
13
|
return ${imports.Either}.of(${imports.Maybe}.empty());
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
return convertToItem(
|
|
16
|
+
return convertToItem(value).map(${imports.Maybe}.of);
|
|
17
17
|
}
|
|
18
18
|
}`);
|
|
19
19
|
//# sourceMappingURL=snippets_convertToMaybe.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_convertWithDefaultValue = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertWithDefaultValue`, code `\
|
|
3
|
-
function ${syntheticNamePrefix}convertWithDefaultValue<
|
|
4
|
-
return (
|
|
3
|
+
function ${syntheticNamePrefix}convertWithDefaultValue<ItemSourceT, ItemTargetT>(convertToItem: ${snippets.ConversionFunction}<ItemSourceT, ItemTargetT>, defaultValue: ItemSourceT) {
|
|
4
|
+
return (value: ItemSourceT | undefined): ${imports.Either}<Error, ItemTargetT> => {
|
|
5
5
|
if (typeof value === "undefined") {
|
|
6
|
-
return convertToItem(
|
|
6
|
+
return convertToItem(defaultValue);
|
|
7
7
|
}
|
|
8
|
-
return convertToItem(
|
|
8
|
+
return convertToItem(value);
|
|
9
9
|
}
|
|
10
10
|
}`);
|
|
11
11
|
//# sourceMappingURL=snippets_convertWithDefaultValue.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_identityConversionFunction = ({ imports, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}identityConversionFunction`, code `\
|
|
3
|
+
function ${syntheticNamePrefix}identityConversionFunction<T>(value: T): ${imports.Either}<Error, T> {
|
|
4
|
+
return ${imports.Either}.of(value);
|
|
5
|
+
}`);
|
|
6
|
+
//# sourceMappingURL=snippets_identityConversionFunction.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_identityValidationFunction = ({ imports, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}identityValidationFunction`, code `\
|
|
3
|
+
function ${syntheticNamePrefix}identityValidationFunction<T>(_schema: unknown, value: T): ${imports.Either}<Error, T> {
|
|
4
|
+
return ${imports.Either}.of(value);
|
|
5
|
+
}`);
|
|
6
|
+
//# sourceMappingURL=snippets_identityValidationFunction.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_validateArray = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}validateArray`, code `\
|
|
3
|
+
function ${syntheticNamePrefix}validateArray<ItemSchemaT, ItemValueT, Readonly extends boolean>(validateItem: ${snippets.ValidationFunction}<ItemSchemaT, ItemValueT>, _readonly: Readonly) {
|
|
4
|
+
type EitherR = Readonly extends true ? ReadonlyArray<ItemValueT> : Array<ItemValueT>;
|
|
5
|
+
return (schema: ${snippets.CollectionSchema}<ItemSchemaT>, valueArray: readonly ItemValueT[]): ${imports.Either}<Error, EitherR> => {
|
|
6
|
+
if (schema.minCount !== undefined && valueArray.length < schema.minCount) {
|
|
7
|
+
return ${imports.Left}(new Error(\`value array has length (\${valueArray.length}) less than minCount (\${schema.minCount})\`)) as ${imports.Either}<Error, EitherR>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return ${imports.Either}.sequence(valueArray.map(value => validateItem(schema.item(), value))) as ${imports.Either}<Error, EitherR>;
|
|
11
|
+
}
|
|
12
|
+
}`);
|
|
13
|
+
//# sourceMappingURL=snippets_validateArray.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_validateMaybe = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}validateMaybe`, code `\
|
|
3
|
+
function ${syntheticNamePrefix}validateMaybe<ItemSchemaT, ItemValueT>(validateItem: ${snippets.ValidationFunction}<ItemSchemaT, ItemValueT>) {
|
|
4
|
+
return (schema: ${snippets.MaybeSchema}<ItemSchemaT>, valueMaybe: ${imports.Maybe}<ItemValueT>): ${imports.Either}<Error, ${imports.Maybe}<ItemValueT>> =>
|
|
5
|
+
valueMaybe.map(value => validateItem(schema.item(), value).map(() => valueMaybe)).orDefault(${imports.Either}.of(valueMaybe));
|
|
6
|
+
}`);
|
|
7
|
+
//# sourceMappingURL=snippets_validateMaybe.js.map
|
|
@@ -178,7 +178,7 @@ export interface PropertyShape {
|
|
|
178
178
|
}
|
|
179
179
|
export declare namespace PropertyShape {
|
|
180
180
|
function create(parameters: {
|
|
181
|
-
readonly $identifier?: (() => PropertyShape.Identifier) |
|
|
181
|
+
readonly $identifier?: (() => PropertyShape.Identifier) | BlankNode | NamedNode | string;
|
|
182
182
|
readonly and?: readonly (BlankNode | NamedNode | string | undefined)[] | Maybe<readonly (BlankNode | NamedNode)[]>;
|
|
183
183
|
readonly classes?: readonly (string | NamedNode)[];
|
|
184
184
|
readonly comment?: string | Maybe<string>;
|
|
@@ -217,7 +217,7 @@ export declare namespace PropertyShape {
|
|
|
217
217
|
readonly xone?: readonly (BlankNode | NamedNode | string | undefined)[] | Maybe<readonly (BlankNode | NamedNode)[]>;
|
|
218
218
|
}): Either<Error, PropertyShape>;
|
|
219
219
|
function createUnsafe(parameters: {
|
|
220
|
-
readonly $identifier?: (() => PropertyShape.Identifier) |
|
|
220
|
+
readonly $identifier?: (() => PropertyShape.Identifier) | BlankNode | NamedNode | string;
|
|
221
221
|
readonly and?: readonly (BlankNode | NamedNode | string | undefined)[] | Maybe<readonly (BlankNode | NamedNode)[]>;
|
|
222
222
|
readonly classes?: readonly (string | NamedNode)[];
|
|
223
223
|
readonly comment?: string | Maybe<string>;
|
|
@@ -708,12 +708,12 @@ export interface PropertyGroup {
|
|
|
708
708
|
}
|
|
709
709
|
export declare namespace PropertyGroup {
|
|
710
710
|
function create(parameters?: {
|
|
711
|
-
readonly $identifier?: (() => PropertyGroup.Identifier) |
|
|
711
|
+
readonly $identifier?: (() => PropertyGroup.Identifier) | BlankNode | NamedNode | string;
|
|
712
712
|
readonly comment?: string | Maybe<string>;
|
|
713
713
|
readonly label?: string | Maybe<string>;
|
|
714
714
|
}): Either<Error, PropertyGroup>;
|
|
715
715
|
function createUnsafe(parameters?: {
|
|
716
|
-
readonly $identifier?: (() => PropertyGroup.Identifier) |
|
|
716
|
+
readonly $identifier?: (() => PropertyGroup.Identifier) | BlankNode | NamedNode | string;
|
|
717
717
|
readonly comment?: string | Maybe<string>;
|
|
718
718
|
readonly label?: string | Maybe<string>;
|
|
719
719
|
}): PropertyGroup;
|
|
@@ -784,12 +784,12 @@ export interface Ontology {
|
|
|
784
784
|
}
|
|
785
785
|
export declare namespace Ontology {
|
|
786
786
|
function create(parameters?: {
|
|
787
|
-
readonly $identifier?: (() => Ontology.Identifier) |
|
|
787
|
+
readonly $identifier?: (() => Ontology.Identifier) | BlankNode | NamedNode | string;
|
|
788
788
|
readonly comment?: string | Maybe<string>;
|
|
789
789
|
readonly label?: string | Maybe<string>;
|
|
790
790
|
}): Either<Error, Ontology>;
|
|
791
791
|
function createUnsafe(parameters?: {
|
|
792
|
-
readonly $identifier?: (() => Ontology.Identifier) |
|
|
792
|
+
readonly $identifier?: (() => Ontology.Identifier) | BlankNode | NamedNode | string;
|
|
793
793
|
readonly comment?: string | Maybe<string>;
|
|
794
794
|
readonly label?: string | Maybe<string>;
|
|
795
795
|
}): Ontology;
|
|
@@ -896,7 +896,7 @@ export interface NodeShape {
|
|
|
896
896
|
}
|
|
897
897
|
export declare namespace NodeShape {
|
|
898
898
|
function create(parameters?: {
|
|
899
|
-
readonly $identifier?: (() => NodeShape.Identifier) |
|
|
899
|
+
readonly $identifier?: (() => NodeShape.Identifier) | BlankNode | NamedNode | string;
|
|
900
900
|
readonly and?: readonly (BlankNode | NamedNode | string | undefined)[] | Maybe<readonly (BlankNode | NamedNode)[]>;
|
|
901
901
|
readonly classes?: readonly (string | NamedNode)[];
|
|
902
902
|
readonly closed?: boolean | Maybe<boolean>;
|
|
@@ -937,7 +937,7 @@ export declare namespace NodeShape {
|
|
|
937
937
|
readonly xone?: readonly (BlankNode | NamedNode | string | undefined)[] | Maybe<readonly (BlankNode | NamedNode)[]>;
|
|
938
938
|
}): Either<Error, NodeShape>;
|
|
939
939
|
function createUnsafe(parameters?: {
|
|
940
|
-
readonly $identifier?: (() => NodeShape.Identifier) |
|
|
940
|
+
readonly $identifier?: (() => NodeShape.Identifier) | BlankNode | NamedNode | string;
|
|
941
941
|
readonly and?: readonly (BlankNode | NamedNode | string | undefined)[] | Maybe<readonly (BlankNode | NamedNode)[]>;
|
|
942
942
|
readonly classes?: readonly (string | NamedNode)[];
|
|
943
943
|
readonly closed?: boolean | Maybe<boolean>;
|