@nfdi4plants/arctrl 1.0.0-alpha7 → 1.0.0-alpha9

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.
@@ -14,13 +14,13 @@ import { tryISAReadContractFromPath } from "./Contracts/Contracts.ARCtrl.js";
14
14
  import { ArcTables__get_Tables, ArcTables_$ctor_Z18C2F36D, ArcTables_updateReferenceTablesBySheets_Z2EE88E97 } from "./ISA/ISA/ArcTypes/ArcTables.js";
15
15
  import { addToDict } from "./fable_modules/fable-library.4.1.4/MapUtil.js";
16
16
  import { ArcInvestigation } from "./ISA/ISA/ArcTypes/ArcTypes.js";
17
- import { printf, toConsole } from "./fable_modules/fable-library.4.1.4/String.js";
18
17
  import { Assay_fileNameFromIdentifier, Study_fileNameFromIdentifier } from "./ISA/ISA/Identifier.js";
19
18
  import { Dictionary_tryGet } from "./fable_modules/FsSpreadsheet.4.1.0/Cells/FsCellsCollection.fs.js";
20
19
  import { Contract } from "./Contract/Contract.js";
21
20
  import { Clone_createCloneContract_5000466F, Init_createAddRemoteContract_Z721C83C5, gitignoreContract, Init_createInitContract_6DFDD678 } from "./Contracts/Contracts.Git.js";
22
21
  import { FSharpSet__Contains, ofSeq, unionMany } from "./fable_modules/fable-library.4.1.4/Set.js";
23
22
  import { comparePrimitives } from "./fable_modules/fable-library.4.1.4/Util.js";
23
+ import { ofSeq as ofSeq_1 } from "./fable_modules/fable-library.4.1.4/Map.js";
24
24
  import { class_type } from "./fable_modules/fable-library.4.1.4/Reflection.js";
25
25
 
26
26
  export function ARCAux_getArcAssaysFromContracts(contracts) {
@@ -82,6 +82,7 @@ export class ARC {
82
82
  set ISA(newISA) {
83
83
  const this$ = this;
84
84
  this$._isa = newISA;
85
+ this$.UpdateFileSystem();
85
86
  }
86
87
  get CWL() {
87
88
  const this$ = this;
@@ -144,7 +145,6 @@ export class ARC {
144
145
  const matchValue = this$.ISA;
145
146
  if (matchValue == null) {
146
147
  addToDict(workbooks, "isa.investigation.xlsx", ["ISA_Investigation", toFsWorkbook(ArcInvestigation.create("MISSING_IDENTIFIER_"))]);
147
- toConsole(printf("ARC contains no ISA part."));
148
148
  }
149
149
  else {
150
150
  const inv = matchValue;
@@ -245,6 +245,11 @@ export class ARC {
245
245
  }
246
246
  }, (tree = ((arg = ((array = FileSystemTree.toFilePaths()(this$._fs.Copy().Tree), array.filter((p) => !FSharpSet__Contains(registeredPayload, p)))), FileSystemTree.fromFilePaths(arg))), ignoreHidden ? FileSystemTree.filterFiles((n) => !(n.indexOf(".") === 0))(tree) : tree)), FileSystemTree.fromFilePaths([]));
247
247
  }
248
+ static get DefaultContracts() {
249
+ return ofSeq_1([[".gitignore", gitignoreContract]], {
250
+ Compare: comparePrimitives,
251
+ });
252
+ }
248
253
  }
249
254
 
250
255
  export function ARC_$reflection() {
@@ -1,14 +1,15 @@
1
1
  import { Dictionary } from "../../../fable_modules/fable-library.4.1.4/MutableMap.js";
2
- import { stringHash, compareArrays, safeHash, disposeSafe, getEnumerator, equals, comparePrimitives, arrayHash, equalArrays } from "../../../fable_modules/fable-library.4.1.4/Util.js";
3
- import { map as map_2, value as value_9, defaultArg, unwrap } from "../../../fable_modules/fable-library.4.1.4/Option.js";
2
+ import { compareArrays, safeHash, disposeSafe, getEnumerator, equals, comparePrimitives, arrayHash, equalArrays } from "../../../fable_modules/fable-library.4.1.4/Util.js";
3
+ import { value as value_9, map as map_2, defaultArg, unwrap } from "../../../fable_modules/fable-library.4.1.4/Option.js";
4
4
  import { Unchecked_extendToRowCount, ProcessParsing_processToRows, ProcessParsing_alignByHeaders, ProcessParsing_mergeIdenticalProcesses, ProcessParsing_getProcessGetter, Unchecked_removeRowCells_withIndexChange, Unchecked_addRow, Unchecked_getEmptyCellForHeader, Unchecked_removeColumnCells_withIndexChange, tryFindDuplicateUniqueInArray, Unchecked_removeColumnCells, Unchecked_removeHeader, Unchecked_fillMissingCells, Unchecked_addColumn, tryFindDuplicateUnique, Unchecked_setCellAt, SanityChecks_validateColumn, SanityChecks_validateRowIndex, SanityChecks_validateColumnIndex, Unchecked_tryGetCellAt, getRowCount, getColumnCount } from "./ArcTableAux.js";
5
- import { sortBy, item, append as append_1, indexed as indexed_1, choose, zip, fold, filter, length, singleton, collect, tryFindIndex, findIndex, toArray, removeAt, map, delay, toList } from "../../../fable_modules/fable-library.4.1.4/Seq.js";
5
+ import { item, append as append_1, indexed as indexed_1, choose, toList, zip, fold, filter, length, tryFindIndex, empty, singleton, collect, removeAt, map, delay, toArray } from "../../../fable_modules/fable-library.4.1.4/Seq.js";
6
6
  import { rangeDouble } from "../../../fable_modules/fable-library.4.1.4/Range.js";
7
7
  import { CompositeColumn } from "./CompositeColumn.js";
8
- import { indexed, mapIndexed, singleton as singleton_1, initialize, sortDescending, iterateIndexed, map as map_1 } from "../../../fable_modules/fable-library.4.1.4/Array.js";
9
- import { append, collect as collect_1, initialize as initialize_1, singleton as singleton_2, empty, iterate, isEmpty } from "../../../fable_modules/fable-library.4.1.4/List.js";
8
+ import { sortBy, indexed, mapIndexed, singleton as singleton_1, initialize, sortDescending, iterateIndexed, map as map_1 } from "../../../fable_modules/fable-library.4.1.4/Array.js";
9
+ import { append, collect as collect_1, initialize as initialize_1, singleton as singleton_2, empty as empty_1, iterate, isEmpty } from "../../../fable_modules/fable-library.4.1.4/List.js";
10
10
  import { StringBuilder__AppendLine_Z721C83C5, StringBuilder_$ctor } from "../../../fable_modules/fable-library.4.1.4/System.Text.js";
11
11
  import { toString } from "../../../fable_modules/fable-library.4.1.4/Types.js";
12
+ import { join, printf, toFail } from "../../../fable_modules/fable-library.4.1.4/String.js";
12
13
  import { CompositeCell } from "./CompositeCell.js";
13
14
  import { CompositeHeader } from "./CompositeHeader.js";
14
15
  import { createMissingIdentifier } from "../Identifier.js";
@@ -21,7 +22,7 @@ import { Array_groupBy, List_distinct } from "../../../fable_modules/fable-libra
21
22
  import { toProtocol } from "./CompositeRow.js";
22
23
  import { Process_create_Z42860F3E } from "../JsonTypes/Process.js";
23
24
  import { getItemFromDict } from "../../../fable_modules/fable-library.4.1.4/MapUtil.js";
24
- import { join } from "../../../fable_modules/fable-library.4.1.4/String.js";
25
+ import { HashCodes_boxHashArray } from "../Helper.js";
25
26
  import { class_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js";
26
27
 
27
28
  export class ArcTable {
@@ -79,7 +80,7 @@ export class ArcTable {
79
80
  let isValid = true;
80
81
  for (let columnIndex = 0; columnIndex <= (this$.ColumnCount - 1); columnIndex++) {
81
82
  const column = this$.GetColumn(columnIndex);
82
- isValid = column.validate(unwrap(raiseException));
83
+ isValid = column.Validate(unwrap(raiseException));
83
84
  }
84
85
  return isValid;
85
86
  }
@@ -96,7 +97,7 @@ export class ArcTable {
96
97
  }
97
98
  get Columns() {
98
99
  const this$ = this;
99
- return toList(delay(() => map((i) => this$.GetColumn(i), rangeDouble(0, 1, this$.ColumnCount - 1))));
100
+ return toArray(delay(() => map((i) => this$.GetColumn(i), rangeDouble(0, 1, this$.ColumnCount - 1))));
100
101
  }
101
102
  Copy() {
102
103
  const this$ = this;
@@ -136,7 +137,7 @@ export class ArcTable {
136
137
  throw new Error(`Invalid input. Tried setting unique header \`${header}\`, but header of same type already exists at index ${matchValue}.`);
137
138
  }
138
139
  const c = new CompositeColumn(newHeader, this$.GetColumn(index).Cells);
139
- if (c.validate()) {
140
+ if (c.Validate()) {
140
141
  let setHeader;
141
142
  setHeader = (this$.Headers[index] = newHeader);
142
143
  }
@@ -169,7 +170,7 @@ export class ArcTable {
169
170
  const forceReplace_1 = defaultArg(forceReplace, false);
170
171
  SanityChecks_validateColumnIndex(index_1, this$.ColumnCount, true);
171
172
  SanityChecks_validateColumn(CompositeColumn.create(header, cells_1));
172
- Unchecked_addColumn(header, cells_1, index_1, forceReplace_1, this$.Headers, this$.Values);
173
+ Unchecked_addColumn(header, cells_1, index_1, forceReplace_1, false, this$.Headers, this$.Values);
173
174
  Unchecked_fillMissingCells(this$.Headers, this$.Values);
174
175
  }
175
176
  static addColumn(header, cells, index, forceReplace) {
@@ -245,7 +246,7 @@ export class ArcTable {
245
246
  });
246
247
  columns.forEach((col) => {
247
248
  const prevHeadersCount = this$.Headers.length | 0;
248
- Unchecked_addColumn(col.Header, col.Cells, index_1, forceReplace_1, this$.Headers, this$.Values);
249
+ Unchecked_addColumn(col.Header, col.Cells, index_1, forceReplace_1, false, this$.Headers, this$.Values);
249
250
  if (this$.Headers.length > prevHeadersCount) {
250
251
  index_1 = ((index_1 + 1) | 0);
251
252
  }
@@ -296,26 +297,83 @@ export class ArcTable {
296
297
  const this$ = this;
297
298
  SanityChecks_validateColumnIndex(columnIndex, this$.ColumnCount, false);
298
299
  const h = this$.Headers[columnIndex];
299
- const cells = toArray(delay(() => map((i) => value_9(this$.TryGetCellAt(columnIndex, i)), rangeDouble(0, 1, this$.RowCount - 1))));
300
+ const cells = toArray(delay(() => collect((i) => {
301
+ const matchValue = this$.TryGetCellAt(columnIndex, i);
302
+ if (matchValue != null) {
303
+ return singleton(matchValue);
304
+ }
305
+ else {
306
+ toFail(printf("Unable to find cell for index: (%i, %i)"))(columnIndex)(i);
307
+ return empty();
308
+ }
309
+ }, rangeDouble(0, 1, this$.RowCount - 1))));
300
310
  return CompositeColumn.create(h, cells);
301
311
  }
302
312
  static getColumn(index) {
303
313
  return (table) => table.GetColumn(index);
304
314
  }
315
+ TryGetColumnByHeader(header) {
316
+ const this$ = this;
317
+ return map_2((i) => this$.GetColumn(i), tryFindIndex((x) => equals(x, header), this$.Headers));
318
+ }
319
+ static tryGetColumnByHeader(header) {
320
+ return (table) => table.TryGetColumnByHeader(header);
321
+ }
305
322
  GetColumnByHeader(header) {
306
323
  const this$ = this;
307
- const index = findIndex((x) => equals(x, header), this$.Headers) | 0;
308
- return this$.GetColumn(index);
324
+ const matchValue = this$.TryGetColumnByHeader(header);
325
+ if (matchValue == null) {
326
+ const arg = this$.Name;
327
+ return toFail(printf("Unable to find column with header in table %s: %O"))(arg)(header);
328
+ }
329
+ else {
330
+ return matchValue;
331
+ }
309
332
  }
310
333
  static getColumnByHeader(header) {
311
334
  return (table) => table.GetColumnByHeader(header);
312
335
  }
313
- TryGetColumnByHeader(header) {
336
+ TryGetInputColumn() {
314
337
  const this$ = this;
315
- return map_2((i) => this$.GetColumn(i), tryFindIndex((x) => equals(x, header), this$.Headers));
338
+ return map_2((i) => this$.GetColumn(i), tryFindIndex((x) => x.isInput, this$.Headers));
316
339
  }
317
- static tryGetColumnByHeader(header) {
318
- return (table) => table.TryGetColumnByHeader(header);
340
+ static tryGetInputColumn() {
341
+ return (table) => table.TryGetInputColumn();
342
+ }
343
+ GetInputColumn() {
344
+ const this$ = this;
345
+ const matchValue = this$.TryGetInputColumn();
346
+ if (matchValue == null) {
347
+ const arg = this$.Name;
348
+ return toFail(printf("Unable to find input column in table %s"))(arg);
349
+ }
350
+ else {
351
+ return matchValue;
352
+ }
353
+ }
354
+ static getInputColumn() {
355
+ return (table) => table.GetInputColumn();
356
+ }
357
+ TryGetOutputColumn() {
358
+ const this$ = this;
359
+ return map_2((i) => this$.GetColumn(i), tryFindIndex((x) => x.isOutput, this$.Headers));
360
+ }
361
+ static tryGetOutputColumn() {
362
+ return (table) => table.TryGetOutputColumn();
363
+ }
364
+ GetOutputColumn() {
365
+ const this$ = this;
366
+ const matchValue = this$.TryGetOutputColumn();
367
+ if (matchValue == null) {
368
+ const arg = this$.Name;
369
+ return toFail(printf("Unable to find output column in table %s"))(arg);
370
+ }
371
+ else {
372
+ return matchValue;
373
+ }
374
+ }
375
+ static getOutputColumn() {
376
+ return (table) => table.GetOutputColumn();
319
377
  }
320
378
  AddRow(cells, index) {
321
379
  const this$ = this;
@@ -476,6 +534,51 @@ export class ArcTable {
476
534
  static getRow(index) {
477
535
  return (table) => table.GetRow(index);
478
536
  }
537
+ Join(table, joinOptions, forceReplace) {
538
+ const this$ = this;
539
+ const joinOptions_1 = defaultArg(joinOptions, "headers");
540
+ const forceReplace_1 = defaultArg(forceReplace, false);
541
+ const onlyHeaders = joinOptions_1 === "headers";
542
+ let columns;
543
+ const pre = table.Columns;
544
+ columns = ((joinOptions_1 === "withUnit") ? map_1((c_1) => {
545
+ const unitsOpt = c_1.TryGetColumnUnits();
546
+ if (unitsOpt == null) {
547
+ return new CompositeColumn(c_1.Header, []);
548
+ }
549
+ else {
550
+ return new CompositeColumn(c_1.Header, map_1((u) => CompositeCell.createUnitized("", u), unitsOpt));
551
+ }
552
+ }, pre) : ((joinOptions_1 === "withValues") ? pre : map_1((c) => (new CompositeColumn(c.Header, [])), pre)));
553
+ const duplicates = tryFindDuplicateUniqueInArray(map((x) => x.Header, columns));
554
+ if (!isEmpty(duplicates)) {
555
+ const sb = StringBuilder_$ctor();
556
+ StringBuilder__AppendLine_Z721C83C5(sb, "Found duplicate unique columns in `columns`.");
557
+ iterate((x_1) => {
558
+ StringBuilder__AppendLine_Z721C83C5(sb, `Duplicate \`${x_1.HeaderType}\` at index ${x_1.Index1} and ${x_1.Index2}.`);
559
+ }, duplicates);
560
+ throw new Error(toString(sb));
561
+ }
562
+ columns.forEach((x_2) => {
563
+ SanityChecks_validateColumn(x_2);
564
+ });
565
+ let index = this$.ColumnCount;
566
+ columns.forEach((col) => {
567
+ const prevHeadersCount = this$.Headers.length | 0;
568
+ Unchecked_addColumn(col.Header, col.Cells, index, forceReplace_1, onlyHeaders, this$.Headers, this$.Values);
569
+ if (this$.Headers.length > prevHeadersCount) {
570
+ index = ((index + 1) | 0);
571
+ }
572
+ });
573
+ Unchecked_fillMissingCells(this$.Headers, this$.Values);
574
+ }
575
+ static join(table, joinOptions, forceReplace) {
576
+ return (this$) => {
577
+ const copy = this$.Copy();
578
+ copy.Join(table, unwrap(joinOptions), unwrap(forceReplace));
579
+ return copy;
580
+ };
581
+ }
479
582
  static insertParameterValue(t, p) {
480
583
  throw new Error();
481
584
  }
@@ -537,7 +640,7 @@ export class ArcTable {
537
640
  }
538
641
  static fromProtocol(p) {
539
642
  const t = ArcTable.init(defaultArg(p.Name, createMissingIdentifier()));
540
- const enumerator = getEnumerator(defaultArg(p.Parameters, empty()));
643
+ const enumerator = getEnumerator(defaultArg(p.Parameters, empty_1()));
541
644
  try {
542
645
  while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
543
646
  const pp = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
@@ -547,7 +650,7 @@ export class ArcTable {
547
650
  finally {
548
651
  disposeSafe(enumerator);
549
652
  }
550
- const enumerator_1 = getEnumerator(defaultArg(p.Components, empty()));
653
+ const enumerator_1 = getEnumerator(defaultArg(p.Components, empty_1()));
551
654
  try {
552
655
  while (enumerator_1["System.Collections.IEnumerator.MoveNext"]()) {
553
656
  const c = enumerator_1["System.Collections.Generic.IEnumerator`1.get_Current"]();
@@ -666,15 +769,10 @@ export class ArcTable {
666
769
  }, indexed_1(refTable_1.Headers)));
667
770
  refTable_1.RemoveColumns(nonProtocolColumns);
668
771
  Unchecked_extendToRowCount(annotationTable_1.RowCount, refTable_1.Headers, refTable_1.Values);
669
- const enumerator = getEnumerator(annotationTable_1.Columns);
670
- try {
671
- while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
672
- const c = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
673
- refTable_1.AddColumn(c.Header, c.Cells, void 0, true);
674
- }
675
- }
676
- finally {
677
- disposeSafe(enumerator);
772
+ const arr = annotationTable_1.Columns;
773
+ for (let idx = 0; idx <= (arr.length - 1); idx++) {
774
+ const c = arr[idx];
775
+ refTable_1.AddColumn(c.Header, c.Cells, void 0, true);
678
776
  }
679
777
  return refTable_1;
680
778
  }
@@ -690,6 +788,9 @@ export class ArcTable {
690
788
  StructurallyEquals(other) {
691
789
  let a, b;
692
790
  const this$ = this;
791
+ const sort = (arg) => sortBy((_arg) => _arg[0], Array.from(arg), {
792
+ Compare: compareArrays,
793
+ });
693
794
  if ((this$.Name === other.Name) && ((a = this$.Headers, (b = other.Headers, (length(a) === length(b)) && fold((acc, e) => {
694
795
  if (acc) {
695
796
  return e;
@@ -698,12 +799,8 @@ export class ArcTable {
698
799
  return false;
699
800
  }
700
801
  }, true, toList(delay(() => map((i) => equals(item(i, a), item(i, b)), rangeDouble(0, 1, length(a) - 1))))))))) {
701
- const a_1 = sortBy((x) => x[0], this$.Values, {
702
- Compare: compareArrays,
703
- });
704
- const b_1 = sortBy((x_2) => x_2[0], other.Values, {
705
- Compare: compareArrays,
706
- });
802
+ const a_1 = sort(this$.Values);
803
+ const b_1 = sort(other.Values);
707
804
  return (length(a_1) === length(b_1)) && fold((acc_1, e_1) => {
708
805
  if (acc_1) {
709
806
  return e_1;
@@ -728,9 +825,16 @@ export class ArcTable {
728
825
  }
729
826
  GetHashCode() {
730
827
  const this$ = this;
731
- return ((stringHash(this$.Name) + fold((state, ele) => (state + safeHash(ele)), 0, this$.Headers)) + fold((state_2, ele_1) => (state_2 + safeHash(ele_1)), 0, sortBy((x) => x[0], this$.Values, {
828
+ const v_2 = map_1((tupledArg) => {
829
+ const _arg = tupledArg[0];
830
+ return HashCodes_boxHashArray([_arg[0], _arg[1], tupledArg[1]]);
831
+ }, sortBy((tuple) => tuple[0], toArray(delay(() => collect((matchValue) => {
832
+ const activePatternResult = matchValue;
833
+ return singleton([activePatternResult[0], activePatternResult[1]]);
834
+ }, this$.Values))), {
732
835
  Compare: compareArrays,
733
- }))) | 0;
836
+ }));
837
+ return HashCodes_boxHashArray([this$.Name, HashCodes_boxHashArray(Array.from(this$.Headers)), HashCodes_boxHashArray(Array.from(v_2))]) | 0;
734
838
  }
735
839
  }
736
840
 
@@ -179,7 +179,7 @@ export function SanityChecks_validateRowIndex(index, rowCount, allowAppend) {
179
179
  }
180
180
 
181
181
  export function SanityChecks_validateColumn(column) {
182
- column.validate(true);
182
+ column.Validate(true);
183
183
  }
184
184
 
185
185
  export function Unchecked_tryGetCellAt(column, row, cells) {
@@ -312,7 +312,10 @@ export function Unchecked_getEmptyCellForHeader(header, columCellOption) {
312
312
  }
313
313
  }
314
314
 
315
- export function Unchecked_addColumn(newHeader, newCells, index, forceReplace, headers, values) {
315
+ /**
316
+ *
317
+ */
318
+ export function Unchecked_addColumn(newHeader, newCells, index, forceReplace, onlyHeaders, headers, values) {
316
319
  let numberOfNewColumns = 1;
317
320
  let index_1 = index;
318
321
  const hasDuplicateUnique = tryFindDuplicateUnique(newHeader, headers);
@@ -326,12 +329,10 @@ export function Unchecked_addColumn(newHeader, newCells, index, forceReplace, he
326
329
  const matchValue = getColumnCount(headers) | 0;
327
330
  const matchValue_1 = getRowCount(values) | 0;
328
331
  const startColCount = matchValue | 0;
329
- let setNewHeader;
330
332
  if (hasDuplicateUnique != null) {
331
333
  Unchecked_removeHeader(index_1, headers);
332
334
  }
333
- setNewHeader = headers.splice(index_1, 0, newHeader);
334
- let increaseColumnIndices;
335
+ headers.splice(index_1, 0, newHeader);
335
336
  if ((index_1 < startColCount) && (hasDuplicateUnique == null)) {
336
337
  const lastColumnIndex = max(startColCount - 1, 0) | 0;
337
338
  for (let columnIndex = lastColumnIndex; columnIndex >= index_1; columnIndex--) {
@@ -340,16 +341,14 @@ export function Unchecked_addColumn(newHeader, newCells, index, forceReplace, he
340
341
  }
341
342
  }
342
343
  }
343
- else {
344
- increaseColumnIndices = void 0;
345
- }
346
- let setNewCells;
347
- if (hasDuplicateUnique != null) {
348
- Unchecked_removeColumnCells(index_1, values);
344
+ if (!onlyHeaders) {
345
+ if (hasDuplicateUnique != null) {
346
+ Unchecked_removeColumnCells(index_1, values);
347
+ }
348
+ iterateIndexed((rowIndex_1, cell) => {
349
+ Unchecked_setCellAt(index_1, rowIndex_1, cell, values);
350
+ }, newCells);
349
351
  }
350
- setNewCells = iterateIndexed((rowIndex_1, cell) => {
351
- Unchecked_setCellAt(index_1, rowIndex_1, cell, values);
352
- }, newCells);
353
352
  }
354
353
 
355
354
  export function Unchecked_fillMissingCells(headers, values) {
@@ -1,16 +1,17 @@
1
- import { append, toArray, reduce, choose, map, delay, toList, length, tryFindIndex } from "../../../fable_modules/fable-library.4.1.4/Seq.js";
2
- import { equals, comparePrimitives, stringHash, compare } from "../../../fable_modules/fable-library.4.1.4/Util.js";
1
+ import { append, toArray, reduce, choose, map as map_1, delay, toList, length, findIndex, tryFindIndex } from "../../../fable_modules/fable-library.4.1.4/Seq.js";
2
+ import { Dict_tryFind } from "../Helper.js";
3
+ import { addToSet, addToDict } from "../../../fable_modules/fable-library.4.1.4/MapUtil.js";
4
+ import { equals, comparePrimitives, stringHash, compare, disposeSafe, getEnumerator } from "../../../fable_modules/fable-library.4.1.4/Util.js";
5
+ import { bind, map as map_3, unwrap, defaultArg, value as value_2 } from "../../../fable_modules/fable-library.4.1.4/Option.js";
6
+ import { collect as collect_1, map as map_4, insertRangeInPlace, fold } from "../../../fable_modules/fable-library.4.1.4/Array.js";
7
+ import { CompositeHeader } from "./CompositeHeader.js";
3
8
  import { Array_groupBy, distinct } from "../../../fable_modules/fable-library.4.1.4/Seq2.js";
4
9
  import { FSharpSet__get_IsEmpty, ofSeq, intersect } from "../../../fable_modules/fable-library.4.1.4/Set.js";
5
10
  import { class_type } from "../../../fable_modules/fable-library.4.1.4/Reflection.js";
6
- import { bind, map as map_2, unwrap, defaultArg } from "../../../fable_modules/fable-library.4.1.4/Option.js";
7
- import { collect as collect_1, map as map_3, insertRangeInPlace } from "../../../fable_modules/fable-library.4.1.4/Array.js";
8
11
  import { ArcTable } from "./ArcTable.js";
9
- import { map as map_1, collect } from "../../../fable_modules/fable-library.4.1.4/List.js";
12
+ import { map as map_2, collect } from "../../../fable_modules/fable-library.4.1.4/List.js";
10
13
  import { Unchecked_fillMissingCells, ProcessParsing_groupProcesses, ProcessParsing_processToRows, ProcessParsing_alignByHeaders } from "./ArcTableAux.js";
11
14
  import { tryFind, ofSeq as ofSeq_1 } from "../../../fable_modules/fable-library.4.1.4/Map.js";
12
- import { CompositeHeader } from "./CompositeHeader.js";
13
- import { addToSet } from "../../../fable_modules/fable-library.4.1.4/MapUtil.js";
14
15
 
15
16
  /**
16
17
  * If a table with the given name exists in the TableList, returns it, else returns None.
@@ -32,6 +33,104 @@ export function ArcTablesAux_findIndexByTableName(name, tables) {
32
33
  }
33
34
  }
34
35
 
36
+ /**
37
+ * Collects the IOType of each distinct entity in the tables. Then merges the IOType of each entity according to the IOType.Merge function.
38
+ */
39
+ export function ArcTablesAux_getIOMap(tables) {
40
+ const mappings = new Map([]);
41
+ const includeInMap = (name, ioType) => {
42
+ if (name !== "") {
43
+ const matchValue = Dict_tryFind(name, mappings);
44
+ if (matchValue == null) {
45
+ addToDict(mappings, name, ioType);
46
+ }
47
+ else {
48
+ const oldIOType = matchValue;
49
+ const newIOType = oldIOType.Merge(ioType);
50
+ mappings.set(name, newIOType);
51
+ }
52
+ }
53
+ };
54
+ let enumerator = getEnumerator(tables);
55
+ try {
56
+ while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
57
+ const table = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
58
+ const matchValue_1 = table.TryGetInputColumn();
59
+ if (matchValue_1 == null) {
60
+ }
61
+ else {
62
+ const ic = matchValue_1;
63
+ const ioType_1 = value_2(ic.Header.tryInput());
64
+ ic.Cells.forEach((c) => {
65
+ includeInMap(c.ToFreeTextCell().AsFreeText, ioType_1);
66
+ });
67
+ }
68
+ const matchValue_2 = table.TryGetOutputColumn();
69
+ if (matchValue_2 == null) {
70
+ }
71
+ else {
72
+ const oc = matchValue_2;
73
+ const ioType_2 = value_2(oc.Header.tryOutput());
74
+ oc.Cells.forEach((c_1) => {
75
+ includeInMap(c_1.ToFreeTextCell().AsFreeText, ioType_2);
76
+ });
77
+ }
78
+ }
79
+ }
80
+ finally {
81
+ disposeSafe(enumerator);
82
+ }
83
+ return mappings;
84
+ }
85
+
86
+ export function ArcTablesAux_applyIOMap(map, tables) {
87
+ let enumerator = getEnumerator(tables);
88
+ try {
89
+ while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
90
+ const table = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
91
+ const matchValue = table.TryGetInputColumn();
92
+ if (matchValue == null) {
93
+ }
94
+ else {
95
+ const ic = matchValue;
96
+ const index = findIndex((x) => x.isInput, table.Headers) | 0;
97
+ const newIOType = fold((io, c) => {
98
+ const matchValue_1 = Dict_tryFind(c.ToFreeTextCell().AsFreeText, map);
99
+ if (matchValue_1 == null) {
100
+ return io;
101
+ }
102
+ else {
103
+ const newIO = matchValue_1;
104
+ return io.Merge(newIO);
105
+ }
106
+ }, value_2(ic.Header.tryInput()), ic.Cells);
107
+ table.UpdateHeader(index, new CompositeHeader(11, [newIOType]));
108
+ }
109
+ const matchValue_2 = table.TryGetOutputColumn();
110
+ if (matchValue_2 == null) {
111
+ }
112
+ else {
113
+ const oc = matchValue_2;
114
+ const index_1 = findIndex((x_1) => x_1.isOutput, table.Headers) | 0;
115
+ const newIOType_1 = fold((io_1, c_1) => {
116
+ const matchValue_3 = Dict_tryFind(c_1.ToFreeTextCell().AsFreeText, map);
117
+ if (matchValue_3 == null) {
118
+ return io_1;
119
+ }
120
+ else {
121
+ const newIO_1 = matchValue_3;
122
+ return io_1.Merge(newIO_1);
123
+ }
124
+ }, value_2(oc.Header.tryOutput()), oc.Cells);
125
+ table.UpdateHeader(index_1, new CompositeHeader(12, [newIOType_1]));
126
+ }
127
+ }
128
+ }
129
+ finally {
130
+ disposeSafe(enumerator);
131
+ }
132
+ }
133
+
35
134
  /**
36
135
  * Fails, if the index is out of range of the Tables collection. When allowAppend is set to true, it may be out of range by at most 1.
37
136
  */
@@ -118,7 +217,7 @@ export function ArcTables__get_Count(this$) {
118
217
  }
119
218
 
120
219
  export function ArcTables__get_TableNames(this$) {
121
- return toList(delay(() => map((s) => s.Name, this$.thisTables)));
220
+ return toList(delay(() => map_1((s) => s.Name, this$.thisTables)));
122
221
  }
123
222
 
124
223
  export function ArcTables__get_Tables(this$) {
@@ -139,7 +238,7 @@ export function ArcTables__AddTable_EC12B15(this$, table, index) {
139
238
  export function ArcTables__AddTables_Z2D453886(this$, tables, index) {
140
239
  const index_1 = defaultArg(index, ArcTables__get_Count(this$)) | 0;
141
240
  ArcTablesAux_SanityChecks_validateSheetIndex(index_1, true, this$.thisTables);
142
- ArcTablesAux_SanityChecks_validateNewNamesUnique(map((x) => x.Name, tables), ArcTables__get_TableNames(this$));
241
+ ArcTablesAux_SanityChecks_validateNewNamesUnique(map_1((x) => x.Name, tables), ArcTables__get_TableNames(this$));
143
242
  insertRangeInPlace(index_1, tables, this$.thisTables);
144
243
  }
145
244
 
@@ -154,9 +253,9 @@ export function ArcTables__InitTable_3B406CA4(this$, tableName, index) {
154
253
 
155
254
  export function ArcTables__InitTables_7B28792B(this$, tableNames, index) {
156
255
  const index_1 = defaultArg(index, ArcTables__get_Count(this$)) | 0;
157
- const tables = map((x) => ArcTable.init(x), tableNames);
256
+ const tables = map_1((x) => ArcTable.init(x), tableNames);
158
257
  ArcTablesAux_SanityChecks_validateSheetIndex(index_1, true, this$.thisTables);
159
- ArcTablesAux_SanityChecks_validateNewNamesUnique(map((x_1) => x_1.Name, tables), ArcTables__get_TableNames(this$));
258
+ ArcTablesAux_SanityChecks_validateNewNamesUnique(map_1((x_1) => x_1.Name, tables), ArcTables__get_TableNames(this$));
160
259
  insertRangeInPlace(index_1, tables, this$.thisTables);
161
260
  }
162
261
 
@@ -330,7 +429,7 @@ export function ArcTables_ofSeq_3B4333A5(tables) {
330
429
  */
331
430
  export function ArcTables_fromProcesses_134EBDED(ps) {
332
431
  let arg;
333
- return ArcTables_$ctor_Z18C2F36D((arg = map_1((tupledArg) => {
432
+ return ArcTables_$ctor_Z18C2F36D((arg = map_2((tupledArg) => {
334
433
  const tupledArg_1 = ProcessParsing_alignByHeaders(true, collect(ProcessParsing_processToRows, tupledArg[1]));
335
434
  return ArcTable.create(tupledArg[0], tupledArg_1[0], tupledArg_1[1]);
336
435
  }, ProcessParsing_groupProcesses(ps)), Array.from(arg)));
@@ -340,13 +439,13 @@ export function ArcTables_updateReferenceTablesBySheets_Z2EE88E97(referenceTable
340
439
  let arg_4, s, array;
341
440
  const keepUnusedRefTables_1 = defaultArg(keepUnusedRefTables, false);
342
441
  const usedTables = new Set([]);
343
- const referenceTableMap = ofSeq_1(choose((t) => map_2((c) => [c.Cells[0].AsFreeText, t], t.TryGetProtocolNameColumn()), ArcTables__get_Tables(referenceTables)), {
442
+ const referenceTableMap = ofSeq_1(choose((t) => map_3((c) => [c.Cells[0].AsFreeText, t], t.TryGetProtocolNameColumn()), ArcTables__get_Tables(referenceTables)), {
344
443
  Compare: comparePrimitives,
345
444
  });
346
- return ArcTables_$ctor_Z18C2F36D((arg_4 = ((s = map_3((t_3) => {
445
+ return ArcTables_$ctor_Z18C2F36D((arg_4 = ((s = map_4((t_3) => {
347
446
  Unchecked_fillMissingCells(t_3.Headers, t_3.Values);
348
447
  return t_3;
349
- }, map_3((tupledArg) => reduce((arg_2, arg_3) => ArcTable.append(arg_2, arg_3), tupledArg[1]), Array_groupBy((t_2) => t_2.Name, map_3((t_1) => {
448
+ }, map_4((tupledArg) => reduce((arg_2, arg_3) => ArcTable.append(arg_2, arg_3), tupledArg[1]), Array_groupBy((t_2) => t_2.Name, map_4((t_1) => {
350
449
  const k = defaultArg(bind((c_1) => {
351
450
  if (c_1.AsFreeText === "") {
352
451
  return void 0;