@f1studio/form-spec 5.0.0-alpha.123 → 5.0.0-alpha.125

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.
Files changed (46) hide show
  1. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRAdapter.d.ts.map +1 -1
  2. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.d.ts +8 -51
  3. package/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.d.ts.map +1 -1
  4. package/FormSpec.FS/Integrations/CorEMR/TemplateDecodeTypes.d.ts +73 -0
  5. package/FormSpec.FS/Integrations/CorEMR/TemplateDecodeTypes.d.ts.map +1 -0
  6. package/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.d.ts +162 -0
  7. package/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.d.ts.map +1 -0
  8. package/FormSpec.FS/Interop/FormSpec.Api.Helpers.d.ts +46 -0
  9. package/FormSpec.FS/Interop/FormSpec.Api.Helpers.d.ts.map +1 -1
  10. package/FormSpec.TS/FormSpec.FS/BitmaskHelpers.js +1 -1
  11. package/FormSpec.TS/FormSpec.FS/BitmaskHelpers.js.map +1 -1
  12. package/FormSpec.TS/FormSpec.FS/BitmaskHelpers.ts.map +1 -1
  13. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRAdapter.js +1 -1
  14. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRAdapter.js.map +1 -1
  15. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRAdapter.ts.map +1 -1
  16. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.js +16 -220
  17. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.js.map +1 -1
  18. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.ts.map +1 -1
  19. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.js.map +1 -1
  20. package/FormSpec.TS/FormSpec.FS/Integrations/Adapters/CorEMR/CoreMREncoder.ts.map +1 -1
  21. package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/TemplateDecodeTypes.js +387 -0
  22. package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/TemplateDecodeTypes.js.map +1 -0
  23. package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/TemplateDecodeTypes.ts.map +1 -0
  24. package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.js +771 -0
  25. package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.js.map +1 -0
  26. package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.ts.map +1 -0
  27. package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Helpers.js +151 -0
  28. package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Helpers.js.map +1 -1
  29. package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Helpers.ts.map +1 -1
  30. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Encode.fs.js.map +1 -1
  31. package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Encode.fs.ts.map +1 -1
  32. package/FormSpec.TS/fable_modules/project_cracked.json +1 -1
  33. package/README.md +7 -7
  34. package/package.json +1 -1
  35. package/src/FormSpec.FS/BitmaskHelpers.ts +1 -1
  36. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRAdapter.ts +2 -2
  37. package/src/FormSpec.FS/Integrations/Adapters/CorEMR/CorEMRTemplateMapper.ts +32 -127
  38. package/src/FormSpec.FS/Integrations/CorEMR/TemplateDecodeTypes.ts +246 -0
  39. package/src/FormSpec.FS/Integrations/CorEMR/TemplateManifestDecoder.ts +431 -0
  40. package/src/FormSpec.FS/Interop/FormSpec.Api.Helpers.ts +184 -3
  41. package/FormSpec.FS/Integrations/CorEMR/CorEmrTemplates.d.ts +0 -95
  42. package/FormSpec.FS/Integrations/CorEMR/CorEmrTemplates.d.ts.map +0 -1
  43. package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/CorEmrTemplates.js +0 -258
  44. package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/CorEmrTemplates.js.map +0 -1
  45. package/FormSpec.TS/FormSpec.FS/Integrations/CorEMR/CorEmrTemplates.ts.map +0 -1
  46. package/src/FormSpec.FS/Integrations/CorEMR/CorEmrTemplates.ts +0 -15
@@ -0,0 +1,246 @@
1
+ import { Record, Union } from "@fable-org/fable-library-js/Types.js";
2
+ import { list_type, record_type, option_type, string_type, int32_type, union_type, TypeInfo } from "@fable-org/fable-library-js/Reflection.js";
3
+ import { int32 } from "@fable-org/fable-library-js/Int32.js";
4
+ import { value, Option } from "@fable-org/fable-library-js/Option.js";
5
+ import { equals, IComparable, IEquatable } from "@fable-org/fable-library-js/Util.js";
6
+ import { isEmpty, take, iterate, filter, length, FSharpList } from "@fable-org/fable-library-js/List.js";
7
+ import { join, printf, toText } from "@fable-org/fable-library-js/String.js";
8
+
9
+ export type DecodeIssueSeverity_$union =
10
+ | DecodeIssueSeverity<0>
11
+ | DecodeIssueSeverity<1>
12
+
13
+ export type DecodeIssueSeverity_$cases = {
14
+ 0: ["Error", []],
15
+ 1: ["Warning", []]
16
+ }
17
+
18
+ export function DecodeIssueSeverity_Error() {
19
+ return new DecodeIssueSeverity<0>(0, []);
20
+ }
21
+
22
+ export function DecodeIssueSeverity_Warning() {
23
+ return new DecodeIssueSeverity<1>(1, []);
24
+ }
25
+
26
+ export class DecodeIssueSeverity<Tag extends keyof DecodeIssueSeverity_$cases> extends Union<Tag, DecodeIssueSeverity_$cases[Tag][0]> {
27
+ constructor(readonly tag: Tag, readonly fields: DecodeIssueSeverity_$cases[Tag][1]) {
28
+ super();
29
+ }
30
+ cases() {
31
+ return ["Error", "Warning"];
32
+ }
33
+ }
34
+
35
+ export function DecodeIssueSeverity_$reflection(): TypeInfo {
36
+ return union_type("FormSpec.Integrations.CorEMR.TemplateDecodeTypes.DecodeIssueSeverity", [], DecodeIssueSeverity, () => [[], []]);
37
+ }
38
+
39
+ export type DecodeIssuePath_$union =
40
+ | DecodeIssuePath<0>
41
+ | DecodeIssuePath<1>
42
+ | DecodeIssuePath<2>
43
+ | DecodeIssuePath<3>
44
+
45
+ export type DecodeIssuePath_$cases = {
46
+ 0: ["PayloadLevel", []],
47
+ 1: ["FormLevel", [int32, string]],
48
+ 2: ["ItemLevel", [int32, string, int32, string]],
49
+ 3: ["ChoiceLevel", [int32, string, int32, string, int32, Option<string>]]
50
+ }
51
+
52
+ export function DecodeIssuePath_PayloadLevel() {
53
+ return new DecodeIssuePath<0>(0, []);
54
+ }
55
+
56
+ export function DecodeIssuePath_FormLevel(formId: int32, formName: string) {
57
+ return new DecodeIssuePath<1>(1, [formId, formName]);
58
+ }
59
+
60
+ export function DecodeIssuePath_ItemLevel(formId: int32, formName: string, itemId: int32, itemText: string) {
61
+ return new DecodeIssuePath<2>(2, [formId, formName, itemId, itemText]);
62
+ }
63
+
64
+ export function DecodeIssuePath_ChoiceLevel(formId: int32, formName: string, itemId: int32, itemText: string, choiceIndex: int32, choiceText: Option<string>) {
65
+ return new DecodeIssuePath<3>(3, [formId, formName, itemId, itemText, choiceIndex, choiceText]);
66
+ }
67
+
68
+ export class DecodeIssuePath<Tag extends keyof DecodeIssuePath_$cases> extends Union<Tag, DecodeIssuePath_$cases[Tag][0]> {
69
+ constructor(readonly tag: Tag, readonly fields: DecodeIssuePath_$cases[Tag][1]) {
70
+ super();
71
+ }
72
+ cases() {
73
+ return ["PayloadLevel", "FormLevel", "ItemLevel", "ChoiceLevel"];
74
+ }
75
+ }
76
+
77
+ export function DecodeIssuePath_$reflection(): TypeInfo {
78
+ return union_type("FormSpec.Integrations.CorEMR.TemplateDecodeTypes.DecodeIssuePath", [], DecodeIssuePath, () => [[], [["formId", int32_type], ["formName", string_type]], [["formId", int32_type], ["formName", string_type], ["itemId", int32_type], ["itemText", string_type]], [["formId", int32_type], ["formName", string_type], ["itemId", int32_type], ["itemText", string_type], ["choiceIndex", int32_type], ["choiceText", option_type(string_type)]]]);
79
+ }
80
+
81
+ export class DecodeIssue extends Record implements IEquatable<DecodeIssue>, IComparable<DecodeIssue> {
82
+ readonly Path: DecodeIssuePath_$union;
83
+ readonly Severity: DecodeIssueSeverity_$union;
84
+ readonly Field: string;
85
+ readonly Expected: string;
86
+ readonly Got: string;
87
+ readonly Message: string;
88
+ constructor(Path: DecodeIssuePath_$union, Severity: DecodeIssueSeverity_$union, Field: string, Expected: string, Got: string, Message: string) {
89
+ super();
90
+ this.Path = Path;
91
+ this.Severity = Severity;
92
+ this.Field = Field;
93
+ this.Expected = Expected;
94
+ this.Got = Got;
95
+ this.Message = Message;
96
+ }
97
+ }
98
+
99
+ export function DecodeIssue_$reflection(): TypeInfo {
100
+ return record_type("FormSpec.Integrations.CorEMR.TemplateDecodeTypes.DecodeIssue", [], DecodeIssue, () => [["Path", DecodeIssuePath_$reflection()], ["Severity", DecodeIssueSeverity_$reflection()], ["Field", string_type], ["Expected", string_type], ["Got", string_type], ["Message", string_type]]);
101
+ }
102
+
103
+ export class DecodeBatchResult$1<T> extends Record implements IEquatable<DecodeBatchResult$1<T>>, IComparable<DecodeBatchResult$1<T>> {
104
+ readonly Succeeded: FSharpList<T>;
105
+ readonly Issues: FSharpList<DecodeIssue>;
106
+ readonly SkippedTemplates: int32;
107
+ readonly SkippedItems: int32;
108
+ readonly SkippedChoices: int32;
109
+ readonly TotalTemplates: int32;
110
+ readonly TotalItems: int32;
111
+ readonly TotalChoices: int32;
112
+ constructor(Succeeded: FSharpList<T>, Issues: FSharpList<DecodeIssue>, SkippedTemplates: int32, SkippedItems: int32, SkippedChoices: int32, TotalTemplates: int32, TotalItems: int32, TotalChoices: int32) {
113
+ super();
114
+ this.Succeeded = Succeeded;
115
+ this.Issues = Issues;
116
+ this.SkippedTemplates = (SkippedTemplates | 0);
117
+ this.SkippedItems = (SkippedItems | 0);
118
+ this.SkippedChoices = (SkippedChoices | 0);
119
+ this.TotalTemplates = (TotalTemplates | 0);
120
+ this.TotalItems = (TotalItems | 0);
121
+ this.TotalChoices = (TotalChoices | 0);
122
+ }
123
+ }
124
+
125
+ export function DecodeBatchResult$1_$reflection(gen0: TypeInfo): TypeInfo {
126
+ return record_type("FormSpec.Integrations.CorEMR.TemplateDecodeTypes.DecodeBatchResult`1", [gen0], DecodeBatchResult$1, () => [["Succeeded", list_type(gen0)], ["Issues", list_type(DecodeIssue_$reflection())], ["SkippedTemplates", int32_type], ["SkippedItems", int32_type], ["SkippedChoices", int32_type], ["TotalTemplates", int32_type], ["TotalItems", int32_type], ["TotalChoices", int32_type]]);
127
+ }
128
+
129
+ function formatPath(path: DecodeIssuePath_$union): string {
130
+ switch (path.tag) {
131
+ case /* FormLevel */ 1: {
132
+ const formName: string = path.fields[1];
133
+ const formId: int32 = path.fields[0] | 0;
134
+ return toText(printf("Form \'%s\' (FormId: %d)"))(formName)(formId);
135
+ }
136
+ case /* ItemLevel */ 2: {
137
+ const itemText: string = path.fields[3];
138
+ const itemId: int32 = path.fields[2] | 0;
139
+ const formName_1: string = path.fields[1];
140
+ const formId_1: int32 = path.fields[0] | 0;
141
+ return toText(printf("Form \'%s\' (FormId: %d): Item #%d \'%s\'"))(formName_1)(formId_1)(itemId)(itemText);
142
+ }
143
+ case /* ChoiceLevel */ 3: {
144
+ const itemText_1: string = path.fields[3];
145
+ const itemId_1: int32 = path.fields[2] | 0;
146
+ const formName_2: string = path.fields[1];
147
+ const formId_2: int32 = path.fields[0] | 0;
148
+ const choiceText: Option<string> = path.fields[5];
149
+ const choiceIndex: int32 = path.fields[4] | 0;
150
+ let choicePart: string;
151
+ if (choiceText == null) {
152
+ choicePart = toText(printf("Choice #%d"))(choiceIndex);
153
+ }
154
+ else {
155
+ const t: string = value(choiceText);
156
+ choicePart = toText(printf("Choice #%d (text: \'%s\')"))(choiceIndex)(t);
157
+ }
158
+ return toText(printf("Form \'%s\' (FormId: %d): Item #%d \'%s\' — %s"))(formName_2)(formId_2)(itemId_1)(itemText_1)(choicePart);
159
+ }
160
+ default:
161
+ return "payload";
162
+ }
163
+ }
164
+
165
+ /**
166
+ * Format a single DecodeIssue for display.
167
+ */
168
+ export function formatIssue(issue: DecodeIssue): string {
169
+ const pathStr: string = formatPath(issue.Path);
170
+ return toText(printf("%s — Field \'%s\': expected %s, got %s"))(pathStr)(issue.Field)(issue.Expected)(issue.Got);
171
+ }
172
+
173
+ /**
174
+ * Human-readable summary for DecodeBatchResult (partial success).
175
+ */
176
+ export function formatSummary<T>(result: DecodeBatchResult$1<T>): string {
177
+ let arg_4: int32, arg_7: int32;
178
+ const lines: string[] = [];
179
+ const successCount: int32 = length(result.Succeeded) | 0;
180
+ void (lines.push(toText(printf("Decoded %d/%d templates successfully."))(successCount)(result.TotalTemplates)));
181
+ if (result.SkippedTemplates > 0) {
182
+ const templateIssues: FSharpList<DecodeIssue> = filter<DecodeIssue>((i: DecodeIssue): boolean => {
183
+ const matchValue: DecodeIssuePath_$union = i.Path;
184
+ switch (matchValue.tag) {
185
+ case /* ItemLevel */ 2:
186
+ case /* ChoiceLevel */ 3:
187
+ return false;
188
+ default:
189
+ return true;
190
+ }
191
+ }, result.Issues);
192
+ void (lines.push(""));
193
+ void (lines.push(toText(printf("%d templates skipped:"))(result.SkippedTemplates)));
194
+ iterate<DecodeIssue>((i_1: DecodeIssue): void => {
195
+ let arg_3: string;
196
+ void (lines.push((arg_3 = formatIssue(i_1), toText(printf(" %s"))(arg_3))));
197
+ }, take<DecodeIssue>(10, templateIssues));
198
+ if (length(templateIssues) > 10) {
199
+ void (lines.push((arg_4 = ((length(templateIssues) - 10) | 0), toText(printf(" ... and %d more"))(arg_4))));
200
+ }
201
+ }
202
+ if (result.SkippedChoices > 0) {
203
+ const choiceIssues: FSharpList<DecodeIssue> = filter<DecodeIssue>((i_2: DecodeIssue): boolean => {
204
+ if (i_2.Path.tag === /* ChoiceLevel */ 3) {
205
+ return equals(i_2.Severity, DecodeIssueSeverity_Warning());
206
+ }
207
+ else {
208
+ return false;
209
+ }
210
+ }, result.Issues);
211
+ void (lines.push(""));
212
+ void (lines.push(toText(printf("%d choices skipped across successful templates (non-fatal warnings):"))(result.SkippedChoices)));
213
+ iterate<DecodeIssue>((i_3: DecodeIssue): void => {
214
+ let arg_6: string;
215
+ void (lines.push((arg_6 = formatIssue(i_3), toText(printf(" %s"))(arg_6))));
216
+ }, take<DecodeIssue>(5, choiceIssues));
217
+ if (length(choiceIssues) > 5) {
218
+ void (lines.push((arg_7 = ((length(choiceIssues) - 5) | 0), toText(printf(" ... and %d more"))(arg_7))));
219
+ }
220
+ }
221
+ return join("\n", lines);
222
+ }
223
+
224
+ /**
225
+ * Human-readable summary for DecodeIssue list (hard failure, no partial success).
226
+ */
227
+ export function formatDecodeErrors(issues: FSharpList<DecodeIssue>): string {
228
+ let arg: int32, arg_2: int32;
229
+ if (isEmpty(issues)) {
230
+ return "Decode failed (no details)";
231
+ }
232
+ else {
233
+ const lines: string[] = [];
234
+ void (lines.push((arg = (length(issues) | 0), toText(printf("Decode failed: %d issue(s)"))(arg))));
235
+ iterate<DecodeIssue>((i: DecodeIssue): void => {
236
+ let arg_1: string;
237
+ void (lines.push((arg_1 = formatIssue(i), toText(printf(" %s"))(arg_1))));
238
+ }, take<DecodeIssue>(10, issues));
239
+ if (length(issues) > 10) {
240
+ void (lines.push((arg_2 = ((length(issues) - 10) | 0), toText(printf(" ... and %d more"))(arg_2))));
241
+ }
242
+ return join("\n", lines);
243
+ }
244
+ }
245
+
246
+ //# sourceMappingURL=TemplateDecodeTypes.ts.map