@nfdi4plants/arctrl 1.0.0-alpha6 → 1.0.0-alpha7

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.
@@ -570,75 +570,39 @@ export function JsonTypes_composeProcessOutput(header, value) {
570
570
  */
571
571
  export function JsonTypes_cellOfValue(value, unit) {
572
572
  const value_2 = defaultArg(value, new Value(3, [""]));
573
- let matchResult, oa, text, u, f, u_1, f_1, i, u_2, i_1;
574
573
  switch (value_2.tag) {
575
- case 3: {
574
+ case 3:
576
575
  if (unit != null) {
577
- if (value_2.fields[0] === "") {
578
- matchResult = 2;
579
- u = unit;
580
- }
581
- else {
582
- matchResult = 7;
583
- }
576
+ const u = unit;
577
+ return new CompositeCell(2, [value_2.fields[0], u]);
584
578
  }
585
579
  else {
586
- matchResult = 1;
587
- text = value_2.fields[0];
580
+ return new CompositeCell(1, [value_2.fields[0]]);
588
581
  }
589
- break;
590
- }
591
- case 2: {
582
+ case 2:
592
583
  if (unit == null) {
593
- matchResult = 4;
594
- f_1 = value_2.fields[0];
584
+ return new CompositeCell(1, [value_2.fields[0].toString()]);
595
585
  }
596
586
  else {
597
- matchResult = 3;
598
- f = value_2.fields[0];
599
- u_1 = unit;
587
+ const u_1 = unit;
588
+ return new CompositeCell(2, [value_2.fields[0].toString(), u_1]);
600
589
  }
601
- break;
602
- }
603
- case 1: {
590
+ case 1:
604
591
  if (unit == null) {
605
- matchResult = 6;
606
- i_1 = value_2.fields[0];
592
+ return new CompositeCell(1, [int32ToString(value_2.fields[0])]);
607
593
  }
608
594
  else {
609
- matchResult = 5;
610
- i = value_2.fields[0];
611
- u_2 = unit;
595
+ const u_2 = unit;
596
+ return new CompositeCell(2, [int32ToString(value_2.fields[0]), u_2]);
612
597
  }
613
- break;
614
- }
615
598
  default:
616
599
  if (unit == null) {
617
- matchResult = 0;
618
- oa = value_2.fields[0];
600
+ return new CompositeCell(0, [value_2.fields[0]]);
619
601
  }
620
602
  else {
621
- matchResult = 7;
603
+ return toFail(printf("Could not parse value %O with unit %O"))(value_2)(unit);
622
604
  }
623
605
  }
624
- switch (matchResult) {
625
- case 0:
626
- return new CompositeCell(0, [oa]);
627
- case 1:
628
- return new CompositeCell(1, [text]);
629
- case 2:
630
- return new CompositeCell(2, ["", u]);
631
- case 3:
632
- return new CompositeCell(2, [f.toString(), u_1]);
633
- case 4:
634
- return new CompositeCell(1, [f_1.toString()]);
635
- case 5:
636
- return new CompositeCell(2, [int32ToString(i), u_2]);
637
- case 6:
638
- return new CompositeCell(1, [int32ToString(i_1)]);
639
- default:
640
- return toFail(printf("Could not parse value %O with unit %O"))(value_2)(unit);
641
- }
642
606
  }
643
607
 
644
608
  /**
@@ -1,15 +1,17 @@
1
1
  import { toString } from "../fable_modules/fable-library.4.1.4/Types.js";
2
- import { datetimeUtc, array, map as map_2, list as list_2, guid as guid_1, object as object_1, string, succeed, andThen } from "../fable_modules/Thoth.Json.10.1.0/Decode.fs.js";
2
+ import { dict, fromString, datetimeUtc, array as array_1, map as map_2, list as list_2, guid as guid_1, object as object_1, string, succeed, andThen } from "../fable_modules/Thoth.Json.10.1.0/Decode.fs.js";
3
3
  import { uncurry2, uncurry3 } from "../fable_modules/fable-library.4.1.4/Util.js";
4
- import { Template, Organisation } from "./Templates.js";
4
+ import { Template, Organisation } from "./Template.js";
5
5
  import { ConverterOptions_$ctor } from "../ISA/ISA.Json/ConverterOptions.js";
6
6
  import { decoder as decoder_2, encoder } from "../ISA/ISA.Json/Person.js";
7
7
  import { OntologyAnnotation_decoder, OntologyAnnotation_encoder } from "../ISA/ISA.Json/Ontology.js";
8
- import { datetime, list as list_1, guid, object } from "../fable_modules/Thoth.Json.10.1.0/Encode.fs.js";
9
- import { map } from "../fable_modules/fable-library.4.1.4/List.js";
8
+ import { toString as toString_1, datetime, list as list_1, guid, object } from "../fable_modules/Thoth.Json.10.1.0/Encode.fs.js";
9
+ import { ofArray, map } from "../fable_modules/fable-library.4.1.4/List.js";
10
10
  import { Process_decoder, Process_encoder } from "../ISA/ISA.Json/Process.js";
11
11
  import { map as map_1, delay, toList } from "../fable_modules/fable-library.4.1.4/Seq.js";
12
12
  import { ArcTables_fromProcesses_134EBDED, ArcTables__get_Item_Z524259A4 } from "../ISA/ISA/ArcTypes/ArcTables.js";
13
+ import { printf, toFail } from "../fable_modules/fable-library.4.1.4/String.js";
14
+ import { defaultArg } from "../fable_modules/fable-library.4.1.4/Option.js";
13
15
 
14
16
  export const Organisation_encode = toString;
15
17
 
@@ -34,7 +36,49 @@ export const Template_decode = (() => {
34
36
  const oaDecoder = OntologyAnnotation_decoder(ConverterOptions_$ctor());
35
37
  return (path_10) => ((v) => object_1((get$) => {
36
38
  let objectArg, arg_3, d, decoder, objectArg_1, objectArg_2, objectArg_3, objectArg_4, objectArg_5, objectArg_6, objectArg_7, objectArg_8, objectArg_9;
37
- return Template.create((objectArg = get$.Required, objectArg.Field("id", guid_1)), (arg_3 = ((d = ((decoder = Process_decoder(ConverterOptions_$ctor()), (path_1) => ((value_1) => list_2(uncurry2(decoder), path_1, value_1)))), (path_2) => ((value_2) => map_2((ps) => ArcTables__get_Item_Z524259A4(ArcTables_fromProcesses_134EBDED(ps), 0), uncurry2(d), path_2, value_2)))), (objectArg_1 = get$.Required, objectArg_1.Field("table", uncurry2(arg_3)))), (objectArg_2 = get$.Required, objectArg_2.Field("name", string)), (objectArg_3 = get$.Required, objectArg_3.Field("description", string)), (objectArg_4 = get$.Required, objectArg_4.Field("organisation", uncurry2(Organisation_decode))), (objectArg_5 = get$.Required, objectArg_5.Field("version", string)), (objectArg_6 = get$.Required, objectArg_6.Field("authors", (path_6, value_6) => array(uncurry2(personDecoder), path_6, value_6))), (objectArg_7 = get$.Required, objectArg_7.Field("endpoint_repositories", (path_7, value_7) => array(uncurry2(oaDecoder), path_7, value_7))), (objectArg_8 = get$.Required, objectArg_8.Field("tags", (path_8, value_8) => array(uncurry2(oaDecoder), path_8, value_8))), (objectArg_9 = get$.Required, objectArg_9.Field("last_updated", datetimeUtc)));
39
+ return Template.create((objectArg = get$.Required, objectArg.Field("id", guid_1)), (arg_3 = ((d = ((decoder = Process_decoder(ConverterOptions_$ctor()), (path_1) => ((value_1) => list_2(uncurry2(decoder), path_1, value_1)))), (path_2) => ((value_2) => map_2((ps) => ArcTables__get_Item_Z524259A4(ArcTables_fromProcesses_134EBDED(ps), 0), uncurry2(d), path_2, value_2)))), (objectArg_1 = get$.Required, objectArg_1.Field("table", uncurry2(arg_3)))), (objectArg_2 = get$.Required, objectArg_2.Field("name", string)), (objectArg_3 = get$.Required, objectArg_3.Field("description", string)), (objectArg_4 = get$.Required, objectArg_4.Field("organisation", uncurry2(Organisation_decode))), (objectArg_5 = get$.Required, objectArg_5.Field("version", string)), (objectArg_6 = get$.Required, objectArg_6.Field("authors", (path_6, value_6) => array_1(uncurry2(personDecoder), path_6, value_6))), (objectArg_7 = get$.Required, objectArg_7.Field("endpoint_repositories", (path_7, value_7) => array_1(uncurry2(oaDecoder), path_7, value_7))), (objectArg_8 = get$.Required, objectArg_8.Field("tags", (path_8, value_8) => array_1(uncurry2(oaDecoder), path_8, value_8))), (objectArg_9 = get$.Required, objectArg_9.Field("last_updated", datetimeUtc)));
38
40
  }, path_10, v));
39
41
  })();
40
42
 
43
+ export function Template_decodeFromString(jsonString) {
44
+ const matchValue = fromString(uncurry2(Template_decode), jsonString);
45
+ if (matchValue.tag === 1) {
46
+ return toFail(printf("Error. Given json string cannot be parsed to Template: %A"))(matchValue.fields[0]);
47
+ }
48
+ else {
49
+ return matchValue.fields[0];
50
+ }
51
+ }
52
+
53
+ export function Template_encodeToString(spaces, template) {
54
+ return toString_1(spaces, Template_encode(template));
55
+ }
56
+
57
+ export function Templates_encode(templateList) {
58
+ return object(map((tupledArg) => [tupledArg[0], Template_encode(tupledArg[1])], ofArray(templateList)));
59
+ }
60
+
61
+ export const Templates_decode = (() => {
62
+ const d = dict(uncurry2(Template_decode));
63
+ return (value) => fromString(uncurry2(d), value);
64
+ })();
65
+
66
+ export function Templates_decodeFromString(jsonString) {
67
+ const matchValue = Templates_decode(jsonString);
68
+ if (matchValue.tag === 1) {
69
+ return toFail(printf("Error. Given json string cannot be parsed to Templates map: %A"))(matchValue.fields[0]);
70
+ }
71
+ else {
72
+ return matchValue.fields[0];
73
+ }
74
+ }
75
+
76
+ export function Templates_encodeToString(spaces, templateList) {
77
+ return toString_1(spaces, Templates_encode(templateList));
78
+ }
79
+
80
+ export function ARCtrl_Template_Template__Template_ToJson_71136F3F(this$, spaces) {
81
+ const spaces_1 = defaultArg(spaces, 0) | 0;
82
+ return (template) => Template_encodeToString(spaces_1, template);
83
+ }
84
+
@@ -14,7 +14,7 @@ import { Person } from "../ISA/ISA/JsonTypes/Person.js";
14
14
  import { toArray } from "../fable_modules/fable-library.4.1.4/Option.js";
15
15
  import { toRows as toRows_1, fromRows as fromRows_1 } from "../ISA/ISA.Spreadsheet/Metadata/Contacts.js";
16
16
  import { parse } from "../fable_modules/fable-library.4.1.4/Guid.js";
17
- import { Template, Organisation } from "./Templates.js";
17
+ import { Template, Organisation } from "./Template.js";
18
18
  import { FsWorksheet } from "../fable_modules/FsSpreadsheet.4.1.0/FsWorksheet.fs.js";
19
19
  import { printf, toFail } from "../fable_modules/fable-library.4.1.4/String.js";
20
20
  import { toFsWorksheet, tryFromFsWorksheet } from "../ISA/ISA.Spreadsheet/AnnotationTable/ArcTable.js";
@@ -73,7 +73,7 @@ export class Metadata_Template_TemplateInfo extends Record {
73
73
  }
74
74
 
75
75
  export function Metadata_Template_TemplateInfo_$reflection() {
76
- return record_type("ARCtrl.Templates.Spreadsheet.Metadata.Template.TemplateInfo", [], Metadata_Template_TemplateInfo, () => [["Id", string_type], ["Name", string_type], ["Version", string_type], ["Description", string_type], ["Organisation", string_type], ["Table", string_type], ["Comments", list_type(Comment$_$reflection())]]);
76
+ return record_type("ARCtrl.Template.Spreadsheet.Metadata.Template.TemplateInfo", [], Metadata_Template_TemplateInfo, () => [["Id", string_type], ["Name", string_type], ["Version", string_type], ["Description", string_type], ["Organisation", string_type], ["Table", string_type], ["Comments", list_type(Comment$_$reflection())]]);
77
77
  }
78
78
 
79
79
  export function Metadata_Template_TemplateInfo_create(id, name, version, description, organisation, table, comments) {
@@ -93,7 +93,7 @@ export function Metadata_Template_TemplateInfo_FromSparseTable_651559CC(matrix)
93
93
  return Metadata_Template_TemplateInfo_create(SparseTable__TryGetValueDefault_5BAE6133(matrix, createMissingIdentifier(), ["Id", 0]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Name", 0]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Version", 0]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Description", 0]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Organisation", 0]), SparseTable__TryGetValueDefault_5BAE6133(matrix, "", ["Table", 0]), comments);
94
94
  }
95
95
 
96
- export function Metadata_Template_TemplateInfo_ToSparseTable_Z71FCD534(template) {
96
+ export function Metadata_Template_TemplateInfo_ToSparseTable_2285DF3F(template) {
97
97
  let copyOfStruct, copyOfStruct_1;
98
98
  const matrix = SparseTable_Create_Z2192E64B(void 0, Metadata_Template_TemplateInfo_get_Labels(), void 0, 2);
99
99
  let commentKeys = empty();
@@ -114,8 +114,8 @@ export function Metadata_Template_TemplateInfo_fromRows_9F97F2A(rows) {
114
114
  return [tupledArg[0], Metadata_Template_TemplateInfo_FromSparseTable_651559CC(tupledArg[3])];
115
115
  }
116
116
 
117
- export function Metadata_Template_TemplateInfo_toRows_Z71FCD534(template) {
118
- return SparseTable_ToRows_6A3D4534(Metadata_Template_TemplateInfo_ToSparseTable_Z71FCD534(template));
117
+ export function Metadata_Template_TemplateInfo_toRows_2285DF3F(template) {
118
+ return SparseTable_ToRows_6A3D4534(Metadata_Template_TemplateInfo_ToSparseTable_2285DF3F(template));
119
119
  }
120
120
 
121
121
  export function Metadata_Template_mapDeprecatedKeys(rows) {
@@ -247,7 +247,7 @@ export function Metadata_Template_fromRows(rows) {
247
247
  }
248
248
 
249
249
  export function Metadata_Template_toRows(template) {
250
- return delay(() => append(singleton(SparseRowModule_fromValues(["TEMPLATE"])), delay(() => append(Metadata_Template_TemplateInfo_toRows_Z71FCD534(template), delay(() => append(singleton(SparseRowModule_fromValues(["ERS"])), delay(() => append(Metadata_ER_toRows(void 0, ofArray(template.EndpointRepositories)), delay(() => append(singleton(SparseRowModule_fromValues(["TAGS"])), delay(() => append(Metadata_Tags_toRows(void 0, ofArray(template.Tags)), delay(() => append(singleton(SparseRowModule_fromValues(["AUTHORS"])), delay(() => toRows_1("Author", ofArray(template.Authors)))))))))))))))));
250
+ return delay(() => append(singleton(SparseRowModule_fromValues(["TEMPLATE"])), delay(() => append(Metadata_Template_TemplateInfo_toRows_2285DF3F(template), delay(() => append(singleton(SparseRowModule_fromValues(["ERS"])), delay(() => append(Metadata_ER_toRows(void 0, ofArray(template.EndpointRepositories)), delay(() => append(singleton(SparseRowModule_fromValues(["TAGS"])), delay(() => append(Metadata_Tags_toRows(void 0, ofArray(template.Tags)), delay(() => append(singleton(SparseRowModule_fromValues(["AUTHORS"])), delay(() => toRows_1("Author", ofArray(template.Authors)))))))))))))))));
251
251
  }
252
252
 
253
253
  export function Template_fromParts(templateInfo, ers, tags, authors, table, lastUpdated) {
@@ -0,0 +1,13 @@
1
+ import { defaultArg } from "../fable_modules/fable-library.4.1.4/Option.js";
2
+ import { singleton } from "../fable_modules/fable-library.4.1.4/AsyncBuilder.js";
3
+ import { downloadFile } from "../WebRequest/WebRequest.js";
4
+ import { Templates_decodeFromString } from "./Template.Json.js";
5
+
6
+ export function getTemplates(url) {
7
+ const url_1 = defaultArg(url, "https://github.com/nfdi4plants/Swate-templates/releases/download/latest/templates.json");
8
+ return singleton.Delay(() => singleton.Bind(downloadFile(url_1), (_arg) => {
9
+ const mapResult = Templates_decodeFromString(_arg);
10
+ return singleton.Return(mapResult);
11
+ }));
12
+ }
13
+
@@ -31,7 +31,7 @@ export class Organisation extends Union {
31
31
  }
32
32
 
33
33
  export function Organisation_$reflection() {
34
- return union_type("ARCtrl.Templates.Organisation", [], Organisation, () => [[], [["Item", string_type]]]);
34
+ return union_type("ARCtrl.Template.Organisation", [], Organisation, () => [[], [["Item", string_type]]]);
35
35
  }
36
36
 
37
37
  export class Template {
@@ -170,10 +170,10 @@ export class Template {
170
170
  }
171
171
 
172
172
  export function Template_$reflection() {
173
- return class_type("ARCtrl.Templates.Template", void 0, Template);
173
+ return class_type("ARCtrl.Template.Template", void 0, Template);
174
174
  }
175
175
 
176
- export function Template_$ctor_67157A5B(id, table, name, description, organisation, version, authors, repos, tags, lastUpdated) {
176
+ export function Template_$ctor_4AC720A8(id, table, name, description, organisation, version, authors, repos, tags, lastUpdated) {
177
177
  return new Template(id, table, name, description, organisation, version, authors, repos, tags, lastUpdated);
178
178
  }
179
179
 
@@ -0,0 +1,38 @@
1
+ import { awaitPromise } from "../fable_modules/fable-library.4.1.4/Async.js";
2
+ import { fetch$ } from "../fable_modules/Fable.Fetch.2.6.0/Fetch.fs.js";
3
+ import { empty } from "../fable_modules/fable-library.4.1.4/List.js";
4
+ import { singleton } from "../fable_modules/fable-library.4.1.4/AsyncBuilder.js";
5
+ import { Http_get } from "../fable_modules/Fable.SimpleHttp.3.5.0/Http.fs.js";
6
+ import { printf, toFail } from "../fable_modules/fable-library.4.1.4/String.js";
7
+ import "isomorphic-fetch";
8
+
9
+ export function NodeJs_isNode() {
10
+ return typeof process !== "undefined" &&
11
+ process.versions != null &&
12
+ process.versions.node != null;;
13
+ }
14
+
15
+ export function NodeJs_downloadFile(url) {
16
+ let pr_1, pr;
17
+ return awaitPromise((pr_1 = ((pr = fetch$(url, empty()), pr.then((res) => res.text()))), pr_1.then((txt) => txt)));
18
+ }
19
+
20
+ export function downloadFile(url) {
21
+ let isFable = false;
22
+ isFable = true;
23
+ const browserAndDotnet = () => singleton.Delay(() => singleton.Bind(Http_get(url), (_arg) => {
24
+ const statusCode = _arg[0] | 0;
25
+ const responseText = _arg[1];
26
+ return singleton.Return((statusCode === 200) ? responseText : toFail(printf("Status %d => %s"))(statusCode)(responseText));
27
+ }));
28
+ if (!isFable) {
29
+ return browserAndDotnet();
30
+ }
31
+ else if (NodeJs_isNode()) {
32
+ return NodeJs_downloadFile(url);
33
+ }
34
+ else {
35
+ return browserAndDotnet();
36
+ }
37
+ }
38
+
@@ -0,0 +1,21 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <Project Sdk="Microsoft.NET.Sdk">
3
+ <PropertyGroup>
4
+ <Version>2.6.0</Version>
5
+ <PackageVersion>2.6.0</PackageVersion>
6
+ <TargetFramework>netstandard2.0</TargetFramework>
7
+ </PropertyGroup>
8
+ <ItemGroup>
9
+ <Compile Include="Fetch.fs" />
10
+ </ItemGroup>
11
+ <ItemGroup>
12
+ <Content Include="*.fsproj; *.fs" PackagePath="fable\" />
13
+ </ItemGroup>
14
+ <ItemGroup>
15
+ <PackageReference Include="Fable.Browser.Blob" Version="1.2.0" />
16
+ <PackageReference Include="Fable.Browser.Event" Version="1.5.0" />
17
+ <PackageReference Include="Fable.Core" Version="3.7.1" />
18
+ <PackageReference Include="Fable.Promise" Version="2.2.2" />
19
+ <PackageReference Update="FSharp.Core" Version="4.7.2" />
20
+ </ItemGroup>
21
+ </Project>