@f1studio/form-spec 5.0.0-alpha.109 → 5.0.0-alpha.111
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/FormSpec.FS/FormSpec.d.ts +3 -1
- package/FormSpec.FS/FormSpec.d.ts.map +1 -1
- package/FormSpec.FS/Helpers.d.ts +7 -0
- package/FormSpec.FS/Helpers.d.ts.map +1 -1
- package/FormSpec.FS/Interop/FormSpec.Api.Helpers.d.ts +29 -3
- package/FormSpec.FS/Interop/FormSpec.Api.Helpers.d.ts.map +1 -1
- package/FormSpec.FS/PathwayExecutor.d.ts +0 -4
- package/FormSpec.FS/PathwayExecutor.d.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/FormSpec.js +11 -1
- package/FormSpec.TS/FormSpec.FS/FormSpec.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/FormSpec.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Helpers.js +52 -24
- package/FormSpec.TS/FormSpec.FS/Helpers.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Helpers.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Helpers.js +201 -43
- package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Helpers.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Helpers.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Option.js +1 -1
- package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Option.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Option.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/PathwayExecutor.js +4 -32
- package/FormSpec.TS/FormSpec.FS/PathwayExecutor.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/PathwayExecutor.ts.map +1 -1
- package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Encode.fs.js.map +1 -1
- package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Encode.fs.ts.map +1 -1
- package/FormSpec.TS/plugins/bmi/src/BMIField.js +1 -1
- package/FormSpec.TS/plugins/bmi/src/BMIField.js.map +1 -1
- package/FormSpec.TS/plugins/bmi/src/BMIField.ts.map +1 -1
- package/FormSpec.TS/plugins/likert/src/LikertField.js +251 -84
- package/FormSpec.TS/plugins/likert/src/LikertField.js.map +1 -1
- package/FormSpec.TS/plugins/likert/src/LikertField.ts.map +1 -1
- package/FormSpec.TS/plugins/signature/src/SignatureField.js +1 -1
- package/FormSpec.TS/plugins/signature/src/SignatureField.js.map +1 -1
- package/FormSpec.TS/plugins/signature/src/SignatureField.ts.map +1 -1
- package/FormSpec.TS/plugins/vitals/src/VitalsField.js +1 -1
- package/FormSpec.TS/plugins/vitals/src/VitalsField.js.map +1 -1
- package/FormSpec.TS/plugins/vitals/src/VitalsField.ts.map +1 -1
- package/README.md +7 -7
- package/package.json +1 -1
- package/plugins/bmi/src/BMIField.d.ts.map +1 -1
- package/plugins/likert/src/LikertField.d.ts.map +1 -1
- package/plugins/signature/src/SignatureField.d.ts.map +1 -1
- package/plugins/vitals/src/VitalsField.d.ts.map +1 -1
- package/src/FormSpec.FS/FormSpec.ts +6 -2
- package/src/FormSpec.FS/Helpers.ts +55 -27
- package/src/FormSpec.FS/Interop/FormSpec.Api.Helpers.ts +212 -55
- package/src/FormSpec.FS/Interop/FormSpec.Api.Option.ts +1 -1
- package/src/FormSpec.FS/PathwayExecutor.ts +40 -69
- package/src/plugins/bmi/src/BMIField.ts +1 -1
- package/src/plugins/likert/src/LikertField.ts +211 -89
- package/src/plugins/signature/src/SignatureField.ts +1 -1
- package/src/plugins/vitals/src/VitalsField.ts +1 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { Values_StepOrder, Shared_FieldValue_Multiple, Shared_FieldValue_Single, Shared_FieldAnswer, Shared_FieldValue_$union, Shared_FieldOption, Spec_FieldType_$union, Spec_FieldType, Spec_FormSpec$1, Spec_FormField$1, Spec_FormStep$1, Shared_FieldKey } from "./FormSpec.js";
|
|
1
|
+
import { Values_StepOrder, Shared_FieldValue_Multiple, Shared_FieldValue_Single, Shared_FieldAnswer, Shared_FieldValue_$union, Shared_FieldOption, Spec_PluginFieldConfig, Spec_FieldType_$union, Spec_FieldType, Spec_FormSpec$1, Spec_FormField$1, Spec_FormStep$1, Shared_FieldKey } from "./FormSpec.js";
|
|
2
2
|
import { arrayToGuid, parse } from "@fable-org/fable-library-js/Guid.js";
|
|
3
3
|
import { toConsole, isNullOrEmpty, trimEnd, trim, isNullOrWhiteSpace } from "@fable-org/fable-library-js/String.js";
|
|
4
4
|
import { replace } from "@fable-org/fable-library-js/RegExp.js";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
5
|
+
import { uint8, int32, parse as parse_1 } from "@fable-org/fable-library-js/Int32.js";
|
|
6
|
+
import sha256 from "crypto-js/sha256";
|
|
7
|
+
import { initialize } from "@fable-org/fable-library-js/Array.js";
|
|
8
8
|
import { value as value_1, Option, map, defaultArg } from "@fable-org/fable-library-js/Option.js";
|
|
9
9
|
import { splitAt, tryFindIndex, forAll, sortBy, find, insertAt, mapIndexed, singleton, append, head, tail, isEmpty, collect, empty, tryFind, FSharpList, filter, map as map_1 } from "@fable-org/fable-library-js/List.js";
|
|
10
10
|
import { Result_Map, FSharpResult$2_$union, FSharpResult$2_Error, FSharpResult$2_Ok } from "@fable-org/fable-library-js/Result.js";
|
|
11
|
+
import { compare, safeHash, comparePrimitives, stringHash, equals } from "@fable-org/fable-library-js/Util.js";
|
|
11
12
|
import { List_distinct } from "@fable-org/fable-library-js/Seq2.js";
|
|
12
13
|
import { map as map_2, tryFind as tryFind_1 } from "@fable-org/fable-library-js/Seq.js";
|
|
13
14
|
import { FieldDetails$1 } from "./FormSpecValues.js";
|
|
@@ -42,18 +43,27 @@ export function Helpers_canonicalizeFieldKey(input: string): string {
|
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
|
|
46
|
+
function Helpers_parseHexByte(hex: string, offset: int32): uint8 {
|
|
47
|
+
let copyOfStruct: string, copyOfStruct_1: string;
|
|
48
|
+
const hi: int32 = parse_1((copyOfStruct = hex[offset], copyOfStruct), 511, false, 32, 16) | 0;
|
|
49
|
+
const lo: int32 = parse_1((copyOfStruct_1 = hex[offset + 1], copyOfStruct_1), 511, false, 32, 16) | 0;
|
|
50
|
+
return ((hi << 4) + lo) & 0xFF;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Generate deterministic GUID from raw input using SHA256 (cross-runtime stable).
|
|
55
|
+
*/
|
|
56
|
+
export function Helpers_generateDeterministicGuidRaw(input: string): string {
|
|
57
|
+
const source: string = (input == null) ? "" : input;
|
|
58
|
+
const hashHex: string = sha256(source).toString();
|
|
59
|
+
return arrayToGuid(initialize<uint8>(16, (i: int32): uint8 => Helpers_parseHexByte(hashHex, i * 2)));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Generate deterministic GUID using canonicalized field-key input.
|
|
64
|
+
*/
|
|
45
65
|
export function Helpers_generateDeterministicGuid(fieldName: string): string {
|
|
46
|
-
|
|
47
|
-
const bytes: uint8[] = fill(new Array(16), 0, 16, 0);
|
|
48
|
-
for (let i = 0; i <= 3; i++) {
|
|
49
|
-
setItem(bytes, i, (hash >> (i * 8)) & 0xFF);
|
|
50
|
-
setItem(bytes, i + 4, ((hash >> 1) >> (i * 8)) & 0xFF);
|
|
51
|
-
setItem(bytes, i + 8, ((hash >> 2) >> (i * 8)) & 0xFF);
|
|
52
|
-
setItem(bytes, i + 12, ((hash >> 3) >> (i * 8)) & 0xFF);
|
|
53
|
-
}
|
|
54
|
-
setItem(bytes, 6, (item(6, bytes) & 15) | 64);
|
|
55
|
-
setItem(bytes, 8, (item(8, bytes) & 63) | 128);
|
|
56
|
-
return arrayToGuid(bytes);
|
|
66
|
+
return Helpers_generateDeterministicGuidRaw(Helpers_canonicalizeFieldKey(fieldName));
|
|
57
67
|
}
|
|
58
68
|
|
|
59
69
|
/**
|
|
@@ -239,14 +249,14 @@ export function Helpers_FieldTypeUtils_fieldTypesMatchByCaseName(fieldType1: any
|
|
|
239
249
|
}
|
|
240
250
|
switch (matchResult) {
|
|
241
251
|
case 0: {
|
|
242
|
-
let matchResult_1: int32;
|
|
252
|
+
let matchResult_1: int32, cfg1_1: Spec_PluginFieldConfig, cfg2_1: Spec_PluginFieldConfig;
|
|
243
253
|
switch (ft1!.tag) {
|
|
244
254
|
case /* Message */ 21: {
|
|
245
255
|
if (ft2!.tag === /* Message */ 21) {
|
|
246
256
|
matchResult_1 = 0;
|
|
247
257
|
}
|
|
248
258
|
else {
|
|
249
|
-
matchResult_1 =
|
|
259
|
+
matchResult_1 = 11;
|
|
250
260
|
}
|
|
251
261
|
break;
|
|
252
262
|
}
|
|
@@ -255,7 +265,7 @@ export function Helpers_FieldTypeUtils_fieldTypesMatchByCaseName(fieldType1: any
|
|
|
255
265
|
matchResult_1 = 1;
|
|
256
266
|
}
|
|
257
267
|
else {
|
|
258
|
-
matchResult_1 =
|
|
268
|
+
matchResult_1 = 11;
|
|
259
269
|
}
|
|
260
270
|
break;
|
|
261
271
|
}
|
|
@@ -264,7 +274,7 @@ export function Helpers_FieldTypeUtils_fieldTypesMatchByCaseName(fieldType1: any
|
|
|
264
274
|
matchResult_1 = 2;
|
|
265
275
|
}
|
|
266
276
|
else {
|
|
267
|
-
matchResult_1 =
|
|
277
|
+
matchResult_1 = 11;
|
|
268
278
|
}
|
|
269
279
|
break;
|
|
270
280
|
}
|
|
@@ -273,7 +283,7 @@ export function Helpers_FieldTypeUtils_fieldTypesMatchByCaseName(fieldType1: any
|
|
|
273
283
|
matchResult_1 = 3;
|
|
274
284
|
}
|
|
275
285
|
else {
|
|
276
|
-
matchResult_1 =
|
|
286
|
+
matchResult_1 = 11;
|
|
277
287
|
}
|
|
278
288
|
break;
|
|
279
289
|
}
|
|
@@ -282,7 +292,7 @@ export function Helpers_FieldTypeUtils_fieldTypesMatchByCaseName(fieldType1: any
|
|
|
282
292
|
matchResult_1 = 4;
|
|
283
293
|
}
|
|
284
294
|
else {
|
|
285
|
-
matchResult_1 =
|
|
295
|
+
matchResult_1 = 11;
|
|
286
296
|
}
|
|
287
297
|
break;
|
|
288
298
|
}
|
|
@@ -291,7 +301,7 @@ export function Helpers_FieldTypeUtils_fieldTypesMatchByCaseName(fieldType1: any
|
|
|
291
301
|
matchResult_1 = 5;
|
|
292
302
|
}
|
|
293
303
|
else {
|
|
294
|
-
matchResult_1 =
|
|
304
|
+
matchResult_1 = 11;
|
|
295
305
|
}
|
|
296
306
|
break;
|
|
297
307
|
}
|
|
@@ -300,7 +310,7 @@ export function Helpers_FieldTypeUtils_fieldTypesMatchByCaseName(fieldType1: any
|
|
|
300
310
|
matchResult_1 = 6;
|
|
301
311
|
}
|
|
302
312
|
else {
|
|
303
|
-
matchResult_1 =
|
|
313
|
+
matchResult_1 = 11;
|
|
304
314
|
}
|
|
305
315
|
break;
|
|
306
316
|
}
|
|
@@ -309,7 +319,7 @@ export function Helpers_FieldTypeUtils_fieldTypesMatchByCaseName(fieldType1: any
|
|
|
309
319
|
matchResult_1 = 7;
|
|
310
320
|
}
|
|
311
321
|
else {
|
|
312
|
-
matchResult_1 =
|
|
322
|
+
matchResult_1 = 11;
|
|
313
323
|
}
|
|
314
324
|
break;
|
|
315
325
|
}
|
|
@@ -318,7 +328,7 @@ export function Helpers_FieldTypeUtils_fieldTypesMatchByCaseName(fieldType1: any
|
|
|
318
328
|
matchResult_1 = 8;
|
|
319
329
|
}
|
|
320
330
|
else {
|
|
321
|
-
matchResult_1 =
|
|
331
|
+
matchResult_1 = 11;
|
|
322
332
|
}
|
|
323
333
|
break;
|
|
324
334
|
}
|
|
@@ -327,12 +337,28 @@ export function Helpers_FieldTypeUtils_fieldTypesMatchByCaseName(fieldType1: any
|
|
|
327
337
|
matchResult_1 = 9;
|
|
328
338
|
}
|
|
329
339
|
else {
|
|
330
|
-
matchResult_1 =
|
|
340
|
+
matchResult_1 = 11;
|
|
341
|
+
}
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
case /* PluginField */ 22: {
|
|
345
|
+
if (ft2!.tag === /* PluginField */ 22) {
|
|
346
|
+
if (ft1!.fields[0].PluginId === ft2!.fields[0].PluginId) {
|
|
347
|
+
matchResult_1 = 10;
|
|
348
|
+
cfg1_1 = ft1!.fields[0];
|
|
349
|
+
cfg2_1 = ft2!.fields[0];
|
|
350
|
+
}
|
|
351
|
+
else {
|
|
352
|
+
matchResult_1 = 11;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
matchResult_1 = 11;
|
|
331
357
|
}
|
|
332
358
|
break;
|
|
333
359
|
}
|
|
334
360
|
default:
|
|
335
|
-
matchResult_1 =
|
|
361
|
+
matchResult_1 = 11;
|
|
336
362
|
}
|
|
337
363
|
switch (matchResult_1) {
|
|
338
364
|
case 0:
|
|
@@ -355,6 +381,8 @@ export function Helpers_FieldTypeUtils_fieldTypesMatchByCaseName(fieldType1: any
|
|
|
355
381
|
return true;
|
|
356
382
|
case 9:
|
|
357
383
|
return true;
|
|
384
|
+
case 10:
|
|
385
|
+
return true;
|
|
358
386
|
default:
|
|
359
387
|
return false;
|
|
360
388
|
}
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { value as value_11, map, unwrap, defaultArgWith as defaultArgWith_1, Option, defaultArg as defaultArg_1 } from "@fable-org/fable-library-js/Option.js";
|
|
2
|
-
import { tryPick, isEmpty, singleton, map as map_3, empty, ofArray as ofArray_1, ofSeq, fold, collect, tryFind, FSharpList } from "@fable-org/fable-library-js/List.js";
|
|
2
|
+
import { tryPick, filter, mapIndexed as mapIndexed_1, isEmpty, singleton, map as map_3, empty, ofArray as ofArray_1, ofSeq, fold, collect, tryFind, FSharpList } from "@fable-org/fable-library-js/List.js";
|
|
3
3
|
import { join, printf, toConsole } from "@fable-org/fable-library-js/String.js";
|
|
4
4
|
import { Auto_generateBoxedEncoder_437914C6, toString } from "../../fable_modules/Thoth.Json.10.4.1/Encode.fs.js";
|
|
5
5
|
import { array_type, string_type, union_type, TypeInfo, obj_type } from "@fable-org/fable-library-js/Reflection.js";
|
|
6
6
|
import { Auto_generateBoxedDecoder_Z6670B51, fromString } from "../../fable_modules/Thoth.Json.10.4.1/Decode.fs.js";
|
|
7
|
-
import { equals, createObj, compare, IDisposable, disposeSafe, IEnumerator, getEnumerator, IMap, isArrayLike, uncurry2 } from "@fable-org/fable-library-js/Util.js";
|
|
8
|
-
import { ClinicalPathway_StateType_$union, ClinicalPathway_TaskPriority_$union, ClinicalPathway_AlertSeverity_$union, ClinicalPathway_ReferralUrgency_$union, ClinicalPathway_ActionInfo_$union, ClinicalPathway_NavigateToFormAction, ClinicalPathway_ProblemAction, ClinicalPathway_AlertAction, ClinicalPathway_EducationAction, ClinicalPathway_ProcedureAction, ClinicalPathway_TestAction, ClinicalPathway_DocumentationAction, ClinicalPathway_FieldValueSource_$union, ClinicalPathway_SetFieldValueAction, ClinicalPathway_PrescriptionAction, ClinicalPathway_MedicationAction, ClinicalPathway_ReferralAction, Shared_FieldValue_$union, ClinicalPathway_ClinicalPathwaySpec, ClinicalPathway_PathRequirement, ClinicalPathway_ConstraintDefinition, ClinicalPathway_PathwayExecutionMode_SinglePathway, ClinicalPathway_SinglePathwayConfig, ClinicalPathway_SelectionStrategy_HighestPriority, ClinicalPathway_TransitionDefinition, ClinicalPathway_TransitionCondition_FieldCondition, Shared_ConditionValue_Single, ClinicalPathway_FieldEvaluator_Equals, Shared_TransitionKey, ClinicalPathway_StateType_Terminal, ClinicalPathway_TerminalInfo, ClinicalPathway_StateDefinition, ClinicalPathway_StateType_Action, ClinicalPathway_ActionInfo_Task, ClinicalPathway_TaskAction, ClinicalPathway_DueDate_Today, ClinicalPathway_TaskPriority_Medium, ClinicalPathway_TaskPriority_Low, ClinicalPathway_TaskPriority_High, Shared_StateKey, Spec_FieldType_PluginField, Spec_PluginFieldConfig, Spec_FieldType_Matrix, Spec_MatrixInfo, Spec_FormLifecycle_Blueprint, Spec_FieldType_Text, Spec_TextInfo, Spec_FieldType_CheckboxList, Spec_MultiChoiceInfo, Shared_FieldOptionKey, Spec_FieldType_Checkbox, Spec_BooleanInfo, Shared_FieldKey, Shared_FieldOption, Shared_FieldValue_Single, Shared_FieldValue_PluginData, Shared_PluginDataProperty, Shared_PluginPropertyKey, Shared_FieldValue_Matrix, Shared_MatrixAnswer, Shared_MatrixItemKey, Shared_FieldValue_Multiple, Shared_FieldAnswer, Spec_FormStep$1, Spec_FormField$1, Spec_FieldType_$union, Spec_FormSpec$1, Spec_FormSpec$1_$reflection, Spec_FieldType_$reflection } from "../FormSpec.js";
|
|
7
|
+
import { equals, createObj, stringHash, compare, IDisposable, disposeSafe, IEnumerator, getEnumerator, IMap, isArrayLike, uncurry2 } from "@fable-org/fable-library-js/Util.js";
|
|
8
|
+
import { ClinicalPathway_StateType_$union, ClinicalPathway_TaskPriority_$union, ClinicalPathway_AlertSeverity_$union, ClinicalPathway_ReferralUrgency_$union, ClinicalPathway_ActionInfo_$union, ClinicalPathway_NavigateToFormAction, ClinicalPathway_ProblemAction, ClinicalPathway_AlertAction, ClinicalPathway_EducationAction, ClinicalPathway_ProcedureAction, ClinicalPathway_TestAction, ClinicalPathway_DocumentationAction, ClinicalPathway_FieldValueSource_$union, ClinicalPathway_SetFieldValueAction, ClinicalPathway_PrescriptionAction, ClinicalPathway_MedicationAction, ClinicalPathway_ReferralAction, Shared_FieldValue, Shared_FieldValue_$union, ClinicalPathway_ClinicalPathwaySpec, ClinicalPathway_PathRequirement, ClinicalPathway_ConstraintDefinition, ClinicalPathway_PathwayExecutionMode_SinglePathway, ClinicalPathway_SinglePathwayConfig, ClinicalPathway_SelectionStrategy_HighestPriority, ClinicalPathway_TransitionDefinition, ClinicalPathway_TransitionCondition_FieldCondition, Shared_ConditionValue_Single, ClinicalPathway_FieldEvaluator_Equals, Shared_TransitionKey, ClinicalPathway_StateType_Terminal, ClinicalPathway_TerminalInfo, ClinicalPathway_StateDefinition, ClinicalPathway_StateType_Action, ClinicalPathway_ActionInfo_Task, ClinicalPathway_TaskAction, ClinicalPathway_DueDate_Today, ClinicalPathway_TaskPriority_Medium, ClinicalPathway_TaskPriority_Low, ClinicalPathway_TaskPriority_High, Shared_StateKey, Spec_FieldType_PluginField, Spec_PluginFieldConfig, Spec_FieldType_Matrix, Spec_MatrixInfo, Spec_FormLifecycle_Blueprint, Spec_FieldType_Text, Spec_TextInfo, Spec_FieldType_CheckboxList, Spec_MultiChoiceInfo, Shared_FieldOptionKey, Spec_FieldType_Checkbox, Spec_BooleanInfo, Shared_FieldKey, Shared_FieldOption, Shared_FieldValue_Single, Shared_FieldValue_PluginData, Shared_PluginDataProperty, Shared_PluginPropertyKey, Shared_FieldValue_Matrix, Shared_MatrixAnswer, Shared_MatrixItemKey, Shared_FieldValue_Multiple, Shared_FieldAnswer, Spec_FormStep$1, Spec_FormField$1, Spec_FieldType_$union, Spec_FormSpec$1, Spec_FormSpec$1_$reflection, Spec_FieldType_$reflection } from "../FormSpec.js";
|
|
9
9
|
import { FSharpResult$2_Ok, FSharpResult$2_Error, FSharpResult$2_$union } from "@fable-org/fable-library-js/Result.js";
|
|
10
|
-
import {
|
|
10
|
+
import { newGuid, parse, tryParse } from "@fable-org/fable-library-js/Guid.js";
|
|
11
|
+
import { Union, FSharpRef } from "@fable-org/fable-library-js/Types.js";
|
|
11
12
|
import { IOptionalGetter, array as array_4, IGetters, dict as dict_1, string, IRequiredGetter, object, fromString as fromString_1 } from "../../fable_modules/Thoth.Json.10.4.1/Decode.fs.js";
|
|
12
13
|
import { ErrorReason_$union } from "../../fable_modules/Thoth.Json.10.4.1/Types.fs.js";
|
|
13
|
-
import { ofSeq as ofSeq_1, FSharpMap } from "@fable-org/fable-library-js/Map.js";
|
|
14
|
+
import { count, ofSeq as ofSeq_1, toList, FSharpMap } from "@fable-org/fable-library-js/Map.js";
|
|
14
15
|
import { addToDict } from "@fable-org/fable-library-js/MapUtil.js";
|
|
15
|
-
import { getFieldDetails as getFieldDetails_1, FieldDetails$1, findStepIndexForField, updateField } from "../FormSpecValues.js";
|
|
16
16
|
import { int32 } from "@fable-org/fable-library-js/Int32.js";
|
|
17
|
-
import {
|
|
17
|
+
import { getFieldDetails as getFieldDetails_1, FieldDetails$1, findStepIndexForField, updateField } from "../FormSpecValues.js";
|
|
18
|
+
import { singleton as singleton_1, empty as empty_1, collect as collect_1, delay, toList as toList_1, mapIndexed, map as map_2, choose } from "@fable-org/fable-library-js/Seq.js";
|
|
18
19
|
import { toArray, ofArray } from "@fable-org/fable-library-js/Set.js";
|
|
19
20
|
import { map as map_1 } from "@fable-org/fable-library-js/Array.js";
|
|
20
|
-
import { newGuid, parse } from "@fable-org/fable-library-js/Guid.js";
|
|
21
21
|
import { now } from "@fable-org/fable-library-js/DateOffset.js";
|
|
22
22
|
import { initializeExecution } from "../PathwayExecutor.js";
|
|
23
|
+
import { List_distinct, distinct } from "@fable-org/fable-library-js/Seq2.js";
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Get value from Option or return default (SAFE - recommended)
|
|
@@ -82,7 +83,17 @@ export function deserializeFormSpec(json: string): Option<Spec_FormSpec$1<Spec_F
|
|
|
82
83
|
* Find FormField by its FieldKey string representation
|
|
83
84
|
*/
|
|
84
85
|
export function findFieldByKey(spec: Spec_FormSpec$1<Spec_FieldType_$union>, fieldKeyString: string): Option<Spec_FormField$1<Spec_FieldType_$union>> {
|
|
85
|
-
|
|
86
|
+
let matchValue: [boolean, string];
|
|
87
|
+
let outArg = "00000000-0000-0000-0000-000000000000";
|
|
88
|
+
matchValue = ([tryParse(fieldKeyString, new FSharpRef<string>((): string => outArg, (v: string): void => {
|
|
89
|
+
outArg = v;
|
|
90
|
+
})), outArg] as [boolean, string]);
|
|
91
|
+
if (matchValue[0]) {
|
|
92
|
+
return tryFind<Spec_FormField$1<Spec_FieldType_$union>>((field: Spec_FormField$1<Spec_FieldType_$union>): boolean => (field.FieldKey.fields[0] === matchValue[1]), collect<Spec_FormStep$1<Spec_FieldType_$union>, Spec_FormField$1<Spec_FieldType_$union>>((step: Spec_FormStep$1<Spec_FieldType_$union>): FSharpList<Spec_FormField$1<Spec_FieldType_$union>> => step.Fields, spec.Steps));
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
86
97
|
}
|
|
87
98
|
|
|
88
99
|
export type ExpectedFieldValueType_$union =
|
|
@@ -227,32 +238,35 @@ export function decodeAsStringArray(fieldKey: string, obj: any): string[] {
|
|
|
227
238
|
|
|
228
239
|
export function decodeAsMatrixValue(fieldKey: string, obj: any): { description: string, values: IMap<string, string> } {
|
|
229
240
|
let str: string;
|
|
241
|
+
const valuesDict: IMap<string, string> = new Map<string, string>([]);
|
|
242
|
+
const arg_3: string = (obj == null) ? "null" : "Object";
|
|
243
|
+
toConsole(printf("[DEBUGGING_FORMSPEC_RENDERER] decodeAsMatrixValue fieldKey=%s path=JSON objType=%s"))(fieldKey)(arg_3);
|
|
230
244
|
const objAsString: string = (typeof obj === "string") ? ((str = (obj as string), str)) : toString(0, Auto_generateBoxedEncoder_437914C6(obj_type, undefined, undefined, undefined)(obj));
|
|
231
245
|
try {
|
|
232
|
-
const matchValue_1: FSharpResult$2_$union<{ description: string, values: IMap<string, string> }, string> = fromString_1<{ description: string, values: IMap<string, string> }>((path_2: string,
|
|
246
|
+
const matchValue_1: FSharpResult$2_$union<{ description: string, values: IMap<string, string> }, string> = fromString_1<{ description: string, values: IMap<string, string> }>((path_2: string, v_1: any): FSharpResult$2_$union<{ description: string, values: IMap<string, string> }, [string, ErrorReason_$union]> => object<{ description: string, values: IMap<string, string> }>((get$: IGetters): { description: string, values: IMap<string, string> } => {
|
|
233
247
|
let description: string;
|
|
234
248
|
const objectArg: IRequiredGetter = get$.Required;
|
|
235
249
|
description = objectArg.Field<string>("description", string);
|
|
236
250
|
let valuesMap: FSharpMap<string, string>;
|
|
237
|
-
const
|
|
251
|
+
const arg_7: ((arg0: string) => ((arg0: any) => FSharpResult$2_$union<FSharpMap<string, string>, [string, ErrorReason_$union]>)) = dict_1<string>(string);
|
|
238
252
|
const objectArg_1: IRequiredGetter = get$.Required;
|
|
239
|
-
valuesMap = objectArg_1.Field<FSharpMap<string, string>>("values", uncurry2(
|
|
240
|
-
const
|
|
241
|
-
const
|
|
253
|
+
valuesMap = objectArg_1.Field<FSharpMap<string, string>>("values", uncurry2(arg_7));
|
|
254
|
+
const valuesDict_1: IMap<string, string> = new Map<string, string>([]);
|
|
255
|
+
const enumerator_1: IEnumerator<[string, string]> = getEnumerator(toList<string, string>(valuesMap));
|
|
242
256
|
try {
|
|
243
|
-
while (
|
|
244
|
-
const
|
|
245
|
-
addToDict(
|
|
257
|
+
while (enumerator_1["System.Collections.IEnumerator.MoveNext"]()) {
|
|
258
|
+
const forLoopVar: [string, string] = enumerator_1["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
259
|
+
addToDict(valuesDict_1, forLoopVar[0], forLoopVar[1]);
|
|
246
260
|
}
|
|
247
261
|
}
|
|
248
262
|
finally {
|
|
249
|
-
disposeSafe(
|
|
263
|
+
disposeSafe(enumerator_1 as IDisposable);
|
|
250
264
|
}
|
|
251
265
|
return {
|
|
252
266
|
description: description,
|
|
253
|
-
values:
|
|
267
|
+
values: valuesDict_1,
|
|
254
268
|
};
|
|
255
|
-
}, path_2,
|
|
269
|
+
}, path_2, v_1), objAsString);
|
|
256
270
|
if (matchValue_1.tag === /* Error */ 1) {
|
|
257
271
|
let matchValue_2: FSharpResult$2_$union<{ description: string, values: IMap<string, string> }, string>;
|
|
258
272
|
const matchValue: FSharpResult$2_$union<FSharpMap<string, string>, string> = fromString_1<FSharpMap<string, string>>(uncurry2(dict_1<string>(string)), objAsString);
|
|
@@ -261,34 +275,42 @@ export function decodeAsMatrixValue(fieldKey: string, obj: any): { description:
|
|
|
261
275
|
}
|
|
262
276
|
else {
|
|
263
277
|
const valuesMap_1: FSharpMap<string, string> = matchValue.fields[0];
|
|
264
|
-
const
|
|
265
|
-
const
|
|
278
|
+
const valuesDict_2: IMap<string, string> = new Map<string, string>([]);
|
|
279
|
+
const enumerator_2: IEnumerator<[string, string]> = getEnumerator(toList<string, string>(valuesMap_1));
|
|
266
280
|
try {
|
|
267
|
-
while (
|
|
268
|
-
const
|
|
269
|
-
addToDict(
|
|
281
|
+
while (enumerator_2["System.Collections.IEnumerator.MoveNext"]()) {
|
|
282
|
+
const forLoopVar_1: [string, string] = enumerator_2["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
283
|
+
addToDict(valuesDict_2, forLoopVar_1[0], forLoopVar_1[1]);
|
|
270
284
|
}
|
|
271
285
|
}
|
|
272
286
|
finally {
|
|
273
|
-
disposeSafe(
|
|
287
|
+
disposeSafe(enumerator_2 as IDisposable);
|
|
274
288
|
}
|
|
275
289
|
matchValue_2 = FSharpResult$2_Ok<{ description: string, values: IMap<string, string> }, string>({
|
|
276
290
|
description: "",
|
|
277
|
-
values:
|
|
291
|
+
values: valuesDict_2,
|
|
278
292
|
});
|
|
279
293
|
}
|
|
280
294
|
if (matchValue_2.tag === /* Error */ 1) {
|
|
281
295
|
throw new Error(`Field ${fieldKey}: Invalid matrix data format - ${matchValue_2.fields[0]}`);
|
|
282
296
|
}
|
|
283
297
|
else {
|
|
284
|
-
|
|
298
|
+
const matrixData_1: { description: string, values: IMap<string, string> } = matchValue_2.fields[0];
|
|
299
|
+
const arg_11: int32 = matrixData_1.values.size | 0;
|
|
300
|
+
toConsole(printf("[DEBUGGING_FORMSPEC_RENDERER] decodeAsMatrixValue fieldKey=%s path=PlainFormat count=%d"))(fieldKey)(arg_11);
|
|
301
|
+
return matrixData_1;
|
|
285
302
|
}
|
|
286
303
|
}
|
|
287
304
|
else {
|
|
288
|
-
|
|
305
|
+
const matrixData: { description: string, values: IMap<string, string> } = matchValue_1.fields[0];
|
|
306
|
+
const arg_9: int32 = matrixData.values.size | 0;
|
|
307
|
+
toConsole(printf("[DEBUGGING_FORMSPEC_RENDERER] decodeAsMatrixValue fieldKey=%s path=StandardFormat count=%d"))(fieldKey)(arg_9);
|
|
308
|
+
return matrixData;
|
|
289
309
|
}
|
|
290
310
|
}
|
|
291
311
|
catch (ex: any) {
|
|
312
|
+
const arg_13: string = ex.message;
|
|
313
|
+
toConsole(printf("[DEBUGGING_FORMSPEC_RENDERER] decodeAsMatrixValue fieldKey=%s path=FAILED ex=%s"))(fieldKey)(arg_13);
|
|
292
314
|
throw new Error(`Field ${fieldKey}: Failed to decode matrix value - ${ex.message}`);
|
|
293
315
|
}
|
|
294
316
|
}
|
|
@@ -355,7 +377,7 @@ export function buildFormSpecWithValues(formSpec: Spec_FormSpec$1<Spec_FieldType
|
|
|
355
377
|
const field_1: Spec_FormField$1<Spec_FieldType_$union> = tupledArg[0];
|
|
356
378
|
return defaultArg_1(map<int32, Spec_FormSpec$1<Spec_FieldType_$union>>((stepIdx: int32): Spec_FormSpec$1<Spec_FieldType_$union> => updateField<Spec_FieldType_$union>(spec, field_1.FieldKey, tupledArg[1].FieldValue, stepIdx), findStepIndexForField<Spec_FieldType_$union>(spec, field_1.FieldKey)), spec);
|
|
357
379
|
}, formSpec, ofSeq<[Spec_FormField$1<Spec_FieldType_$union>, FieldDetails$1<Spec_FieldType_$union>]>(choose<{ fieldKey: string, objectValue: any }, [Spec_FormField$1<Spec_FieldType_$union>, FieldDetails$1<Spec_FieldType_$union>]>((input: { fieldKey: string, objectValue: any }): Option<[Spec_FormField$1<Spec_FieldType_$union>, FieldDetails$1<Spec_FieldType_$union>]> => {
|
|
358
|
-
let matchValue_1: ExpectedFieldValueType_$union, matrixData: { description: string, values: IMap<string, string> }, matchValue_2: Spec_FieldType_$union;
|
|
380
|
+
let matchValue_1: ExpectedFieldValueType_$union, matrixData: { description: string, values: IMap<string, string> }, matrixValues: FSharpMap<Shared_MatrixItemKey, string>, matrixAnswer: Shared_MatrixAnswer, arg_1: int32, matchValue_2: Spec_FieldType_$union;
|
|
359
381
|
const matchValue: Option<Spec_FormField$1<Spec_FieldType_$union>> = findFieldByKey(formSpec, input.fieldKey);
|
|
360
382
|
if (matchValue == null) {
|
|
361
383
|
toConsole(`Warning: Field ${input.fieldKey} not found in FormSpec`);
|
|
@@ -366,9 +388,9 @@ export function buildFormSpecWithValues(formSpec: Spec_FormSpec$1<Spec_FieldType
|
|
|
366
388
|
try {
|
|
367
389
|
return [field, new FieldDetails$1(field.FieldOrder, field.FieldKey, field.Label, (matchValue_1 = getExpectedFieldValueType(field.FieldType), (matchValue_1.tag === /* MultipleValues */ 1) ? Shared_FieldValue_Multiple(ofArray<Shared_FieldAnswer>(map_1<string, Shared_FieldAnswer>((value: string): Shared_FieldAnswer => (new Shared_FieldAnswer(field.FieldKey, field.Label, value)), decodeAsStringArray(input.fieldKey, input.objectValue)), {
|
|
368
390
|
Compare: compare,
|
|
369
|
-
})) : ((matchValue_1.tag === /* MatrixValue */ 2) ? ((matrixData = decodeAsMatrixValue(input.fieldKey, input.objectValue),
|
|
391
|
+
})) : ((matchValue_1.tag === /* MatrixValue */ 2) ? ((matrixData = decodeAsMatrixValue(input.fieldKey, input.objectValue), (matrixValues = ofSeq_1<Shared_MatrixItemKey, string>(map_2<[string, string], [Shared_MatrixItemKey, string]>((kvp: [string, string]): [Shared_MatrixItemKey, string] => ([new Shared_MatrixItemKey(parse(kvp[0])), kvp[1]] as [Shared_MatrixItemKey, string]), matrixData.values), {
|
|
370
392
|
Compare: compare,
|
|
371
|
-
}))))) : ((matchValue_1.tag === /* PluginDataValue */ 3) ? Shared_FieldValue_PluginData(ofArray_1<Shared_PluginDataProperty>(map_1<{ dataType: string, description?: string, displayName?: string, name: string, propertyKey: string, unit?: string, value: string }, Shared_PluginDataProperty>((prop: { dataType: string, description?: string, displayName?: string, name: string, propertyKey: string, unit?: string, value: string }): Shared_PluginDataProperty => (new Shared_PluginDataProperty(new Shared_PluginPropertyKey(parse(prop.propertyKey)), prop.name, prop.dataType, prop.value, prop.displayName, prop.unit, prop.description)), decodeAsPluginDataArray(input.fieldKey, input.objectValue)))) : Shared_FieldValue_Single(new Shared_FieldAnswer(field.FieldKey, field.Label, decodeAsString(input.fieldKey, input.objectValue)))))), field.FieldType, (matchValue_2 = field.FieldType, (matchValue_2.tag === /* Radio */ 12) ? matchValue_2.fields[0].Options : ((matchValue_2.tag === /* SingleChoice */ 13) ? matchValue_2.fields[0].Options : ((matchValue_2.tag === /* Dropdown */ 14) ? matchValue_2.fields[0].Options : ((matchValue_2.tag === /* MultiChoice */ 15) ? matchValue_2.fields[0].Options : ((matchValue_2.tag === /* CheckboxList */ 16) ? matchValue_2.fields[0].Options : ((matchValue_2.tag === /* TagList */ 17) ? matchValue_2.fields[0].Options : ((matchValue_2.tag === /* TextAutoComplete */ 18) ? matchValue_2.fields[0].Options : ((matchValue_2.tag === /* Matrix */ 19) ? matchValue_2.fields[0].Options : empty<Shared_FieldOption>())))))))))] as [Spec_FormField$1<Spec_FieldType_$union>, FieldDetails$1<Spec_FieldType_$union>];
|
|
393
|
+
}), (matrixAnswer = (new Shared_MatrixAnswer(field.FieldKey, matrixData.description, matrixValues)), ((arg_1 = (count<Shared_MatrixItemKey, string>(matrixValues) | 0), toConsole(printf("[DEBUGGING_FORMSPEC_RENDERER] buildFormSpecWithValues Matrix fieldKey=%s valuesCount=%d"))(input.fieldKey)(arg_1)), Shared_FieldValue_Matrix(matrixAnswer)))))) : ((matchValue_1.tag === /* PluginDataValue */ 3) ? Shared_FieldValue_PluginData(ofArray_1<Shared_PluginDataProperty>(map_1<{ dataType: string, description?: string, displayName?: string, name: string, propertyKey: string, unit?: string, value: string }, Shared_PluginDataProperty>((prop: { dataType: string, description?: string, displayName?: string, name: string, propertyKey: string, unit?: string, value: string }): Shared_PluginDataProperty => (new Shared_PluginDataProperty(new Shared_PluginPropertyKey(parse(prop.propertyKey)), prop.name, prop.dataType, prop.value, prop.displayName, prop.unit, prop.description)), decodeAsPluginDataArray(input.fieldKey, input.objectValue)))) : Shared_FieldValue_Single(new Shared_FieldAnswer(field.FieldKey, field.Label, decodeAsString(input.fieldKey, input.objectValue)))))), field.FieldType, (matchValue_2 = field.FieldType, (matchValue_2.tag === /* Radio */ 12) ? matchValue_2.fields[0].Options : ((matchValue_2.tag === /* SingleChoice */ 13) ? matchValue_2.fields[0].Options : ((matchValue_2.tag === /* Dropdown */ 14) ? matchValue_2.fields[0].Options : ((matchValue_2.tag === /* MultiChoice */ 15) ? matchValue_2.fields[0].Options : ((matchValue_2.tag === /* CheckboxList */ 16) ? matchValue_2.fields[0].Options : ((matchValue_2.tag === /* TagList */ 17) ? matchValue_2.fields[0].Options : ((matchValue_2.tag === /* TextAutoComplete */ 18) ? matchValue_2.fields[0].Options : ((matchValue_2.tag === /* Matrix */ 19) ? matchValue_2.fields[0].Options : empty<Shared_FieldOption>())))))))))] as [Spec_FormField$1<Spec_FieldType_$union>, FieldDetails$1<Spec_FieldType_$union>];
|
|
372
394
|
}
|
|
373
395
|
catch (ex: any) {
|
|
374
396
|
toConsole(`Error processing field ${input.fieldKey}: ${ex.message}`);
|
|
@@ -440,7 +462,7 @@ export function createMatrixField(fieldKeyString: string, label: string, items:
|
|
|
440
462
|
* TypeScript: createPluginField(fieldKey: string, label: string, config: {pluginId: string})
|
|
441
463
|
*/
|
|
442
464
|
export function createPluginField(fieldKeyString: string, label: string, config: { pluginId: string }): Spec_FormField$1<Spec_FieldType_$union> {
|
|
443
|
-
return new Spec_FormField$1(1, new Shared_FieldKey(parse(fieldKeyString)), label, undefined, undefined, false, false, Spec_FieldType_PluginField(new Spec_PluginFieldConfig(config.pluginId)), undefined);
|
|
465
|
+
return new Spec_FormField$1(1, new Shared_FieldKey(parse(fieldKeyString)), label, undefined, undefined, false, false, Spec_FieldType_PluginField(new Spec_PluginFieldConfig(config.pluginId, undefined, undefined)), undefined);
|
|
444
466
|
}
|
|
445
467
|
|
|
446
468
|
/**
|
|
@@ -550,7 +572,7 @@ export function getFieldDetails(formSpec: Spec_FormSpec$1<Spec_FieldType_$union>
|
|
|
550
572
|
export function createTestFormSpec(): Spec_FormSpec$1<Spec_FieldType_$union> {
|
|
551
573
|
const option1: Shared_FieldOption = new Shared_FieldOption("Option 1", "opt1", new Shared_FieldOptionKey(newGuid()), undefined);
|
|
552
574
|
const option2: Shared_FieldOption = new Shared_FieldOption("Option 2", "opt2", new Shared_FieldOptionKey(newGuid()), undefined);
|
|
553
|
-
const testStep: Spec_FormStep$1<Spec_FieldType_$union> = new Spec_FormStep$1(1, "Test Step", ofArray_1([new Spec_FormField$1(1, new Shared_FieldKey("11111111-1111-1111-1111-111111111111"), "Test Text Field", undefined, undefined, false, false, Spec_FieldType_Text(new Spec_TextInfo(undefined)), undefined), new Spec_FormField$1(2, new Shared_FieldKey("22222222-2222-2222-2222-222222222222"), "Test Checkbox List", undefined, undefined, false, false, Spec_FieldType_CheckboxList(new Spec_MultiChoiceInfo(ofArray_1([option1, option2]))), undefined), new Spec_FormField$1(3, new Shared_FieldKey("33333333-3333-3333-3333-333333333333"), "Test Matrix", undefined, undefined, false, false, Spec_FieldType_Matrix(new Spec_MatrixInfo(ofArray_1([option1, option2]), ofArray_1([new Shared_FieldOption("Scale 1", "1", new Shared_FieldOptionKey(newGuid()), 1), new Shared_FieldOption("Scale 2", "2", new Shared_FieldOptionKey(newGuid()), 2)]))), undefined), new Spec_FormField$1(4, new Shared_FieldKey("44444444-4444-4444-4444-444444444444"), "Test Plugin Field", undefined, undefined, false, false, Spec_FieldType_PluginField(new Spec_PluginFieldConfig("test.plugin")), undefined)]));
|
|
575
|
+
const testStep: Spec_FormStep$1<Spec_FieldType_$union> = new Spec_FormStep$1(1, "Test Step", ofArray_1([new Spec_FormField$1(1, new Shared_FieldKey("11111111-1111-1111-1111-111111111111"), "Test Text Field", undefined, undefined, false, false, Spec_FieldType_Text(new Spec_TextInfo(undefined)), undefined), new Spec_FormField$1(2, new Shared_FieldKey("22222222-2222-2222-2222-222222222222"), "Test Checkbox List", undefined, undefined, false, false, Spec_FieldType_CheckboxList(new Spec_MultiChoiceInfo(ofArray_1([option1, option2]))), undefined), new Spec_FormField$1(3, new Shared_FieldKey("33333333-3333-3333-3333-333333333333"), "Test Matrix", undefined, undefined, false, false, Spec_FieldType_Matrix(new Spec_MatrixInfo(ofArray_1([option1, option2]), ofArray_1([new Shared_FieldOption("Scale 1", "1", new Shared_FieldOptionKey(newGuid()), 1), new Shared_FieldOption("Scale 2", "2", new Shared_FieldOptionKey(newGuid()), 2)]))), undefined), new Spec_FormField$1(4, new Shared_FieldKey("44444444-4444-4444-4444-444444444444"), "Test Plugin Field", undefined, undefined, false, false, Spec_FieldType_PluginField(new Spec_PluginFieldConfig("test.plugin", undefined, undefined)), undefined)]));
|
|
554
576
|
return new Spec_FormSpec$1(newGuid(), "TEST-001", "Test Form", "Test form for buildDynamicFormResultData", "1.0.0", "5.0.0", singleton(testStep), empty<string>(), undefined, empty<string>(), false, false, undefined, Spec_FormLifecycle_Blueprint(), undefined);
|
|
555
577
|
}
|
|
556
578
|
|
|
@@ -584,15 +606,31 @@ export function getFieldTypeInfo(field: Spec_FormField$1<Spec_FieldType_$union>)
|
|
|
584
606
|
}
|
|
585
607
|
|
|
586
608
|
/**
|
|
587
|
-
* Extract plugin field config (PluginId) for PluginField types.
|
|
588
|
-
* TypeScript: getPluginFieldConfig(field: FormField) => {pluginId: string} | null
|
|
609
|
+
* Extract plugin field config (PluginId, optional items/options) for PluginField types.
|
|
610
|
+
* TypeScript: getPluginFieldConfig(field: FormField) => {pluginId: string, items?: ..., options?: ...} | null
|
|
589
611
|
* Returns null for non-PluginField fields.
|
|
590
612
|
*/
|
|
591
|
-
export function getPluginFieldConfig(field: Spec_FormField$1<Spec_FieldType_$union>): Option<{ pluginId: string }> {
|
|
613
|
+
export function getPluginFieldConfig(field: Spec_FormField$1<Spec_FieldType_$union>): Option<{ items?: { key: string, label: string }[], options?: { description: string, key: string, value: string }[], pluginId: string }> {
|
|
592
614
|
const matchValue: Spec_FieldType_$union = field.FieldType;
|
|
593
615
|
if (matchValue.tag === /* PluginField */ 22) {
|
|
616
|
+
const config: Spec_PluginFieldConfig = matchValue.fields[0];
|
|
594
617
|
return {
|
|
595
|
-
|
|
618
|
+
items: unwrap(map<FSharpList<Shared_FieldOption>, { key: string, label: string }[]>((items: FSharpList<Shared_FieldOption>): { key: string, label: string }[] => {
|
|
619
|
+
const collection: FSharpList<{ key: string, label: string }> = map_3<Shared_FieldOption, { key: string, label: string }>((item: Shared_FieldOption): { key: string, label: string } => ({
|
|
620
|
+
key: item.OptionKey.fields[0],
|
|
621
|
+
label: item.Description,
|
|
622
|
+
}), items);
|
|
623
|
+
return Array.from(collection);
|
|
624
|
+
}, config.Items)),
|
|
625
|
+
options: unwrap(map<FSharpList<Shared_FieldOption>, { description: string, key: string, value: string }[]>((opts: FSharpList<Shared_FieldOption>): { description: string, key: string, value: string }[] => {
|
|
626
|
+
const collection_1: FSharpList<{ description: string, key: string, value: string }> = map_3<Shared_FieldOption, { description: string, key: string, value: string }>((opt: Shared_FieldOption): { description: string, key: string, value: string } => ({
|
|
627
|
+
description: opt.Description,
|
|
628
|
+
key: opt.OptionKey.fields[0],
|
|
629
|
+
value: opt.Value,
|
|
630
|
+
}), opts);
|
|
631
|
+
return Array.from(collection_1);
|
|
632
|
+
}, config.Options)),
|
|
633
|
+
pluginId: config.PluginId,
|
|
596
634
|
};
|
|
597
635
|
}
|
|
598
636
|
else {
|
|
@@ -656,28 +694,147 @@ export function getFieldChoiceOptions(field: Spec_FormField$1<Spec_FieldType_$un
|
|
|
656
694
|
}
|
|
657
695
|
|
|
658
696
|
/**
|
|
659
|
-
* Extract matrix field structure (items and options)
|
|
697
|
+
* Extract matrix field structure (items and options).
|
|
698
|
+
* Handles both Matrix fields and PluginField (e.g. Likert) when config has Items and Options.
|
|
660
699
|
* TypeScript: getFieldMatrixInfo(field: FormField) => {items: {key: string, label: string}[], options: {key: string, description: string, value: string}[]} | null
|
|
661
700
|
*/
|
|
662
701
|
export function getFieldMatrixInfo(field: Spec_FormField$1<Spec_FieldType_$union>): Option<{ items: { key: string, label: string }[], options: { description: string, key: string, value: string }[] }> {
|
|
663
|
-
let collection: FSharpList<{ key: string, label: string }>, collection_1: FSharpList<{ description: string, key: string, value: string }
|
|
702
|
+
let collection: FSharpList<{ key: string, label: string }>, collection_1: FSharpList<{ description: string, key: string, value: string }>, collection_2: FSharpList<{ key: string, label: string }>, collection_3: FSharpList<{ description: string, key: string, value: string }>, config: Spec_PluginFieldConfig;
|
|
664
703
|
const matchValue: Spec_FieldType_$union = field.FieldType;
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
}
|
|
677
|
-
|
|
704
|
+
let matchResult: int32, matrixInfo: Spec_MatrixInfo, config_1: Spec_PluginFieldConfig;
|
|
705
|
+
switch (matchValue.tag) {
|
|
706
|
+
case /* Matrix */ 19: {
|
|
707
|
+
matchResult = 0;
|
|
708
|
+
matrixInfo = matchValue.fields[0];
|
|
709
|
+
break;
|
|
710
|
+
}
|
|
711
|
+
case /* PluginField */ 22: {
|
|
712
|
+
if ((config = matchValue.fields[0], (config.Items != null) && (config.Options != null))) {
|
|
713
|
+
matchResult = 1;
|
|
714
|
+
config_1 = matchValue.fields[0];
|
|
715
|
+
}
|
|
716
|
+
else {
|
|
717
|
+
matchResult = 2;
|
|
718
|
+
}
|
|
719
|
+
break;
|
|
720
|
+
}
|
|
721
|
+
default:
|
|
722
|
+
matchResult = 2;
|
|
723
|
+
}
|
|
724
|
+
switch (matchResult) {
|
|
725
|
+
case 0:
|
|
726
|
+
return {
|
|
727
|
+
items: (collection = map_3<Shared_FieldOption, { key: string, label: string }>((item: Shared_FieldOption): { key: string, label: string } => ({
|
|
728
|
+
key: item.OptionKey.fields[0],
|
|
729
|
+
label: item.Description,
|
|
730
|
+
}), matrixInfo!.Items), Array.from(collection)),
|
|
731
|
+
options: (collection_1 = map_3<Shared_FieldOption, { description: string, key: string, value: string }>((opt: Shared_FieldOption): { description: string, key: string, value: string } => ({
|
|
732
|
+
description: opt.Description,
|
|
733
|
+
key: opt.OptionKey.fields[0],
|
|
734
|
+
value: opt.Value,
|
|
735
|
+
}), matrixInfo!.Options), Array.from(collection_1)),
|
|
736
|
+
};
|
|
737
|
+
case 1:
|
|
738
|
+
return {
|
|
739
|
+
items: (collection_2 = map_3<Shared_FieldOption, { key: string, label: string }>((item_1: Shared_FieldOption): { key: string, label: string } => ({
|
|
740
|
+
key: item_1.OptionKey.fields[0],
|
|
741
|
+
label: item_1.Description,
|
|
742
|
+
}), value_11(config_1!.Items)), Array.from(collection_2)),
|
|
743
|
+
options: (collection_3 = map_3<Shared_FieldOption, { description: string, key: string, value: string }>((opt_1: Shared_FieldOption): { description: string, key: string, value: string } => ({
|
|
744
|
+
description: opt_1.Description,
|
|
745
|
+
key: opt_1.OptionKey.fields[0],
|
|
746
|
+
value: opt_1.Value,
|
|
747
|
+
}), value_11(config_1!.Options)), Array.from(collection_3)),
|
|
748
|
+
};
|
|
749
|
+
default:
|
|
750
|
+
return undefined;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* Extract matrix info from field.Value when it's Matrix or PluginData (FilledForm).
|
|
756
|
+
* Use when getFieldMatrixInfo returns null - e.g. when FieldType doesn't match but Value has Matrix/PluginData.
|
|
757
|
+
* TypeScript: getFieldMatrixInfoFromValue(field: FormField) => {items, options} | null
|
|
758
|
+
*/
|
|
759
|
+
export function getFieldMatrixInfoFromValue(field: Spec_FormField$1<Spec_FieldType_$union>): Option<{ items: { key: string, label: string }[], options: { description: string, key: string, value: string }[] }> {
|
|
760
|
+
let collection: FSharpList<{ key: string, label: string }>, collection_1: FSharpList<{ description: string, key: string, value: string }>, collection_2: FSharpList<{ key: string, label: string }>, collection_3: FSharpList<{ description: string, key: string, value: string }>;
|
|
761
|
+
const matchValue: Option<Shared_FieldValue_$union> = field.Value;
|
|
762
|
+
let matchResult: int32, ma: Shared_MatrixAnswer, props: FSharpList<Shared_PluginDataProperty>;
|
|
763
|
+
if (matchValue != null) {
|
|
764
|
+
switch (value_11(matchValue).tag) {
|
|
765
|
+
case /* Matrix */ 2: {
|
|
766
|
+
matchResult = 0;
|
|
767
|
+
ma = (value_11(matchValue) as Shared_FieldValue<2>).fields[0];
|
|
768
|
+
break;
|
|
769
|
+
}
|
|
770
|
+
case /* PluginData */ 3: {
|
|
771
|
+
matchResult = 1;
|
|
772
|
+
props = (value_11(matchValue) as Shared_FieldValue<3>).fields[0];
|
|
773
|
+
break;
|
|
774
|
+
}
|
|
775
|
+
default:
|
|
776
|
+
matchResult = 2;
|
|
777
|
+
}
|
|
678
778
|
}
|
|
679
779
|
else {
|
|
680
|
-
|
|
780
|
+
matchResult = 2;
|
|
781
|
+
}
|
|
782
|
+
switch (matchResult) {
|
|
783
|
+
case 0: {
|
|
784
|
+
const itemKeys: FSharpList<string> = toList_1<string>(distinct<string>(map_2<[Shared_MatrixItemKey, string], string>((kvp: [Shared_MatrixItemKey, string]): string => kvp[0].fields[0], ma!.Values), {
|
|
785
|
+
Equals: (x: string, y: string): boolean => (x === y),
|
|
786
|
+
GetHashCode: stringHash,
|
|
787
|
+
}));
|
|
788
|
+
const optionValues: FSharpList<string> = toList_1<string>(distinct<string>(map_2<[Shared_MatrixItemKey, string], string>((kvp_1: [Shared_MatrixItemKey, string]): string => kvp_1[1], ma!.Values), {
|
|
789
|
+
Equals: (x_1: string, y_1: string): boolean => (x_1 === y_1),
|
|
790
|
+
GetHashCode: stringHash,
|
|
791
|
+
}));
|
|
792
|
+
if (isEmpty(itemKeys) ? true : isEmpty(optionValues)) {
|
|
793
|
+
return undefined;
|
|
794
|
+
}
|
|
795
|
+
else {
|
|
796
|
+
return {
|
|
797
|
+
items: (collection = mapIndexed_1<string, { key: string, label: string }>((i: int32, k: string): { key: string, label: string } => ({
|
|
798
|
+
key: k,
|
|
799
|
+
label: k,
|
|
800
|
+
}), itemKeys), Array.from(collection)),
|
|
801
|
+
options: (collection_1 = mapIndexed_1<string, { description: string, key: string, value: string }>((i_1: int32, v: string): { description: string, key: string, value: string } => ({
|
|
802
|
+
description: v,
|
|
803
|
+
key: v,
|
|
804
|
+
value: v,
|
|
805
|
+
}), optionValues), Array.from(collection_1)),
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
case 1: {
|
|
810
|
+
const likertProps: FSharpList<Shared_PluginDataProperty> = filter<Shared_PluginDataProperty>((p: Shared_PluginDataProperty): boolean => (p.Name !== "TotalScore"), props!);
|
|
811
|
+
const itemKeys_1: FSharpList<string> = List_distinct<string>(map_3<Shared_PluginDataProperty, string>((p_1: Shared_PluginDataProperty): string => p_1.Name, likertProps), {
|
|
812
|
+
Equals: (x_2: string, y_2: string): boolean => (x_2 === y_2),
|
|
813
|
+
GetHashCode: stringHash,
|
|
814
|
+
});
|
|
815
|
+
const optionValues_1: FSharpList<string> = List_distinct<string>(map_3<Shared_PluginDataProperty, string>((p_2: Shared_PluginDataProperty): string => p_2.Value, likertProps), {
|
|
816
|
+
Equals: (x_3: string, y_3: string): boolean => (x_3 === y_3),
|
|
817
|
+
GetHashCode: stringHash,
|
|
818
|
+
});
|
|
819
|
+
if (isEmpty(itemKeys_1) ? true : isEmpty(optionValues_1)) {
|
|
820
|
+
return undefined;
|
|
821
|
+
}
|
|
822
|
+
else {
|
|
823
|
+
return {
|
|
824
|
+
items: (collection_2 = mapIndexed_1<string, { key: string, label: string }>((i_2: int32, k_1: string): { key: string, label: string } => ({
|
|
825
|
+
key: k_1,
|
|
826
|
+
label: k_1,
|
|
827
|
+
}), itemKeys_1), Array.from(collection_2)),
|
|
828
|
+
options: (collection_3 = mapIndexed_1<string, { description: string, key: string, value: string }>((i_3: int32, v_1: string): { description: string, key: string, value: string } => ({
|
|
829
|
+
description: v_1,
|
|
830
|
+
key: v_1,
|
|
831
|
+
value: v_1,
|
|
832
|
+
}), optionValues_1), Array.from(collection_3)),
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
default:
|
|
837
|
+
return undefined;
|
|
681
838
|
}
|
|
682
839
|
}
|
|
683
840
|
|
|
@@ -695,7 +852,7 @@ export function getFieldKeyString(fieldKey: Shared_FieldKey): string {
|
|
|
695
852
|
* TypeScript: extractFormValuesFromFormSpec(formSpec: FormSpec) => Record<string, any>
|
|
696
853
|
*/
|
|
697
854
|
export function extractFormValuesFromFormSpec(spec: Spec_FormSpec$1<Spec_FieldType_$union>): any {
|
|
698
|
-
const pairs: FSharpList<[string, any]> =
|
|
855
|
+
const pairs: FSharpList<[string, any]> = toList_1<[string, any]>(delay<[string, any]>((): Iterable<[string, any]> => collect_1<Spec_FormStep$1<Spec_FieldType_$union>, Iterable<[string, any]>, [string, any]>((step: Spec_FormStep$1<Spec_FieldType_$union>): Iterable<[string, any]> => collect_1<Spec_FormField$1<Spec_FieldType_$union>, Iterable<[string, any]>, [string, any]>((field: Spec_FormField$1<Spec_FieldType_$union>): Iterable<[string, any]> => {
|
|
699
856
|
let arr: string[], ma: Shared_MatrixAnswer, dict: IMap<string, string>, enumerator: IEnumerator<[Shared_MatrixItemKey, string]>, arr_1: FSharpList<any>;
|
|
700
857
|
const matchValue: Option<Shared_FieldValue_$union> = field.Value;
|
|
701
858
|
if (matchValue == null) {
|
|
@@ -1168,7 +1168,7 @@ export function Converters_fieldTypeFromTS(fieldType: Types_FieldTypeTS): Option
|
|
|
1168
1168
|
return undefined;
|
|
1169
1169
|
}
|
|
1170
1170
|
else {
|
|
1171
|
-
return Spec_FieldType_PluginField(new Spec_PluginFieldConfig(value_2(matchValue_34).PluginId));
|
|
1171
|
+
return Spec_FieldType_PluginField(new Spec_PluginFieldConfig(value_2(matchValue_34).PluginId, undefined, undefined));
|
|
1172
1172
|
}
|
|
1173
1173
|
}
|
|
1174
1174
|
default:
|