jspurefix 3.5.0 → 4.0.0

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 (235) hide show
  1. package/appveyor.yml +1 -1
  2. package/dist/buffer/ascii/ascii-encoder.d.ts +2 -2
  3. package/dist/buffer/ascii/ascii-encoder.js +1 -1
  4. package/dist/buffer/ascii/ascii-encoder.js.map +1 -1
  5. package/dist/buffer/ascii/ascii-parser-state.d.ts +3 -2
  6. package/dist/buffer/ascii/ascii-parser-state.js +1 -2
  7. package/dist/buffer/ascii/ascii-parser-state.js.map +1 -1
  8. package/dist/buffer/ascii/ascii-parser.d.ts +1 -1
  9. package/dist/buffer/ascii/ascii-parser.js +5 -4
  10. package/dist/buffer/ascii/ascii-parser.js.map +1 -1
  11. package/dist/buffer/ascii/ascii-segment-parser.js.map +1 -1
  12. package/dist/buffer/ascii/ascii-view.d.ts +4 -3
  13. package/dist/buffer/ascii/ascii-view.js +8 -5
  14. package/dist/buffer/ascii/ascii-view.js.map +1 -1
  15. package/dist/buffer/encode-proxy.js +1 -1
  16. package/dist/buffer/encode-proxy.js.map +1 -1
  17. package/dist/buffer/fixml/fixml-encoder.d.ts +2 -2
  18. package/dist/buffer/fixml/fixml-encoder.js +1 -1
  19. package/dist/buffer/fixml/fixml-encoder.js.map +1 -1
  20. package/dist/buffer/fixml/fixml-parser.js +2 -2
  21. package/dist/buffer/fixml/fixml-parser.js.map +1 -1
  22. package/dist/buffer/fixml/fixml-view.d.ts +3 -2
  23. package/dist/buffer/fixml/fixml-view.js +5 -4
  24. package/dist/buffer/fixml/fixml-view.js.map +1 -1
  25. package/dist/buffer/msg-encoder.d.ts +2 -2
  26. package/dist/buffer/msg-encoder.js.map +1 -1
  27. package/dist/buffer/msg-view.d.ts +8 -6
  28. package/dist/buffer/msg-view.js +10 -8
  29. package/dist/buffer/msg-view.js.map +1 -1
  30. package/dist/buffer/segment/segment-description.d.ts +3 -3
  31. package/dist/buffer/segment/segment-description.js.map +1 -1
  32. package/dist/buffer/tag/tags.d.ts +2 -5
  33. package/dist/buffer/tag/tags.js +4 -5
  34. package/dist/buffer/tag/tags.js.map +1 -1
  35. package/dist/collections/collection.d.ts +0 -1
  36. package/dist/collections/collection.js.map +1 -1
  37. package/dist/collections/index.d.ts +0 -1
  38. package/dist/collections/index.js +0 -17
  39. package/dist/collections/index.js.map +1 -1
  40. package/dist/config/js-fix-config.d.ts +2 -1
  41. package/dist/config/js-fix-config.js +3 -3
  42. package/dist/config/js-fix-config.js.map +1 -1
  43. package/dist/dictionary/compiler/compiler-type.d.ts +3 -3
  44. package/dist/dictionary/compiler/compiler-type.js.map +1 -1
  45. package/dist/dictionary/compiler/enum-compiler.js +2 -2
  46. package/dist/dictionary/compiler/enum-compiler.js.map +1 -1
  47. package/dist/dictionary/compiler/msg-compiler.d.ts +1 -2
  48. package/dist/dictionary/compiler/msg-compiler.js +6 -7
  49. package/dist/dictionary/compiler/msg-compiler.js.map +1 -1
  50. package/dist/dictionary/contained/contained-component-field.d.ts +1 -1
  51. package/dist/dictionary/contained/contained-component-field.js.map +1 -1
  52. package/dist/dictionary/contained/contained-field-set.d.ts +9 -20
  53. package/dist/dictionary/contained/contained-field-set.js +16 -149
  54. package/dist/dictionary/contained/contained-field-set.js.map +1 -1
  55. package/dist/dictionary/contained/contained-group-field.d.ts +1 -1
  56. package/dist/dictionary/contained/contained-group-field.js.map +1 -1
  57. package/dist/dictionary/contained/contained-set-builder.d.ts +15 -0
  58. package/dist/dictionary/contained/contained-set-builder.js +142 -0
  59. package/dist/dictionary/contained/contained-set-builder.js.map +1 -0
  60. package/dist/dictionary/contained/contained-set.d.ts +32 -0
  61. package/dist/{types/FIX.5.0SP2/quickfix/xm_lnon_fix.js → dictionary/contained/contained-set.js} +1 -1
  62. package/dist/dictionary/contained/contained-set.js.map +1 -0
  63. package/dist/dictionary/contained/contained-simple-field.d.ts +1 -1
  64. package/dist/dictionary/contained/contained-simple-field.js.map +1 -1
  65. package/dist/dictionary/contained/index.d.ts +4 -1
  66. package/dist/dictionary/contained/index.js +4 -1
  67. package/dist/dictionary/contained/index.js.map +1 -1
  68. package/dist/dictionary/definition/category-simple-set.d.ts +1 -2
  69. package/dist/dictionary/definition/category-simple-set.js +1 -2
  70. package/dist/dictionary/definition/category-simple-set.js.map +1 -1
  71. package/dist/dictionary/definition/component-field-definition.d.ts +1 -1
  72. package/dist/dictionary/definition/component-field-definition.js +2 -2
  73. package/dist/dictionary/definition/component-field-definition.js.map +1 -1
  74. package/dist/dictionary/definition/fix-definitions.d.ts +8 -9
  75. package/dist/dictionary/definition/fix-definitions.js +22 -20
  76. package/dist/dictionary/definition/fix-definitions.js.map +1 -1
  77. package/dist/dictionary/definition/group-field-definition.d.ts +1 -1
  78. package/dist/dictionary/definition/group-field-definition.js +2 -2
  79. package/dist/dictionary/definition/group-field-definition.js.map +1 -1
  80. package/dist/dictionary/definition/message-definition.d.ts +1 -1
  81. package/dist/dictionary/definition/message-definition.js +2 -2
  82. package/dist/dictionary/definition/message-definition.js.map +1 -1
  83. package/dist/dictionary/definition/simple-field-definition.d.ts +2 -3
  84. package/dist/dictionary/definition/simple-field-definition.js +6 -7
  85. package/dist/dictionary/definition/simple-field-definition.js.map +1 -1
  86. package/dist/dictionary/parser/fix-repository/repository.js +20 -20
  87. package/dist/dictionary/parser/fix-repository/repository.js.map +1 -1
  88. package/dist/dictionary/parser/fixml/components-parser.js +18 -16
  89. package/dist/dictionary/parser/fixml/components-parser.js.map +1 -1
  90. package/dist/dictionary/parser/fixml/fields-parser.js +2 -3
  91. package/dist/dictionary/parser/fixml/fields-parser.js.map +1 -1
  92. package/dist/dictionary/parser/fixml/include-graph.js +8 -9
  93. package/dist/dictionary/parser/fixml/include-graph.js.map +1 -1
  94. package/dist/dictionary/parser/quickfix/field-definition-parser.js.map +1 -1
  95. package/dist/dictionary/parser/quickfix/message-parser.js +2 -1
  96. package/dist/dictionary/parser/quickfix/message-parser.js.map +1 -1
  97. package/dist/dictionary/parser/quickfix/node-parser.js +3 -2
  98. package/dist/dictionary/parser/quickfix/node-parser.js.map +1 -1
  99. package/dist/dictionary/parser/quickfix/parse-context.d.ts +3 -3
  100. package/dist/dictionary/parser/quickfix/parse-context.js.map +1 -1
  101. package/dist/dictionary/parser/quickfix/parse-progress.d.ts +1 -2
  102. package/dist/dictionary/parser/quickfix/parse-progress.js +2 -3
  103. package/dist/dictionary/parser/quickfix/parse-progress.js.map +1 -1
  104. package/dist/dictionary/parser/quickfix/quick-fix-xml-file-builder.js +4 -5
  105. package/dist/dictionary/parser/quickfix/quick-fix-xml-file-builder.js.map +1 -1
  106. package/dist/dictionary/parser/quickfix/quick-fix-xml-file-parser.js +6 -6
  107. package/dist/dictionary/parser/quickfix/quick-fix-xml-file-parser.js.map +1 -1
  108. package/dist/dictionary/parser/quickfix/quick-fix-xml-formatter.d.ts +1 -1
  109. package/dist/dictionary/parser/quickfix/quick-fix-xml-formatter.js.map +1 -1
  110. package/dist/dictionary/set-reduce.d.ts +2 -2
  111. package/dist/dictionary/set-reduce.js.map +1 -1
  112. package/dist/index.d.ts +0 -1
  113. package/dist/index.js +0 -1
  114. package/dist/index.js.map +1 -1
  115. package/dist/jsfix-cmd.js +4 -5
  116. package/dist/jsfix-cmd.js.map +1 -1
  117. package/dist/sample/tcp/recovering-skeleton/respawn-acceptor.js +7 -8
  118. package/dist/sample/tcp/recovering-skeleton/respawn-acceptor.js.map +1 -1
  119. package/dist/sample/tcp/trade-capture/trade-capture-client.js +3 -4
  120. package/dist/sample/tcp/trade-capture/trade-capture-client.js.map +1 -1
  121. package/dist/sample/tcp/trade-capture/trade-capture-server.js.map +1 -1
  122. package/dist/store/fix-msg-memory-store.js +3 -4
  123. package/dist/store/fix-msg-memory-store.js.map +1 -1
  124. package/dist/store/fix-msg-store-record.js.map +1 -1
  125. package/dist/test/ascii/ascii-encoder.test.js.map +1 -1
  126. package/dist/test/ascii/fix-log-replay.test.js.map +1 -1
  127. package/dist/test/ascii/fix-repo-dict.test.js.map +1 -1
  128. package/dist/test/ascii/qf-50sp0-dict.test.js +7 -7
  129. package/dist/test/ascii/qf-50sp0-dict.test.js.map +1 -1
  130. package/dist/test/ascii/qf-50sp2-dict.test.js +5 -2
  131. package/dist/test/ascii/qf-50sp2-dict.test.js.map +1 -1
  132. package/dist/test/env/encoder-test.d.ts +3 -3
  133. package/dist/test/env/encoder-test.js.map +1 -1
  134. package/dist/test/env/set-constraint-helper.d.ts +4 -4
  135. package/dist/test/env/set-constraint-helper.js.map +1 -1
  136. package/dist/transport/ascii/ascii-msg-transmitter.js.map +1 -1
  137. package/dist/transport/ascii/ascii-session.js +1 -1
  138. package/dist/transport/ascii/ascii-session.js.map +1 -1
  139. package/dist/transport/fixml/fixml-session.js.map +1 -1
  140. package/dist/transport/http/http-acceptor.js +3 -4
  141. package/dist/transport/http/http-acceptor.js.map +1 -1
  142. package/dist/transport/http/http-json-sample-adapter.js +3 -4
  143. package/dist/transport/http/http-json-sample-adapter.js.map +1 -1
  144. package/dist/transport/session/dynamic-session-manager.d.ts +8 -0
  145. package/dist/transport/session/dynamic-session-manager.js +15 -0
  146. package/dist/transport/session/dynamic-session-manager.js.map +1 -0
  147. package/dist/transport/session/session-description.d.ts +9 -7
  148. package/dist/transport/session/session-description.js.map +1 -1
  149. package/dist/util/json-helper.d.ts +2 -2
  150. package/dist/util/json-helper.js.map +1 -1
  151. package/dist/util/message-generator.js +1 -1
  152. package/dist/util/message-generator.js.map +1 -1
  153. package/package.json +16 -16
  154. package/src/buffer/ascii/ascii-encoder.ts +7 -7
  155. package/src/buffer/ascii/ascii-parser-state.ts +4 -4
  156. package/src/buffer/ascii/ascii-parser.ts +6 -5
  157. package/src/buffer/ascii/ascii-segment-parser.ts +2 -2
  158. package/src/buffer/ascii/ascii-view.ts +9 -7
  159. package/src/buffer/encode-proxy.ts +9 -9
  160. package/src/buffer/fixml/fixml-encoder.ts +14 -10
  161. package/src/buffer/fixml/fixml-parser.ts +5 -5
  162. package/src/buffer/fixml/fixml-view.ts +5 -5
  163. package/src/buffer/msg-encoder.ts +3 -3
  164. package/src/buffer/msg-view.ts +18 -18
  165. package/src/buffer/segment/segment-description.ts +2 -2
  166. package/src/buffer/tag/tags.ts +4 -6
  167. package/src/collections/collection.ts +0 -1
  168. package/src/collections/index.ts +1 -1
  169. package/src/config/js-fix-config.ts +3 -2
  170. package/src/dictionary/compiler/compiler-type.ts +8 -2
  171. package/src/dictionary/compiler/enum-compiler.ts +2 -2
  172. package/src/dictionary/compiler/msg-compiler.ts +11 -12
  173. package/src/dictionary/contained/contained-component-field.ts +1 -1
  174. package/src/dictionary/contained/contained-field-set.ts +21 -176
  175. package/src/dictionary/contained/contained-group-field.ts +1 -1
  176. package/src/dictionary/contained/contained-set-builder.ts +164 -0
  177. package/src/dictionary/contained/contained-set.ts +83 -0
  178. package/src/dictionary/contained/contained-simple-field.ts +1 -1
  179. package/src/dictionary/contained/index.ts +4 -1
  180. package/src/dictionary/definition/category-simple-set.ts +1 -2
  181. package/src/dictionary/definition/component-field-definition.ts +1 -1
  182. package/src/dictionary/definition/fix-definitions.ts +28 -26
  183. package/src/dictionary/definition/group-field-definition.ts +1 -1
  184. package/src/dictionary/definition/message-definition.ts +6 -6
  185. package/src/dictionary/definition/simple-field-definition.ts +9 -10
  186. package/src/dictionary/parser/fix-repository/repository.ts +47 -40
  187. package/src/dictionary/parser/fixml/components-parser.ts +41 -38
  188. package/src/dictionary/parser/fixml/fields-parser.ts +3 -4
  189. package/src/dictionary/parser/fixml/include-graph.ts +13 -14
  190. package/src/dictionary/parser/quickfix/field-definition-parser.ts +5 -5
  191. package/src/dictionary/parser/quickfix/message-parser.ts +7 -5
  192. package/src/dictionary/parser/quickfix/node-parser.ts +13 -6
  193. package/src/dictionary/parser/quickfix/parse-context.ts +2 -2
  194. package/src/dictionary/parser/quickfix/parse-progress.ts +2 -3
  195. package/src/dictionary/parser/quickfix/quick-fix-xml-file-builder.ts +4 -5
  196. package/src/dictionary/parser/quickfix/quick-fix-xml-file-parser.ts +10 -12
  197. package/src/dictionary/parser/quickfix/quick-fix-xml-formatter.ts +1 -1
  198. package/src/dictionary/set-reduce.ts +3 -3
  199. package/src/index.ts +0 -1
  200. package/src/jsfix-cmd.ts +5 -6
  201. package/src/sample/tcp/recovering-skeleton/respawn-acceptor.ts +7 -8
  202. package/src/sample/tcp/trade-capture/trade-capture-client.ts +4 -5
  203. package/src/sample/tcp/trade-capture/trade-capture-server.ts +1 -1
  204. package/src/store/fix-msg-memory-store.ts +3 -4
  205. package/src/store/fix-msg-store-record.ts +1 -1
  206. package/src/transport/ascii/ascii-msg-transmitter.ts +6 -6
  207. package/src/transport/ascii/ascii-session.ts +6 -6
  208. package/src/transport/fixml/fixml-session.ts +3 -3
  209. package/src/transport/http/http-acceptor.ts +4 -5
  210. package/src/transport/http/http-json-sample-adapter.ts +3 -4
  211. package/src/transport/session/dynamic-session-manager.ts +16 -0
  212. package/src/transport/session/session-description.ts +10 -7
  213. package/src/util/json-helper.ts +3 -3
  214. package/src/util/message-generator.ts +4 -4
  215. package/dist/collections/dictionary.d.ts +0 -15
  216. package/dist/collections/dictionary.js +0 -57
  217. package/dist/collections/dictionary.js.map +0 -1
  218. package/dist/types/FIX.5.0SP2/quickfix/execution_acknowledgement.d.ts +0 -31
  219. package/dist/types/FIX.5.0SP2/quickfix/execution_acknowledgement.js +0 -3
  220. package/dist/types/FIX.5.0SP2/quickfix/execution_acknowledgement.js.map +0 -1
  221. package/dist/types/FIX.5.0SP2/quickfix/mass_quote_acknowledgement.d.ts +0 -26
  222. package/dist/types/FIX.5.0SP2/quickfix/mass_quote_acknowledgement.js +0 -3
  223. package/dist/types/FIX.5.0SP2/quickfix/mass_quote_acknowledgement.js.map +0 -1
  224. package/dist/types/FIX.5.0SP2/quickfix/set/hop_grp.d.ts +0 -5
  225. package/dist/types/FIX.5.0SP2/quickfix/set/hop_grp.js +0 -3
  226. package/dist/types/FIX.5.0SP2/quickfix/set/hop_grp.js.map +0 -1
  227. package/dist/types/FIX.5.0SP2/quickfix/set/msg_type_grp.d.ts +0 -8
  228. package/dist/types/FIX.5.0SP2/quickfix/set/msg_type_grp.js +0 -3
  229. package/dist/types/FIX.5.0SP2/quickfix/set/msg_type_grp.js.map +0 -1
  230. package/dist/types/FIX.5.0SP2/quickfix/set/not_affected_orders_grp.d.ts +0 -4
  231. package/dist/types/FIX.5.0SP2/quickfix/set/not_affected_orders_grp.js +0 -3
  232. package/dist/types/FIX.5.0SP2/quickfix/set/not_affected_orders_grp.js.map +0 -1
  233. package/dist/types/FIX.5.0SP2/quickfix/xm_lnon_fix.d.ts +0 -6
  234. package/dist/types/FIX.5.0SP2/quickfix/xm_lnon_fix.js.map +0 -1
  235. package/src/collections/dictionary.ts +0 -62
@@ -1,27 +1,23 @@
1
1
  import { INumericKeyed } from '../../collections/collection'
2
- import { Dictionary } from '../../collections'
3
- import { ContainedComponentField } from './contained-component-field'
4
2
  import { ContainedField } from './contained-field'
5
- import { ContainedGroupField } from './contained-group-field'
6
3
  import { ContainedSimpleField } from './contained-simple-field'
7
4
  import { ElasticBuffer } from '../../buffer/elastic-buffer'
8
- import { ContainedFieldType } from './contained-field-type'
9
- import { TagType } from '../../buffer/tag/tag-type'
10
5
  import { ContainedSetType } from '../contained-set-type'
6
+ import { IContainedSet } from './contained-set'
11
7
 
12
- export abstract class ContainedFieldSet {
8
+ export abstract class ContainedFieldSet implements IContainedSet {
13
9
  /**
14
10
  * index of name to any group that may be present within the field list
15
11
  */
16
- public readonly groups: Dictionary<ContainedGroupField> = new Dictionary<ContainedGroupField>()
12
+ public readonly groups: Map<string, IContainedSet> = new Map<string, IContainedSet>()
17
13
  /**
18
14
  * index of name to any component that may be present within the field list
19
15
  */
20
- public readonly components: Dictionary<ContainedComponentField> = new Dictionary<ContainedComponentField>()
16
+ public readonly components: Map<string, IContainedSet> = new Map<string, IContainedSet>()
21
17
  /**
22
18
  * index of name to any simple field that may be present within the field list
23
19
  */
24
- public readonly simple: Dictionary<ContainedSimpleField> = new Dictionary<ContainedSimpleField>()
20
+ public readonly simple: Map<string, ContainedSimpleField> = new Map<string, ContainedSimpleField>()
25
21
  /**
26
22
  * sequence of fields representing this type - can be simple, group or component
27
23
  */
@@ -57,11 +53,11 @@ export abstract class ContainedFieldSet {
57
53
  /**
58
54
  * only repository directly in this set indexed by name
59
55
  */
60
- public readonly localNameToField: Dictionary<ContainedField> = new Dictionary<ContainedField>()
56
+ public readonly localNameToField: Map<string, ContainedField> = new Map<string, ContainedField>()
61
57
  /**
62
58
  * for FixMl notation this set of fields appear as attributes i.e. <Pty ID="323" R="38">
63
59
  */
64
- public readonly nameToLocalAttribute: Dictionary<ContainedSimpleField> = new Dictionary<ContainedSimpleField>()
60
+ public readonly nameToLocalAttribute: Map<string, ContainedSimpleField> = new Map<string, ContainedSimpleField>()
65
61
  /**
66
62
  * all attributes in order of being declared
67
63
  */
@@ -114,187 +110,36 @@ export abstract class ContainedFieldSet {
114
110
 
115
111
  public abstract getPrefix (): string
116
112
 
113
+ public keys (): number[] {
114
+ const keys: string[] = Object.keys(this.containedTag)
115
+ const nums: number[] = new Array(keys.length)
116
+ for (let j: number = 0; j < keys.length; ++j) {
117
+ nums[j] = parseInt(keys[j], 10)
118
+ }
119
+ return nums
120
+ }
121
+
117
122
  public getFieldName (tag: number): string {
118
123
  const s = this.tagToSimple[tag]
119
124
  if (s == null) {
120
- const gf = this.tagToField[tag] as ContainedGroupField
125
+ const gf: ContainedField = this.tagToField[tag]
121
126
  if (gf !== null) {
122
- return `${gf.definition.name}`
127
+ return `${gf.name}`
123
128
  }
124
129
  return `${tag}`
125
130
  }
126
131
  return s.name
127
132
  }
128
133
 
129
- /**
130
- * adds a field to this set - simple, component or group
131
- * @param field
132
- */
133
- public add (field: ContainedField): void {
134
- this.fields.push(field)
135
- this.localNameToField.addUpdate(field.name, field)
136
- this.addUpdate(field)
137
- this.addContained(this, field)
138
- }
139
-
140
134
  /**
141
135
  * recurses down a path to return nested set definitiom of a group or component
142
136
  * given in dot notation 'SecListGrp.NoRelatedSym.SecurityTradingRules.BaseTradingRules'
143
137
  * @param path in dot notation
144
138
  */
145
- public getSet (path: string): (ContainedFieldSet | null) {
139
+ public getSet (path: string): (IContainedSet | null) {
146
140
  if (!path) return null
147
- return path.split('.').reduce((set: ContainedFieldSet, next: string): (ContainedFieldSet | null) => {
148
- return set.groups.get(next)?.definition ?? set.components.get(next)?.definition ?? null
141
+ return path.split('.').reduce((set: IContainedSet, next: string): (IContainedSet | null) => {
142
+ return set.groups.get(next) ?? set.components.get(next) ?? null
149
143
  }, this)
150
144
  }
151
-
152
- private addUpdate (field: ContainedField): void {
153
- switch (field.type) {
154
- case ContainedFieldType.Simple: {
155
- this.addLocalSimple(field as ContainedSimpleField)
156
- break
157
- }
158
-
159
- case ContainedFieldType.Component: {
160
- const cf = field as ContainedComponentField
161
- const definition = cf.definition
162
- if (definition.abbreviation && definition.abbreviation !== field.name) {
163
- this.localNameToField.addUpdate(definition.abbreviation, field)
164
- }
165
- break
166
- }
167
-
168
- case ContainedFieldType.Group: {
169
- const gf = field as ContainedComponentField
170
- const definition = gf.definition
171
- if (definition.abbreviation && definition.abbreviation !== field.name) {
172
- this.localNameToField.addUpdate(definition.abbreviation, field)
173
- }
174
- break
175
- }
176
-
177
- default:
178
- throw new Error(`unknown field type ${field.type}`)
179
- }
180
- }
181
-
182
- private addLocalSimple (field: ContainedSimpleField): void {
183
- const definition = field.definition
184
- if (definition.abbreviation && definition.abbreviation !== definition.name) {
185
- this.localNameToField.addUpdate(definition.abbreviation, field)
186
- }
187
- if (definition.baseCategoryAbbreviation && definition.baseCategory === this.category) {
188
- this.localNameToField.addUpdate(definition.baseCategoryAbbreviation, field)
189
- }
190
- if (field.attribute) {
191
- this.nameToLocalAttribute.addUpdate(definition.abbreviation, field)
192
- this.localAttribute.push(field)
193
- // an attribute for FixMl lives in attribute set not fields - in this case xml sub elements
194
- this.fields.pop()
195
- }
196
- const tag = definition.tag
197
- this.localTag[tag] = field
198
- if (field.required) {
199
- this.localRequired[tag] = field
200
- }
201
- }
202
-
203
- private addContained (parent: ContainedFieldSet, field: ContainedField): void {
204
- switch (field.type) {
205
- case ContainedFieldType.Group: {
206
- this.addGroupFieldDef(field as ContainedGroupField)
207
- break
208
- }
209
-
210
- case ContainedFieldType.Component: {
211
- this.addComponentFieldDef(field as ContainedComponentField)
212
- break
213
- }
214
-
215
- case ContainedFieldType.Simple: {
216
- this.addSimpleFieldDef(parent, field as ContainedSimpleField)
217
- break
218
- }
219
-
220
- default:
221
- throw new Error(`unknown field type ${field.type}`)
222
- }
223
- }
224
-
225
- private addAllFields (containedField: ContainedFieldSet): void {
226
- containedField.fields.forEach((f: ContainedField) => {
227
- this.addContained(containedField, f)
228
- })
229
- }
230
-
231
- private addGroupFieldDef (groupField: ContainedGroupField): void {
232
- if (this.groups.containsKey(groupField.name)) {
233
- return
234
- }
235
- const definition = groupField.definition
236
- this.groups.add(groupField.name, groupField)
237
- const nof = definition.noOfField
238
- if (nof) {
239
- const tag = nof.tag
240
- this.containedTag[tag] = true
241
- this.flattenedTag.push(tag)
242
- }
243
- this.addAllFields(definition)
244
- this.mapAllBelow(definition, groupField)
245
- }
246
-
247
- private addComponentFieldDef (componentField: ContainedComponentField): void {
248
- const components = this.components
249
- if (components.containsKey(componentField.name)) {
250
- return
251
- }
252
- const definition = componentField.definition
253
- components.add(componentField.name, componentField)
254
- this.addAllFields(definition)
255
- this.mapAllBelow(definition, componentField)
256
- }
257
-
258
- public keys (): number[] {
259
- const keys: string[] = Object.keys(this.containedTag)
260
- const nums: number[] = new Array(keys.length)
261
- for (let j: number = 0; j < keys.length; ++j) {
262
- nums[j] = parseInt(keys[j], 10)
263
- }
264
- return nums
265
- }
266
-
267
- private mapAllBelow (set: ContainedFieldSet, field: ContainedField): void {
268
- // point all tags in this component to this field.
269
- const tagsBelow: number[] = set.keys()
270
- for (const t of tagsBelow) {
271
- this.tagToField[t] = field
272
- }
273
- }
274
-
275
- private addSimpleFieldDef (parent: ContainedFieldSet, field: ContainedSimpleField): void {
276
- if (this.simple.containsKey(field.name)) {
277
- return
278
- }
279
- if (!this.firstSimple) {
280
- this.firstSimple = field
281
- }
282
- switch (field.definition.tagType) {
283
- case TagType.RawData: {
284
- const dataLengthField: ContainedSimpleField = parent.fields[field.position - 1] as ContainedSimpleField
285
- if (dataLengthField && dataLengthField.definition.tagType === TagType.Length) {
286
- this.containedLength[dataLengthField.definition.tag] = true
287
- this.containsRaw = true
288
- }
289
- break
290
- }
291
- default:
292
- break
293
- }
294
- const tag = field.definition.tag
295
- this.simple.add(field.name, field)
296
- this.containedTag[tag] = true
297
- this.flattenedTag.push(tag)
298
- this.tagToSimple[tag] = field
299
- }
300
145
  }
@@ -1,5 +1,5 @@
1
1
  import { ContainedField } from './contained-field'
2
- import { GroupFieldDefinition } from '../definition'
2
+ import { GroupFieldDefinition } from '../definition/group-field-definition'
3
3
  import { ContainedFieldType } from './contained-field-type'
4
4
 
5
5
  export class ContainedGroupField extends ContainedField {
@@ -0,0 +1,164 @@
1
+ import { ContainedFieldSet } from './contained-field-set'
2
+ import { ContainedField } from './contained-field'
3
+ import { ContainedFieldType } from './contained-field-type'
4
+ import { ContainedSimpleField } from './contained-simple-field'
5
+ import { ContainedComponentField } from './contained-component-field'
6
+ import { ContainedGroupField } from './contained-group-field'
7
+ import { TagType } from '../../buffer/tag/tag-type'
8
+ import { IContainedSet } from './contained-set'
9
+
10
+ export class ContainedSetBuilder {
11
+ public constructor (public set: IContainedSet) {
12
+ }
13
+
14
+ /**
15
+ * adds a field to this set - simple, component or group
16
+ * @param field
17
+ */
18
+ public add (field: ContainedField): void {
19
+ this.set.fields.push(field)
20
+ this.set.localNameToField.set(field.name, field)
21
+ this.addUpdate(field)
22
+ this.addContained(this.set, field)
23
+ }
24
+
25
+ private addUpdate (field: ContainedField): void {
26
+ switch (field.type) {
27
+ case ContainedFieldType.Simple: {
28
+ this.addLocalSimple(field as ContainedSimpleField)
29
+ break
30
+ }
31
+
32
+ case ContainedFieldType.Component: {
33
+ const cf = field as ContainedComponentField
34
+ const definition = cf.definition
35
+ if (definition.abbreviation && definition.abbreviation !== field.name) {
36
+ this.set.localNameToField.set(definition.abbreviation, field)
37
+ }
38
+ break
39
+ }
40
+
41
+ case ContainedFieldType.Group: {
42
+ const gf = field as ContainedComponentField
43
+ const definition = gf.definition
44
+ if (definition.abbreviation && definition.abbreviation !== field.name) {
45
+ this.set.localNameToField.set(definition.abbreviation, field)
46
+ }
47
+ break
48
+ }
49
+
50
+ default:
51
+ throw new Error(`unknown field type ${field.type}`)
52
+ }
53
+ }
54
+
55
+ private addLocalSimple (field: ContainedSimpleField): void {
56
+ const definition = field.definition
57
+ if (definition.abbreviation && definition.abbreviation !== definition.name) {
58
+ this.set.localNameToField.set(definition.abbreviation, field)
59
+ }
60
+ if (definition.baseCategoryAbbreviation && definition.baseCategory === this.set.category) {
61
+ this.set.localNameToField.set(definition.baseCategoryAbbreviation, field)
62
+ }
63
+ if (field.attribute) {
64
+ this.set.nameToLocalAttribute.set(definition.abbreviation, field)
65
+ this.set.localAttribute.push(field)
66
+ // an attribute for FixMl lives in attribute set not fields - in this case xml sub elements
67
+ this.set.fields.pop()
68
+ }
69
+ const tag = definition.tag
70
+ this.set.localTag[tag] = field
71
+ if (field.required) {
72
+ this.set.localRequired[tag] = field
73
+ }
74
+ }
75
+
76
+ private addContained (parent: IContainedSet, field: ContainedField): void {
77
+ switch (field.type) {
78
+ case ContainedFieldType.Group: {
79
+ this.addGroupFieldDef(field as ContainedGroupField)
80
+ break
81
+ }
82
+
83
+ case ContainedFieldType.Component: {
84
+ this.addComponentFieldDef(field as ContainedComponentField)
85
+ break
86
+ }
87
+
88
+ case ContainedFieldType.Simple: {
89
+ this.addSimpleFieldDef(parent, field as ContainedSimpleField)
90
+ break
91
+ }
92
+
93
+ default:
94
+ throw new Error(`unknown field type ${field.type}`)
95
+ }
96
+ }
97
+
98
+ private addGroupFieldDef (groupField: ContainedGroupField): void {
99
+ if (this.set.groups.has(groupField.name)) {
100
+ return
101
+ }
102
+ const definition = groupField.definition
103
+ this.set.groups.set(groupField.name, definition)
104
+ const nof = definition.noOfField
105
+ if (nof) {
106
+ const tag = nof.tag
107
+ this.set.containedTag[tag] = true
108
+ this.set.flattenedTag.push(tag)
109
+ }
110
+ this.addAllFields(definition)
111
+ this.mapAllBelow(definition, groupField)
112
+ }
113
+
114
+ private addComponentFieldDef (componentField: ContainedComponentField): void {
115
+ const components = this.set.components
116
+ if (components.has(componentField.name)) {
117
+ return
118
+ }
119
+ const definition = componentField.definition
120
+ components.set(componentField.name, definition)
121
+ this.addAllFields(definition)
122
+ this.mapAllBelow(definition, componentField)
123
+ }
124
+
125
+ private mapAllBelow (set: ContainedFieldSet, field: ContainedField): void {
126
+ // point all tags in this component to this field.
127
+ const tagsBelow: number[] = set.keys()
128
+ for (const t of tagsBelow) {
129
+ this.set.tagToField[t] = field
130
+ }
131
+ }
132
+
133
+ private addSimpleFieldDef (parent: IContainedSet, field: ContainedSimpleField): void {
134
+ if (this.set.simple.has(field.name)) {
135
+ return
136
+ }
137
+ if (!this.set.firstSimple) {
138
+ this.set.firstSimple = field
139
+ }
140
+ switch (field.definition.tagType) {
141
+ case TagType.RawData: {
142
+ const dataLengthField: ContainedSimpleField = parent.fields[field.position - 1] as ContainedSimpleField
143
+ if (dataLengthField && dataLengthField.definition.tagType === TagType.Length) {
144
+ this.set.containedLength[dataLengthField.definition.tag] = true
145
+ this.set.containsRaw = true
146
+ }
147
+ break
148
+ }
149
+ default:
150
+ break
151
+ }
152
+ const tag = field.definition.tag
153
+ this.set.simple.set(field.name, field)
154
+ this.set.containedTag[tag] = true
155
+ this.set.flattenedTag.push(tag)
156
+ this.set.tagToSimple[tag] = field
157
+ }
158
+
159
+ private addAllFields (containedField: ContainedFieldSet): void {
160
+ containedField.fields.forEach((f: ContainedField) => {
161
+ this.addContained(containedField, f)
162
+ })
163
+ }
164
+ }
@@ -0,0 +1,83 @@
1
+ import { ContainedSimpleField } from './contained-simple-field'
2
+ import { ContainedField } from './contained-field'
3
+ import { INumericKeyed } from '../../collections/collection'
4
+ import { ContainedSetType } from '../contained-set-type'
5
+
6
+ export interface IContainedSet {
7
+ /**
8
+ * index of name to any group that may be present within the field list
9
+ */
10
+ readonly groups: Map<string, IContainedSet>
11
+ /**
12
+ * index of name to any component that may be present within the field list
13
+ */
14
+ readonly components: Map<string, IContainedSet>
15
+ /**
16
+ * index of name to any simple field that may be present within the field list
17
+ */
18
+ readonly simple: Map<string, ContainedSimpleField>
19
+ /**
20
+ * sequence of fields representing this type - can be simple, group or component
21
+ */
22
+ readonly fields: ContainedField[]
23
+ /**
24
+ * any tag at any level i.e. does this set contain a tag
25
+ */
26
+ readonly containedTag: INumericKeyed<boolean>
27
+ /**
28
+ * any tag at any level ordered i.e. all tags flattened to list
29
+ */
30
+ readonly flattenedTag: number[]
31
+ /**
32
+ * any data tags contained length within this set.
33
+ */
34
+ readonly containedLength: INumericKeyed<boolean>
35
+ /**
36
+ * tags only in repository at this level, not from any at deeper levels
37
+ */
38
+ readonly localTag: INumericKeyed<ContainedSimpleField>
39
+ /**
40
+ * tags marked required at this level only
41
+ */
42
+ readonly localRequired: INumericKeyed<ContainedSimpleField>
43
+ /**
44
+ * all tags contained within this field set flattened from all levels
45
+ */
46
+ readonly tagToSimple: INumericKeyed<ContainedSimpleField>
47
+ /**
48
+ * direct any tag contained within this set to field one level down where it belongs.
49
+ */
50
+ readonly tagToField: INumericKeyed<ContainedField>
51
+ /**
52
+ * only repository directly in this set indexed by name
53
+ */
54
+ readonly localNameToField: Map<string, ContainedField>
55
+ /**
56
+ * for FixMl notation this set of fields appear as attributes i.e. <Pty ID="323" R="38">
57
+ */
58
+ readonly nameToLocalAttribute: Map<string, ContainedSimpleField>
59
+ /**
60
+ * all attributes in order of being declared
61
+ */
62
+ readonly localAttribute: ContainedSimpleField[]
63
+ readonly type: ContainedSetType
64
+ readonly name: string
65
+ readonly category: string | null
66
+ readonly abbreviation: string | null
67
+ readonly description: string | null
68
+ /**
69
+ * at any level on this set, first declared simple field
70
+ */
71
+ firstSimple: (ContainedSimpleField | null)
72
+ containsRaw: boolean
73
+
74
+ toString: () => string
75
+
76
+ getPrefix: () => string
77
+
78
+ getFieldName: (tag: number) => string
79
+
80
+ getSet: (path: string) => IContainedSet | null
81
+
82
+ keys: () => number[]
83
+ }
@@ -1,5 +1,5 @@
1
1
  import { ContainedField } from './contained-field'
2
- import { SimpleFieldDefinition } from '../definition'
2
+ import { SimpleFieldDefinition } from '../definition/simple-field-definition'
3
3
  import { ContainedFieldType } from './contained-field-type'
4
4
 
5
5
  export class ContainedSimpleField extends ContainedField {
@@ -2,7 +2,10 @@ export * from './contained-component-field'
2
2
  export * from './contained-field-type'
3
3
  export * from './contained-field'
4
4
  export * from './contained-field-dispatch'
5
- export * from './contained-field-set'
5
+ export * from './fields-dispatch'
6
+ export * from './contained-set'
7
+ export * from './contained-set-builder'
6
8
  export * from './contained-group-field'
7
9
  export * from './contained-simple-field'
8
10
  export * from './fields-dispatch'
11
+ export * from './contained-set-builder'
@@ -1,8 +1,7 @@
1
1
  import { SimpleFieldDefinition } from './simple-field-definition'
2
- import { Dictionary } from '../../collections'
3
2
 
4
3
  export class CategorySimpleSet {
5
- public readonly simple: Dictionary<SimpleFieldDefinition> = new Dictionary<SimpleFieldDefinition>()
4
+ public readonly simple: Map<string, SimpleFieldDefinition> = new Map<string, SimpleFieldDefinition>()
6
5
  constructor (public readonly category: string) {
7
6
  }
8
7
  }
@@ -1,4 +1,4 @@
1
- import { ContainedFieldSet } from '../contained'
1
+ import { ContainedFieldSet } from '../contained/contained-field-set'
2
2
  import { ContainedSetType } from '../contained-set-type'
3
3
 
4
4
  export class ComponentFieldDefinition extends ContainedFieldSet {