@shaclmate/compiler 4.0.96 → 4.0.98
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/_ShapesGraphToAstTransformer/synthesizePartialAstStructType.d.ts +6 -0
- package/dist/_ShapesGraphToAstTransformer/synthesizePartialAstStructType.js +38 -0
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstStructTypeField.js +114 -145
- package/dist/_ShapesGraphToAstTransformer/transformShapeNodeConstraintToAstType.d.ts +7 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeNodeConstraintToAstType.js +13 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstStructType.d.ts +1 -1
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstStructType.js +0 -52
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.js +2 -0
- package/dist/ast/StructCompoundType.d.ts +3 -2
- package/dist/ast/StructCompoundType.js +29 -46
- package/dist/ast/StructDiscriminatedUnionType.d.ts +5 -1
- package/dist/ast/StructIntersectionType.d.ts +4 -1
- package/dist/generators/ts/AbstractLazyType.js +4 -4
- package/dist/generators/ts/AbstractStructuredType.js +2 -2
- package/dist/generators/ts/Imports.d.ts +1 -0
- package/dist/generators/ts/Imports.js +1 -0
- package/dist/generators/ts/IriType.js +13 -3
- package/dist/generators/ts/ObjectDiscriminatedUnionType.d.ts +7 -4
- package/dist/generators/ts/ObjectDiscriminatedUnionType.js +18 -2
- package/dist/generators/ts/ObjectIntersectionType.d.ts +7 -4
- package/dist/generators/ts/RdfjsDatasetObjectSetType.js +21 -10
- package/dist/generators/ts/Snippets.d.ts +7 -6
- package/dist/generators/ts/Snippets.js +41 -34
- package/dist/generators/ts/TypeFactory.js +19 -33
- package/dist/generators/ts/_ObjectIntersectionType/ObjectIntersectionType_fromJsonObjectFunction.js +1 -1
- package/dist/generators/ts/_ObjectType/ObjectType_IdentifierProperty.js +1 -1
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonObjectFunction.js +7 -2
- package/dist/generators/ts/_ObjectType/ObjectType_toJsonObjectFunction.js +1 -1
- package/dist/generators/ts/_snippets/snippets_FromJsonFunction.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_FromJsonFunction.js +28 -0
- package/dist/generators/ts/_snippets/snippets_ToJsonFunction.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_ToJsonFunction.js +3 -0
- package/dist/generators/ts/_snippets/snippets_arrayFromJsonArray.js +1 -1
- package/dist/generators/ts/_snippets/snippets_arrayToJsonArray.js +1 -1
- package/dist/generators/ts/_snippets/snippets_bigDecimalFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_bigDecimalFromJsonString.js +1 -1
- package/dist/generators/ts/_snippets/snippets_bigDecimalToJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_bigDecimalToJsonString.js +1 -1
- package/dist/generators/ts/_snippets/snippets_bigIntFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_bigIntFromJsonString.js +1 -1
- package/dist/generators/ts/_snippets/snippets_bigIntToJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_bigIntToJsonString.js +1 -1
- package/dist/generators/ts/_snippets/snippets_blankNodeFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_blankNodeFromJsonString.js +1 -1
- package/dist/generators/ts/_snippets/snippets_blankNodeToJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_blankNodeToJsonString.js +1 -1
- package/dist/generators/ts/_snippets/snippets_booleanFromJsonBoolean.js +1 -1
- package/dist/generators/ts/_snippets/snippets_booleanFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_convertToIdentifier.js +1 -1
- package/dist/generators/ts/_snippets/snippets_convertToIdentifierProperty.js +2 -4
- package/dist/generators/ts/_snippets/snippets_convertToIri.js +1 -1
- package/dist/generators/ts/_snippets/snippets_convertToIriIdentifierProperty.js +1 -2
- package/dist/generators/ts/_snippets/snippets_convertToIriLiteral.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToIriLiteral.js +11 -0
- package/dist/generators/ts/_snippets/snippets_convertToIriLiteralIdentifierProperty.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToIriLiteralIdentifierProperty.js +17 -0
- package/dist/generators/ts/_snippets/snippets_dateFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_dateFromJsonString.js +1 -1
- package/dist/generators/ts/_snippets/snippets_dateTimeFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_dateTimeToJsonString.js +1 -1
- package/dist/generators/ts/_snippets/snippets_dateToJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_dateToJsonString.js +1 -1
- package/dist/generators/ts/_snippets/snippets_defaultValueFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_defaultValueFromJsonValue.js +1 -1
- package/dist/generators/ts/_snippets/snippets_floatFromJsonNumber.js +1 -1
- package/dist/generators/ts/_snippets/snippets_floatFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_identifierFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_identifierFromJsonString.js +1 -1
- package/dist/generators/ts/_snippets/snippets_identifierToJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_identifierToJsonString.js +1 -1
- package/dist/generators/ts/_snippets/snippets_intFromJsonNumber.js +1 -1
- package/dist/generators/ts/_snippets/snippets_intFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_iriFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_iriFromJsonString.js +2 -2
- package/dist/generators/ts/_snippets/snippets_iriFromString.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_iriFromString.js +76 -0
- package/dist/generators/ts/_snippets/snippets_iriLiteralFromJsonObject.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_iriLiteralFromJsonObject.js +6 -0
- package/dist/generators/ts/_snippets/snippets_iriLiteralFromJsonString.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_iriLiteralFromJsonString.js +6 -0
- package/dist/generators/ts/_snippets/snippets_langStringFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_langStringToJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_listFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_listToJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_literalFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_literalToJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_maybeFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_maybeFromJsonValue.js +1 -1
- package/dist/generators/ts/_snippets/snippets_maybeToJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_maybeToJsonValue.js +1 -1
- package/dist/generators/ts/_snippets/snippets_primitiveToJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_stringFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_stringFromJsonString.js +1 -1
- package/dist/generators/ts/_snippets/snippets_termFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_termToJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_typedLiteralToJsonObject.js +1 -1
- package/dist/input/input.shaclmate.d.ts +2474 -2124
- package/dist/input/input.shaclmate.js +558 -1292
- package/dist/input/input.shaclmate.ttl +9 -5
- package/package.json +20 -16
- package/dist/generators/ts/_ObjectDiscriminatedUnionType/ObjectDiscriminatedUnionType_schemaExpression.d.ts +0 -4
- package/dist/generators/ts/_ObjectDiscriminatedUnionType/ObjectDiscriminatedUnionType_schemaExpression.js +0 -37
- package/dist/generators/ts/_snippets/snippets_FromJsonObjectFunction.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_FromJsonObjectFunction.js +0 -21
- package/dist/generators/ts/_snippets/snippets_FromJsonValueFunction.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_FromJsonValueFunction.js +0 -21
- package/dist/generators/ts/_snippets/snippets_ToJsonObjectFunction.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_ToJsonObjectFunction.js +0 -3
- package/dist/generators/ts/_snippets/snippets_ToJsonValueFunction.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_ToJsonValueFunction.js +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToInIri.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToInIri.js +0 -11
- package/dist/generators/ts/_snippets/snippets_convertToInIriIdentifierProperty.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToInIriIdentifierProperty.js +0 -17
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { code, conditionalOutput, joinCode, } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_FromJsonFunction = ({ configuration, imports, snippets, syntheticNamePrefix, }) => {
|
|
3
|
+
const options = [code `context?: unknown;`];
|
|
4
|
+
options.push(code `defaultNamespace?: ${snippets.NamespaceBuilder};`);
|
|
5
|
+
if (configuration.features.has("ObjectSet")) {
|
|
6
|
+
options.push(code `objectSet?: ${syntheticNamePrefix}ObjectSet;`);
|
|
7
|
+
}
|
|
8
|
+
options.push(code `prefixMap?: ${imports.PrefixMap};`);
|
|
9
|
+
const joinedOptions = joinCode(options.map((option) => code ` ${option}`), { on: "\n" });
|
|
10
|
+
return conditionalOutput(`${syntheticNamePrefix}FromJsonFunction`, code `\
|
|
11
|
+
export type ${syntheticNamePrefix}FromJsonFunction<JsonValueT, ValueT, ValueSchemaT> =
|
|
12
|
+
[ValueSchemaT] extends [undefined]
|
|
13
|
+
? (
|
|
14
|
+
jsonValue: JsonValueT,
|
|
15
|
+
options?: {
|
|
16
|
+
${joinedOptions}
|
|
17
|
+
schema?: unknown;
|
|
18
|
+
},
|
|
19
|
+
) => ${imports.Either}<Error, ValueT>
|
|
20
|
+
: (
|
|
21
|
+
jsonValue: JsonValueT,
|
|
22
|
+
options: {
|
|
23
|
+
${joinedOptions}
|
|
24
|
+
schema: ValueSchemaT;
|
|
25
|
+
},
|
|
26
|
+
) => ${imports.Either}<Error, ValueT>;`);
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=snippets_FromJsonFunction.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_ToJsonFunction = ({ syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}ToJsonFunction`, code `export type ${syntheticNamePrefix}ToJsonFunction<T, JsonT> = (value: T) => JsonT;`);
|
|
3
|
+
//# sourceMappingURL=snippets_ToJsonFunction.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_arrayFromJsonArray = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}arrayFromJsonArray`, code `\
|
|
3
|
-
function ${syntheticNamePrefix}arrayFromJsonArray<ItemJsonValueT, ItemT, ItemSchemaT>(itemFromJsonValue: ${snippets.
|
|
3
|
+
function ${syntheticNamePrefix}arrayFromJsonArray<ItemJsonValueT, ItemT, ItemSchemaT>(itemFromJsonValue: ${snippets.FromJsonFunction}<ItemJsonValueT, ItemT, ItemSchemaT>): ${snippets.FromJsonFunction}<ItemJsonValueT[] | undefined, ItemT[], ${snippets.CollectionSchema}<ItemSchemaT>> {
|
|
4
4
|
return (jsonArray, options) => {
|
|
5
5
|
if (jsonArray === undefined) {
|
|
6
6
|
return ${imports.Either}.of([]);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_arrayToJsonArray = ({ snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}arrayToJsonArray`, code `\
|
|
3
|
-
function ${syntheticNamePrefix}arrayToJsonArray<ItemT, ItemJsonValueT>(itemToJsonValue: ${snippets.
|
|
3
|
+
function ${syntheticNamePrefix}arrayToJsonArray<ItemT, ItemJsonValueT>(itemToJsonValue: ${snippets.ToJsonFunction}<ItemT, ItemJsonValueT>): ${snippets.ToJsonFunction}<readonly ItemT[], ItemJsonValueT[]> {
|
|
4
4
|
return (array) => array.map(itemToJsonValue);
|
|
5
5
|
}`);
|
|
6
6
|
//# sourceMappingURL=snippets_arrayToJsonArray.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_bigDecimalFromJsonObject = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}bigDecimalFromJsonObject`, code `\
|
|
3
|
-
const ${syntheticNamePrefix}bigDecimalFromJsonObject: ${snippets.
|
|
3
|
+
const ${syntheticNamePrefix}bigDecimalFromJsonObject: ${snippets.FromJsonFunction}<${snippets.TypedLiteralJsonObject}, ${imports.BigDecimal}, ${snippets.NumericSchema}<${imports.BigDecimal}>> =
|
|
4
4
|
(jsonObject, options) => ${snippets.literalFromJsonObject}(jsonObject, options).chain(${imports.LiteralDecoder}.decodeBigDecimalLiteral);`);
|
|
5
5
|
//# sourceMappingURL=snippets_bigDecimalFromJsonObject.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_bigDecimalFromJsonString = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}bigDecimalFromJsonString`, code `\
|
|
3
|
-
const ${syntheticNamePrefix}bigDecimalFromJsonString: ${snippets.
|
|
3
|
+
const ${syntheticNamePrefix}bigDecimalFromJsonString: ${snippets.FromJsonFunction}<string, ${imports.BigDecimal}, ${snippets.NumericSchema}<${imports.BigDecimal}>> =
|
|
4
4
|
(jsonValue) => ${imports.Either}.encase(() => new ${imports.BigDecimal}(jsonValue));`);
|
|
5
5
|
//# sourceMappingURL=snippets_bigDecimalFromJsonString.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_bigDecimalToJsonObject = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}bigDecimalToJsonObject`, code `\
|
|
3
|
-
function ${syntheticNamePrefix}bigDecimalToJsonObject(datatype: ${imports.NamedNode}): ${snippets.
|
|
3
|
+
function ${syntheticNamePrefix}bigDecimalToJsonObject(datatype: ${imports.NamedNode}): ${snippets.ToJsonFunction}<${imports.BigDecimal}, ${snippets.TypedLiteralJsonObject}> {
|
|
4
4
|
return (value) => ${snippets.typedLiteralToJsonObject}(${snippets.literalFactory}.bigdecimal(value, datatype));
|
|
5
5
|
}`);
|
|
6
6
|
//# sourceMappingURL=snippets_bigDecimalToJsonObject.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_bigDecimalToJsonString = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}bigDecimalToJsonString`, code `\
|
|
3
|
-
const ${syntheticNamePrefix}bigDecimalToJsonString: ${snippets.
|
|
3
|
+
const ${syntheticNamePrefix}bigDecimalToJsonString: ${snippets.ToJsonFunction}<${imports.BigDecimal}, string> =
|
|
4
4
|
(bigDecimal) => bigDecimal.toFixed();`);
|
|
5
5
|
//# sourceMappingURL=snippets_bigDecimalToJsonString.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_bigIntFromJsonObject = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}bigIntFromJsonObject`, code `\
|
|
3
|
-
function ${syntheticNamePrefix}bigIntFromJsonObject<BigIntT extends bigint>(jsonObject: ${snippets.TypedLiteralJsonObject}, options: Parameters<${snippets.
|
|
3
|
+
function ${syntheticNamePrefix}bigIntFromJsonObject<BigIntT extends bigint>(jsonObject: ${snippets.TypedLiteralJsonObject}, options: Parameters<${snippets.FromJsonFunction}<${snippets.TypedLiteralJsonObject}, BigIntT, ${snippets.NumericSchema}<BigIntT>>>[1]): ${imports.Either}<Error, BigIntT> {
|
|
4
4
|
const { schema } = options;
|
|
5
5
|
return ${snippets.literalFromJsonObject}(jsonObject)
|
|
6
6
|
.chain(${imports.LiteralDecoder}.decodeBigIntLiteral)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_bigIntFromJsonString = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}bigIntFromJsonString`, code `\
|
|
3
|
-
function ${syntheticNamePrefix}bigIntFromJsonString<JsonValueT extends string, BigIntT extends bigint>(jsonValue: JsonValueT, options: Parameters<${snippets.
|
|
3
|
+
function ${syntheticNamePrefix}bigIntFromJsonString<JsonValueT extends string, BigIntT extends bigint>(jsonValue: JsonValueT, options: Parameters<${snippets.FromJsonFunction}<string, BigIntT, ${snippets.NumericSchema}<BigIntT>>>[1]): ${imports.Either}<Error, BigIntT> {
|
|
4
4
|
const { schema } = options;
|
|
5
5
|
return ${imports.Either}.encase(() => BigInt(jsonValue) as BigIntT)
|
|
6
6
|
.chain(value => ${snippets.constrainPrimitive}<BigIntT, bigint>(value, schema.in)) as ${imports.Either}<Error, BigIntT>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_bigIntToJsonObject = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}bigIntToJsonObject`, code `\
|
|
3
|
-
function ${syntheticNamePrefix}bigIntToJsonObject(datatype: ${imports.NamedNode}): ${snippets.
|
|
3
|
+
function ${syntheticNamePrefix}bigIntToJsonObject(datatype: ${imports.NamedNode}): ${snippets.ToJsonFunction}<bigint, ${snippets.TypedLiteralJsonObject}> {
|
|
4
4
|
return (value) => ${snippets.typedLiteralToJsonObject}(${snippets.literalFactory}.bigint(value, datatype));
|
|
5
5
|
}`);
|
|
6
6
|
//# sourceMappingURL=snippets_bigIntToJsonObject.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_bigIntToJsonString = ({ snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}bigIntToJsonString`, code `\
|
|
3
|
-
const ${syntheticNamePrefix}bigIntToJsonString: ${snippets.
|
|
3
|
+
const ${syntheticNamePrefix}bigIntToJsonString: ${snippets.ToJsonFunction}<bigint, string> =
|
|
4
4
|
(bigInt) => bigInt.toString();`);
|
|
5
5
|
//# sourceMappingURL=snippets_bigIntToJsonString.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_blankNodeFromJsonObject = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}blankNodeFromJsonObject`, code `\
|
|
3
|
-
const ${syntheticNamePrefix}blankNodeFromJsonObject: ${snippets.
|
|
3
|
+
const ${syntheticNamePrefix}blankNodeFromJsonObject: ${snippets.FromJsonFunction}<${snippets.IdentifierJsonObject}, ${imports.BlankNode}, undefined> =
|
|
4
4
|
(jsonObject) => ${snippets.blankNodeFromJsonString}(jsonObject["@id"]);`);
|
|
5
5
|
//# sourceMappingURL=snippets_blankNodeFromJsonObject.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_blankNodeFromJsonString = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}blankNodeFromJsonString`, code `\
|
|
3
|
-
const ${syntheticNamePrefix}blankNodeFromJsonString: ${snippets.
|
|
3
|
+
const ${syntheticNamePrefix}blankNodeFromJsonString: ${snippets.FromJsonFunction}<string, ${imports.BlankNode}, undefined> =
|
|
4
4
|
(jsonValue) => ${imports.Right}(${imports.dataFactory}.blankNode(jsonValue.substring(2)));`);
|
|
5
5
|
//# sourceMappingURL=snippets_blankNodeFromJsonString.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_blankNodeToJsonObject = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}blankNodeToJsonObject`, code `\
|
|
3
|
-
const ${syntheticNamePrefix}blankNodeToJsonObject: ${snippets.
|
|
3
|
+
const ${syntheticNamePrefix}blankNodeToJsonObject: ${snippets.ToJsonFunction}<${imports.BlankNode}, ${snippets.IdentifierJsonObject}> =
|
|
4
4
|
(blankNode) => ({ "@id": ${snippets.blankNodeToJsonString}(blankNode) });`);
|
|
5
5
|
//# sourceMappingURL=snippets_blankNodeToJsonObject.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_blankNodeToJsonString = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}blankNodeToJsonString`, code `\
|
|
3
|
-
const ${syntheticNamePrefix}blankNodeToJsonString: ${snippets.
|
|
3
|
+
const ${syntheticNamePrefix}blankNodeToJsonString: ${snippets.ToJsonFunction}<${imports.BlankNode}, string> =
|
|
4
4
|
(blankNode) => \`_:\${blankNode.value}\`;`);
|
|
5
5
|
//# sourceMappingURL=snippets_blankNodeToJsonString.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_booleanFromJsonBoolean = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}booleanFromJsonBoolean`, code `\
|
|
3
|
-
function ${syntheticNamePrefix}booleanFromJsonBoolean<BooleanT extends boolean>(jsonBoolean: BooleanT, _options: Parameters<${snippets.
|
|
3
|
+
function ${syntheticNamePrefix}booleanFromJsonBoolean<BooleanT extends boolean>(jsonBoolean: BooleanT, _options: Parameters<${snippets.FromJsonFunction}<BooleanT, BooleanT, ${snippets.BooleanSchema}<BooleanT>>>[1]): ${imports.Either}<Error, BooleanT> {
|
|
4
4
|
return ${imports.Either}.of(jsonBoolean);
|
|
5
5
|
}`);
|
|
6
6
|
//# sourceMappingURL=snippets_booleanFromJsonBoolean.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_booleanFromJsonObject = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}booleanFromJsonObject`, code `\
|
|
3
|
-
function ${syntheticNamePrefix}booleanFromJsonObject<BooleanT extends boolean>(jsonObject: ${snippets.TypedLiteralJsonObject}, options: Parameters<${snippets.
|
|
3
|
+
function ${syntheticNamePrefix}booleanFromJsonObject<BooleanT extends boolean>(jsonObject: ${snippets.TypedLiteralJsonObject}, options: Parameters<${snippets.FromJsonFunction}<${snippets.TypedLiteralJsonObject}, BooleanT, ${snippets.BooleanSchema}<BooleanT>>>[1]): ${imports.Either}<Error, BooleanT> {
|
|
4
4
|
const { schema } = options;
|
|
5
5
|
return ${snippets.literalFromJsonObject}(jsonObject)
|
|
6
6
|
.chain(${imports.LiteralDecoder}.decodeBooleanLiteral)
|
|
@@ -5,7 +5,7 @@ function ${syntheticNamePrefix}convertToIdentifier<DefaultNamespaceT extends ${s
|
|
|
5
5
|
case "object":
|
|
6
6
|
return ${imports.Either}.of(value);
|
|
7
7
|
case "string":
|
|
8
|
-
return ${
|
|
8
|
+
return ${snippets.iriFromString}(value, { defaultNamespace });
|
|
9
9
|
case "undefined":
|
|
10
10
|
return ${imports.Either}.of(${imports.dataFactory}.blankNode());
|
|
11
11
|
}
|
|
@@ -8,10 +8,8 @@ function ${syntheticNamePrefix}convertToIdentifierProperty<DefaultNamespaceT ext
|
|
|
8
8
|
const captureIdentifier = identifier;
|
|
9
9
|
return ${imports.Either}.of(() => captureIdentifier);
|
|
10
10
|
}
|
|
11
|
-
case "string":
|
|
12
|
-
|
|
13
|
-
return ${imports.Either}.of(() => captureIdentifier);
|
|
14
|
-
}
|
|
11
|
+
case "string":
|
|
12
|
+
return ${snippets.iriFromString}(identifier, { defaultNamespace }).map(iri => (() => iri));
|
|
15
13
|
case "undefined": {
|
|
16
14
|
const captureIdentifier = ${imports.dataFactory}.blankNode();
|
|
17
15
|
return ${imports.Either}.of(() => captureIdentifier);
|
|
@@ -5,7 +5,7 @@ function ${syntheticNamePrefix}convertToIri<DefaultNamespaceT extends ${snippets
|
|
|
5
5
|
case "object":
|
|
6
6
|
return ${imports.Either}.of(value);
|
|
7
7
|
case "string":
|
|
8
|
-
return ${
|
|
8
|
+
return ${snippets.iriFromString}(value, { defaultNamespace });
|
|
9
9
|
}
|
|
10
10
|
}`);
|
|
11
11
|
//# sourceMappingURL=snippets_convertToIri.js.map
|
|
@@ -9,8 +9,7 @@ function ${syntheticNamePrefix}convertToIriIdentifierProperty<DefaultNamespaceT
|
|
|
9
9
|
return ${imports.Either}.of(() => captureIdentifier);
|
|
10
10
|
}
|
|
11
11
|
case "string": {
|
|
12
|
-
|
|
13
|
-
return ${imports.Either}.of(() => captureIdentifier);
|
|
12
|
+
return ${snippets.iriFromString}(identifier, { defaultNamespace }).map(iri => (() => iri));
|
|
14
13
|
}
|
|
15
14
|
}
|
|
16
15
|
}`);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_convertToIriLiteral = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToIriLiteral`, code `\
|
|
3
|
+
function ${syntheticNamePrefix}convertToIriLiteral<IriT extends string>(value: IriT | ${imports.NamedNode}<IriT>, _defaultNamespace?: ${snippets.NamespaceBuilder}): ${imports.Either}<Error, ${imports.NamedNode}<IriT>> {
|
|
4
|
+
switch (typeof value) {
|
|
5
|
+
case "object":
|
|
6
|
+
return ${imports.Either}.of(value);
|
|
7
|
+
case "string":
|
|
8
|
+
return ${imports.Either}.of(${imports.dataFactory}.namedNode<IriT>(value));
|
|
9
|
+
}
|
|
10
|
+
}`);
|
|
11
|
+
//# sourceMappingURL=snippets_convertToIriLiteral.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_convertToIriLiteralIdentifierProperty = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToIriLiteralIdentifierProperty`, code `\
|
|
3
|
+
function ${syntheticNamePrefix}convertToIriLiteralIdentifierProperty<InIriT extends string>(identifier: (() => ${imports.NamedNode}<InIriT>) | ${imports.NamedNode}<InIriT> | InIriT, _defaultNamespace?: ${snippets.NamespaceBuilder}): ${imports.Either}<Error, (() => ${imports.NamedNode}<InIriT>)> {
|
|
4
|
+
switch (typeof identifier) {
|
|
5
|
+
case "function":
|
|
6
|
+
return ${imports.Either}.of(identifier);
|
|
7
|
+
case "object": {
|
|
8
|
+
const captureIdentifier = identifier;
|
|
9
|
+
return ${imports.Either}.of(() => captureIdentifier);
|
|
10
|
+
}
|
|
11
|
+
case "string": {
|
|
12
|
+
const captureIdentifier = ${imports.dataFactory}.namedNode<InIriT>(identifier);
|
|
13
|
+
return ${imports.Either}.of(() => captureIdentifier);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}`);
|
|
17
|
+
//# sourceMappingURL=snippets_convertToIriLiteralIdentifierProperty.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_dateFromJsonObject = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}dateFromJsonObject`, code `\
|
|
3
|
-
const ${syntheticNamePrefix}dateFromJsonObject: ${snippets.
|
|
3
|
+
const ${syntheticNamePrefix}dateFromJsonObject: ${snippets.FromJsonFunction}<${snippets.TypedLiteralJsonObject}, Date, undefined> =
|
|
4
4
|
(jsonObject) => ${snippets.literalFromJsonObject}(jsonObject).chain(${imports.LiteralDecoder}.decodeDateLiteral);`);
|
|
5
5
|
//# sourceMappingURL=snippets_dateFromJsonObject.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_dateFromJsonString = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}dateFromJsonString`, code `\
|
|
3
|
-
const ${syntheticNamePrefix}dateFromJsonString: ${snippets.
|
|
3
|
+
const ${syntheticNamePrefix}dateFromJsonString: ${snippets.FromJsonFunction}<string, Date, ${snippets.DateSchema}> =
|
|
4
4
|
(jsonValue) => ${imports.Either}.encase(() => new Date(jsonValue));`);
|
|
5
5
|
//# sourceMappingURL=snippets_dateFromJsonString.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_dateTimeFromJsonObject = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}dateTimeFromJsonObject`, code `\
|
|
3
|
-
const ${syntheticNamePrefix}dateTimeFromJsonObject: ${snippets.
|
|
3
|
+
const ${syntheticNamePrefix}dateTimeFromJsonObject: ${snippets.FromJsonFunction}<${snippets.TypedLiteralJsonObject}, Date, undefined> =
|
|
4
4
|
(jsonObject) => ${snippets.literalFromJsonObject}(jsonObject).chain(${imports.LiteralDecoder}.decodeDateTimeLiteral);`);
|
|
5
5
|
//# sourceMappingURL=snippets_dateTimeFromJsonObject.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_dateTimeToJsonString = ({ snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}dateTimeToJsonString`, code `\
|
|
3
|
-
const ${syntheticNamePrefix}dateTimeToJsonString: ${snippets.
|
|
3
|
+
const ${syntheticNamePrefix}dateTimeToJsonString: ${snippets.ToJsonFunction}<Date, string> =
|
|
4
4
|
(date) => date.toISOString();`);
|
|
5
5
|
//# sourceMappingURL=snippets_dateTimeToJsonString.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_dateToJsonObject = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}dateToJsonObject`, code `\
|
|
3
|
-
function ${syntheticNamePrefix}dateToJsonObject(datatype: ${imports.NamedNode}): ${snippets.
|
|
3
|
+
function ${syntheticNamePrefix}dateToJsonObject(datatype: ${imports.NamedNode}): ${snippets.ToJsonFunction}<Date, ${snippets.TypedLiteralJsonObject}> {
|
|
4
4
|
return (value) => ${snippets.typedLiteralToJsonObject}(${snippets.literalFactory}.date(value, datatype));
|
|
5
5
|
}`);
|
|
6
6
|
//# sourceMappingURL=snippets_dateToJsonObject.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_dateToJsonString = ({ snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}dateToJsonString`, code `\
|
|
3
|
-
const ${syntheticNamePrefix}dateToJsonString: ${snippets.
|
|
3
|
+
const ${syntheticNamePrefix}dateToJsonString: ${snippets.ToJsonFunction}<Date, string> =
|
|
4
4
|
(date) => ${snippets.toIsoDateString}(date);`);
|
|
5
5
|
//# sourceMappingURL=snippets_dateToJsonString.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_defaultValueFromJsonObject = ({ snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}defaultValueFromJsonObject`, code `\
|
|
3
|
-
function ${syntheticNamePrefix}defaultValueFromJsonObject<ItemJsonObjectT extends object, ItemT, ItemSchemaT>(itemFromJsonObject: ${snippets.
|
|
3
|
+
function ${syntheticNamePrefix}defaultValueFromJsonObject<ItemJsonObjectT extends object, ItemT, ItemSchemaT>(itemFromJsonObject: ${snippets.FromJsonFunction}<ItemJsonObjectT, ItemT, ItemSchemaT>): ${snippets.FromJsonFunction}<ItemJsonObjectT, ItemT, ${snippets.DefaultValueSchema}<ItemSchemaT>> {
|
|
4
4
|
return (jsonObject, options) => {
|
|
5
5
|
const { schema, ...otherOptions } = options;
|
|
6
6
|
return itemFromJsonObject(jsonObject, { schema: schema.itemType, ...otherOptions });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_defaultValueFromJsonValue = ({ snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}defaultValueFromJsonValue`, code `\
|
|
3
|
-
function ${syntheticNamePrefix}defaultValueFromJsonValue<ItemJsonValueT, ItemT, ItemSchemaT>(itemFromJsonValue: ${snippets.
|
|
3
|
+
function ${syntheticNamePrefix}defaultValueFromJsonValue<ItemJsonValueT, ItemT, ItemSchemaT>(itemFromJsonValue: ${snippets.FromJsonFunction}<ItemJsonValueT, ItemT, ItemSchemaT>): ${snippets.FromJsonFunction}<ItemJsonValueT, ItemT, ${snippets.DefaultValueSchema}<ItemSchemaT>> {
|
|
4
4
|
return (jsonValue, options) => {
|
|
5
5
|
const { schema, ...otherOptions } = options;
|
|
6
6
|
return itemFromJsonValue(jsonValue, { schema: schema.itemType, ...otherOptions });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_floatFromJsonNumber = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}floatFromJsonNumber`, code `\
|
|
3
|
-
function ${syntheticNamePrefix}floatFromJsonNumber<FloatT extends number>(jsonNumber: FloatT, _options: Parameters<${snippets.
|
|
3
|
+
function ${syntheticNamePrefix}floatFromJsonNumber<FloatT extends number>(jsonNumber: FloatT, _options: Parameters<${snippets.FromJsonFunction}<FloatT, FloatT, ${snippets.NumericSchema}<FloatT>>>[1]): ${imports.Either}<Error, FloatT> {
|
|
4
4
|
return ${imports.Either}.of(jsonNumber);
|
|
5
5
|
}`);
|
|
6
6
|
//# sourceMappingURL=snippets_floatFromJsonNumber.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_floatFromJsonObject = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}floatFromJsonObject`, code `\
|
|
3
|
-
function ${syntheticNamePrefix}floatFromJsonObject<FloatT extends number>(jsonObject: ${snippets.TypedLiteralJsonObject}, options: Parameters<${snippets.
|
|
3
|
+
function ${syntheticNamePrefix}floatFromJsonObject<FloatT extends number>(jsonObject: ${snippets.TypedLiteralJsonObject}, options: Parameters<${snippets.FromJsonFunction}<${snippets.TypedLiteralJsonObject}, FloatT, ${snippets.NumericSchema}<FloatT>>>[1]): ${imports.Either}<Error, FloatT> {
|
|
4
4
|
const { schema } = options;
|
|
5
5
|
return ${snippets.literalFromJsonObject}(jsonObject)
|
|
6
6
|
.chain(${imports.LiteralDecoder}.decodeFloatLiteral)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_identifierFromJsonObject = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}identifierFromJsonObject`, code `\
|
|
3
|
-
const ${syntheticNamePrefix}identifierFromJsonObject: ${snippets.
|
|
3
|
+
const ${syntheticNamePrefix}identifierFromJsonObject: ${snippets.FromJsonFunction}<${snippets.IdentifierJsonObject}, ${imports.BlankNode} | ${imports.NamedNode}, ${snippets.IdentifierSchema}> =
|
|
4
4
|
(jsonObject, options) => ${snippets.identifierFromJsonString}(jsonObject["@id"], options);`);
|
|
5
5
|
//# sourceMappingURL=snippets_identifierFromJsonObject.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_identifierFromJsonString = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}identifierFromJsonString`, code `\
|
|
3
|
-
const ${syntheticNamePrefix}identifierFromJsonString: ${snippets.
|
|
3
|
+
const ${syntheticNamePrefix}identifierFromJsonString: ${snippets.FromJsonFunction}<string, ${imports.BlankNode} | ${imports.NamedNode}, ${snippets.IdentifierSchema}> =
|
|
4
4
|
(jsonString, options) => jsonString.startsWith("_:") ? ${snippets.blankNodeFromJsonString}(jsonString, options) as ${imports.Either}<Error, ${imports.BlankNode} | ${imports.NamedNode}> : ${snippets.iriFromJsonString}(jsonString, options) as ${imports.Either}<Error, ${imports.BlankNode} | ${imports.NamedNode}>;`);
|
|
5
5
|
//# sourceMappingURL=snippets_identifierFromJsonString.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_identifierToJsonObject = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}identifierToJsonObject`, code `\
|
|
3
|
-
const ${syntheticNamePrefix}identifierToJsonObject: ${snippets.
|
|
3
|
+
const ${syntheticNamePrefix}identifierToJsonObject: ${snippets.ToJsonFunction}<${imports.BlankNode} | ${imports.NamedNode}, ${snippets.IdentifierJsonObject}> =
|
|
4
4
|
(identifier) => identifier.termType === "BlankNode" ? ${snippets.blankNodeToJsonObject}(identifier) : ${snippets.iriToJsonObject}(identifier);`);
|
|
5
5
|
//# sourceMappingURL=snippets_identifierToJsonObject.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_identifierToJsonString = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}identifierToJsonString`, code `\
|
|
3
|
-
const ${syntheticNamePrefix}identifierToJsonString: ${snippets.
|
|
3
|
+
const ${syntheticNamePrefix}identifierToJsonString: ${snippets.ToJsonFunction}<${imports.BlankNode} | ${imports.NamedNode}, string> =
|
|
4
4
|
(identifier) => identifier.termType === "BlankNode" ? ${snippets.blankNodeToJsonString}(identifier) : ${snippets.iriToJsonString}(identifier);`);
|
|
5
5
|
//# sourceMappingURL=snippets_identifierToJsonString.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_intFromJsonNumber = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}intFromJsonNumber`, code `\
|
|
3
|
-
function ${syntheticNamePrefix}intFromJsonNumber<IntT extends number>(jsonNumber: IntT, _options: Parameters<${snippets.
|
|
3
|
+
function ${syntheticNamePrefix}intFromJsonNumber<IntT extends number>(jsonNumber: IntT, _options: Parameters<${snippets.FromJsonFunction}<IntT, IntT, ${snippets.NumericSchema}<IntT>>>[1]): ${imports.Either}<Error, IntT> {
|
|
4
4
|
return ${imports.Either}.of(jsonNumber);
|
|
5
5
|
}`);
|
|
6
6
|
//# sourceMappingURL=snippets_intFromJsonNumber.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_intFromJsonObject = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}intFromJsonObject`, code `\
|
|
3
|
-
function ${syntheticNamePrefix}intFromJsonObject<IntT extends number>(jsonObject: ${snippets.TypedLiteralJsonObject}, options: Parameters<${snippets.
|
|
3
|
+
function ${syntheticNamePrefix}intFromJsonObject<IntT extends number>(jsonObject: ${snippets.TypedLiteralJsonObject}, options: Parameters<${snippets.FromJsonFunction}<${snippets.TypedLiteralJsonObject}, IntT, ${snippets.NumericSchema}<IntT>>>[1]): ${imports.Either}<Error, IntT> {
|
|
4
4
|
const { schema } = options;
|
|
5
5
|
return ${snippets.literalFromJsonObject}(jsonObject)
|
|
6
6
|
.chain(${imports.LiteralDecoder}.decodeIntLiteral)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_iriFromJsonObject = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}iriFromJsonObject`, code `\
|
|
3
|
-
function ${syntheticNamePrefix}iriFromJsonObject
|
|
3
|
+
function ${syntheticNamePrefix}iriFromJsonObject(jsonObject: ${snippets.IdentifierJsonObject}, options: Parameters<${snippets.FromJsonFunction}<${snippets.IdentifierJsonObject}, ${imports.NamedNode}, ${snippets.IriSchema}>>[1]): ${imports.Either}<Error, ${imports.NamedNode}> {
|
|
4
4
|
return ${snippets.iriFromJsonString}(jsonObject["@id"], options);
|
|
5
5
|
}`);
|
|
6
6
|
//# sourceMappingURL=snippets_iriFromJsonObject.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_iriFromJsonString = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}iriFromJsonString`, code `\
|
|
3
|
-
function ${syntheticNamePrefix}iriFromJsonString
|
|
4
|
-
return ${
|
|
3
|
+
function ${syntheticNamePrefix}iriFromJsonString(jsonString: string, options: Parameters<${snippets.FromJsonFunction}<string, ${imports.NamedNode}, object>>[1]): ${imports.Either}<Error, ${imports.NamedNode}> {
|
|
4
|
+
return ${snippets.iriFromString}(jsonString, options);
|
|
5
5
|
}`);
|
|
6
6
|
//# sourceMappingURL=snippets_iriFromJsonString.js.map
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { code, conditionalOutput, joinCode, literalOf, } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_iriFromString = ({ imports, snippets, syntheticNamePrefix, }) => {
|
|
3
|
+
const leadingDoubleSlashSchemes = [
|
|
4
|
+
"file",
|
|
5
|
+
"ftp",
|
|
6
|
+
"http",
|
|
7
|
+
"https",
|
|
8
|
+
"git",
|
|
9
|
+
"irc",
|
|
10
|
+
"ldap",
|
|
11
|
+
"postgres",
|
|
12
|
+
"rtsp",
|
|
13
|
+
"sftp",
|
|
14
|
+
"smb",
|
|
15
|
+
"ssh",
|
|
16
|
+
"ws",
|
|
17
|
+
"wss",
|
|
18
|
+
];
|
|
19
|
+
return conditionalOutput(`${syntheticNamePrefix}iriFromString`, code `\
|
|
20
|
+
export function ${syntheticNamePrefix}iriFromString(
|
|
21
|
+
string: string,
|
|
22
|
+
options?: {
|
|
23
|
+
defaultNamespace?: ${snippets.NamespaceBuilder};
|
|
24
|
+
prefixMap?: ${imports.PrefixMap};
|
|
25
|
+
}
|
|
26
|
+
): ${imports.Either}<Error, ${imports.NamedNode}> {
|
|
27
|
+
if (string.trim().length === 0) {
|
|
28
|
+
return ${imports.Left}(new Error("empty/blank IRI"));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const defaultNamespace = options?.defaultNamespace;
|
|
32
|
+
|
|
33
|
+
const colonIndex = string.indexOf(":");
|
|
34
|
+
if (colonIndex === -1) {
|
|
35
|
+
// No : in the string.
|
|
36
|
+
if (defaultNamespace) {
|
|
37
|
+
return ${imports.Right}(defaultNamespace(string));
|
|
38
|
+
} else {
|
|
39
|
+
return ${imports.Left}(new Error(\`ill-formed IRI: \${string}\`));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const prefix = string.substring(0, colonIndex);
|
|
44
|
+
const path = string.substring(colonIndex + 1);
|
|
45
|
+
if (path.length === 0) {
|
|
46
|
+
return ${imports.Left}(new Error(\`ill-formed IRI: \${string}\`));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Absolute IRIs with scheme:// always win over prefixes with the same name.
|
|
50
|
+
switch (prefix.toLowerCase()) {
|
|
51
|
+
${joinCode(leadingDoubleSlashSchemes.map((scheme) => code ` case ${literalOf(scheme)}:`, { on: "\n" }))}
|
|
52
|
+
if (path.startsWith("//")) {
|
|
53
|
+
return ${imports.Right}(${imports.dataFactory}.namedNode(string));
|
|
54
|
+
}
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const prefixMap = options?.prefixMap;
|
|
59
|
+
if (prefixMap) {
|
|
60
|
+
const prefixNamespace = prefixMap.get(prefix);
|
|
61
|
+
if (prefixNamespace !== undefined) {
|
|
62
|
+
return ${imports.Right}(
|
|
63
|
+
${imports.dataFactory}.namedNode(\`\${prefixNamespace.value}\${path}\`),
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (prefix.length === 0 && defaultNamespace) {
|
|
69
|
+
// a "" prefixMap entry takes precedence, above.
|
|
70
|
+
return ${imports.Right}(defaultNamespace(path));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return ${imports.Right}(${imports.dataFactory}.namedNode(string));
|
|
74
|
+
}`);
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=snippets_iriFromString.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_iriLiteralFromJsonObject = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}iriLiteralFromJsonObject`, code `\
|
|
3
|
+
function ${syntheticNamePrefix}iriLiteralFromJsonObject<IriT extends string>(jsonObject: ${snippets.IdentifierJsonObject}<IriT>, options: Parameters<${snippets.FromJsonFunction}<${snippets.IdentifierJsonObject}<IriT>, ${imports.NamedNode}<IriT>, ${snippets.IriSchema}<IriT>>>[1]): ${imports.Either}<Error, ${imports.NamedNode}<IriT>> {
|
|
4
|
+
return ${snippets.iriLiteralFromJsonString}(jsonObject["@id"], options);
|
|
5
|
+
}`);
|
|
6
|
+
//# sourceMappingURL=snippets_iriLiteralFromJsonObject.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_iriLiteralFromJsonString = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}iriLiteralFromJsonString`, code `\
|
|
3
|
+
function ${syntheticNamePrefix}iriLiteralFromJsonString<IriT extends string>(jsonString: IriT, _options: Parameters<${snippets.FromJsonFunction}<IriT, ${imports.NamedNode}<IriT>, object>>[1]): ${imports.Either}<Error, ${imports.NamedNode}<IriT>> {
|
|
4
|
+
return ${imports.Right}(${imports.dataFactory}.namedNode(jsonString));
|
|
5
|
+
}`);
|
|
6
|
+
//# sourceMappingURL=snippets_iriLiteralFromJsonString.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_langStringFromJsonObject = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}langStringFromJsonObject`, code `\
|
|
3
|
-
const ${syntheticNamePrefix}langStringFromJsonObject: ${snippets.
|
|
3
|
+
const ${syntheticNamePrefix}langStringFromJsonObject: ${snippets.FromJsonFunction}<${snippets.LangStringJsonObject}, ${imports.Literal}, ${snippets.LangStringSchema}> =
|
|
4
4
|
(jsonObject) => ${imports.Either}.of<Error, ${imports.Literal}>(${imports.dataFactory}.literal(jsonObject["@value"], jsonObject["@language"]))`);
|
|
5
5
|
//# sourceMappingURL=snippets_langStringFromJsonObject.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_langStringToJsonObject = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}langStringToJsonObject`, code `\
|
|
3
|
-
const ${syntheticNamePrefix}langStringToJsonObject: ${snippets.
|
|
3
|
+
const ${syntheticNamePrefix}langStringToJsonObject: ${snippets.ToJsonFunction}<${imports.Literal}, ${snippets.LangStringJsonObject}> =
|
|
4
4
|
(literal) => ({ "@language": literal.language, "@value": literal.value });`);
|
|
5
5
|
//# sourceMappingURL=snippets_langStringToJsonObject.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_listFromJsonObject = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}listFromJsonObject`, code `\
|
|
3
|
-
function ${syntheticNamePrefix}listFromJsonObject<ItemJsonValueT, ItemT, ItemSchemaT>(itemFromJsonValue: ${snippets.
|
|
3
|
+
function ${syntheticNamePrefix}listFromJsonObject<ItemJsonValueT, ItemT, ItemSchemaT>(itemFromJsonValue: ${snippets.FromJsonFunction}<ItemJsonValueT, ItemT, ItemSchemaT>): ${snippets.FromJsonFunction}<{ "@list": ItemJsonValueT[] }, ItemT[], ${snippets.CollectionSchema}<ItemSchemaT>> {
|
|
4
4
|
return (jsonObject, options) => {
|
|
5
5
|
const { schema, ...otherOptions } = options;
|
|
6
6
|
const itemFromJsonValueOptions = { schema: schema.itemType, ...otherOptions };
|