@nfdi4plants/arctrl 2.0.0-beta.2 → 2.0.0
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/ARC.js +55 -18
- package/Contract/ArcAssay.js +4 -4
- package/Contract/ArcInvestigation.js +4 -4
- package/Contract/ArcStudy.js +3 -3
- package/Contract/Datamap.js +1 -1
- package/Contract/ValidationPackagesConfig.js +96 -0
- package/Core/ArcTypes.js +93 -90
- package/Core/Conversion.js +13 -13
- package/Core/DataContext.js +53 -6
- package/Core/{Table/DataMap.js → DataMap.js} +34 -22
- package/Core/Process/Component.js +15 -5
- package/Core/Process/FactorValue.js +14 -5
- package/Core/Process/MaterialAttributeValue.js +14 -5
- package/Core/Process/ProcessParameterValue.js +11 -2
- package/Core/Table/ArcTable.js +99 -11
- package/Core/Table/CompositeCell.js +38 -23
- package/Core/Table/CompositeColumn.js +7 -30
- package/Core/Table/CompositeHeader.js +5 -215
- package/Core/{Process/Value.js → Value.js} +9 -9
- package/Json/Assay.js +10 -9
- package/Json/{Process/Data.js → Data.js} +17 -17
- package/Json/{Process/DataFile.js → DataFile.js} +9 -9
- package/Json/DataMap/DataContext.js +30 -0
- package/Json/DataMap/DataMap.js +25 -0
- package/Json/Encode.js +10 -1
- package/Json/Process/Component.js +1 -1
- package/Json/Process/FactorValue.js +1 -1
- package/Json/Process/MaterialAttributeValue.js +1 -1
- package/Json/Process/ProcessInput.js +1 -1
- package/Json/Process/ProcessOutput.js +1 -1
- package/Json/Process/ProcessParameterValue.js +2 -2
- package/Json/Process/Value.js +3 -3
- package/Json/{Process/PropertyValue.js → PropertyValue.js} +30 -21
- package/Json/Study.js +9 -8
- package/Json/Table/CompositeCell.js +1 -1
- package/Json/context/rocrate/isa_data_context.js +1 -1
- package/Json/context/rocrate/isa_investigation_context.js +1 -1
- package/Json/context/rocrate/property_value_context.js +1 -1
- package/Spreadsheet/AnnotationTable/ArcTable.js +3 -2
- package/Spreadsheet/AnnotationTable/CompositeColumn.js +9 -7
- package/Spreadsheet/ArcAssay.js +62 -26
- package/Spreadsheet/ArcInvestigation.js +59 -38
- package/Spreadsheet/ArcStudy.js +51 -20
- package/Spreadsheet/DataMap.js +1 -1
- package/Spreadsheet/DataMapTable/DataMapTable.js +3 -3
- package/Spreadsheet/Template.js +1 -1
- package/ValidationPackages/ValidationPackage.js +61 -0
- package/ValidationPackages/ValidationPackagesConfig.js +88 -0
- package/Xlsx.js +9 -9
- package/Yaml/Encode.js +8 -0
- package/Yaml/ValidationPackage.js +47 -0
- package/Yaml/ValidationPackagesConfig.js +48 -0
- package/fable_modules/YAMLicious.0.0.1/Decode.fs +374 -0
- package/fable_modules/YAMLicious.0.0.1/Decode.fs.js +1684 -0
- package/fable_modules/YAMLicious.0.0.1/Encode.fs +148 -0
- package/fable_modules/YAMLicious.0.0.1/Encode.fs.js +74 -0
- package/fable_modules/YAMLicious.0.0.1/Interop/JsInterop.fs +14 -0
- package/fable_modules/YAMLicious.0.0.1/Interop/JsInterop.fs.js +11 -0
- package/fable_modules/YAMLicious.0.0.1/Interop/PyInterop.fs +9 -0
- package/fable_modules/YAMLicious.0.0.1/Library.fs +138 -0
- package/fable_modules/YAMLicious.0.0.1/Library.fs.js +7 -0
- package/fable_modules/YAMLicious.0.0.1/Persil.fs +86 -0
- package/fable_modules/YAMLicious.0.0.1/Persil.fs.js +49 -0
- package/fable_modules/YAMLicious.0.0.1/Preprocessing.fs +59 -0
- package/fable_modules/YAMLicious.0.0.1/Preprocessing.fs.js +102 -0
- package/fable_modules/YAMLicious.0.0.1/Reader.fs +295 -0
- package/fable_modules/YAMLicious.0.0.1/Reader.fs.js +530 -0
- package/fable_modules/YAMLicious.0.0.1/Regex.fs +108 -0
- package/fable_modules/YAMLicious.0.0.1/Regex.fs.js +19 -0
- package/fable_modules/YAMLicious.0.0.1/RegexActivePatterns.fs +166 -0
- package/fable_modules/YAMLicious.0.0.1/RegexActivePatterns.fs.js +225 -0
- package/fable_modules/YAMLicious.0.0.1/Writer.fs +84 -0
- package/fable_modules/YAMLicious.0.0.1/Writer.fs.js +161 -0
- package/fable_modules/YAMLicious.0.0.1/YAMLicious.fableproj +39 -0
- package/fable_modules/YAMLicious.0.0.1/YAMLiciousTypes.fs +82 -0
- package/fable_modules/YAMLicious.0.0.1/YAMLiciousTypes.fs.js +130 -0
- package/fable_modules/YAMLicious.0.0.1/obj/Debug/netstandard2.0/.NETStandard,Version=v2.0.AssemblyAttributes.fs +3 -0
- package/fable_modules/YAMLicious.0.0.1/obj/Debug/netstandard2.0/YAMLicious.AssemblyInfo.fs +19 -0
- package/fable_modules/YAMLicious.0.0.1/obj/Release/netstandard2.0/.NETStandard,Version=v2.0.AssemblyAttributes.fs +3 -0
- package/fable_modules/YAMLicious.0.0.1/obj/Release/netstandard2.0/YAMLicious.AssemblyInfo.fs +19 -0
- package/fable_modules/project_cracked.json +1 -1
- package/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/// To YAML
|
|
2
|
+
[<RequireQualifiedAccessAttribute>]
|
|
3
|
+
module YAMLicious.Encode
|
|
4
|
+
|
|
5
|
+
open System
|
|
6
|
+
open System.Collections.Generic
|
|
7
|
+
open System.Globalization
|
|
8
|
+
|
|
9
|
+
open YAMLicious
|
|
10
|
+
open YAMLicious.YAMLiciousTypes
|
|
11
|
+
|
|
12
|
+
module Helper =
|
|
13
|
+
|
|
14
|
+
let inline getUnionCaseName (x:'a) =
|
|
15
|
+
match Microsoft.FSharp.Reflection.FSharpValue.GetUnionFields(x, typeof<'a>) with
|
|
16
|
+
| case, _ -> case.Name
|
|
17
|
+
|
|
18
|
+
let int (value: int) = (YAMLContent.create(string value)) |> YAMLElement.Value
|
|
19
|
+
|
|
20
|
+
let float (value: float) = (YAMLContent.create(value.ToString("O", CultureInfo.InvariantCulture))) |> YAMLElement.Value
|
|
21
|
+
|
|
22
|
+
let char (value: char) = YAMLContent.create(string value) |> YAMLElement.Value
|
|
23
|
+
|
|
24
|
+
let bool (value: bool) = YAMLContent.create(string value) |> YAMLElement.Value
|
|
25
|
+
|
|
26
|
+
let inline map (keyEncoder: 'a -> string) (valueEncoder: 'b -> YAMLElement) (value: Map<'a, 'b>) =
|
|
27
|
+
[
|
|
28
|
+
for KeyValue (k, v) in value do
|
|
29
|
+
YAMLElement.Mapping (YAMLContent.create(keyEncoder k), valueEncoder v)
|
|
30
|
+
]
|
|
31
|
+
|> YAMLElement.Object
|
|
32
|
+
|
|
33
|
+
let inline dict (keyEncoder: 'a -> string) (valueEncoder: 'b -> YAMLElement) (value: Dictionary<'a, 'b>) =
|
|
34
|
+
[for KeyValue (k, v) in value do
|
|
35
|
+
YAMLElement.Mapping (YAMLContent.create(keyEncoder k), valueEncoder v)
|
|
36
|
+
] |> YAMLElement.Object
|
|
37
|
+
|
|
38
|
+
let datetime (value: DateTime) = (YAMLContent.create(value.ToString("O", CultureInfo.InvariantCulture))) |> YAMLElement.Value
|
|
39
|
+
|
|
40
|
+
let datetimeOffset (value: DateTimeOffset) = (YAMLContent.create(value.ToString("O", CultureInfo.InvariantCulture))) |> YAMLElement.Value
|
|
41
|
+
|
|
42
|
+
let inline option (enc: 'a -> YAMLElement) (value: 'a option) =
|
|
43
|
+
match value with
|
|
44
|
+
| Some v -> enc v
|
|
45
|
+
| None -> YAMLElement.Value <| YAMLContent.create YAML_NULL
|
|
46
|
+
|
|
47
|
+
let inline tuple2 (encA: 'a -> YAMLElement) (encB: 'b -> YAMLElement) (value: 'a * 'b) = YAMLElement.Sequence [encA (fst value); encB (snd value)]
|
|
48
|
+
|
|
49
|
+
let inline tuple3 (encA: 'a -> YAMLElement) (encB: 'b -> YAMLElement) (encC: 'c -> YAMLElement) (value: 'a * 'b * 'c) =
|
|
50
|
+
let a,b,c = value
|
|
51
|
+
YAMLElement.Sequence [encA a; encB b; encC c]
|
|
52
|
+
|
|
53
|
+
let inline tuple4 (encA: 'a -> YAMLElement) (encB: 'b -> YAMLElement) (encC: 'c -> YAMLElement) (encD: 'd -> YAMLElement) (value: 'a * 'b * 'c * 'd) =
|
|
54
|
+
let a,b,c,d = value
|
|
55
|
+
YAMLElement.Sequence [encA a; encB b; encC c; encD d]
|
|
56
|
+
|
|
57
|
+
let inline tuple5 (encA: 'a -> YAMLElement) (encB: 'b -> YAMLElement) (encC: 'c -> YAMLElement) (encD: 'd -> YAMLElement) (encE: 'e -> YAMLElement) (value: 'a * 'b * 'c * 'd * 'e) =
|
|
58
|
+
let a,b,c,d,e = value
|
|
59
|
+
YAMLElement.Sequence [encA a; encB b; encC c; encD d; encE e]
|
|
60
|
+
|
|
61
|
+
let inline tuple6
|
|
62
|
+
(encA: 'a -> YAMLElement)
|
|
63
|
+
(encB: 'b -> YAMLElement)
|
|
64
|
+
(encC: 'c -> YAMLElement)
|
|
65
|
+
(encD: 'd -> YAMLElement)
|
|
66
|
+
(encE: 'e -> YAMLElement)
|
|
67
|
+
(encF: 'f -> YAMLElement)
|
|
68
|
+
(value: 'a * 'b * 'c * 'd * 'e * 'f)
|
|
69
|
+
=
|
|
70
|
+
let a,b,c,d,e,f = value
|
|
71
|
+
YAMLElement.Sequence [encA a; encB b; encC c; encD d; encE e; encF f]
|
|
72
|
+
|
|
73
|
+
let inline tuple7
|
|
74
|
+
(encA: 'a -> YAMLElement)
|
|
75
|
+
(encB: 'b -> YAMLElement)
|
|
76
|
+
(encC: 'c -> YAMLElement)
|
|
77
|
+
(encD: 'd -> YAMLElement)
|
|
78
|
+
(encE: 'e -> YAMLElement)
|
|
79
|
+
(encF: 'f -> YAMLElement)
|
|
80
|
+
(encG: 'g -> YAMLElement)
|
|
81
|
+
(value: 'a * 'b * 'c * 'd * 'e * 'f * 'g)
|
|
82
|
+
=
|
|
83
|
+
let a,b,c,d,e,f,g = value
|
|
84
|
+
YAMLElement.Sequence [encA a; encB b; encC c; encD d; encE e; encF f; encG g]
|
|
85
|
+
|
|
86
|
+
let inline tuple8
|
|
87
|
+
(encA: 'a -> YAMLElement)
|
|
88
|
+
(encB: 'b -> YAMLElement)
|
|
89
|
+
(encC: 'c -> YAMLElement)
|
|
90
|
+
(encD: 'd -> YAMLElement)
|
|
91
|
+
(encE: 'e -> YAMLElement)
|
|
92
|
+
(encF: 'f -> YAMLElement)
|
|
93
|
+
(encG: 'g -> YAMLElement)
|
|
94
|
+
(encH: 'h -> YAMLElement)
|
|
95
|
+
(value: 'a * 'b * 'c * 'd * 'e * 'f * 'g * 'h)
|
|
96
|
+
=
|
|
97
|
+
let a,b,c,d,e,f,g,h = value
|
|
98
|
+
YAMLElement.Sequence [encA a; encB b; encC c; encD d; encE e; encF f; encG g; encH h]
|
|
99
|
+
|
|
100
|
+
let string (value: string) = (YAMLContent.create(value)) |> YAMLElement.Value
|
|
101
|
+
|
|
102
|
+
let seq (encoder: 'a -> YAMLElement) (s: seq<'a>) = s |> Seq.map encoder |> List.ofSeq |> YAMLElement.Sequence
|
|
103
|
+
|
|
104
|
+
let array (encoder: 'a -> YAMLElement) (arr: 'a []) = YAMLElement.Sequence (List.map encoder (List.ofArray arr))
|
|
105
|
+
|
|
106
|
+
let resizearray (encoder: 'a -> YAMLElement) (arr: ResizeArray<'a>) = YAMLElement.Sequence (List.map encoder (List.ofSeq arr))
|
|
107
|
+
|
|
108
|
+
let list (encoder: 'a -> YAMLElement) (l: 'a list) = YAMLElement.Sequence (List.map encoder l)
|
|
109
|
+
|
|
110
|
+
let values (encoder: 'a -> string) (values: 'a seq) =
|
|
111
|
+
values
|
|
112
|
+
|> Seq.map (encoder >> YAMLContent.create >> YAMLElement.Value)
|
|
113
|
+
|> List.ofSeq
|
|
114
|
+
|> YAMLElement.Object
|
|
115
|
+
|
|
116
|
+
let inline object (objSeq: #seq<(string*YAMLElement)>) =
|
|
117
|
+
[
|
|
118
|
+
for (key, v) in objSeq do
|
|
119
|
+
YAMLElement.Mapping (YAMLContent.create(key), v)
|
|
120
|
+
]
|
|
121
|
+
|> YAMLElement.Object
|
|
122
|
+
|
|
123
|
+
let inline withComment (comment: string) (ele: YAMLElement) =
|
|
124
|
+
match ele with
|
|
125
|
+
| YAMLElement.Value v -> YAMLElement.Value {v with Comment = Some comment}
|
|
126
|
+
| YAMLElement.Mapping (k, v) -> YAMLElement.Mapping ({k with Comment = Some comment}, v)
|
|
127
|
+
| anyElse -> invalidArg "ele" (sprintf "Unsupported element type for `Encode.withComment`: %s" (Helper.getUnionCaseName anyElse))
|
|
128
|
+
|
|
129
|
+
let comment (string) = string |> YAMLElement.Comment
|
|
130
|
+
|
|
131
|
+
let nil = YAMLElement.Nil
|
|
132
|
+
|
|
133
|
+
/// Try to encode the given object using the given encoder, or return Encode.nil if the object is null
|
|
134
|
+
let tryInclude (name : string) (encoder : 'a -> YAMLElement) (value : 'a option) =
|
|
135
|
+
name,
|
|
136
|
+
match value with
|
|
137
|
+
| Some(o) -> encoder o
|
|
138
|
+
| _ -> nil
|
|
139
|
+
|
|
140
|
+
let inline choose (kvs : (string * YAMLElement) list) =
|
|
141
|
+
kvs
|
|
142
|
+
|> List.choose (fun (k,v) ->
|
|
143
|
+
if v = YAMLElement.Nil then None
|
|
144
|
+
else Some (k,v)
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
let write (whitespaces: int) (ele: YAMLElement) =
|
|
148
|
+
Writer.write ele (Some (fun c -> {c with Whitespace = whitespaces}))
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Config, YAMLElement, YAMLContent_create_27AED5E3 } from "./YAMLiciousTypes.fs.js";
|
|
2
|
+
import { int32ToString } from "../fable-library-js.4.16.0/Util.js";
|
|
3
|
+
import { toString } from "../fable-library-js.4.16.0/Types.js";
|
|
4
|
+
import { toString as toString_1 } from "../fable-library-js.4.16.0/Date.js";
|
|
5
|
+
import { ofArray, map as map_1, ofSeq } from "../fable-library-js.4.16.0/List.js";
|
|
6
|
+
import { map } from "../fable-library-js.4.16.0/Seq.js";
|
|
7
|
+
import { value as value_1 } from "../fable-library-js.4.16.0/Option.js";
|
|
8
|
+
import { write as write_1 } from "./Writer.fs.js";
|
|
9
|
+
|
|
10
|
+
export function int(value) {
|
|
11
|
+
return new YAMLElement(1, [YAMLContent_create_27AED5E3(int32ToString(value))]);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function float(value) {
|
|
15
|
+
return new YAMLElement(1, [YAMLContent_create_27AED5E3(String(value))]);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function char(value) {
|
|
19
|
+
return new YAMLElement(1, [YAMLContent_create_27AED5E3(value)]);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function bool(value) {
|
|
23
|
+
return new YAMLElement(1, [YAMLContent_create_27AED5E3(toString(value))]);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function datetime(value) {
|
|
27
|
+
return new YAMLElement(1, [YAMLContent_create_27AED5E3(toString_1(value, "O", {}))]);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function datetimeOffset(value) {
|
|
31
|
+
return new YAMLElement(1, [YAMLContent_create_27AED5E3(toString_1(value, "O", {}))]);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function string(value) {
|
|
35
|
+
return new YAMLElement(1, [YAMLContent_create_27AED5E3(value)]);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function seq(encoder, s) {
|
|
39
|
+
return new YAMLElement(2, [ofSeq(map(encoder, s))]);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function array(encoder, arr) {
|
|
43
|
+
return new YAMLElement(2, [map_1(encoder, ofArray(arr))]);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function resizearray(encoder, arr) {
|
|
47
|
+
return new YAMLElement(2, [map_1(encoder, ofSeq(arr))]);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function list(encoder, l) {
|
|
51
|
+
return new YAMLElement(2, [map_1(encoder, l)]);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function values(encoder, values_1) {
|
|
55
|
+
return new YAMLElement(3, [ofSeq(map((arg_1) => (new YAMLElement(1, [YAMLContent_create_27AED5E3(encoder(arg_1))])), values_1))]);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function comment(string_1) {
|
|
59
|
+
return new YAMLElement(4, [string_1]);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const nil = new YAMLElement(5, []);
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Try to encode the given object using the given encoder, or return Encode.nil if the object is null
|
|
66
|
+
*/
|
|
67
|
+
export function tryInclude(name, encoder, value) {
|
|
68
|
+
return [name, (value != null) ? encoder(value_1(value)) : nil];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function write(whitespaces, ele) {
|
|
72
|
+
return write_1(ele, (c) => (new Config(whitespaces, c.Level)));
|
|
73
|
+
}
|
|
74
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
[<RequireQualifiedAccessAttribute>]
|
|
2
|
+
module YAMLicious.JsInterop
|
|
3
|
+
|
|
4
|
+
#if FABLE_COMPILER_JAVASCRIPT || FABLE_COMPILER_TYPESCRIPT
|
|
5
|
+
open Fable.Core.JsInterop
|
|
6
|
+
|
|
7
|
+
let isInt (s:string): bool =
|
|
8
|
+
emitJsStatement (s) """if (typeof $0 != "string") return false // we only process strings!
|
|
9
|
+
return !isNaN($0) && // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)...
|
|
10
|
+
!isNaN(parseFloat($0)) // ...and ensure strings of whitespace fail"""
|
|
11
|
+
|
|
12
|
+
let isString (s:string): bool =
|
|
13
|
+
emitJsStatement s """return typeof $0 === 'string' || value instanceof String"""
|
|
14
|
+
#endif
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
export function isInt(s) {
|
|
3
|
+
if (typeof s != "string") return false // we only process strings!
|
|
4
|
+
return !isNaN(s) && // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)...
|
|
5
|
+
!isNaN(parseFloat(s)) // ...and ensure strings of whitespace fail;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function isString(s) {
|
|
9
|
+
return typeof s === 'string' || value instanceof String;
|
|
10
|
+
}
|
|
11
|
+
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
namespace YAMLicious
|
|
2
|
+
|
|
3
|
+
open YAMLiciousTypes
|
|
4
|
+
|
|
5
|
+
module TestCases =
|
|
6
|
+
|
|
7
|
+
[<Literal>]
|
|
8
|
+
let KeyValue = """
|
|
9
|
+
My Key: My Value
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
[<Literal>]
|
|
13
|
+
let String = """
|
|
14
|
+
My Value
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
[<Literal>]
|
|
18
|
+
let Sequence = """
|
|
19
|
+
- My Value 1
|
|
20
|
+
- My Value 2
|
|
21
|
+
- My Value 3
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
[<Literal>]
|
|
25
|
+
let SequenceObjects = """
|
|
26
|
+
- My Value 1
|
|
27
|
+
My Value 2
|
|
28
|
+
- My Value 3
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
[<Literal>]
|
|
32
|
+
let SequenceImplicit = """
|
|
33
|
+
My Key:
|
|
34
|
+
My Value1
|
|
35
|
+
My Value2
|
|
36
|
+
My Value3
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
[<Literal>]
|
|
40
|
+
let SequenceSameIndentAsMapping = """
|
|
41
|
+
My Key:
|
|
42
|
+
- My Value1
|
|
43
|
+
- My Value2
|
|
44
|
+
- My Value3
|
|
45
|
+
"""
|
|
46
|
+
[<Literal>]
|
|
47
|
+
let SequenceMappings = """
|
|
48
|
+
-
|
|
49
|
+
My Key1: My Value1
|
|
50
|
+
My Key2: My Value2
|
|
51
|
+
My Key3: My Value3
|
|
52
|
+
-
|
|
53
|
+
My Key4: My Value4
|
|
54
|
+
My Key5: My Value5
|
|
55
|
+
My Key6: My Value6
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
[<Literal>]
|
|
59
|
+
let SequenceOfSequences = """
|
|
60
|
+
- [v1, v2, v3]
|
|
61
|
+
- [v4, v5, v6]
|
|
62
|
+
- [v7, v8, v9]
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
[<Literal>]
|
|
66
|
+
let SequenceOfSequences2 = """
|
|
67
|
+
-
|
|
68
|
+
[v1, v2, v3]
|
|
69
|
+
-
|
|
70
|
+
[v4, v5, v6]
|
|
71
|
+
-
|
|
72
|
+
[v7, v8, v9]
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
[<Literal>]
|
|
76
|
+
let SequenceSquare = """
|
|
77
|
+
[
|
|
78
|
+
v1,
|
|
79
|
+
v2,
|
|
80
|
+
v3
|
|
81
|
+
]
|
|
82
|
+
"""
|
|
83
|
+
|
|
84
|
+
let SequenceMappingsAST =
|
|
85
|
+
Level [
|
|
86
|
+
Line "-"
|
|
87
|
+
Intendation [
|
|
88
|
+
Line "My Key1: My Value1"
|
|
89
|
+
Line "My Key2: My Value2"
|
|
90
|
+
Line "My Key3: My Value3"
|
|
91
|
+
]
|
|
92
|
+
Line "-"
|
|
93
|
+
Intendation [
|
|
94
|
+
Line "My Key4: My Value4"
|
|
95
|
+
Line "My Key5: My Value5"
|
|
96
|
+
Line "My Key6: My Value6"
|
|
97
|
+
]
|
|
98
|
+
]
|
|
99
|
+
|
|
100
|
+
[<Literal>]
|
|
101
|
+
let LineComment = """
|
|
102
|
+
# This is a line comment
|
|
103
|
+
"""
|
|
104
|
+
|
|
105
|
+
[<Literal>]
|
|
106
|
+
let InlineComment = """
|
|
107
|
+
My Key: # This is a comment
|
|
108
|
+
My Value1
|
|
109
|
+
My Value2
|
|
110
|
+
My Value3 # :::: This is also a comment
|
|
111
|
+
"""
|
|
112
|
+
|
|
113
|
+
[<Literal>]
|
|
114
|
+
let StringReplace = """
|
|
115
|
+
My Key: "[{Special character place # |}"
|
|
116
|
+
"""
|
|
117
|
+
|
|
118
|
+
let StringReplaceClean = """
|
|
119
|
+
My Key: </1>
|
|
120
|
+
"""
|
|
121
|
+
|
|
122
|
+
[<Literal>]
|
|
123
|
+
let StringReplaceWithComment = """
|
|
124
|
+
My Key: "[{Special character place # |}" # A # in string is allowed!
|
|
125
|
+
"""
|
|
126
|
+
|
|
127
|
+
[<Literal>]
|
|
128
|
+
let StringReplaceWithCommentHashs = """
|
|
129
|
+
My Key: "[{Special character place # |}" ### A # in string is allowed!
|
|
130
|
+
"""
|
|
131
|
+
|
|
132
|
+
[<Literal>]
|
|
133
|
+
let JsonMappings ="""
|
|
134
|
+
Mark McGwire: {hr: 65, avg: 0.278}
|
|
135
|
+
Sammy Sosa: {
|
|
136
|
+
hr: 63,
|
|
137
|
+
avg: 0.288,
|
|
138
|
+
}"""
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PreprocessorElement } from "./YAMLiciousTypes.fs.js";
|
|
2
|
+
import { ofArray } from "../fable-library-js.4.16.0/List.js";
|
|
3
|
+
|
|
4
|
+
export const SequenceMappingsAST = new PreprocessorElement(0, [ofArray([new PreprocessorElement(2, ["-"]), new PreprocessorElement(1, [ofArray([new PreprocessorElement(2, ["My Key1: My Value1"]), new PreprocessorElement(2, ["My Key2: My Value2"]), new PreprocessorElement(2, ["My Key3: My Value3"])])]), new PreprocessorElement(2, ["-"]), new PreprocessorElement(1, [ofArray([new PreprocessorElement(2, ["My Key4: My Value4"]), new PreprocessorElement(2, ["My Key5: My Value5"]), new PreprocessorElement(2, ["My Key6: My Value6"])])])])]);
|
|
5
|
+
|
|
6
|
+
export const StringReplaceClean = "\r\nMy Key: </1>\r\n";
|
|
7
|
+
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
module YAMLicious.Persil
|
|
2
|
+
|
|
3
|
+
open System
|
|
4
|
+
open System.Collections.Generic
|
|
5
|
+
open System.Text.RegularExpressions
|
|
6
|
+
|
|
7
|
+
// Patterns:
|
|
8
|
+
// https://regex101.com/r/V0AkIH/1
|
|
9
|
+
|
|
10
|
+
[<Literal>]
|
|
11
|
+
let StringMatchPattern =
|
|
12
|
+
// (?<iscomment>#.*?)? checks if inside comment. if group is found do not parse as string
|
|
13
|
+
#if FABLE_COMPILER_PYTHON
|
|
14
|
+
"(?P<all>(?P<iscomment>#.*?)?\"(?P<stringValue>.+)\\\")"
|
|
15
|
+
#endif
|
|
16
|
+
#if FABLE_COMPILER_JAVASCRIPT || FABLE_COMPILER_TYPESCRIPT
|
|
17
|
+
"(?<all>(?<iscomment>#.*?)?\"(?<stringValue>.+)\")" // fable sets /gu for js regex (unicode, not required to escape ")
|
|
18
|
+
#endif
|
|
19
|
+
#if !FABLE_COMPILER
|
|
20
|
+
"(?<all>(?<iscomment>#.*?)?\\\"(?<stringValue>.+)\\\")" // \\\" --> escaped \"
|
|
21
|
+
#endif
|
|
22
|
+
|
|
23
|
+
[<Literal>]
|
|
24
|
+
let CommentMatchPattern =
|
|
25
|
+
#if FABLE_COMPILER_PYTHON
|
|
26
|
+
"#(?P<comment>.*)"
|
|
27
|
+
#else
|
|
28
|
+
"#(?<comment>.*)"
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
[<Literal>]
|
|
32
|
+
let NewLineChar = '\n'
|
|
33
|
+
|
|
34
|
+
let encodingCleanUp (s: string) =
|
|
35
|
+
//let newLineChars = "\f\u0085\u2028\u2029" |> Array.ofSeq
|
|
36
|
+
let s1 = s.Replace("\r\n", string NewLineChar)
|
|
37
|
+
//let mutable index = s1.IndexOfAny(newLineChars)
|
|
38
|
+
//if index = -1 then s1
|
|
39
|
+
//else
|
|
40
|
+
// let sb = new System.Text.StringBuilder(s1)
|
|
41
|
+
// while index <> -1 do
|
|
42
|
+
// sb.Chars(index) <- replacementChar
|
|
43
|
+
// index <- s1.IndexOfAny(newLineChars, index + 1)
|
|
44
|
+
// sb.ToString()
|
|
45
|
+
s1
|
|
46
|
+
|
|
47
|
+
let stringCleanUp (dict: Dictionary<int, string>) (s: string) =
|
|
48
|
+
let mutable n = 0
|
|
49
|
+
let regex = Regex(StringMatchPattern)
|
|
50
|
+
let matcheval = new MatchEvaluator(fun m ->
|
|
51
|
+
match m.Groups.["iscomment"].Success with
|
|
52
|
+
| true ->
|
|
53
|
+
m.Groups.["all"].Value
|
|
54
|
+
| false ->
|
|
55
|
+
let v = m.Groups.["stringValue"].Value
|
|
56
|
+
let currentN = n
|
|
57
|
+
n <- n + 1
|
|
58
|
+
dict.Add(currentN, v)
|
|
59
|
+
sprintf "<s f=%i/>" currentN
|
|
60
|
+
)
|
|
61
|
+
regex.Replace(s, matcheval)
|
|
62
|
+
|
|
63
|
+
let commentCleanUp (dict: Dictionary<int, string>) (s: string) =
|
|
64
|
+
let mutable n = 0
|
|
65
|
+
let regex = Regex(CommentMatchPattern)
|
|
66
|
+
let matcheval = new MatchEvaluator(fun m ->
|
|
67
|
+
let v = m.Groups.["comment"].Value
|
|
68
|
+
let currentN = n
|
|
69
|
+
n <- n + 1
|
|
70
|
+
dict.Add(currentN, v)
|
|
71
|
+
sprintf "<c f=%i/>" currentN
|
|
72
|
+
)
|
|
73
|
+
regex.Replace(s, matcheval)
|
|
74
|
+
|
|
75
|
+
let cut(yamlString: string) =
|
|
76
|
+
yamlString.Split([|NewLineChar|], StringSplitOptions.RemoveEmptyEntries)
|
|
77
|
+
|
|
78
|
+
let pipeline (yamlString: string) =
|
|
79
|
+
let stringMap = new Dictionary<int, string>()
|
|
80
|
+
let commentMap = new Dictionary<int, string>()
|
|
81
|
+
let lines =
|
|
82
|
+
encodingCleanUp yamlString
|
|
83
|
+
|> stringCleanUp stringMap
|
|
84
|
+
|> commentCleanUp commentMap
|
|
85
|
+
|> cut
|
|
86
|
+
{|StringMap = stringMap; CommentMap = commentMap; Lines = lines|}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { split, printf, toText, replace } from "../fable-library-js.4.16.0/String.js";
|
|
2
|
+
import { replace as replace_1 } from "../fable-library-js.4.16.0/RegExp.js";
|
|
3
|
+
import { addToDict } from "../fable-library-js.4.16.0/MapUtil.js";
|
|
4
|
+
|
|
5
|
+
export function encodingCleanUp(s) {
|
|
6
|
+
return replace(s, "\r\n", "\n");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function stringCleanUp(dict, s) {
|
|
10
|
+
let n = 0;
|
|
11
|
+
return replace_1(/(?<all>(?<iscomment>#.*?)?"(?<stringValue>.+)")/gu, s, (m) => {
|
|
12
|
+
if ((m.groups && m.groups.iscomment) != null) {
|
|
13
|
+
return (m.groups && m.groups.all) || "";
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
const v = (m.groups && m.groups.stringValue) || "";
|
|
17
|
+
const currentN = n | 0;
|
|
18
|
+
n = ((n + 1) | 0);
|
|
19
|
+
addToDict(dict, currentN, v);
|
|
20
|
+
return toText(printf("<s f=%i/>"))(currentN);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function commentCleanUp(dict, s) {
|
|
26
|
+
let n = 0;
|
|
27
|
+
return replace_1(/#(?<comment>.*)/gu, s, (m) => {
|
|
28
|
+
const v = (m.groups && m.groups.comment) || "";
|
|
29
|
+
const currentN = n | 0;
|
|
30
|
+
n = ((n + 1) | 0);
|
|
31
|
+
addToDict(dict, currentN, v);
|
|
32
|
+
return toText(printf("<c f=%i/>"))(currentN);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function cut(yamlString) {
|
|
37
|
+
return split(yamlString, ["\n"], void 0, 1);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function pipeline(yamlString) {
|
|
41
|
+
const stringMap = new Map([]);
|
|
42
|
+
const commentMap = new Map([]);
|
|
43
|
+
return {
|
|
44
|
+
CommentMap: commentMap,
|
|
45
|
+
Lines: cut(commentCleanUp(commentMap, stringCleanUp(stringMap, encodingCleanUp(yamlString)))),
|
|
46
|
+
StringMap: stringMap,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
module YAMLicious.Preprocessing
|
|
2
|
+
|
|
3
|
+
open System.Text
|
|
4
|
+
open System.Collections.Generic
|
|
5
|
+
open YAMLiciousTypes
|
|
6
|
+
|
|
7
|
+
module ReadHelpers =
|
|
8
|
+
let indentLevel (line: string) =
|
|
9
|
+
line |> Seq.takeWhile (fun c -> c = ' ') |> Seq.length
|
|
10
|
+
|
|
11
|
+
let write(rootElement:PreprocessorElement, fconfig: (Config -> Config) option) =
|
|
12
|
+
let config = Config.init() |> fun config -> if fconfig.IsSome then fconfig.Value config else config
|
|
13
|
+
let sb = new StringBuilder()
|
|
14
|
+
let rec loop (current: PreprocessorElement) (sb: StringBuilder) (config: Config) =
|
|
15
|
+
match current with
|
|
16
|
+
| Line line ->
|
|
17
|
+
sb.AppendLine(config.WhitespaceString+line) |> ignore
|
|
18
|
+
| Intendation children ->
|
|
19
|
+
let nextConfig = {config with Level = config.Level + 1}
|
|
20
|
+
for child in children do
|
|
21
|
+
loop child sb nextConfig
|
|
22
|
+
| Level children ->
|
|
23
|
+
for child in children do
|
|
24
|
+
loop child sb config
|
|
25
|
+
| Nil -> ()
|
|
26
|
+
loop rootElement sb config
|
|
27
|
+
sb.ToString()
|
|
28
|
+
|
|
29
|
+
let read(yamlStr: string) =
|
|
30
|
+
let content = Persil.pipeline yamlStr
|
|
31
|
+
let rec loop (lines: string list) (currentIntendation: int) (acc: PreprocessorElement list) =
|
|
32
|
+
match lines with
|
|
33
|
+
| [] -> acc
|
|
34
|
+
| line::rest ->
|
|
35
|
+
let lineEle = Line (line.Trim())
|
|
36
|
+
let nextIntendation = ReadHelpers.indentLevel line
|
|
37
|
+
if nextIntendation = currentIntendation then
|
|
38
|
+
loop rest currentIntendation (Line (line.Trim())::acc)
|
|
39
|
+
else
|
|
40
|
+
let nextLevelLines = rest |> List.takeWhile (fun l -> ReadHelpers.indentLevel l > currentIntendation)
|
|
41
|
+
let currentLevelLines = rest |> List.skipWhile (fun l -> ReadHelpers.indentLevel l > currentIntendation)
|
|
42
|
+
let otherChildren = loop nextLevelLines nextIntendation [] |> List.rev
|
|
43
|
+
let children = lineEle::otherChildren
|
|
44
|
+
loop currentLevelLines currentIntendation (Intendation children::acc)
|
|
45
|
+
let ast =
|
|
46
|
+
loop (List.ofArray content.Lines) 0 []
|
|
47
|
+
|> List.rev
|
|
48
|
+
|> Level
|
|
49
|
+
{
|
|
50
|
+
AST = ast
|
|
51
|
+
StringMap = content.StringMap
|
|
52
|
+
CommentMap = content.CommentMap
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let mkLine (line:string) = Line line
|
|
56
|
+
|
|
57
|
+
let mklLevel (children: #seq<PreprocessorElement>) = List.ofSeq children |> Level
|
|
58
|
+
|
|
59
|
+
let mkIntendation (children: #seq<PreprocessorElement>) = List.ofSeq children |> Intendation
|