@nfdi4plants/arctrl 1.0.0-alpha6
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/ARCtrl.js +257 -0
- package/Contract/Contract.js +95 -0
- package/Contracts/Contracts.ARCtrl.js +35 -0
- package/Contracts/Contracts.ArcAssay.js +65 -0
- package/Contracts/Contracts.ArcInvestigation.js +58 -0
- package/Contracts/Contracts.ArcStudy.js +65 -0
- package/Contracts/Contracts.Git.js +91 -0
- package/FileSystem/Commit.js +18 -0
- package/FileSystem/DefaultGitignore.js +3 -0
- package/FileSystem/FileSystem.js +53 -0
- package/FileSystem/FileSystemTree.js +223 -0
- package/FileSystem/Path.js +38 -0
- package/FileSystemTree.js +51 -0
- package/ISA/ISA/ArcTypes/ArcTable.js +744 -0
- package/ISA/ISA/ArcTypes/ArcTableAux.js +1142 -0
- package/ISA/ISA/ArcTypes/ArcTables.js +380 -0
- package/ISA/ISA/ArcTypes/ArcTypes.js +2018 -0
- package/ISA/ISA/ArcTypes/CompositeCell.js +180 -0
- package/ISA/ISA/ArcTypes/CompositeColumn.js +42 -0
- package/ISA/ISA/ArcTypes/CompositeHeader.js +358 -0
- package/ISA/ISA/ArcTypes/CompositeRow.js +111 -0
- package/ISA/ISA/ArcTypes/IdentifierSetters.js +26 -0
- package/ISA/ISA/Builder/Types.js +243 -0
- package/ISA/ISA/Fable.js +50 -0
- package/ISA/ISA/Helper.js +326 -0
- package/ISA/ISA/Identifier.js +76 -0
- package/ISA/ISA/JsonTypes/AnnotationValue.js +56 -0
- package/ISA/ISA/JsonTypes/Assay.js +620 -0
- package/ISA/ISA/JsonTypes/AssayMaterials.js +39 -0
- package/ISA/ISA/JsonTypes/ColumnIndex.js +246 -0
- package/ISA/ISA/JsonTypes/Comment.js +58 -0
- package/ISA/ISA/JsonTypes/CommentList.js +139 -0
- package/ISA/ISA/JsonTypes/Component.js +158 -0
- package/ISA/ISA/JsonTypes/Data.js +55 -0
- package/ISA/ISA/JsonTypes/DataFile.js +68 -0
- package/ISA/ISA/JsonTypes/Factor.js +128 -0
- package/ISA/ISA/JsonTypes/FactorValue.js +109 -0
- package/ISA/ISA/JsonTypes/Investigation.js +204 -0
- package/ISA/ISA/JsonTypes/Material.js +66 -0
- package/ISA/ISA/JsonTypes/MaterialAttribute.js +101 -0
- package/ISA/ISA/JsonTypes/MaterialAttributeValue.js +126 -0
- package/ISA/ISA/JsonTypes/MaterialType.js +41 -0
- package/ISA/ISA/JsonTypes/OntologyAnnotation.js +219 -0
- package/ISA/ISA/JsonTypes/OntologySourceReference.js +85 -0
- package/ISA/ISA/JsonTypes/Person.js +137 -0
- package/ISA/ISA/JsonTypes/Process.js +401 -0
- package/ISA/ISA/JsonTypes/ProcessInput.js +297 -0
- package/ISA/ISA/JsonTypes/ProcessOutput.js +263 -0
- package/ISA/ISA/JsonTypes/ProcessParameterValue.js +129 -0
- package/ISA/ISA/JsonTypes/ProcessSequence.js +255 -0
- package/ISA/ISA/JsonTypes/Protocol.js +277 -0
- package/ISA/ISA/JsonTypes/ProtocolParameter.js +101 -0
- package/ISA/ISA/JsonTypes/Publication.js +105 -0
- package/ISA/ISA/JsonTypes/Sample.js +71 -0
- package/ISA/ISA/JsonTypes/Source.js +54 -0
- package/ISA/ISA/JsonTypes/Study.js +942 -0
- package/ISA/ISA/JsonTypes/StudyMaterials.js +45 -0
- package/ISA/ISA/JsonTypes/URI.js +19 -0
- package/ISA/ISA/JsonTypes/Value.js +210 -0
- package/ISA/ISA/Regex.js +588 -0
- package/ISA/ISA.Json/Assay.js +123 -0
- package/ISA/ISA.Json/Comment.js +84 -0
- package/ISA/ISA.Json/ConverterOptions.js +33 -0
- package/ISA/ISA.Json/Data.js +271 -0
- package/ISA/ISA.Json/Decode.js +46 -0
- package/ISA/ISA.Json/Factor.js +194 -0
- package/ISA/ISA.Json/GEncode.js +15 -0
- package/ISA/ISA.Json/Investigation.js +132 -0
- package/ISA/ISA.Json/Material.js +233 -0
- package/ISA/ISA.Json/Ontology.js +204 -0
- package/ISA/ISA.Json/Person.js +204 -0
- package/ISA/ISA.Json/Process.js +291 -0
- package/ISA/ISA.Json/Protocol.js +242 -0
- package/ISA/ISA.Json/Publication.js +92 -0
- package/ISA/ISA.Json/Study.js +230 -0
- package/ISA/ISA.Json/Validation/Fable.js +69 -0
- package/ISA/ISA.Json/Validation/JsonSchemaValidation.js +88 -0
- package/ISA/ISA.Json/Validation/ValidationResult.js +45 -0
- package/ISA/ISA.Spreadsheet/AnnotationTable/ArcTable.js +137 -0
- package/ISA/ISA.Spreadsheet/AnnotationTable/CompositeCell.js +78 -0
- package/ISA/ISA.Spreadsheet/AnnotationTable/CompositeColumn.js +59 -0
- package/ISA/ISA.Spreadsheet/AnnotationTable/CompositeHeader.js +478 -0
- package/ISA/ISA.Spreadsheet/ArcAssay.js +150 -0
- package/ISA/ISA.Spreadsheet/ArcInvestigation.js +314 -0
- package/ISA/ISA.Spreadsheet/ArcStudy.js +67 -0
- package/ISA/ISA.Spreadsheet/CollectionAux.js +128 -0
- package/ISA/ISA.Spreadsheet/Metadata/Assays.js +81 -0
- package/ISA/ISA.Spreadsheet/Metadata/Comment.js +60 -0
- package/ISA/ISA.Spreadsheet/Metadata/Contacts.js +104 -0
- package/ISA/ISA.Spreadsheet/Metadata/Conversions.js +180 -0
- package/ISA/ISA.Spreadsheet/Metadata/DesignDescriptors.js +27 -0
- package/ISA/ISA.Spreadsheet/Metadata/Factors.js +85 -0
- package/ISA/ISA.Spreadsheet/Metadata/OntologyAnnotation.js +65 -0
- package/ISA/ISA.Spreadsheet/Metadata/OntologySourceReference.js +73 -0
- package/ISA/ISA.Spreadsheet/Metadata/Protocols.js +116 -0
- package/ISA/ISA.Spreadsheet/Metadata/Publication.js +96 -0
- package/ISA/ISA.Spreadsheet/Metadata/SparseTable.js +451 -0
- package/ISA/ISA.Spreadsheet/Metadata/Study.js +260 -0
- package/README.md +277 -0
- package/SemVer.js +60 -0
- package/Templates/Templates.Json.js +40 -0
- package/Templates/Templates.Spreadsheet.js +315 -0
- package/Templates/Templates.js +179 -0
- package/fable_modules/FsSpreadsheet.4.1.0/Cells/FsCell.fs +387 -0
- package/fable_modules/FsSpreadsheet.4.1.0/Cells/FsCell.fs.js +240 -0
- package/fable_modules/FsSpreadsheet.4.1.0/Cells/FsCellsCollection.fs +725 -0
- package/fable_modules/FsSpreadsheet.4.1.0/Cells/FsCellsCollection.fs.js +522 -0
- package/fable_modules/FsSpreadsheet.4.1.0/DSL/CellBuilder.fs +195 -0
- package/fable_modules/FsSpreadsheet.4.1.0/DSL/CellBuilder.fs.js +208 -0
- package/fable_modules/FsSpreadsheet.4.1.0/DSL/ColumnBuilder.fs +209 -0
- package/fable_modules/FsSpreadsheet.4.1.0/DSL/ColumnBuilder.fs.js +137 -0
- package/fable_modules/FsSpreadsheet.4.1.0/DSL/DSL.fs +61 -0
- package/fable_modules/FsSpreadsheet.4.1.0/DSL/DSL.fs.js +62 -0
- package/fable_modules/FsSpreadsheet.4.1.0/DSL/Expression.fs +24 -0
- package/fable_modules/FsSpreadsheet.4.1.0/DSL/Expression.fs.js +56 -0
- package/fable_modules/FsSpreadsheet.4.1.0/DSL/Operators.fs +102 -0
- package/fable_modules/FsSpreadsheet.4.1.0/DSL/Operators.fs.js +6 -0
- package/fable_modules/FsSpreadsheet.4.1.0/DSL/RowBuilder.fs +200 -0
- package/fable_modules/FsSpreadsheet.4.1.0/DSL/RowBuilder.fs.js +137 -0
- package/fable_modules/FsSpreadsheet.4.1.0/DSL/SheetBuilder.fs +139 -0
- package/fable_modules/FsSpreadsheet.4.1.0/DSL/SheetBuilder.fs.js +116 -0
- package/fable_modules/FsSpreadsheet.4.1.0/DSL/TableBuilder.fs +120 -0
- package/fable_modules/FsSpreadsheet.4.1.0/DSL/TableBuilder.fs.js +120 -0
- package/fable_modules/FsSpreadsheet.4.1.0/DSL/Transform.fs +229 -0
- package/fable_modules/FsSpreadsheet.4.1.0/DSL/Transform.fs.js +421 -0
- package/fable_modules/FsSpreadsheet.4.1.0/DSL/Types.fs +151 -0
- package/fable_modules/FsSpreadsheet.4.1.0/DSL/Types.fs.js +277 -0
- package/fable_modules/FsSpreadsheet.4.1.0/DSL/WorkbookBuilder.fs +114 -0
- package/fable_modules/FsSpreadsheet.4.1.0/DSL/WorkbookBuilder.fs.js +104 -0
- package/fable_modules/FsSpreadsheet.4.1.0/FsAddress.fs +177 -0
- package/fable_modules/FsSpreadsheet.4.1.0/FsAddress.fs.js +249 -0
- package/fable_modules/FsSpreadsheet.4.1.0/FsColumn.fs +200 -0
- package/fable_modules/FsSpreadsheet.4.1.0/FsColumn.fs.js +125 -0
- package/fable_modules/FsSpreadsheet.4.1.0/FsRow.fs +202 -0
- package/fable_modules/FsSpreadsheet.4.1.0/FsRow.fs.js +135 -0
- package/fable_modules/FsSpreadsheet.4.1.0/FsSpreadsheet.fableproj +58 -0
- package/fable_modules/FsSpreadsheet.4.1.0/FsWorkbook.fs +183 -0
- package/fable_modules/FsSpreadsheet.4.1.0/FsWorkbook.fs.js +138 -0
- package/fable_modules/FsSpreadsheet.4.1.0/FsWorksheet.fs +628 -0
- package/fable_modules/FsSpreadsheet.4.1.0/FsWorksheet.fs.js +398 -0
- package/fable_modules/FsSpreadsheet.4.1.0/Ranges/FsRange.fs +19 -0
- package/fable_modules/FsSpreadsheet.4.1.0/Ranges/FsRange.fs.js +41 -0
- package/fable_modules/FsSpreadsheet.4.1.0/Ranges/FsRangeAddress.fs +222 -0
- package/fable_modules/FsSpreadsheet.4.1.0/Ranges/FsRangeAddress.fs.js +235 -0
- package/fable_modules/FsSpreadsheet.4.1.0/Ranges/FsRangeBase.fs +93 -0
- package/fable_modules/FsSpreadsheet.4.1.0/Ranges/FsRangeBase.fs.js +91 -0
- package/fable_modules/FsSpreadsheet.4.1.0/Ranges/FsRangeColumn.fs +65 -0
- package/fable_modules/FsSpreadsheet.4.1.0/Ranges/FsRangeColumn.fs.js +74 -0
- package/fable_modules/FsSpreadsheet.4.1.0/Ranges/FsRangeRow.fs +22 -0
- package/fable_modules/FsSpreadsheet.4.1.0/Ranges/FsRangeRow.fs.js +40 -0
- package/fable_modules/FsSpreadsheet.4.1.0/SheetBuilder.fs +249 -0
- package/fable_modules/FsSpreadsheet.4.1.0/SheetBuilder.fs.js +325 -0
- package/fable_modules/FsSpreadsheet.4.1.0/Tables/FsTable.fs +455 -0
- package/fable_modules/FsSpreadsheet.4.1.0/Tables/FsTable.fs.js +310 -0
- package/fable_modules/FsSpreadsheet.4.1.0/Tables/FsTableField.fs +140 -0
- package/fable_modules/FsSpreadsheet.4.1.0/Tables/FsTableField.fs.js +173 -0
- package/fable_modules/FsSpreadsheet.4.1.0/Tables/FsTableRow.fs +6 -0
- package/fable_modules/FsSpreadsheet.4.1.0/Tables/FsTableRow.fs.js +17 -0
- package/fable_modules/FsSpreadsheet.4.1.0/obj/Debug/netstandard2.0/.NETStandard,Version=v2.0.AssemblyAttributes.fs +3 -0
- package/fable_modules/FsSpreadsheet.4.1.0/obj/Debug/netstandard2.0/FsSpreadsheet.AssemblyInfo.fs +19 -0
- package/fable_modules/FsSpreadsheet.4.1.0/obj/Release/netstandard2.0/.NETStandard,Version=v2.0.AssemblyAttributes.fs +3 -0
- package/fable_modules/FsSpreadsheet.4.1.0/obj/Release/netstandard2.0/FsSpreadsheet.AssemblyInfo.fs +19 -0
- package/fable_modules/Thoth.Json.10.1.0/Decode.fs +1366 -0
- package/fable_modules/Thoth.Json.10.1.0/Decode.fs.js +1798 -0
- package/fable_modules/Thoth.Json.10.1.0/Encode.fs +621 -0
- package/fable_modules/Thoth.Json.10.1.0/Encode.fs.js +472 -0
- package/fable_modules/Thoth.Json.10.1.0/Extra.fs +31 -0
- package/fable_modules/Thoth.Json.10.1.0/Extra.fs.js +8 -0
- package/fable_modules/Thoth.Json.10.1.0/Thoth.Json.fableproj +30 -0
- package/fable_modules/Thoth.Json.10.1.0/Types.fs +59 -0
- package/fable_modules/Thoth.Json.10.1.0/Types.fs.js +98 -0
- package/fable_modules/Thoth.Json.10.1.0/obj/Release/netstandard2.0/Thoth.Json.AssemblyInfo.fs +19 -0
- package/fable_modules/Thoth.Json.10.1.0/package.json +5 -0
- package/fable_modules/fable-library.4.1.4/Array.d.ts +120 -0
- package/fable_modules/fable-library.4.1.4/Array.js +1204 -0
- package/fable_modules/fable-library.4.1.4/Async.d.ts +32 -0
- package/fable_modules/fable-library.4.1.4/Async.js +158 -0
- package/fable_modules/fable-library.4.1.4/AsyncBuilder.d.ts +59 -0
- package/fable_modules/fable-library.4.1.4/AsyncBuilder.js +183 -0
- package/fable_modules/fable-library.4.1.4/BigInt.d.ts +115 -0
- package/fable_modules/fable-library.4.1.4/BigInt.js +282 -0
- package/fable_modules/fable-library.4.1.4/BitConverter.d.ts +27 -0
- package/fable_modules/fable-library.4.1.4/BitConverter.js +138 -0
- package/fable_modules/fable-library.4.1.4/Boolean.d.ts +3 -0
- package/fable_modules/fable-library.4.1.4/Boolean.js +21 -0
- package/fable_modules/fable-library.4.1.4/Char.d.ts +65 -0
- package/fable_modules/fable-library.4.1.4/Char.js +169 -0
- package/fable_modules/fable-library.4.1.4/Choice.d.ts +138 -0
- package/fable_modules/fable-library.4.1.4/Choice.js +227 -0
- package/fable_modules/fable-library.4.1.4/Date.d.ts +70 -0
- package/fable_modules/fable-library.4.1.4/Date.js +451 -0
- package/fable_modules/fable-library.4.1.4/DateOffset.d.ts +63 -0
- package/fable_modules/fable-library.4.1.4/DateOffset.js +268 -0
- package/fable_modules/fable-library.4.1.4/DateOnly.d.ts +18 -0
- package/fable_modules/fable-library.4.1.4/DateOnly.js +124 -0
- package/fable_modules/fable-library.4.1.4/Decimal.d.ts +45 -0
- package/fable_modules/fable-library.4.1.4/Decimal.js +212 -0
- package/fable_modules/fable-library.4.1.4/Double.d.ts +11 -0
- package/fable_modules/fable-library.4.1.4/Double.js +46 -0
- package/fable_modules/fable-library.4.1.4/Encoding.d.ts +12 -0
- package/fable_modules/fable-library.4.1.4/Encoding.js +173 -0
- package/fable_modules/fable-library.4.1.4/Event.d.ts +31 -0
- package/fable_modules/fable-library.4.1.4/Event.js +93 -0
- package/fable_modules/fable-library.4.1.4/FSharp.Collections.d.ts +7 -0
- package/fable_modules/fable-library.4.1.4/FSharp.Collections.js +27 -0
- package/fable_modules/fable-library.4.1.4/FSharp.Core.d.ts +17 -0
- package/fable_modules/fable-library.4.1.4/FSharp.Core.js +69 -0
- package/fable_modules/fable-library.4.1.4/Global.d.ts +24 -0
- package/fable_modules/fable-library.4.1.4/Global.js +8 -0
- package/fable_modules/fable-library.4.1.4/Guid.d.ts +10 -0
- package/fable_modules/fable-library.4.1.4/Guid.js +142 -0
- package/fable_modules/fable-library.4.1.4/Int32.d.ts +28 -0
- package/fable_modules/fable-library.4.1.4/Int32.js +135 -0
- package/fable_modules/fable-library.4.1.4/List.d.ts +143 -0
- package/fable_modules/fable-library.4.1.4/List.js +1273 -0
- package/fable_modules/fable-library.4.1.4/Long.d.ts +3 -0
- package/fable_modules/fable-library.4.1.4/Long.js +46 -0
- package/fable_modules/fable-library.4.1.4/MailboxProcessor.d.ts +25 -0
- package/fable_modules/fable-library.4.1.4/MailboxProcessor.js +93 -0
- package/fable_modules/fable-library.4.1.4/Map.d.ts +178 -0
- package/fable_modules/fable-library.4.1.4/Map.js +1396 -0
- package/fable_modules/fable-library.4.1.4/MapUtil.d.ts +10 -0
- package/fable_modules/fable-library.4.1.4/MapUtil.js +112 -0
- package/fable_modules/fable-library.4.1.4/MutableMap.d.ts +52 -0
- package/fable_modules/fable-library.4.1.4/MutableMap.js +326 -0
- package/fable_modules/fable-library.4.1.4/MutableSet.d.ts +39 -0
- package/fable_modules/fable-library.4.1.4/MutableSet.js +232 -0
- package/fable_modules/fable-library.4.1.4/Native.d.ts +2 -0
- package/fable_modules/fable-library.4.1.4/Native.js +8 -0
- package/fable_modules/fable-library.4.1.4/Numeric.d.ts +19 -0
- package/fable_modules/fable-library.4.1.4/Numeric.js +71 -0
- package/fable_modules/fable-library.4.1.4/Observable.d.ts +32 -0
- package/fable_modules/fable-library.4.1.4/Observable.js +113 -0
- package/fable_modules/fable-library.4.1.4/Option.d.ts +28 -0
- package/fable_modules/fable-library.4.1.4/Option.js +96 -0
- package/fable_modules/fable-library.4.1.4/README.md +3 -0
- package/fable_modules/fable-library.4.1.4/Random.d.ts +37 -0
- package/fable_modules/fable-library.4.1.4/Random.js +170 -0
- package/fable_modules/fable-library.4.1.4/Range.d.ts +12 -0
- package/fable_modules/fable-library.4.1.4/Range.js +45 -0
- package/fable_modules/fable-library.4.1.4/Reflection.d.ts +119 -0
- package/fable_modules/fable-library.4.1.4/Reflection.js +461 -0
- package/fable_modules/fable-library.4.1.4/RegExp.d.ts +10 -0
- package/fable_modules/fable-library.4.1.4/RegExp.js +132 -0
- package/fable_modules/fable-library.4.1.4/Seq.d.ts +165 -0
- package/fable_modules/fable-library.4.1.4/Seq.js +1379 -0
- package/fable_modules/fable-library.4.1.4/Seq2.d.ts +18 -0
- package/fable_modules/fable-library.4.1.4/Seq2.js +111 -0
- package/fable_modules/fable-library.4.1.4/Set.d.ts +190 -0
- package/fable_modules/fable-library.4.1.4/Set.js +1789 -0
- package/fable_modules/fable-library.4.1.4/String.d.ts +49 -0
- package/fable_modules/fable-library.4.1.4/String.js +540 -0
- package/fable_modules/fable-library.4.1.4/System.Collections.Generic.d.ts +71 -0
- package/fable_modules/fable-library.4.1.4/System.Collections.Generic.js +307 -0
- package/fable_modules/fable-library.4.1.4/System.Text.d.ts +30 -0
- package/fable_modules/fable-library.4.1.4/System.Text.js +110 -0
- package/fable_modules/fable-library.4.1.4/SystemException.d.ts +5 -0
- package/fable_modules/fable-library.4.1.4/SystemException.js +5 -0
- package/fable_modules/fable-library.4.1.4/TimeOnly.d.ts +15 -0
- package/fable_modules/fable-library.4.1.4/TimeOnly.js +122 -0
- package/fable_modules/fable-library.4.1.4/TimeSpan.d.ts +34 -0
- package/fable_modules/fable-library.4.1.4/TimeSpan.js +177 -0
- package/fable_modules/fable-library.4.1.4/Timer.d.ts +19 -0
- package/fable_modules/fable-library.4.1.4/Timer.js +67 -0
- package/fable_modules/fable-library.4.1.4/Types.d.ts +58 -0
- package/fable_modules/fable-library.4.1.4/Types.js +208 -0
- package/fable_modules/fable-library.4.1.4/Unicode.13.0.0.d.ts +2 -0
- package/fable_modules/fable-library.4.1.4/Unicode.13.0.0.js +4 -0
- package/fable_modules/fable-library.4.1.4/Uri.d.ts +29 -0
- package/fable_modules/fable-library.4.1.4/Uri.js +142 -0
- package/fable_modules/fable-library.4.1.4/Util.d.ts +187 -0
- package/fable_modules/fable-library.4.1.4/Util.js +662 -0
- package/fable_modules/fable-library.4.1.4/lib/big.d.ts +338 -0
- package/fable_modules/fable-library.4.1.4/lib/big.js +826 -0
- package/fable_modules/fable-library.4.1.4/package.json +23 -0
- package/fable_modules/project_cracked.json +1 -0
- package/package.json +22 -0
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
import { toString as toString_1 } from "../fable-library.4.1.4/Decimal.js";
|
|
2
|
+
import { comparePrimitives, Lazy, disposeSafe, getEnumerator, defaultOf } from "../fable-library.4.1.4/Util.js";
|
|
3
|
+
import { empty, map as map_5, tryFind, add, toList } from "../fable-library.4.1.4/Map.js";
|
|
4
|
+
import { toString as toString_2 } from "../fable-library.4.1.4/BigInt.js";
|
|
5
|
+
import { toString as toString_3 } from "../fable-library.4.1.4/Date.js";
|
|
6
|
+
import { toString as toString_4 } from "../fable-library.4.1.4/TimeSpan.js";
|
|
7
|
+
import { map as map_1 } from "../fable-library.4.1.4/List.js";
|
|
8
|
+
import { defaultArg, map as map_2, defaultArgWith, some } from "../fable-library.4.1.4/Option.js";
|
|
9
|
+
import { toString as toString_5, FSharpRef } from "../fable-library.4.1.4/Types.js";
|
|
10
|
+
import { class_type, getGenerics, getGenericTypeDefinition, getTupleFields, getTupleElements, isTuple, isGenericType, getEnumUnderlyingType, isEnum, getElementType, isArray, getUnionCaseFields, getUnionFields, isUnion, getRecordElements, getRecordField, name, isRecord, fullName as fullName_1 } from "../fable-library.4.1.4/Reflection.js";
|
|
11
|
+
import { fill, map as map_3 } from "../fable-library.4.1.4/Array.js";
|
|
12
|
+
import { Util_CachedEncoders, Util_Cache$1__GetOrAdd_43981464, CaseStrategy, Util_Casing_convert } from "./Types.fs.js";
|
|
13
|
+
import { mapIndexed, map as map_4, fold } from "../fable-library.4.1.4/Seq.js";
|
|
14
|
+
import { toFail, printf, toText } from "../fable-library.4.1.4/String.js";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* **Description**
|
|
18
|
+
* Encode a GUID
|
|
19
|
+
*
|
|
20
|
+
* **Parameters**
|
|
21
|
+
* * `value` - parameter of type `System.Guid`
|
|
22
|
+
*
|
|
23
|
+
* **Output Type**
|
|
24
|
+
* * `Value`
|
|
25
|
+
*
|
|
26
|
+
* **Exceptions**
|
|
27
|
+
*/
|
|
28
|
+
export function guid(value) {
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* **Description**
|
|
34
|
+
* Encode a Decimal.
|
|
35
|
+
*
|
|
36
|
+
* **Parameters**
|
|
37
|
+
* * `value` - parameter of type `decimal`
|
|
38
|
+
*
|
|
39
|
+
* **Output Type**
|
|
40
|
+
* * `Value`
|
|
41
|
+
*
|
|
42
|
+
* **Exceptions**
|
|
43
|
+
*/
|
|
44
|
+
export function decimal(value) {
|
|
45
|
+
return toString_1(value);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const nil = defaultOf();
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* **Description**
|
|
52
|
+
* Encode an object
|
|
53
|
+
*
|
|
54
|
+
* **Parameters**
|
|
55
|
+
* * `values` - parameter of type `(string * Value) list`
|
|
56
|
+
*
|
|
57
|
+
* **Output Type**
|
|
58
|
+
* * `Value`
|
|
59
|
+
*
|
|
60
|
+
* **Exceptions**
|
|
61
|
+
*/
|
|
62
|
+
export function object(values) {
|
|
63
|
+
const o = {};
|
|
64
|
+
const enumerator = getEnumerator(values);
|
|
65
|
+
try {
|
|
66
|
+
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
67
|
+
const forLoopVar = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
68
|
+
o[forLoopVar[0]] = forLoopVar[1];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
disposeSafe(enumerator);
|
|
73
|
+
}
|
|
74
|
+
return o;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* **Description**
|
|
79
|
+
* Encode a list
|
|
80
|
+
* **Parameters**
|
|
81
|
+
* * `values` - parameter of type `Value list`
|
|
82
|
+
*
|
|
83
|
+
* **Output Type**
|
|
84
|
+
* * `Value`
|
|
85
|
+
*
|
|
86
|
+
* **Exceptions**
|
|
87
|
+
*/
|
|
88
|
+
export function list(values) {
|
|
89
|
+
return Array.from(values);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function seq(values) {
|
|
93
|
+
return Array.from(values);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* **Description**
|
|
98
|
+
* Encode a dictionary
|
|
99
|
+
* **Parameters**
|
|
100
|
+
* * `values` - parameter of type `Map<string, Value>`
|
|
101
|
+
*
|
|
102
|
+
* **Output Type**
|
|
103
|
+
* * `Value`
|
|
104
|
+
*
|
|
105
|
+
* **Exceptions**
|
|
106
|
+
*/
|
|
107
|
+
export function dict(values) {
|
|
108
|
+
return object(toList(values));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function bigint(value) {
|
|
112
|
+
return toString_2(value);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function datetimeOffset(value) {
|
|
116
|
+
return toString_3(value, "O", {});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* **Description**
|
|
121
|
+
* Encode a timespan
|
|
122
|
+
* **Parameters**
|
|
123
|
+
* * `value` - parameter of type `System.TimeSpan`
|
|
124
|
+
*
|
|
125
|
+
* **Output Type**
|
|
126
|
+
* * `Value`
|
|
127
|
+
*
|
|
128
|
+
* **Exceptions**
|
|
129
|
+
*/
|
|
130
|
+
export function timespan(value) {
|
|
131
|
+
return toString_4(value);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export function int64(value) {
|
|
135
|
+
return String(value);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function uint64(value) {
|
|
139
|
+
return String(value);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function unit() {
|
|
143
|
+
return defaultOf();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function tuple2(enc1, enc2, v1, v2) {
|
|
147
|
+
return [enc1(v1), enc2(v2)];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export function tuple3(enc1, enc2, enc3, v1, v2, v3) {
|
|
151
|
+
return [enc1(v1), enc2(v2), enc3(v3)];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export function tuple4(enc1, enc2, enc3, enc4, v1, v2, v3, v4) {
|
|
155
|
+
return [enc1(v1), enc2(v2), enc3(v3), enc4(v4)];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export function tuple5(enc1, enc2, enc3, enc4, enc5, v1, v2, v3, v4, v5) {
|
|
159
|
+
return [enc1(v1), enc2(v2), enc3(v3), enc4(v4), enc5(v5)];
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export function tuple6(enc1, enc2, enc3, enc4, enc5, enc6, v1, v2, v3, v4, v5, v6) {
|
|
163
|
+
return [enc1(v1), enc2(v2), enc3(v3), enc4(v4), enc5(v5), enc6(v6)];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export function tuple7(enc1, enc2, enc3, enc4, enc5, enc6, enc7, v1, v2, v3, v4, v5, v6, v7) {
|
|
167
|
+
return [enc1(v1), enc2(v2), enc3(v3), enc4(v4), enc5(v5), enc6(v6), enc7(v7)];
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export function tuple8(enc1, enc2, enc3, enc4, enc5, enc6, enc7, enc8, v1, v2, v3, v4, v5, v6, v7, v8) {
|
|
171
|
+
return [enc1(v1), enc2(v2), enc3(v3), enc4(v4), enc5(v5), enc6(v6), enc7(v7), enc8(v8)];
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export function map(keyEncoder, valueEncoder, values) {
|
|
175
|
+
return list(map_1((tupledArg) => tuple2(keyEncoder, valueEncoder, tupledArg[0], tupledArg[1]), toList(values)));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function Enum_byte(value) {
|
|
179
|
+
return value;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function Enum_sbyte(value) {
|
|
183
|
+
return value;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export function Enum_int16(value) {
|
|
187
|
+
return value;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export function Enum_uint16(value) {
|
|
191
|
+
return value;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export function Enum_int(value) {
|
|
195
|
+
return value;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export function Enum_uint32(value) {
|
|
199
|
+
return value;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* **Description**
|
|
204
|
+
*
|
|
205
|
+
* The DateTime is always encoded using UTC representation
|
|
206
|
+
*
|
|
207
|
+
* **Parameters**
|
|
208
|
+
* * `value` - parameter of type `System.DateTime`
|
|
209
|
+
*
|
|
210
|
+
* **Output Type**
|
|
211
|
+
* * `Value`
|
|
212
|
+
*
|
|
213
|
+
* **Exceptions**
|
|
214
|
+
*/
|
|
215
|
+
export function datetime(value) {
|
|
216
|
+
return toString_3(value, "O", {});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* **Description**
|
|
221
|
+
* Convert a `Value` into a prettified string.
|
|
222
|
+
* **Parameters**
|
|
223
|
+
* * `space` - parameter of type `int` - Amount of indentation
|
|
224
|
+
* * `value` - parameter of type `obj` - Value to convert
|
|
225
|
+
*
|
|
226
|
+
* **Output Type**
|
|
227
|
+
* * `string`
|
|
228
|
+
*
|
|
229
|
+
* **Exceptions**
|
|
230
|
+
*/
|
|
231
|
+
export function toString(space, value) {
|
|
232
|
+
return JSON.stringify(value, void 0, some(space));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* **Description**
|
|
237
|
+
* Encode an option
|
|
238
|
+
* **Parameters**
|
|
239
|
+
* * `encoder` - parameter of type `'a -> Value`
|
|
240
|
+
*
|
|
241
|
+
* **Output Type**
|
|
242
|
+
* * `'a option -> Value`
|
|
243
|
+
*
|
|
244
|
+
* **Exceptions**
|
|
245
|
+
*/
|
|
246
|
+
export function option(encoder) {
|
|
247
|
+
return (arg) => defaultArgWith(map_2(encoder, arg), () => nil);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function autoEncodeRecordsAndUnions(extra, caseStrategy, skipNullField, t) {
|
|
251
|
+
let arg;
|
|
252
|
+
const encoderRef = new FSharpRef(defaultOf());
|
|
253
|
+
let extra_1;
|
|
254
|
+
const matchValue = fullName_1(t);
|
|
255
|
+
extra_1 = ((matchValue === "") ? extra : add(matchValue, encoderRef, extra));
|
|
256
|
+
let encoder;
|
|
257
|
+
if (isRecord(t, true)) {
|
|
258
|
+
const setters = map_3((fi) => {
|
|
259
|
+
const targetKey = Util_Casing_convert(caseStrategy, name(fi));
|
|
260
|
+
const encode_1 = autoEncoder(extra_1, caseStrategy, skipNullField, fi[1]);
|
|
261
|
+
return (source) => ((target) => {
|
|
262
|
+
const value = getRecordField(source, fi);
|
|
263
|
+
if (!skipNullField ? true : (skipNullField && !(value == null))) {
|
|
264
|
+
target[targetKey]=encode_1(value);
|
|
265
|
+
}
|
|
266
|
+
return target;
|
|
267
|
+
});
|
|
268
|
+
}, getRecordElements(t, true));
|
|
269
|
+
encoder = ((source_1) => fold((target_1, set$) => set$(source_1)(target_1), {}, setters));
|
|
270
|
+
}
|
|
271
|
+
else if (isUnion(t, true)) {
|
|
272
|
+
encoder = ((value_1) => {
|
|
273
|
+
const patternInput = getUnionFields(value_1, t, true);
|
|
274
|
+
const info = patternInput[0];
|
|
275
|
+
const fields = patternInput[1];
|
|
276
|
+
const matchValue_1 = fields.length | 0;
|
|
277
|
+
if (matchValue_1 === 0) {
|
|
278
|
+
return name(info);
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
const len = matchValue_1 | 0;
|
|
282
|
+
const fieldTypes = getUnionCaseFields(info);
|
|
283
|
+
const target_2 = fill(new Array(len + 1), 0, len + 1, null);
|
|
284
|
+
target_2[0] = name(info);
|
|
285
|
+
for (let i = 1; i <= len; i++) {
|
|
286
|
+
const encode_2 = autoEncoder(extra_1, caseStrategy, skipNullField, fieldTypes[i - 1][1]);
|
|
287
|
+
target_2[i] = encode_2(fields[i - 1]);
|
|
288
|
+
}
|
|
289
|
+
return target_2;
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
throw new Error((arg = fullName_1(t), toText(printf("Cannot generate auto encoder for %s. Please pass an extra encoder.\n\nDocumentation available at: https://thoth-org.github.io/Thoth.Json/documentation/auto/extra-coders.html#ready-to-use-extra-coders"))(arg)));
|
|
295
|
+
}
|
|
296
|
+
encoderRef.contents = encoder;
|
|
297
|
+
return encoder;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function autoEncoder(extra, caseStrategy, skipNullField, t) {
|
|
301
|
+
const fullname = fullName_1(t);
|
|
302
|
+
const matchValue = tryFind(fullname, extra);
|
|
303
|
+
if (matchValue == null) {
|
|
304
|
+
if (isArray(t)) {
|
|
305
|
+
const encoder = autoEncoder(extra, caseStrategy, skipNullField, getElementType(t));
|
|
306
|
+
return (value) => seq(map_4(encoder, value));
|
|
307
|
+
}
|
|
308
|
+
else if (isEnum(t)) {
|
|
309
|
+
const enumType = fullName_1(getEnumUnderlyingType(t));
|
|
310
|
+
switch (enumType) {
|
|
311
|
+
case "System.SByte":
|
|
312
|
+
return (value_1) => value_1;
|
|
313
|
+
case "System.Byte":
|
|
314
|
+
return (value_3) => value_3;
|
|
315
|
+
case "System.Int16":
|
|
316
|
+
return (value_5) => value_5;
|
|
317
|
+
case "System.UInt16":
|
|
318
|
+
return (value_7) => value_7;
|
|
319
|
+
case "System.Int32":
|
|
320
|
+
return (value_9) => value_9;
|
|
321
|
+
case "System.UInt32":
|
|
322
|
+
return (value_11) => value_11;
|
|
323
|
+
default: {
|
|
324
|
+
const arg = fullName_1(t);
|
|
325
|
+
const clo_1 = toFail(printf("Cannot generate auto encoder for %s.\nThoth.Json.Net only support the following enum types:\n- sbyte\n- byte\n- int16\n- uint16\n- int\n- uint32\n\nIf you can\'t use one of these types, please pass an extra encoder.\n\nDocumentation available at: https://thoth-org.github.io/Thoth.Json/documentation/auto/extra-coders.html#ready-to-use-extra-coders\n "))(arg);
|
|
326
|
+
return clo_1;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
else if (isGenericType(t)) {
|
|
331
|
+
if (isTuple(t)) {
|
|
332
|
+
const encoders = map_3((t_2) => autoEncoder(extra, caseStrategy, skipNullField, t_2), getTupleElements(t));
|
|
333
|
+
return (value_13) => seq(mapIndexed((i, x) => encoders[i](x), getTupleFields(value_13)));
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
const fullname_1 = fullName_1(getGenericTypeDefinition(t));
|
|
337
|
+
if (fullname_1 === "Microsoft.FSharp.Core.FSharpOption`1[System.Object]") {
|
|
338
|
+
const encoder_2 = new Lazy(() => option(autoEncoder(extra, caseStrategy, skipNullField, getGenerics(t)[0])));
|
|
339
|
+
return (value_14) => {
|
|
340
|
+
if (value_14 == null) {
|
|
341
|
+
return nil;
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
return encoder_2.Value(value_14);
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
else if (((fullname_1 === "Microsoft.FSharp.Collections.FSharpList`1[System.Object]") ? true : (fullname_1 === "Microsoft.FSharp.Collections.FSharpSet`1[System.Object]")) ? true : (fullname_1 === "System.Collections.Generic.IEnumerable`1[System.Object]")) {
|
|
349
|
+
const encoder_3 = autoEncoder(extra, caseStrategy, skipNullField, getGenerics(t)[0]);
|
|
350
|
+
return (value_15) => seq(map_4(encoder_3, value_15));
|
|
351
|
+
}
|
|
352
|
+
else if (fullname_1 === "Microsoft.FSharp.Collections.FSharpMap`2[System.Object,System.Object]") {
|
|
353
|
+
const keyType = getGenerics(t)[0];
|
|
354
|
+
const valueEncoder = autoEncoder(extra, caseStrategy, skipNullField, getGenerics(t)[1]);
|
|
355
|
+
if ((fullName_1(keyType) === "System.String") ? true : (fullName_1(keyType) === "System.Guid")) {
|
|
356
|
+
return (value_16) => fold((target, _arg) => {
|
|
357
|
+
const activePatternResult = _arg;
|
|
358
|
+
target[activePatternResult[0]]=valueEncoder(activePatternResult[1]);
|
|
359
|
+
return target;
|
|
360
|
+
}, {}, value_16);
|
|
361
|
+
}
|
|
362
|
+
else {
|
|
363
|
+
let keyEncoder;
|
|
364
|
+
const clo_2 = autoEncoder(extra, caseStrategy, skipNullField, keyType);
|
|
365
|
+
keyEncoder = (clo_2);
|
|
366
|
+
return (value_17) => seq(map_4((_arg_1) => {
|
|
367
|
+
const activePatternResult_1 = _arg_1;
|
|
368
|
+
return [keyEncoder(activePatternResult_1[0]), valueEncoder(activePatternResult_1[1])];
|
|
369
|
+
}, value_17));
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
return autoEncodeRecordsAndUnions(extra, caseStrategy, skipNullField, t);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
switch (fullname) {
|
|
379
|
+
case "System.Boolean":
|
|
380
|
+
return (value_18) => value_18;
|
|
381
|
+
case "Microsoft.FSharp.Core.Unit":
|
|
382
|
+
return unit;
|
|
383
|
+
case "System.String":
|
|
384
|
+
return (value_20) => value_20;
|
|
385
|
+
case "System.Char":
|
|
386
|
+
return (value_22) => value_22;
|
|
387
|
+
case "System.SByte":
|
|
388
|
+
return (value_24) => value_24;
|
|
389
|
+
case "System.Byte":
|
|
390
|
+
return (value_26) => value_26;
|
|
391
|
+
case "System.Int16":
|
|
392
|
+
return (value_28) => value_28;
|
|
393
|
+
case "System.UInt16":
|
|
394
|
+
return (value_30) => value_30;
|
|
395
|
+
case "System.Int32":
|
|
396
|
+
return (value_32) => value_32;
|
|
397
|
+
case "System.UInt32":
|
|
398
|
+
return (value_34) => value_34;
|
|
399
|
+
case "System.Double":
|
|
400
|
+
return (value_36) => value_36;
|
|
401
|
+
case "System.Single":
|
|
402
|
+
return (value_38) => value_38;
|
|
403
|
+
case "System.DateTime":
|
|
404
|
+
return datetime;
|
|
405
|
+
case "System.DateTimeOffset":
|
|
406
|
+
return datetimeOffset;
|
|
407
|
+
case "System.TimeSpan":
|
|
408
|
+
return timespan;
|
|
409
|
+
case "System.Guid":
|
|
410
|
+
return guid;
|
|
411
|
+
case "System.Object":
|
|
412
|
+
return (x_1) => x_1;
|
|
413
|
+
default:
|
|
414
|
+
return autoEncodeRecordsAndUnions(extra, caseStrategy, skipNullField, t);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
else {
|
|
419
|
+
const encoderRef = matchValue;
|
|
420
|
+
return (v) => encoderRef.contents(v);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
function makeExtra(extra) {
|
|
425
|
+
if (extra != null) {
|
|
426
|
+
return map_5((_arg, tupledArg) => (new FSharpRef(tupledArg[0])), extra.Coders);
|
|
427
|
+
}
|
|
428
|
+
else {
|
|
429
|
+
return empty({
|
|
430
|
+
Compare: comparePrimitives,
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
export class Auto {
|
|
436
|
+
constructor() {
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
export function Auto_$reflection() {
|
|
441
|
+
return class_type("Thoth.Json.Encode.Auto", void 0, Auto);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
export function Auto_generateBoxedEncoderCached_437914C6(t, caseStrategy, extra, skipNullField) {
|
|
445
|
+
let y_1, y;
|
|
446
|
+
const caseStrategy_1 = defaultArg(caseStrategy, new CaseStrategy(0, []));
|
|
447
|
+
const skipNullField_1 = defaultArg(skipNullField, true);
|
|
448
|
+
return Util_Cache$1__GetOrAdd_43981464(Util_CachedEncoders, (y_1 = ((y = fullName_1(t), toString_5(caseStrategy_1) + y)), defaultArg(map_2((e) => e.Hash, extra), "") + y_1), () => autoEncoder(makeExtra(extra), caseStrategy_1, skipNullField_1, t));
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
export function Auto_generateBoxedEncoder_437914C6(t, caseStrategy, extra, skipNullField) {
|
|
452
|
+
const caseStrategy_1 = defaultArg(caseStrategy, new CaseStrategy(0, []));
|
|
453
|
+
const skipNullField_1 = defaultArg(skipNullField, true);
|
|
454
|
+
return autoEncoder(makeExtra(extra), caseStrategy_1, skipNullField_1, t);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* **Description**
|
|
459
|
+
* Convert a `Value` into a prettified string.
|
|
460
|
+
* **Parameters**
|
|
461
|
+
* * `space` - parameter of type `int` - Amount of indentation
|
|
462
|
+
* * `value` - parameter of type `obj` - Value to convert
|
|
463
|
+
*
|
|
464
|
+
* **Output Type**
|
|
465
|
+
* * `string`
|
|
466
|
+
*
|
|
467
|
+
* **Exceptions**
|
|
468
|
+
*/
|
|
469
|
+
export function encode(space, value) {
|
|
470
|
+
return toString(space, value);
|
|
471
|
+
}
|
|
472
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
[<RequireQualifiedAccess>]
|
|
2
|
+
module Thoth.Json.Extra
|
|
3
|
+
|
|
4
|
+
open Fable.Core
|
|
5
|
+
|
|
6
|
+
#if !FABLE_REPL_LIB
|
|
7
|
+
let empty: ExtraCoders =
|
|
8
|
+
{ Hash = ""
|
|
9
|
+
Coders = Map.empty }
|
|
10
|
+
|
|
11
|
+
let inline internal withCustomAndKey (encoder: Encoder<'Value>) (decoder: Decoder<'Value>)
|
|
12
|
+
(extra: ExtraCoders): ExtraCoders =
|
|
13
|
+
{ extra with
|
|
14
|
+
Hash = System.Guid.NewGuid().ToString()
|
|
15
|
+
Coders =
|
|
16
|
+
extra.Coders |> Map.add typeof<'Value>.FullName (Encode.boxEncoder encoder, Decode.boxDecoder decoder) }
|
|
17
|
+
|
|
18
|
+
let inline withCustom (encoder: Encoder<'Value>) (decoder: Decoder<'Value>) (extra: ExtraCoders): ExtraCoders =
|
|
19
|
+
withCustomAndKey encoder decoder extra
|
|
20
|
+
|
|
21
|
+
let inline withInt64 (extra: ExtraCoders): ExtraCoders = withCustomAndKey Encode.int64 Decode.int64 extra
|
|
22
|
+
|
|
23
|
+
let inline withUInt64 (extra: ExtraCoders): ExtraCoders =
|
|
24
|
+
withCustomAndKey Encode.uint64 Decode.uint64 extra
|
|
25
|
+
|
|
26
|
+
let inline withDecimal (extra: ExtraCoders): ExtraCoders =
|
|
27
|
+
withCustomAndKey Encode.decimal Decode.decimal extra
|
|
28
|
+
|
|
29
|
+
let inline withBigInt (extra: ExtraCoders): ExtraCoders =
|
|
30
|
+
withCustomAndKey Encode.bigint Decode.bigint extra
|
|
31
|
+
#endif
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { empty as empty_1 } from "../fable-library.4.1.4/Map.js";
|
|
2
|
+
import { comparePrimitives } from "../fable-library.4.1.4/Util.js";
|
|
3
|
+
import { ExtraCoders } from "./Types.fs.js";
|
|
4
|
+
|
|
5
|
+
export const empty = new ExtraCoders("", empty_1({
|
|
6
|
+
Compare: comparePrimitives,
|
|
7
|
+
}));
|
|
8
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
|
3
|
+
<PropertyGroup>
|
|
4
|
+
<Description>
|
|
5
|
+
Elm-inspired encoder and decoder for JSON, this package is intended to be use on Fable side only.
|
|
6
|
+
|
|
7
|
+
If you are interested on using it against .NET Core or .NET Framework, please use Thoth.Json.Net.
|
|
8
|
+
</Description>
|
|
9
|
+
<PackageProjectUrl>https://github.com/thoth-org/Thoth.Json</PackageProjectUrl>
|
|
10
|
+
<Packagelicense>https://github.com/thoth-org/Thoth.Json/blob/master/LICENSE.md</Packagelicense>
|
|
11
|
+
<RepositoryUrl>https://github.com/thoth-org/Thoth.Json</RepositoryUrl>
|
|
12
|
+
<PackageTags>fable;fsharp;json</PackageTags>
|
|
13
|
+
<Authors>Maxime Mangel</Authors>
|
|
14
|
+
<Version>10.1.0</Version>
|
|
15
|
+
</PropertyGroup>
|
|
16
|
+
<PropertyGroup>
|
|
17
|
+
<TargetFramework>netstandard2.0</TargetFramework>
|
|
18
|
+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
|
19
|
+
</PropertyGroup>
|
|
20
|
+
<ItemGroup>
|
|
21
|
+
<Compile Include="Types.fs" />
|
|
22
|
+
<Compile Include="Decode.fs" />
|
|
23
|
+
<Compile Include="Encode.fs" />
|
|
24
|
+
<Compile Include="Extra.fs" />
|
|
25
|
+
</ItemGroup>
|
|
26
|
+
<ItemGroup>
|
|
27
|
+
<Content Include="*.fsproj; **\*.fs; **\*.js; package.json" PackagePath="fable" />
|
|
28
|
+
</ItemGroup>
|
|
29
|
+
<Import Project="..\.paket\Paket.Restore.targets" />
|
|
30
|
+
</Project>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
namespace Thoth.Json
|
|
2
|
+
open System.Text.RegularExpressions
|
|
3
|
+
|
|
4
|
+
type JsonValue = obj
|
|
5
|
+
|
|
6
|
+
type ErrorReason =
|
|
7
|
+
| BadPrimitive of string * JsonValue
|
|
8
|
+
| BadPrimitiveExtra of string * JsonValue * string
|
|
9
|
+
| BadType of string * JsonValue
|
|
10
|
+
| BadField of string * JsonValue
|
|
11
|
+
| BadPath of string * JsonValue * string
|
|
12
|
+
| TooSmallArray of string * JsonValue
|
|
13
|
+
| FailMessage of string
|
|
14
|
+
| BadOneOf of string list
|
|
15
|
+
|
|
16
|
+
type CaseStrategy =
|
|
17
|
+
| PascalCase
|
|
18
|
+
| CamelCase
|
|
19
|
+
| SnakeCase
|
|
20
|
+
|
|
21
|
+
type DecoderError = string * ErrorReason
|
|
22
|
+
|
|
23
|
+
type Decoder<'T> = string -> JsonValue -> Result<'T, DecoderError>
|
|
24
|
+
|
|
25
|
+
type Encoder<'T> = 'T -> JsonValue
|
|
26
|
+
|
|
27
|
+
type BoxedDecoder = Decoder<obj>
|
|
28
|
+
|
|
29
|
+
type BoxedEncoder = Encoder<obj>
|
|
30
|
+
|
|
31
|
+
type ExtraCoders =
|
|
32
|
+
{ Hash: string
|
|
33
|
+
Coders: Map<string, BoxedEncoder * BoxedDecoder> }
|
|
34
|
+
|
|
35
|
+
module internal Util =
|
|
36
|
+
open System.Collections.Generic
|
|
37
|
+
|
|
38
|
+
type Cache<'Value>() =
|
|
39
|
+
let cache = Dictionary<string, 'Value>()
|
|
40
|
+
member __.GetOrAdd(key, factory) =
|
|
41
|
+
match cache.TryGetValue(key) with
|
|
42
|
+
| true, x -> x
|
|
43
|
+
| false, _ ->
|
|
44
|
+
let x = factory()
|
|
45
|
+
cache.Add(key, x)
|
|
46
|
+
x
|
|
47
|
+
|
|
48
|
+
// Tree shaking will remove this if not used
|
|
49
|
+
// so no need to make them lazy in Fable
|
|
50
|
+
let CachedEncoders = Cache<BoxedEncoder>()
|
|
51
|
+
let CachedDecoders = Cache<BoxedDecoder>()
|
|
52
|
+
|
|
53
|
+
module Casing =
|
|
54
|
+
let lowerFirst (str : string) = str.[..0].ToLowerInvariant() + str.[1..]
|
|
55
|
+
let convert caseStrategy fieldName =
|
|
56
|
+
match caseStrategy with
|
|
57
|
+
| CamelCase -> lowerFirst fieldName
|
|
58
|
+
| SnakeCase -> Regex.Replace(lowerFirst fieldName, "[A-Z]","_$0").ToLowerInvariant()
|
|
59
|
+
| PascalCase -> fieldName
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { FSharpRef, Record, Union } from "../fable-library.4.1.4/Types.js";
|
|
2
|
+
import { record_type, class_type, tuple_type, lambda_type, union_type, list_type, obj_type, string_type } from "../fable-library.4.1.4/Reflection.js";
|
|
3
|
+
import { FSharpResult$2 } from "../fable-library.4.1.4/Choice.js";
|
|
4
|
+
import { defaultOf } from "../fable-library.4.1.4/Util.js";
|
|
5
|
+
import { addToDict, tryGetValue } from "../fable-library.4.1.4/MapUtil.js";
|
|
6
|
+
import { replace } from "../fable-library.4.1.4/RegExp.js";
|
|
7
|
+
|
|
8
|
+
export class ErrorReason extends Union {
|
|
9
|
+
constructor(tag, fields) {
|
|
10
|
+
super();
|
|
11
|
+
this.tag = tag;
|
|
12
|
+
this.fields = fields;
|
|
13
|
+
}
|
|
14
|
+
cases() {
|
|
15
|
+
return ["BadPrimitive", "BadPrimitiveExtra", "BadType", "BadField", "BadPath", "TooSmallArray", "FailMessage", "BadOneOf"];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function ErrorReason_$reflection() {
|
|
20
|
+
return union_type("Thoth.Json.ErrorReason", [], ErrorReason, () => [[["Item1", string_type], ["Item2", obj_type]], [["Item1", string_type], ["Item2", obj_type], ["Item3", string_type]], [["Item1", string_type], ["Item2", obj_type]], [["Item1", string_type], ["Item2", obj_type]], [["Item1", string_type], ["Item2", obj_type], ["Item3", string_type]], [["Item1", string_type], ["Item2", obj_type]], [["Item", string_type]], [["Item", list_type(string_type)]]]);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export class CaseStrategy extends Union {
|
|
24
|
+
constructor(tag, fields) {
|
|
25
|
+
super();
|
|
26
|
+
this.tag = tag;
|
|
27
|
+
this.fields = fields;
|
|
28
|
+
}
|
|
29
|
+
cases() {
|
|
30
|
+
return ["PascalCase", "CamelCase", "SnakeCase"];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function CaseStrategy_$reflection() {
|
|
35
|
+
return union_type("Thoth.Json.CaseStrategy", [], CaseStrategy, () => [[], [], []]);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export class ExtraCoders extends Record {
|
|
39
|
+
constructor(Hash, Coders) {
|
|
40
|
+
super();
|
|
41
|
+
this.Hash = Hash;
|
|
42
|
+
this.Coders = Coders;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function ExtraCoders_$reflection() {
|
|
47
|
+
return record_type("Thoth.Json.ExtraCoders", [], ExtraCoders, () => [["Hash", string_type], ["Coders", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, tuple_type(lambda_type(obj_type, obj_type), lambda_type(string_type, lambda_type(obj_type, union_type("Microsoft.FSharp.Core.FSharpResult`2", [obj_type, tuple_type(string_type, ErrorReason_$reflection())], FSharpResult$2, () => [[["ResultValue", obj_type]], [["ErrorValue", tuple_type(string_type, ErrorReason_$reflection())]]]))))])]]);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export class Util_Cache$1 {
|
|
51
|
+
constructor() {
|
|
52
|
+
this.cache = (new Map([]));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function Util_Cache$1_$reflection(gen0) {
|
|
57
|
+
return class_type("Thoth.Json.Util.Cache`1", [gen0], Util_Cache$1);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function Util_Cache$1_$ctor() {
|
|
61
|
+
return new Util_Cache$1();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function Util_Cache$1__GetOrAdd_43981464(__, key, factory) {
|
|
65
|
+
let matchValue;
|
|
66
|
+
let outArg = defaultOf();
|
|
67
|
+
matchValue = [tryGetValue(__.cache, key, new FSharpRef(() => outArg, (v) => {
|
|
68
|
+
outArg = v;
|
|
69
|
+
})), outArg];
|
|
70
|
+
if (matchValue[0]) {
|
|
71
|
+
return matchValue[1];
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
const x_1 = factory();
|
|
75
|
+
addToDict(__.cache, key, x_1);
|
|
76
|
+
return x_1;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export const Util_CachedEncoders = Util_Cache$1_$ctor();
|
|
81
|
+
|
|
82
|
+
export const Util_CachedDecoders = Util_Cache$1_$ctor();
|
|
83
|
+
|
|
84
|
+
export function Util_Casing_lowerFirst(str) {
|
|
85
|
+
return str.slice(void 0, 0 + 1).toLowerCase() + str.slice(1, str.length);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function Util_Casing_convert(caseStrategy, fieldName) {
|
|
89
|
+
switch (caseStrategy.tag) {
|
|
90
|
+
case 2:
|
|
91
|
+
return replace(Util_Casing_lowerFirst(fieldName), "[A-Z]", "_$0").toLowerCase();
|
|
92
|
+
case 0:
|
|
93
|
+
return fieldName;
|
|
94
|
+
default:
|
|
95
|
+
return Util_Casing_lowerFirst(fieldName);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|