jspurefix 5.8.5 → 5.9.2
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/.gitattributes +4 -0
- package/BACKPORT_PLAN.md +84 -0
- package/DEMO_PORT_PLAN.md +10 -0
- package/README.md +3 -0
- package/WORKLOG.md +119 -0
- package/dist/benchmark/bench-report.d.ts +5 -0
- package/dist/benchmark/bench-report.js +91 -0
- package/dist/benchmark/bench-report.js.map +1 -0
- package/dist/benchmark/bench-runner.d.ts +12 -0
- package/dist/benchmark/bench-runner.js +193 -0
- package/dist/benchmark/bench-runner.js.map +1 -0
- package/dist/benchmark/bench-stats.d.ts +10 -0
- package/dist/benchmark/bench-stats.js +56 -0
- package/dist/benchmark/bench-stats.js.map +1 -0
- package/dist/benchmark/bench-types.d.ts +74 -0
- package/dist/benchmark/bench-types.js +3 -0
- package/dist/benchmark/bench-types.js.map +1 -0
- package/dist/benchmark/gc-probe.d.ts +18 -0
- package/dist/benchmark/gc-probe.js +103 -0
- package/dist/benchmark/gc-probe.js.map +1 -0
- package/dist/benchmark/index.d.ts +6 -0
- package/dist/benchmark/index.js +23 -0
- package/dist/benchmark/index.js.map +1 -0
- package/dist/benchmark/parse-bench.d.ts +28 -0
- package/dist/benchmark/parse-bench.js +85 -0
- package/dist/benchmark/parse-bench.js.map +1 -0
- package/dist/buffer/ascii/ascii-parser.d.ts +1 -0
- package/dist/buffer/ascii/ascii-parser.js +4 -1
- package/dist/buffer/ascii/ascii-parser.js.map +1 -1
- package/dist/buffer/ascii/ascii-segment-parser.js +3 -2
- package/dist/buffer/ascii/ascii-segment-parser.js.map +1 -1
- package/dist/buffer/ascii/tag-index.js.map +1 -1
- package/dist/buffer/msg-view.d.ts +1 -0
- package/dist/buffer/msg-view.js +25 -19
- package/dist/buffer/msg-view.js.map +1 -1
- package/dist/config/js-fix-config.d.ts +4 -0
- package/dist/config/js-fix-config.js.map +1 -1
- package/dist/dictionary/parser/quickfix/dictionary-validator.d.ts +1 -1
- package/dist/dictionary/parser/quickfix/dictionary-validator.js.map +1 -1
- package/dist/dictionary/parser/quickfix/quick-fix-graph-parser.d.ts +1 -1
- package/dist/dictionary/parser/quickfix/quick-fix-graph-parser.js +1 -2
- package/dist/dictionary/parser/quickfix/quick-fix-graph-parser.js.map +1 -1
- package/dist/dictionary/parser/quickfix/validation-error.d.ts +2 -2
- package/dist/dictionary/parser/quickfix/validation-error.js.map +1 -1
- package/dist/jsfix-bench.d.ts +1 -0
- package/dist/jsfix-bench.js +213 -0
- package/dist/jsfix-bench.js.map +1 -0
- package/dist/runtime/session-launcher.js +1 -1
- package/dist/runtime/session-launcher.js.map +1 -1
- package/dist/runtime/session-scope.d.ts +3 -0
- package/dist/runtime/session-scope.js +47 -0
- package/dist/runtime/session-scope.js.map +1 -0
- package/dist/sample/http/oms/app.js +3 -3
- package/dist/sample/http/oms/app.js.map +1 -1
- package/dist/sample/tcp/qf-md/app.js +3 -3
- package/dist/sample/tcp/qf-md/app.js.map +1 -1
- package/dist/sample/tcp/skeleton/app.js +1 -1
- package/dist/sample/tcp/skeleton/app.js.map +1 -1
- package/dist/sample/tcp/trade-capture/app-launcher.js +3 -3
- package/dist/sample/tcp/trade-capture/app-launcher.js.map +1 -1
- package/dist/store/file-session-store.js +1 -1
- package/dist/store/file-session-store.js.map +1 -1
- package/dist/store/file-session-stream-provider.d.ts +1 -0
- package/dist/store/file-session-stream-provider.js +13 -13
- package/dist/store/file-session-stream-provider.js.map +1 -1
- package/dist/store/fix-session-store-factory.d.ts +1 -1
- package/dist/store/fix-session-store-factory.js.map +1 -1
- package/dist/store/fix-session-store.d.ts +11 -11
- package/dist/store/fix-session-store.js.map +1 -1
- package/dist/store/memory-session-store.js.map +1 -1
- package/dist/store/session-stream-provider.d.ts +13 -13
- package/dist/store/session-stream-provider.js.map +1 -1
- package/dist/transport/ascii/ascii-session.d.ts +17 -3
- package/dist/transport/ascii/ascii-session.js +121 -8
- package/dist/transport/ascii/ascii-session.js.map +1 -1
- package/dist/transport/duplex/fix-duplex.d.ts +1 -0
- package/dist/transport/duplex/fix-duplex.js +3 -0
- package/dist/transport/duplex/fix-duplex.js.map +1 -1
- package/dist/transport/duplex/tcp-duplex.d.ts +1 -0
- package/dist/transport/duplex/tcp-duplex.js +5 -0
- package/dist/transport/duplex/tcp-duplex.js.map +1 -1
- package/dist/transport/factory/msg-transport.d.ts +2 -0
- package/dist/transport/factory/msg-transport.js +17 -2
- package/dist/transport/factory/msg-transport.js.map +1 -1
- package/dist/transport/session/a-session-msg-factory.d.ts +1 -0
- package/dist/transport/session/a-session-msg-factory.js +4 -0
- package/dist/transport/session/a-session-msg-factory.js.map +1 -1
- package/dist/transport/session/clone-session-description.d.ts +6 -0
- package/dist/transport/session/clone-session-description.js +11 -0
- package/dist/transport/session/clone-session-description.js.map +1 -0
- package/dist/transport/session/fix-clock.d.ts +1 -1
- package/dist/transport/session/fix-clock.js.map +1 -1
- package/dist/transport/session/fix-session.d.ts +5 -1
- package/dist/transport/session/fix-session.js +93 -24
- package/dist/transport/session/fix-session.js.map +1 -1
- package/dist/transport/session/index.d.ts +2 -0
- package/dist/transport/session/index.js +2 -0
- package/dist/transport/session/index.js.map +1 -1
- package/dist/transport/session/resend-request-manager.d.ts +2 -2
- package/dist/transport/session/resend-request-manager.js.map +1 -1
- package/dist/transport/session/session-msg-factory.d.ts +1 -0
- package/dist/transport/session/session-msg-factory.js.map +1 -1
- package/dist/transport/session/session-registry.d.ts +23 -0
- package/dist/transport/session/session-registry.js +59 -0
- package/dist/transport/session/session-registry.js.map +1 -0
- package/dist/transport/session/session-sequence-coordinator.d.ts +1 -1
- package/dist/transport/session/session-sequence-coordinator.js.map +1 -1
- package/dist/transport/session/session-sequence-store.d.ts +3 -3
- package/dist/transport/session/session-sequence-store.js.map +1 -1
- package/dist/transport/tcp/tcp-acceptor-listener.d.ts +3 -0
- package/dist/transport/tcp/tcp-acceptor-listener.js +26 -4
- package/dist/transport/tcp/tcp-acceptor-listener.js.map +1 -1
- package/dist/transport/tcp/tcp-acceptor.d.ts +5 -0
- package/dist/transport/tcp/tcp-acceptor.js +74 -20
- package/dist/transport/tcp/tcp-acceptor.js.map +1 -1
- package/dist/transport/tcp/tcp-initiator.js +15 -5
- package/dist/transport/tcp/tcp-initiator.js.map +1 -1
- package/dist/transport/tcp/tcp-transport-description.d.ts +1 -0
- package/dist/transport/tcp/tcp-transport-description.js.map +1 -1
- package/dist/transport/tcp/tls-diagnostics.d.ts +5 -0
- package/dist/transport/tcp/tls-diagnostics.js +64 -0
- package/dist/transport/tcp/tls-diagnostics.js.map +1 -0
- package/dist/transport/tcp/tls-options-factory.d.ts +1 -0
- package/dist/transport/tcp/tls-options-factory.js +24 -2
- package/dist/transport/tcp/tls-options-factory.js.map +1 -1
- package/docs/acceptor.md +207 -0
- package/docs/benchmarking.md +117 -0
- package/eslint.config.mjs +15 -1
- package/jsfix.test_client.txt +62 -75
- package/jsfix.test_server.txt +72 -72
- package/package.json +19 -10
- package/script/pack-local.js +68 -0
- package/src/benchmark/bench-report.ts +101 -0
- package/src/benchmark/bench-runner.ts +196 -0
- package/src/benchmark/bench-stats.ts +86 -0
- package/src/benchmark/bench-types.ts +110 -0
- package/src/benchmark/gc-probe.ts +145 -0
- package/src/benchmark/index.ts +6 -0
- package/src/benchmark/parse-bench.ts +144 -0
- package/src/buffer/ascii/ascii-parser.ts +16 -1
- package/src/buffer/ascii/ascii-segment-parser.ts +9 -6
- package/src/buffer/ascii/tag-index.ts +3 -3
- package/src/buffer/msg-view.ts +35 -18
- package/src/config/js-fix-config.ts +8 -0
- package/src/dictionary/parser/quickfix/dictionary-validator.ts +1 -1
- package/src/dictionary/parser/quickfix/quick-fix-graph-parser.ts +2 -3
- package/src/dictionary/parser/quickfix/validation-error.ts +1 -1
- package/src/jsfix-bench.ts +204 -0
- package/src/runtime/session-launcher.ts +5 -1
- package/src/runtime/session-scope.ts +84 -0
- package/src/sample/http/oms/app.ts +3 -3
- package/src/sample/tcp/qf-md/app.ts +3 -3
- package/src/sample/tcp/skeleton/app.ts +1 -1
- package/src/sample/tcp/trade-capture/app-launcher.ts +3 -3
- package/src/store/file-session-store.ts +2 -2
- package/src/store/file-session-stream-provider.ts +17 -11
- package/src/store/fix-session-store-factory.ts +1 -1
- package/src/store/fix-session-store.ts +11 -11
- package/src/store/memory-session-store.ts +1 -1
- package/src/store/session-stream-provider.ts +13 -13
- package/src/transport/ascii/ascii-session.ts +186 -11
- package/src/transport/duplex/fix-duplex.ts +9 -0
- package/src/transport/duplex/tcp-duplex.ts +10 -0
- package/src/transport/factory/msg-transport.ts +20 -0
- package/src/transport/session/a-session-msg-factory.ts +18 -0
- package/src/transport/session/clone-session-description.ts +41 -0
- package/src/transport/session/fix-clock.ts +1 -1
- package/src/transport/session/fix-session.ts +136 -25
- package/src/transport/session/index.ts +2 -0
- package/src/transport/session/resend-request-manager.ts +4 -4
- package/src/transport/session/session-msg-factory.ts +13 -0
- package/src/transport/session/session-registry.ts +112 -0
- package/src/transport/session/session-sequence-coordinator.ts +1 -1
- package/src/transport/session/session-sequence-store.ts +3 -3
- package/src/transport/tcp/tcp-acceptor-listener.ts +43 -5
- package/src/transport/tcp/tcp-acceptor.ts +92 -18
- package/src/transport/tcp/tcp-initiator.ts +26 -5
- package/src/transport/tcp/tcp-transport-description.ts +7 -0
- package/src/transport/tcp/tls-diagnostics.ts +76 -0
- package/src/transport/tcp/tls-options-factory.ts +34 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ascii-segment-parser.js","sourceRoot":"","sources":["../../../src/buffer/ascii/ascii-segment-parser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wEAAmE;AACnE,4CAAwC;AAExC,4DAGoC;AACpC,0DAKmC;AACnC,uCAA6C;AAC7C,uDAAkD;AAClD,0DAAqD;AACrD,6EAA+D;AAE/D,2CAAsC;AAM/B,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC7B,YAA2D,WAA2B;QAA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;IAD9B,IAAA,qBAAU,GAAE;IAEG,WAAA,IAAA,iBAAM,EAAC,oBAAQ,CAAC,WAAW,CAAC,CAAA;qCAA8B,2BAAc;GAD3E,kBAAkB,CAkM9B","sourcesContent":["import { SegmentDescription } from '../segment/segment-description'\nimport { Structure } from '../structure'\nimport { Tags } from '../tag/tags'\nimport {\n FixDefinitions,\n MessageDefinition\n} from '../../dictionary/definition'\nimport {\n ContainedComponentField,\n ContainedGroupField,\n ContainedSimpleField,\n ContainedFieldType\n} from '../../dictionary/contained'\nimport { inject, injectable } from 'tsyringe'\nimport { DITokens } from '../../runtime/di-tokens'\nimport { SegmentType } from '../segment/segment-type'\nimport { AsciiParserError } from './ascii-segment-parser-error'\nimport { AsciiSegmentParserSummary } from './ascii-segment-parser-summary'\nimport { TagIndex } from './tag-index'\n\n// this takes linear time i.e. it constantly makes forward progress\n// one tag at a time\n\n@injectable()\nexport class AsciiSegmentParser {\n constructor (@inject(DITokens.Definitions) public readonly definitions: FixDefinitions) {\n }\n\n public parse (msgType: string, tags: Tags, last: number): Structure | null {\n // completed segments in that they are fully parsed\n const segments: SegmentDescription[] = []\n const msgDefinition: MessageDefinition | undefined = this.definitions.message.get(msgType)\n if (!msgDefinition) {\n return null\n }\n // in process of being discovered and may have any amount of depth\n // i.e. a component containing a repeated group of components\n // with sub-groups of components\n const structureStack: SegmentDescription[] = []\n let currentTagPosition: number = 0\n let peek: SegmentDescription\n\n // track depth-1 components that have been exited for fragmentation detection\n const exitedDepth1Components: Set<string> = new Set()\n const fragmentedComponents: Set<string> = new Set()\n\n // having finished one segments keep unwinding until tag matches further up stack\n function unwind (tag: number): void {\n while (structureStack.length > 1) {\n const done = structureStack.pop()\n if (!done) continue\n done.end(segments.length, currentTagPosition - 1, tags.tagPos[currentTagPosition - 1].tag)\n segments.push(done)\n\n // track when we exit depth-1 components for fragmentation detection\n if (done.depth === 1 && done.name) {\n exitedDepth1Components.add(done.name)\n }\n\n peek = structureStack[structureStack.length - 1]\n if (peek.set?.containedTag[tag]) {\n // unwound to point this tag lives in this set.\n break\n }\n if (peek.type === SegmentType.Msg) {\n // this is unknown tag and it is not part of trailer so raise unknown\n break\n }\n }\n }\n\n function summarise (): AsciiSegmentParserSummary {\n return <AsciiSegmentParserSummary>{\n msgType,\n tags: tags.clone().tagPos,\n last,\n msgDefinition: msgDefinition?.toString(),\n currentTagPosition,\n peek: peek.toString(),\n segments: segments.map(s => s.toString()),\n structureStack: structureStack.map(s => s.toString())\n }\n }\n\n function examine (tag: number): SegmentDescription | null {\n let structure: SegmentDescription | null = null\n const currentField = peek.currentField\n if (!currentField) return null\n switch (currentField.type) {\n case ContainedFieldType.Simple: {\n const sf: ContainedSimpleField = currentField as ContainedSimpleField\n if (sf.definition.tag === tag) {\n currentTagPosition = currentTagPosition + 1\n }\n break\n }\n // moving deeper into structure, start a new context\n case ContainedFieldType.Component: {\n const cf: ContainedComponentField = currentField as ContainedComponentField\n // detect fragmentation: re-entering a depth-1 component we already exited\n if (structureStack.length === 1 && exitedDepth1Components.has(cf.name)) {\n fragmentedComponents.add(cf.name)\n }\n structure = new SegmentDescription(cf.name, tag, cf.definition,\n currentTagPosition, structureStack.length, SegmentType.Component)\n break\n }\n // for a group also need to know where all delimiters are positioned\n case ContainedFieldType.Group: {\n const gf: ContainedComponentField = currentField as ContainedGroupField\n structure = new SegmentDescription(gf.name, tag, gf.definition,\n currentTagPosition, structureStack.length, SegmentType.Group)\n currentTagPosition = currentTagPosition + 1\n structure.startGroup(tags.tagPos[currentTagPosition].tag)\n break\n }\n\n default: {\n const c = summarise()\n throw new AsciiParserError(`examine unknown type for tag = ${tag}`, c)\n }\n }\n return structure\n }\n\n function groupDelimiter (tag: number): boolean {\n let delimiter: boolean = false\n if (tag === peek.delimiterTag) {\n peek.addDelimiterPosition(currentTagPosition)\n } else if (structureStack.length > 1) {\n // if a group is represented by a repeated component, then the tag representing delimiter\n // needs to be added further up stack to group itself.\n delimiter = structureStack[structureStack.length - 2].groupAddDelimiter(tag, currentTagPosition)\n }\n return delimiter\n }\n\n function gap (tag: number): void {\n const gap = new SegmentDescription('.undefined', tag, peek.set,\n currentTagPosition, structureStack.length, SegmentType.Gap)\n gap.end(segments.length, currentTagPosition, tag)\n segments.push(gap)\n currentTagPosition++\n }\n\n function discover (): void {\n while (currentTagPosition <= last) {\n const tag: number = tags.tagPos[currentTagPosition].tag\n peek = structureStack[structureStack.length - 1]\n peek.setCurrentField(tag)\n if (!peek.set?.containedTag[tag] || groupDelimiter(tag)) {\n // unravelled all way back to root hence this is not recognised\n const unknown = peek.type === SegmentType.Msg\n if (unknown) {\n gap(tag)\n } else if (structureStack.length > 1) {\n // move back up the segments and save the finished group / component\n unwind(tag)\n }\n continue\n }\n if (!peek.currentField || !peek.set) {\n throw new AsciiParserError(`discover no currentField or set for tag = ${tag}`, summarise())\n }\n const structure = examine(tag)\n if (structure) {\n structureStack.push(structure)\n }\n }\n }\n\n function clean (): void {\n // any remainder components can be closed.\n while (structureStack.length > 0) {\n const done = structureStack.pop()\n if (!done) continue\n done.end(segments.length, currentTagPosition - 1, tags.tagPos[currentTagPosition - 1].tag)\n segments[segments.length] = done\n }\n // logically reverse the trailer and message so trailer is last in list.\n const m1 = segments.length - 1\n const m2 = segments.length - 2\n const tmp = segments[m1]\n segments[m1] = segments[m2]\n segments[m2] = tmp\n }\n\n function fragments (): void {\n // only build SegmentViews for components detected as fragmented during discover\n // non-fragmented components use their position ranges directly (zero overhead)\n if (fragmentedComponents.size === 0) return\n const ti = new TagIndex(msgDefinition!, tags, last + 1)\n const seen: Set<string> = new Set()\n for (let i = 1; i < segments.length - 1; i++) {\n const seg = segments[i]\n if (seg.depth !== 1) continue\n if (!seg.name) continue\n if (seg.segmentView) continue\n if (seen.has(seg.name)) continue\n if (!fragmentedComponents.has(seg.name)) continue\n if (ti.isComponentGroupWrapper(seg.name)) continue\n const v = ti.getInstance(seg.name)\n if (!v) continue\n seen.add(seg.name)\n seg.addSegmentView(v)\n }\n }\n\n const msgStructure = new SegmentDescription(msgDefinition.name, tags.tagPos[0].tag, msgDefinition,\n currentTagPosition, structureStack.length, SegmentType.Msg)\n structureStack.push(msgStructure)\n discover()\n clean()\n fragments()\n\n // now know where all components and groups are positioned within message\n return new Structure(tags, segments)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ascii-segment-parser.js","sourceRoot":"","sources":["../../../src/buffer/ascii/ascii-segment-parser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wEAAmE;AACnE,4CAAwC;AAExC,4DAGoC;AACpC,0DAKmC;AACnC,uCAA6C;AAC7C,uDAAkD;AAClD,0DAAqD;AACrD,6EAA+D;AAE/D,2CAAsC;AAM/B,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC7B,YAA2D,WAA2B;QAA3B,gBAAW,GAAX,WAAW,CAAgB;IACtF,CAAC;IAEM,KAAK,CAAE,OAAe,EAAE,IAAU,EAAE,IAAY;QAErD,MAAM,QAAQ,GAAyB,EAAE,CAAA;QACzC,MAAM,QAAQ,GAAkC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;QACrF,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,IAAI,CAAA;QACb,CAAC;QAGD,MAAM,aAAa,GAAsB,QAAQ,CAAA;QAIjD,MAAM,cAAc,GAAyB,EAAE,CAAA;QAC/C,IAAI,kBAAkB,GAAW,CAAC,CAAA;QAClC,IAAI,IAAwB,CAAA;QAG5B,MAAM,sBAAsB,GAAG,IAAI,GAAG,EAAU,CAAA;QAChD,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAU,CAAA;QAG9C,SAAS,MAAM,CAAE,GAAW;;YAC1B,OAAO,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACjC,MAAM,IAAI,GAAG,cAAc,CAAC,GAAG,EAAE,CAAA;gBACjC,IAAI,CAAC,IAAI;oBAAE,SAAQ;gBACnB,IAAI,CAAC,GAAG,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CAAC,CAAA;gBAClB,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,CAAA;YACvB,CAAC;QACH,CAAC;QAED,MAAM,YAAY,GAAG,IAAI,wCAAkB,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,aAAa,EAC/F,kBAAkB,EAAE,cAAc,CAAC,MAAM,EAAE,0BAAW,CAAC,GAAG,CAAC,CAAA;QAC7D,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;QACjC,QAAQ,EAAE,CAAA;QACV,KAAK,EAAE,CAAA;QACP,SAAS,EAAE,CAAA;QAGX,OAAO,IAAI,qBAAS,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;IACtC,CAAC;CACF,CAAA;AArMY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,qBAAU,GAAE;IAEG,WAAA,IAAA,iBAAM,EAAC,oBAAQ,CAAC,WAAW,CAAC,CAAA;qCAA8B,2BAAc;GAD3E,kBAAkB,CAqM9B","sourcesContent":["import { SegmentDescription } from '../segment/segment-description'\nimport { Structure } from '../structure'\nimport { Tags } from '../tag/tags'\nimport {\n FixDefinitions,\n MessageDefinition\n} from '../../dictionary/definition'\nimport {\n ContainedComponentField,\n ContainedGroupField,\n ContainedSimpleField,\n ContainedFieldType\n} from '../../dictionary/contained'\nimport { inject, injectable } from 'tsyringe'\nimport { DITokens } from '../../runtime/di-tokens'\nimport { SegmentType } from '../segment/segment-type'\nimport { AsciiParserError } from './ascii-segment-parser-error'\nimport { AsciiSegmentParserSummary } from './ascii-segment-parser-summary'\nimport { TagIndex } from './tag-index'\n\n// this takes linear time i.e. it constantly makes forward progress\n// one tag at a time\n\n@injectable()\nexport class AsciiSegmentParser {\n constructor (@inject(DITokens.Definitions) public readonly definitions: FixDefinitions) {\n }\n\n public parse (msgType: string, tags: Tags, last: number): Structure | null {\n // completed segments in that they are fully parsed\n const segments: SegmentDescription[] = []\n const resolved: MessageDefinition | undefined = this.definitions.message.get(msgType)\n if (!resolved) {\n return null\n }\n // narrowing of resolved is not visible inside the hoisted helpers below, so\n // carry the definition on a const the compiler already sees as non-optional\n const msgDefinition: MessageDefinition = resolved\n // in process of being discovered and may have any amount of depth\n // i.e. a component containing a repeated group of components\n // with sub-groups of components\n const structureStack: SegmentDescription[] = []\n let currentTagPosition: number = 0\n let peek: SegmentDescription\n\n // track depth-1 components that have been exited for fragmentation detection\n const exitedDepth1Components = new Set<string>()\n const fragmentedComponents = new Set<string>()\n\n // having finished one segments keep unwinding until tag matches further up stack\n function unwind (tag: number): void {\n while (structureStack.length > 1) {\n const done = structureStack.pop()\n if (!done) continue\n done.end(segments.length, currentTagPosition - 1, tags.tagPos[currentTagPosition - 1].tag)\n segments.push(done)\n\n // track when we exit depth-1 components for fragmentation detection\n if (done.depth === 1 && done.name) {\n exitedDepth1Components.add(done.name)\n }\n\n peek = structureStack[structureStack.length - 1]\n if (peek.set?.containedTag[tag]) {\n // unwound to point this tag lives in this set.\n break\n }\n if (peek.type === SegmentType.Msg) {\n // this is unknown tag and it is not part of trailer so raise unknown\n break\n }\n }\n }\n\n function summarise (): AsciiSegmentParserSummary {\n return <AsciiSegmentParserSummary>{\n msgType,\n tags: tags.clone().tagPos,\n last,\n msgDefinition: msgDefinition?.toString(),\n currentTagPosition,\n peek: peek.toString(),\n segments: segments.map(s => s.toString()),\n structureStack: structureStack.map(s => s.toString())\n }\n }\n\n function examine (tag: number): SegmentDescription | null {\n let structure: SegmentDescription | null = null\n const currentField = peek.currentField\n if (!currentField) return null\n switch (currentField.type) {\n case ContainedFieldType.Simple: {\n const sf: ContainedSimpleField = currentField as ContainedSimpleField\n if (sf.definition.tag === tag) {\n currentTagPosition = currentTagPosition + 1\n }\n break\n }\n // moving deeper into structure, start a new context\n case ContainedFieldType.Component: {\n const cf: ContainedComponentField = currentField as ContainedComponentField\n // detect fragmentation: re-entering a depth-1 component we already exited\n if (structureStack.length === 1 && exitedDepth1Components.has(cf.name)) {\n fragmentedComponents.add(cf.name)\n }\n structure = new SegmentDescription(cf.name, tag, cf.definition,\n currentTagPosition, structureStack.length, SegmentType.Component)\n break\n }\n // for a group also need to know where all delimiters are positioned\n case ContainedFieldType.Group: {\n const gf: ContainedComponentField = currentField as ContainedGroupField\n structure = new SegmentDescription(gf.name, tag, gf.definition,\n currentTagPosition, structureStack.length, SegmentType.Group)\n currentTagPosition = currentTagPosition + 1\n structure.startGroup(tags.tagPos[currentTagPosition].tag)\n break\n }\n\n default: {\n const c = summarise()\n throw new AsciiParserError(`examine unknown type for tag = ${tag}`, c)\n }\n }\n return structure\n }\n\n function groupDelimiter (tag: number): boolean {\n let delimiter: boolean = false\n if (tag === peek.delimiterTag) {\n peek.addDelimiterPosition(currentTagPosition)\n } else if (structureStack.length > 1) {\n // if a group is represented by a repeated component, then the tag representing delimiter\n // needs to be added further up stack to group itself.\n delimiter = structureStack[structureStack.length - 2].groupAddDelimiter(tag, currentTagPosition)\n }\n return delimiter\n }\n\n function gap (tag: number): void {\n const gap = new SegmentDescription('.undefined', tag, peek.set,\n currentTagPosition, structureStack.length, SegmentType.Gap)\n gap.end(segments.length, currentTagPosition, tag)\n segments.push(gap)\n currentTagPosition++\n }\n\n function discover (): void {\n while (currentTagPosition <= last) {\n const tag: number = tags.tagPos[currentTagPosition].tag\n peek = structureStack[structureStack.length - 1]\n peek.setCurrentField(tag)\n if (!peek.set?.containedTag[tag] || groupDelimiter(tag)) {\n // unravelled all way back to root hence this is not recognised\n const unknown = peek.type === SegmentType.Msg\n if (unknown) {\n gap(tag)\n } else if (structureStack.length > 1) {\n // move back up the segments and save the finished group / component\n unwind(tag)\n }\n continue\n }\n if (!peek.currentField || !peek.set) {\n throw new AsciiParserError(`discover no currentField or set for tag = ${tag}`, summarise())\n }\n const structure = examine(tag)\n if (structure) {\n structureStack.push(structure)\n }\n }\n }\n\n function clean (): void {\n // any remainder components can be closed.\n while (structureStack.length > 0) {\n const done = structureStack.pop()\n if (!done) continue\n done.end(segments.length, currentTagPosition - 1, tags.tagPos[currentTagPosition - 1].tag)\n segments[segments.length] = done\n }\n // logically reverse the trailer and message so trailer is last in list.\n const m1 = segments.length - 1\n const m2 = segments.length - 2\n const tmp = segments[m1]\n segments[m1] = segments[m2]\n segments[m2] = tmp\n }\n\n function fragments (): void {\n // only build SegmentViews for components detected as fragmented during discover\n // non-fragmented components use their position ranges directly (zero overhead)\n if (fragmentedComponents.size === 0) return\n const ti = new TagIndex(msgDefinition, tags, last + 1)\n const seen = new Set<string>()\n for (let i = 1; i < segments.length - 1; i++) {\n const seg = segments[i]\n if (seg.depth !== 1) continue\n if (!seg.name) continue\n if (seg.segmentView) continue\n if (seen.has(seg.name)) continue\n if (!fragmentedComponents.has(seg.name)) continue\n if (ti.isComponentGroupWrapper(seg.name)) continue\n const v = ti.getInstance(seg.name)\n if (!v) continue\n seen.add(seg.name)\n seg.addSegmentView(v)\n }\n }\n\n const msgStructure = new SegmentDescription(msgDefinition.name, tags.tagPos[0].tag, msgDefinition,\n currentTagPosition, structureStack.length, SegmentType.Msg)\n structureStack.push(msgStructure)\n discover()\n clean()\n fragments()\n\n // now know where all components and groups are positioned within message\n return new Structure(tags, segments)\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag-index.js","sourceRoot":"","sources":["../../../src/buffer/ascii/tag-index.ts"],"names":[],"mappings":";;;AACA,0DAAqD;AACrD,4CAAuC;AAQvC,MAAa,QAAQ;IAMnB,YACkB,GAAkB,EAClC,IAAU,EACV,KAAa;QAFG,QAAG,GAAH,GAAG,CAAe;QALnB,aAAQ,
|
|
1
|
+
{"version":3,"file":"tag-index.js","sourceRoot":"","sources":["../../../src/buffer/ascii/tag-index.ts"],"names":[],"mappings":";;;AACA,0DAAqD;AACrD,4CAAuC;AAQvC,MAAa,QAAQ;IAMnB,YACkB,GAAkB,EAClC,IAAU,EACV,KAAa;QAFG,QAAG,GAAH,GAAG,CAAe;QALnB,aAAQ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,IAAI,CAAC,CAAA;YAC1B,OAAO,IAAI,CAAA;QACb,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,0BAAW,CAAC,IAAI,EAAE,YAAY,CAAC,CAAA;QAChD,MAAM,QAAQ,GAAG,YAAY,CAAC,YAAY,CAAA;QAC1C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACzC,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;YACrB,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;YACjC,IAAI,CAAC,IAAI;gBAAE,SAAQ;YACnB,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,GAAG,EAAE,CAAC;gBAC5B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;YACzC,CAAC;iBAAM,CAAC;gBACN,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;oBAC5C,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;gBAChC,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QAC1B,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,uBAAuB,CAAE,IAAY;QAC1C,OAAO,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAC9C,CAAC;CACF;AA1FD,4BA0FC","sourcesContent":["import { IContainedSet } from '../../dictionary/contained'\nimport { SegmentView } from '../segment/segment-view'\nimport { TagPos } from '../tag/tag-pos'\nimport { Tags } from '../tag/tags'\n\nexport interface TagSpan {\n start: number\n end: number\n}\n\nexport class TagIndex {\n private readonly sortedTagPos: TagPos[]\n private readonly tagSpans = new Map<number, TagSpan>()\n private readonly componentGroupWrappers = new Set<string>()\n private readonly cache = new Map<string, SegmentView | null>()\n\n constructor (\n public readonly set: IContainedSet,\n tags: Tags,\n count: number) {\n this.sortedTagPos = new Array(count)\n for (let i = 0; i < count; i++) {\n this.sortedTagPos[i] = tags.tagPos[i]\n }\n this.sortedTagPos.sort(TagPos.compare)\n this.populateTagSpans()\n this.calcGroups(tags, count)\n }\n\n private populateTagSpans (): void {\n for (let i = 0; i < this.sortedTagPos.length; i++) {\n const t = this.sortedTagPos[i]\n const existing = this.tagSpans.get(t.tag)\n if (existing) {\n existing.end = i\n } else {\n this.tagSpans.set(t.tag, { start: i, end: i })\n }\n }\n }\n\n private calcGroups (tags: Tags, count: number): void {\n for (let i = 0; i < count; i++) {\n const tag = tags.tagPos[i]\n const field = this.set.tagToField[tag.tag]\n if (!field) continue\n // detect component group wrappers (single-field components containing a group)\n const component = this.findParentComponent(tag.tag)\n if (component) {\n const componentSet = this.set.components.get(component)\n if (componentSet && componentSet.fields.length === 1) {\n this.componentGroupWrappers.add(component)\n }\n }\n }\n }\n\n private findParentComponent (tag: number): string | null {\n for (const [name, componentSet] of this.set.components) {\n if (componentSet.containedTag[tag]) {\n return name\n }\n }\n return null\n }\n\n public getInstance (name: string): SegmentView | null {\n const cached = this.cache.get(name)\n if (cached !== undefined) {\n return cached\n }\n\n const componentSet = this.set.components.get(name)\n if (!componentSet) {\n this.cache.set(name, null)\n return null\n }\n\n const view = new SegmentView(name, componentSet)\n const flatTags = componentSet.flattenedTag\n for (let x = 0; x < flatTags.length; x++) {\n const t = flatTags[x]\n const span = this.tagSpans.get(t)\n if (!span) continue\n if (span.start === span.end) {\n view.add(this.sortedTagPos[span.start])\n } else {\n for (let j = span.start; j <= span.end; j++) {\n view.add(this.sortedTagPos[j])\n }\n }\n }\n\n this.cache.set(name, view)\n return view\n }\n\n public isComponentGroupWrapper (name: string): boolean {\n return this.componentGroupWrappers.has(name)\n }\n}\n"]}
|
|
@@ -30,6 +30,7 @@ export declare abstract class MsgView {
|
|
|
30
30
|
toVerbose(): string;
|
|
31
31
|
toJson(): string;
|
|
32
32
|
getView(name: string): MsgView | null;
|
|
33
|
+
private resolveChild;
|
|
33
34
|
abstract checksum(): number;
|
|
34
35
|
abstract clone(): MsgView;
|
|
35
36
|
protected abstract create(singleton: SegmentDescription): MsgView;
|
package/dist/buffer/msg-view.js
CHANGED
|
@@ -150,27 +150,33 @@ class MsgView {
|
|
|
150
150
|
return JSON.stringify(this.toObject(), null, 4);
|
|
151
151
|
}
|
|
152
152
|
getView(name) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
153
|
+
if (!name.includes('.')) {
|
|
154
|
+
return this.resolveChild(name);
|
|
155
|
+
}
|
|
156
|
+
let view = this;
|
|
157
|
+
for (const part of name.split('.')) {
|
|
158
|
+
view = view.resolveChild(part);
|
|
159
|
+
if (!view) {
|
|
160
|
+
return null;
|
|
158
161
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
162
|
+
}
|
|
163
|
+
return view;
|
|
164
|
+
}
|
|
165
|
+
resolveChild(name) {
|
|
166
|
+
var _a, _b, _c, _d;
|
|
167
|
+
const structure = this.structure;
|
|
168
|
+
const singleton = (_a = structure === null || structure === void 0 ? void 0 : structure.firstContainedWithin(name, this.segment)) !== null && _a !== void 0 ? _a : null;
|
|
169
|
+
if (singleton) {
|
|
170
|
+
return this.create(singleton);
|
|
171
|
+
}
|
|
172
|
+
const component = (_c = (_b = this.segment.set) === null || _b === void 0 ? void 0 : _b.localNameToField.get(name)) !== null && _c !== void 0 ? _c : null;
|
|
173
|
+
if (component) {
|
|
174
|
+
const abbreviated = (_d = structure === null || structure === void 0 ? void 0 : structure.firstContainedWithin(component.name, this.segment)) !== null && _d !== void 0 ? _d : null;
|
|
175
|
+
if (abbreviated) {
|
|
176
|
+
return this.create(abbreviated);
|
|
170
177
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
return parts.reduce(reducer, this);
|
|
178
|
+
}
|
|
179
|
+
return null;
|
|
174
180
|
}
|
|
175
181
|
resolveTag(tagOrName) {
|
|
176
182
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"msg-view.js","sourceRoot":"","sources":["../../src/buffer/msg-view.ts"],"names":[],"mappings":";;;AAAA,2CAAsC;AAWtC,8CAAyC;AAEzC,qDAAgD;AAGhD,yEAAmE;AAEnE,MAAsB,OAAO;IAK3B,YAAuC,WAA2B,EAAkB,OAA2B,EAAkB,SAA2B;QAArH,gBAAW,GAAX,WAAW,CAAgB;QAAkB,YAAO,GAAP,OAAO,CAAoB;QAAkB,cAAS,GAAT,SAAS,CAAkB;QAF3I,YAAO,GAA4B,IAAI,sBAAS,EAAgB,CAAA;IAGjF,CAAC;IA+CM,OAAO;;QACZ,MAAM,WAAW,GAAa,EAAE,CAAA;QAChC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAA;QAC5B,IAAI,GAAG,IAAI,IAAI;YAAE,OAAO,EAAE,CAAA;QAC1B,MAAM,IAAI,GAAG,MAAA,MAAA,IAAI,CAAC,SAAS,0CAAE,IAAI,mCAAI,IAAI,CAAA;QACzC,IAAI,IAAI,IAAI,IAAI;YAAE,OAAO,EAAE,CAAA;QAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC;YACzC,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;YAC9B,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,C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K,IAAI,OAAO,IAAI,EAAE,CAAA;AAC/C,CAAC,AAhByB,CAgBzB;AAEgB,eAAO,GAAG,CAAC,KAA4B,EAAE,GAAW,EAAE,CAAS,EAAE,KAAa,EAAE,EAAU,EAAU,EAAE;IACrH,MAAM,OAAO,GAAW,CAAC,CAAA;IACzB,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAA;IAEjC,IAAI,IAAY,CAAA;IAChB,IAAI,IAAY,CAAA;IAChB,IAAI,KAAK,EAAE,CAAC;QACV,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,SAAS,CAAA;QAC9B,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;YACnB,IAAI,GAAG,GAAG,GAAG,IAAI,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAA;QAC5C,CAAC;aAAM,CAAC;YACN,IAAI,GAAG,GAAG,GAAG,EAAE,CAAA;QACjB,CAAC;IACH,CAAC;SAAM,CAAC;QACN,IAAI,GAAG,GAAG,GAAG,EAAE,CAAA;QACf,IAAI,GAAG,SAAS,CAAA;IAClB,CAAC;IACD,IAAI,SAAiB,CAAA;IACrB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACpD,SAAS,GAAG,OAAO,CAAA;IACrB,CAAC;SAAM,CAAC;QACN,SAAS,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAA;IACnC,CAAC;IACD,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,KAAK,IAAI,OAAO,IAAI,GAAG,SAAS,EAAE,CAAA;AAC3D,CAAC,AAxBuB,CAwBvB","sourcesContent":["import { TagPos } from './tag/tag-pos'\nimport { SegmentDescription } from './segment/segment-description'\nimport { Structure } from './structure'\nimport { Tags } from './tag/tags'\nimport {\n ContainedComponentField,\n ContainedField,\n IContainedSet,\n ContainedGroupField,\n ContainedSimpleField\n} from '../dictionary/contained'\nimport { SetReduce } from '../dictionary'\nimport { ILooseObject } from '../collections/collection'\nimport { ElasticBuffer } from './elastic-buffer'\nimport { FixDefinitions, GroupFieldDefinition, SimpleFieldDefinition } from '../dictionary/definition'\nimport { ITypeDispatcher } from '../dictionary/type-dispatcher'\nimport { ContainedSetType } from '../dictionary/contained-set-type'\n\nexport abstract class MsgView {\n protected sortedTagPosForwards: TagPos[]\n protected sortedTagPosBackwards: TagPos[]\n private readonly reducer: SetReduce<ILooseObject> = new SetReduce<ILooseObject>()\n\n protected constructor (public readonly definitions: FixDefinitions, public readonly segment: SegmentDescription, public readonly structure: Structure | null) {\n }\n\n protected static asVerbose = (field: SimpleFieldDefinition, val: string, i: number, count: number, tp: TagPos): string => {\n const newLine = require('os').EOL\n let desc: string\n let name: string\n if (field) {\n name = field.name || 'unknown'\n if (field.isEnum()) {\n desc = `${val}[${field.resolveEnum(val)}]${newLine}\\t${field.description ?? ''}${newLine}${newLine}`\n } else {\n desc = `${val}${newLine}t${field.description ?? ''}${newLine}${newLine}`\n }\n } else {\n name = 'unknown'\n desc = 'na'\n }\n return `[${i}] ${tp.tag} (${name}) = ${desc}`\n }\n\n protected static asToken = (field: SimpleFieldDefinition, val: string, i: number, count: number, tp: TagPos): string => {\n const perLine: number = 2\n const newLine = require('os').EOL\n // [280] 814 (ApplQueueResolution) = 2[OverlayLast][281] 10 (CheckSum) = 80\n let desc: string\n let name: string\n if (field) {\n name = field.name || 'unknown'\n if (field.isEnum()) {\n desc = `${val}[${field.resolveEnum(val)}]`\n } else {\n desc = `${val}`\n }\n } else {\n desc = `${val}`\n name = 'unknown'\n }\n let delimiter: string\n if (i === 1 || (i < count && i % perLine - 1 === 0)) {\n delimiter = newLine\n } else {\n delimiter = i < count ? ', ' : ''\n }\n return `[${i}] ${tp.tag} (${name}) = ${desc}${delimiter}`\n }\n\n // return list of any tags parsed that are not valid\n public invalid (): number[] {\n const invalidTags: number[] = []\n const set = this.segment.set\n if (set == null) return []\n const tags = this.structure?.tags ?? null\n if (tags == null) return []\n for (let i = 0; i < tags.nextTagPos; ++i) {\n const tag = tags.tagPos[i].tag\n if (tag <= 0 || !set.containedTag[tag]) {\n invalidTags[invalidTags.length] = tag\n }\n }\n return invalidTags\n }\n\n // list of tags that must be present\n public missing (): number[] {\n if (this.segment == null) return []\n if (this.segment.set == null) return []\n return this.missingRequired(this.segment.set, [])\n }\n\n /**\n * does this view contain this tag\n * @param tagOrName the name or tag of field to check 8 or BeginString\n */\n public contains (tagOrName: number | string): boolean {\n const tag: number = this.resolveTag(tagOrName)\n const position: number = this.getPosition(tag)\n return position >= 0\n }\n\n /**\n * if this view represents a repeated group then return a sub view representing\n * this instance of repeated group.\n * @param i the index to return i.e. 0 is first within repeated group\n */\n public getGroupInstance (i: number): MsgView | null {\n const instance: SegmentDescription | null = this.segment?.getInstance(i)\n if (!instance) {\n return null\n }\n return this.create(instance)\n }\n\n public getUndefined (): SegmentDescription | SegmentDescription[] | null {\n return this.structure?.layout['.undefined']\n }\n\n public undefinedForMsg (): string | null {\n let msg: string | null = null\n const undefinedTags = this.getUndefined()\n if (undefinedTags) {\n if (Array.isArray(undefinedTags)) {\n msg = 'undefined tags = ' + undefinedTags.map((e: SegmentDescription) => e.startTag.toString()).join(', ')\n } else {\n msg = `undefined tag = ${undefinedTags.startTag}`\n }\n }\n return msg\n }\n\n /**\n * if this view represents a repeated group then return number\n * of repeated instances within this view\n */\n public groupCount (): number {\n const positions = this.segment.delimiterPositions\n return positions ? positions.length : 0\n }\n\n /**\n * regardless of how this type is represented in data dictionary,\n * return its value as a string.\n * @param tagOrName name or tag to return 8 or BeginString\n */\n public getString (tagOrName: number | string): string | null {\n const tag: number = this.resolveTag(tagOrName)\n if (tag == null) {\n return null\n }\n const position: number = this.getPosition(tag)\n if (position < 0) {\n return null\n }\n return this.stringAtPosition(position)\n }\n\n /**\n * for a repeated group, one field may be repeted across each instance of a component\n * return all values for a specified field as array of strings\n * @param tagOrName the name of the repeated field to fetch\n */\n public getStrings (tagOrName: number | string | null = null): Array<(string | null)> | null {\n if (!tagOrName) {\n return this.allStrings()\n }\n tagOrName = tagOrName || -1\n const tag: number = this.resolveTag(tagOrName)\n if (tag == null) {\n return null\n }\n const positions: number[] = this.getPositions(tag)\n if (positions == null) {\n return null\n }\n return positions.map((position: number) => {\n return this.stringAtPosition(position)\n })\n }\n\n /**\n * returns typed value of a sinple field within this view\n * @param tagOrName the name or tag of required field e.g. 8, BeginString\n */\n public getTyped (tagOrName: number | string): (boolean | string | number | Date | Buffer | null) {\n const tag: number = this.resolveTag(tagOrName)\n if (tag == null) {\n return null\n }\n const field: SimpleFieldDefinition | null = this.definitions.tagToSimple[tag] ?? null\n if (field == null) {\n return null\n }\n return this.toTyped(field)\n }\n\n /**\n * use a varargs list of tags or tag names to fetch typed values for those fields within this view.\n * @param tagOrNames list of tags e.g. 'BeginString', 'BodyLength', ...\n */\n public getTypedList (...tagOrNames: Array<number | string>): Array<boolean | string | number | Date | Buffer | null> {\n return tagOrNames.map((s) => this.getTyped(s))\n }\n\n /**\n * use an array of tags or tag names to fetch typed values for those fields within this view.\n * @param tagOrName the list of params as array ['BeginString','BodyLength', 'MsgType']\n */\n public getTypedTags (tagOrName: Array<string | number>): Array<boolean | string | number | Date | Buffer | null> {\n return tagOrName.map((s) => this.getTyped(s))\n }\n\n /**\n * produce an object representation of the view which when coupled with its\n * interface (generated against the same dictionary source) will allow easy\n * navigation of the object where a group is resolved to an array and simple\n * fields are properties. This is relatively expensive operation as every\n * field is fully resolved regardless of depth i.e. all groups and compoennts\n * are fully resolved.\n */\n public toObject (): ILooseObject | ILooseObject[] | null {\n const segment: SegmentDescription = this.segment\n if (segment.set == null) return null\n if (segment.delimiterTag) {\n switch (segment.set.type) {\n case ContainedSetType.Group: {\n return this.asInstances((segment.set as GroupFieldDefinition).name)\n }\n case ContainedSetType.Msg: {\n // this is a batch of messages\n const hdrView = this.getView('Hdr')\n const batch: ILooseObject = {}\n if (hdrView) {\n const name = hdrView.segment.set?.name ?? 'na'\n batch[name] = hdrView.toObject()\n }\n batch[segment.name] = this.asInstances(segment.name)\n return batch\n }\n }\n }\n return this.asLoose(segment.set)\n }\n\n /**\n * easy human-readable format showing each field, its position, value and resolved\n * enum.\n */\n public toString (): string {\n return this.stringify(MsgView.asToken)\n }\n\n public toVerbose (): string {\n return this.stringify(MsgView.asVerbose)\n }\n\n /**\n * a string in JSON format representing this view as an object\n */\n public toJson (): string {\n return JSON.stringify(this.toObject(), null, 4)\n }\n\n public getView (name: string): MsgView | null {\n const parts: string[] = name.split('.')\n const reducer = (a: MsgView | null, current: string): MsgView | null => {\n if (!a) {\n return a\n }\n const structure = a.structure\n const singleton: SegmentDescription | null = structure?.firstContainedWithin(current, a.segment) ?? null\n if (singleton) {\n return a.create(singleton)\n }\n // is this a full name where abbreviation exists\n const component: ContainedField | null = a.segment.set?.localNameToField.get(current) ?? null\n\n if (component) {\n const abbreviated: SegmentDescription | null = structure?.firstContainedWithin(component.name, a.segment) ?? null\n if (abbreviated) {\n return a.create(abbreviated)\n }\n }\n return null\n }\n return parts.reduce<MsgView | null>(reducer, this)\n }\n\n public abstract checksum (): number\n\n public abstract clone (): MsgView\n\n protected abstract create (singleton: SegmentDescription): MsgView\n\n protected abstract stringAtPosition (position: number): string | null\n\n protected abstract toTyped (field: SimpleFieldDefinition): boolean | string | number | Date | Buffer | null\n\n protected resolveTag (tagOrName: number | string): number {\n let tag: number\n const set = this.segment.set\n if (typeof (tagOrName) === 'string') {\n if (set == null) return 0\n const cf = set.simple.get(tagOrName)\n const f: SimpleFieldDefinition | null = cf ? cf.definition : this.definitions.simple.get(tagOrName) ?? null\n if (f == null) {\n return -1\n }\n tag = f.tag\n } else {\n tag = tagOrName\n }\n return tag\n }\n\n // fetch all positions of a particular tag.\n protected getPositions (tag: number): number[] {\n const forwards: TagPos[] = this.sortedTagPosForwards\n const backwards: TagPos[] = this.sortedTagPosBackwards\n const position: number = this.binarySearch(tag)\n if (position < 0) {\n return []\n }\n\n const count: number = forwards.length\n const last: number = count - 1\n let end: number = position\n while (end <= last) {\n if (tag !== forwards[end].tag) {\n break\n }\n ++end\n }\n // avoid backtracking over an array by scan forwards on a reversed copy\n let start: number = last - position\n while (start <= last) {\n if (tag !== backwards[start].tag) {\n break\n }\n ++start\n }\n const begin: number = last - (start - 1)\n const len: number = end - begin\n const positions: number[] = new Array(len)\n for (let i: number = begin; i < end; ++i) {\n positions[i - begin] = forwards[i].position\n }\n return positions\n }\n\n protected getPosition (tag: number): number {\n const pos: number = this.binarySearch(tag)\n if (pos >= 0) {\n return this.sortedTagPosForwards[pos].position\n } else {\n return -1\n }\n }\n\n private allStrings (): Array<(string | null)> {\n const segment: SegmentDescription = this.segment\n const range: number[] = []\n if (segment.segmentView) {\n for (const tp of segment.segmentView.tags) {\n range[range.length] = tp.position\n }\n } else {\n for (let i: number = segment.startPosition; i <= segment.endPosition; ++i) {\n range[range.length] = i\n }\n }\n return range.map((i: number) => this.stringAtPosition(i))\n }\n\n private asInstances (name: string): Array<ILooseObject | null> | null {\n const groupView: MsgView | null = this.getView(name)\n if (groupView == null) {\n return null\n }\n const groupArray = new Array<ILooseObject | null>(groupView.groupCount())\n const count: number = groupView.groupCount()\n for (let j: number = 0; j < count; ++j) {\n const instance: MsgView | null = groupView.getGroupInstance(j)\n groupArray[j] = instance?.toObject() ?? null\n }\n return groupArray\n }\n\n private asLoose (def: IContainedSet): ILooseObject {\n\n return this.reducer.reduce(def, {\n group: (a: ILooseObject, field: ContainedGroupField) => { this.asLooseGroup(a, field) },\n simple: (a: ILooseObject, field: ContainedSimpleField) => { this.asLooseSimple(a, field) },\n component: (a: ILooseObject, field: ContainedComponentField) => { this.asLooseComponent(a, field) }\n } as ITypeDispatcher<ILooseObject>, def.localAttribute.reduce<ILooseObject>((a: ILooseObject, sf: ContainedSimpleField) => {\n const def = sf.definition\n const position: number = this.getPosition(def.tag)\n if (position >= 0) {\n a[def.name] = this.toTyped(def)\n }\n return a\n }, {}))\n }\n\n private missingRequired (def: IContainedSet, tags: number []): number[] {\n const reducer = new SetReduce<number[]>()\n const dispatcher: ITypeDispatcher<number[]> = {\n group: (a: number[], field: ContainedGroupField) => { this.missingGroup(def, field, a) },\n simple: (a: number[], field: ContainedSimpleField) => { this.missingSimple(field, a) },\n component: (a: number[], field: ContainedComponentField) => { this.missingComponent(field, a) }\n }\n return reducer.reduce(def, dispatcher, tags)\n }\n\n private missingSimple (sf: ContainedSimpleField, a: number[]): void {\n if (sf.required && this.getPosition(sf.definition.tag) < 0) {\n a.push(sf.definition.tag)\n }\n }\n\n private missingComponent (cf: ContainedComponentField, a: number[]): void {\n const view: MsgView | null = this.getView(cf.name)\n if (view) {\n view.missingRequired(cf.definition, a)\n }\n }\n\n private missingGroup (def: IContainedSet, gf: ContainedGroupField, tags: number []): void {\n const name = gf.definition.noOfField ? gf.definition.noOfField.name : def.name\n const groupView: MsgView | null = this.getView(name) ?? this.getView(gf.definition.name)\n if (groupView == null) {\n return\n }\n const count: number = groupView.groupCount()\n for (let j: number = 0; j < count; ++j) {\n const instance: MsgView | null = groupView.getGroupInstance(j)\n instance?.missingRequired(gf.definition, tags)\n }\n }\n\n private asLooseComponent (a: ILooseObject, cf: ContainedComponentField): void {\n const view: MsgView | null = this.getView(cf.name)\n if (view) {\n const component = view.toObject()\n if (component) {\n a[cf.definition.name] = component\n }\n }\n }\n\n private asLooseSimple (a: ILooseObject, sf: ContainedSimpleField): void {\n const def = sf.definition\n const position: number = this.getPosition(def.tag)\n if (position >= 0) {\n const asSimple: boolean | string | number | Date | Buffer | null = this.toTyped(def)\n if (asSimple != null) { // beware, may be false value\n a[sf.name] = asSimple\n }\n }\n }\n\n private asLooseGroup (a: ILooseObject, gf: ContainedGroupField): void {\n const def = gf.definition\n const name = def.noOfField ? def.noOfField.name : def.name\n const instances: ILooseObject | null = this.asInstances(name) ?? this.asInstances(def.name)\n if (instances) {\n a[def.name] = instances\n }\n }\n\n private binarySearch (tag: number): number {\n if (this.structure == null) return -1\n let forwards = this.sortedTagPosForwards\n if (!forwards) {\n const segment = this.segment\n if (segment.segmentView) {\n // fragmented component: use the collected tags from SegmentView\n forwards = this.sortedTagPosForwards = segment.segmentView.tags.slice()\n forwards.sort(TagPos.compare)\n } else {\n forwards = this.sortedTagPosForwards = this.structure.tags.tagPos.slice(segment.startPosition, segment.endPosition + 1)\n forwards.sort(TagPos.compare)\n }\n this.sortedTagPosBackwards = forwards.slice().reverse()\n }\n return TagPos.binarySearch(forwards, tag)\n }\n\n private stringify (getToken: (field: SimpleFieldDefinition, val: string, i: number, count: number, tp: TagPos) => string): string {\n const structure = this.structure\n const buffer: ElasticBuffer = new ElasticBuffer()\n const segment: SegmentDescription = this.segment\n if (structure == null) return ''\n const tags: Tags = structure.tags\n const count: number = segment.endPosition - segment.startPosition\n const simple: Map<string, SimpleFieldDefinition> = this.definitions.simple\n\n for (let i: number = segment.startPosition; i <= segment.endPosition; ++i) {\n const tagPos: TagPos = tags.tagPos[i]\n const field: SimpleFieldDefinition | undefined = simple.get(tagPos.tag.toString())\n const val: string | null = this.stringAtPosition(i) ?? ''\n // [0] 8 (BeginString) = FIX4.4\n const token = field ? getToken(field, val, i - segment.startPosition, count, tagPos) : `[${i}] ${tagPos.tag} (unknown) = ${val}, `\n buffer.writeString(token)\n }\n\n return buffer.toString()\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"msg-view.js","sourceRoot":"","sources":["../../src/buffer/msg-view.ts"],"names":[],"mappings":";;;AAAA,2CAAsC;AAWtC,8CAAyC;AAEzC,qDAAgD;AAGhD,yEAAmE;AAEnE,MAAsB,OAAO;IAK3B,YAAuC,WAA2B,EAAkB,OAA2B,EAAkB,SAA2B;QAArH,gBAAW,GAAX,WAAW,CAAgB;QAAkB,YAAO,GAAP,OAAO,CAAoB;QAAkB,cAAS,GAAT,SAAS,CAAkB;QAF3I,YAAO,GAA4B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K,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAA;QAC5C,CAAC;aAAM,CAAC;YACN,IAAI,GAAG,GAAG,GAAG,EAAE,CAAA;QACjB,CAAC;IACH,CAAC;SAAM,CAAC;QACN,IAAI,GAAG,GAAG,GAAG,EAAE,CAAA;QACf,IAAI,GAAG,SAAS,CAAA;IAClB,CAAC;IACD,IAAI,SAAiB,CAAA;IACrB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACpD,SAAS,GAAG,OAAO,CAAA;IACrB,CAAC;SAAM,CAAC;QACN,SAAS,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAA;IACnC,CAAC;IACD,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,KAAK,IAAI,OAAO,IAAI,GAAG,SAAS,EAAE,CAAA;AAC3D,CAAC,AAxBuB,CAwBvB","sourcesContent":["import { TagPos } from './tag/tag-pos'\nimport { SegmentDescription } from './segment/segment-description'\nimport { Structure } from './structure'\nimport { Tags } from './tag/tags'\nimport {\n ContainedComponentField,\n ContainedField,\n IContainedSet,\n ContainedGroupField,\n ContainedSimpleField\n} from '../dictionary/contained'\nimport { SetReduce } from '../dictionary'\nimport { ILooseObject } from '../collections/collection'\nimport { ElasticBuffer } from './elastic-buffer'\nimport { FixDefinitions, GroupFieldDefinition, SimpleFieldDefinition } from '../dictionary/definition'\nimport { ITypeDispatcher } from '../dictionary/type-dispatcher'\nimport { ContainedSetType } from '../dictionary/contained-set-type'\n\nexport abstract class MsgView {\n protected sortedTagPosForwards: TagPos[]\n protected sortedTagPosBackwards: TagPos[]\n private readonly reducer: SetReduce<ILooseObject> = new SetReduce<ILooseObject>()\n\n protected constructor (public readonly definitions: FixDefinitions, public readonly segment: SegmentDescription, public readonly structure: Structure | null) {\n }\n\n protected static asVerbose = (field: SimpleFieldDefinition, val: string, i: number, count: number, tp: TagPos): string => {\n const newLine = require('os').EOL\n let desc: string\n let name: string\n if (field) {\n name = field.name || 'unknown'\n if (field.isEnum()) {\n desc = `${val}[${field.resolveEnum(val)}]${newLine}\\t${field.description ?? ''}${newLine}${newLine}`\n } else {\n desc = `${val}${newLine}t${field.description ?? ''}${newLine}${newLine}`\n }\n } else {\n name = 'unknown'\n desc = 'na'\n }\n return `[${i}] ${tp.tag} (${name}) = ${desc}`\n }\n\n protected static asToken = (field: SimpleFieldDefinition, val: string, i: number, count: number, tp: TagPos): string => {\n const perLine: number = 2\n const newLine = require('os').EOL\n // [280] 814 (ApplQueueResolution) = 2[OverlayLast][281] 10 (CheckSum) = 80\n let desc: string\n let name: string\n if (field) {\n name = field.name || 'unknown'\n if (field.isEnum()) {\n desc = `${val}[${field.resolveEnum(val)}]`\n } else {\n desc = `${val}`\n }\n } else {\n desc = `${val}`\n name = 'unknown'\n }\n let delimiter: string\n if (i === 1 || (i < count && i % perLine - 1 === 0)) {\n delimiter = newLine\n } else {\n delimiter = i < count ? ', ' : ''\n }\n return `[${i}] ${tp.tag} (${name}) = ${desc}${delimiter}`\n }\n\n // return list of any tags parsed that are not valid\n public invalid (): number[] {\n const invalidTags: number[] = []\n const set = this.segment.set\n if (set == null) return []\n const tags = this.structure?.tags ?? null\n if (tags == null) return []\n for (let i = 0; i < tags.nextTagPos; ++i) {\n const tag = tags.tagPos[i].tag\n if (tag <= 0 || !set.containedTag[tag]) {\n invalidTags[invalidTags.length] = tag\n }\n }\n return invalidTags\n }\n\n // list of tags that must be present\n public missing (): number[] {\n if (this.segment == null) return []\n if (this.segment.set == null) return []\n return this.missingRequired(this.segment.set, [])\n }\n\n /**\n * does this view contain this tag\n * @param tagOrName the name or tag of field to check 8 or BeginString\n */\n public contains (tagOrName: number | string): boolean {\n const tag: number = this.resolveTag(tagOrName)\n const position: number = this.getPosition(tag)\n return position >= 0\n }\n\n /**\n * if this view represents a repeated group then return a sub view representing\n * this instance of repeated group.\n * @param i the index to return i.e. 0 is first within repeated group\n */\n public getGroupInstance (i: number): MsgView | null {\n const instance: SegmentDescription | null = this.segment?.getInstance(i)\n if (!instance) {\n return null\n }\n return this.create(instance)\n }\n\n public getUndefined (): SegmentDescription | SegmentDescription[] | null {\n return this.structure?.layout['.undefined']\n }\n\n public undefinedForMsg (): string | null {\n let msg: string | null = null\n const undefinedTags = this.getUndefined()\n if (undefinedTags) {\n if (Array.isArray(undefinedTags)) {\n msg = 'undefined tags = ' + undefinedTags.map((e: SegmentDescription) => e.startTag.toString()).join(', ')\n } else {\n msg = `undefined tag = ${undefinedTags.startTag}`\n }\n }\n return msg\n }\n\n /**\n * if this view represents a repeated group then return number\n * of repeated instances within this view\n */\n public groupCount (): number {\n const positions = this.segment.delimiterPositions\n return positions ? positions.length : 0\n }\n\n /**\n * regardless of how this type is represented in data dictionary,\n * return its value as a string.\n * @param tagOrName name or tag to return 8 or BeginString\n */\n public getString (tagOrName: number | string): string | null {\n const tag: number = this.resolveTag(tagOrName)\n if (tag == null) {\n return null\n }\n const position: number = this.getPosition(tag)\n if (position < 0) {\n return null\n }\n return this.stringAtPosition(position)\n }\n\n /**\n * for a repeated group, one field may be repeted across each instance of a component\n * return all values for a specified field as array of strings\n * @param tagOrName the name of the repeated field to fetch\n */\n public getStrings (tagOrName: number | string | null = null): Array<(string | null)> | null {\n if (!tagOrName) {\n return this.allStrings()\n }\n tagOrName = tagOrName || -1\n const tag: number = this.resolveTag(tagOrName)\n if (tag == null) {\n return null\n }\n const positions: number[] = this.getPositions(tag)\n if (positions == null) {\n return null\n }\n return positions.map((position: number) => {\n return this.stringAtPosition(position)\n })\n }\n\n /**\n * returns typed value of a sinple field within this view\n * @param tagOrName the name or tag of required field e.g. 8, BeginString\n */\n public getTyped (tagOrName: number | string): (boolean | string | number | Date | Buffer | null) {\n const tag: number = this.resolveTag(tagOrName)\n if (tag == null) {\n return null\n }\n const field: SimpleFieldDefinition | null = this.definitions.tagToSimple[tag] ?? null\n if (field == null) {\n return null\n }\n return this.toTyped(field)\n }\n\n /**\n * use a varargs list of tags or tag names to fetch typed values for those fields within this view.\n * @param tagOrNames list of tags e.g. 'BeginString', 'BodyLength', ...\n */\n public getTypedList (...tagOrNames: Array<number | string>): Array<boolean | string | number | Date | Buffer | null> {\n return tagOrNames.map((s) => this.getTyped(s))\n }\n\n /**\n * use an array of tags or tag names to fetch typed values for those fields within this view.\n * @param tagOrName the list of params as array ['BeginString','BodyLength', 'MsgType']\n */\n public getTypedTags (tagOrName: Array<string | number>): Array<boolean | string | number | Date | Buffer | null> {\n return tagOrName.map((s) => this.getTyped(s))\n }\n\n /**\n * produce an object representation of the view which when coupled with its\n * interface (generated against the same dictionary source) will allow easy\n * navigation of the object where a group is resolved to an array and simple\n * fields are properties. This is relatively expensive operation as every\n * field is fully resolved regardless of depth i.e. all groups and compoennts\n * are fully resolved.\n */\n public toObject (): ILooseObject | ILooseObject[] | null {\n const segment: SegmentDescription = this.segment\n if (segment.set == null) return null\n if (segment.delimiterTag) {\n switch (segment.set.type) {\n case ContainedSetType.Group: {\n return this.asInstances((segment.set as GroupFieldDefinition).name)\n }\n case ContainedSetType.Msg: {\n // this is a batch of messages\n const hdrView = this.getView('Hdr')\n const batch: ILooseObject = {}\n if (hdrView) {\n const name = hdrView.segment.set?.name ?? 'na'\n batch[name] = hdrView.toObject()\n }\n batch[segment.name] = this.asInstances(segment.name)\n return batch\n }\n }\n }\n return this.asLoose(segment.set)\n }\n\n /**\n * easy human-readable format showing each field, its position, value and resolved\n * enum.\n */\n public toString (): string {\n return this.stringify(MsgView.asToken)\n }\n\n public toVerbose (): string {\n return this.stringify(MsgView.asVerbose)\n }\n\n /**\n * a string in JSON format representing this view as an object\n */\n public toJson (): string {\n return JSON.stringify(this.toObject(), null, 4)\n }\n\n /**\n * fetch a nested view, either by a single name - getView('Instrument') - or by a\n * dotted path walked a step at a time - getView('Parties.PtysSubGrp')\n */\n public getView (name: string): MsgView | null {\n // the dotted form is the exception. resolve a plain name without paying for\n // the parts array and the closure a split and reduce would allocate - the\n // component walk in toObject and validate comes through here per component.\n if (!name.includes('.')) {\n return this.resolveChild(name)\n }\n let view: MsgView | null = this\n for (const part of name.split('.')) {\n view = view.resolveChild(part)\n if (!view) {\n return null\n }\n }\n return view\n }\n\n /**\n * resolve one step of a view path against this view\n */\n private resolveChild (name: string): MsgView | null {\n const structure = this.structure\n const singleton: SegmentDescription | null = structure?.firstContainedWithin(name, this.segment) ?? null\n if (singleton) {\n return this.create(singleton)\n }\n // is this a full name where abbreviation exists\n const component: ContainedField | null = this.segment.set?.localNameToField.get(name) ?? null\n\n if (component) {\n const abbreviated: SegmentDescription | null = structure?.firstContainedWithin(component.name, this.segment) ?? null\n if (abbreviated) {\n return this.create(abbreviated)\n }\n }\n return null\n }\n\n public abstract checksum (): number\n\n public abstract clone (): MsgView\n\n protected abstract create (singleton: SegmentDescription): MsgView\n\n protected abstract stringAtPosition (position: number): string | null\n\n protected abstract toTyped (field: SimpleFieldDefinition): boolean | string | number | Date | Buffer | null\n\n protected resolveTag (tagOrName: number | string): number {\n let tag: number\n const set = this.segment.set\n if (typeof (tagOrName) === 'string') {\n if (set == null) return 0\n const cf = set.simple.get(tagOrName)\n const f: SimpleFieldDefinition | null = cf ? cf.definition : this.definitions.simple.get(tagOrName) ?? null\n if (f == null) {\n return -1\n }\n tag = f.tag\n } else {\n tag = tagOrName\n }\n return tag\n }\n\n // fetch all positions of a particular tag.\n protected getPositions (tag: number): number[] {\n const forwards: TagPos[] = this.sortedTagPosForwards\n const backwards: TagPos[] = this.sortedTagPosBackwards\n const position: number = this.binarySearch(tag)\n if (position < 0) {\n return []\n }\n\n const count: number = forwards.length\n const last: number = count - 1\n let end: number = position\n while (end <= last) {\n if (tag !== forwards[end].tag) {\n break\n }\n ++end\n }\n // avoid backtracking over an array by scan forwards on a reversed copy\n let start: number = last - position\n while (start <= last) {\n if (tag !== backwards[start].tag) {\n break\n }\n ++start\n }\n const begin: number = last - (start - 1)\n const len: number = end - begin\n const positions: number[] = new Array(len)\n for (let i: number = begin; i < end; ++i) {\n positions[i - begin] = forwards[i].position\n }\n return positions\n }\n\n protected getPosition (tag: number): number {\n const pos: number = this.binarySearch(tag)\n if (pos >= 0) {\n return this.sortedTagPosForwards[pos].position\n } else {\n return -1\n }\n }\n\n private allStrings (): Array<(string | null)> {\n const segment: SegmentDescription = this.segment\n const range: number[] = []\n if (segment.segmentView) {\n for (const tp of segment.segmentView.tags) {\n range[range.length] = tp.position\n }\n } else {\n for (let i: number = segment.startPosition; i <= segment.endPosition; ++i) {\n range[range.length] = i\n }\n }\n return range.map((i: number) => this.stringAtPosition(i))\n }\n\n private asInstances (name: string): Array<ILooseObject | null> | null {\n const groupView: MsgView | null = this.getView(name)\n if (groupView == null) {\n return null\n }\n const groupArray = new Array<ILooseObject | null>(groupView.groupCount())\n const count: number = groupView.groupCount()\n for (let j: number = 0; j < count; ++j) {\n const instance: MsgView | null = groupView.getGroupInstance(j)\n groupArray[j] = instance?.toObject() ?? null\n }\n return groupArray\n }\n\n private asLoose (def: IContainedSet): ILooseObject {\n\n return this.reducer.reduce(def, {\n group: (a: ILooseObject, field: ContainedGroupField) => { this.asLooseGroup(a, field) },\n simple: (a: ILooseObject, field: ContainedSimpleField) => { this.asLooseSimple(a, field) },\n component: (a: ILooseObject, field: ContainedComponentField) => { this.asLooseComponent(a, field) }\n } as ITypeDispatcher<ILooseObject>, def.localAttribute.reduce<ILooseObject>((a: ILooseObject, sf: ContainedSimpleField) => {\n const def = sf.definition\n const position: number = this.getPosition(def.tag)\n if (position >= 0) {\n a[def.name] = this.toTyped(def)\n }\n return a\n }, {}))\n }\n\n private missingRequired (def: IContainedSet, tags: number []): number[] {\n const reducer = new SetReduce<number[]>()\n const dispatcher: ITypeDispatcher<number[]> = {\n group: (a: number[], field: ContainedGroupField) => { this.missingGroup(def, field, a) },\n simple: (a: number[], field: ContainedSimpleField) => { this.missingSimple(field, a) },\n component: (a: number[], field: ContainedComponentField) => { this.missingComponent(field, a) }\n }\n return reducer.reduce(def, dispatcher, tags)\n }\n\n private missingSimple (sf: ContainedSimpleField, a: number[]): void {\n if (sf.required && this.getPosition(sf.definition.tag) < 0) {\n a.push(sf.definition.tag)\n }\n }\n\n private missingComponent (cf: ContainedComponentField, a: number[]): void {\n const view: MsgView | null = this.getView(cf.name)\n if (view) {\n view.missingRequired(cf.definition, a)\n }\n }\n\n private missingGroup (def: IContainedSet, gf: ContainedGroupField, tags: number []): void {\n const name = gf.definition.noOfField ? gf.definition.noOfField.name : def.name\n const groupView: MsgView | null = this.getView(name) ?? this.getView(gf.definition.name)\n if (groupView == null) {\n return\n }\n const count: number = groupView.groupCount()\n for (let j: number = 0; j < count; ++j) {\n const instance: MsgView | null = groupView.getGroupInstance(j)\n instance?.missingRequired(gf.definition, tags)\n }\n }\n\n private asLooseComponent (a: ILooseObject, cf: ContainedComponentField): void {\n const view: MsgView | null = this.getView(cf.name)\n if (view) {\n const component = view.toObject()\n if (component) {\n a[cf.definition.name] = component\n }\n }\n }\n\n private asLooseSimple (a: ILooseObject, sf: ContainedSimpleField): void {\n const def = sf.definition\n const position: number = this.getPosition(def.tag)\n if (position >= 0) {\n const asSimple: boolean | string | number | Date | Buffer | null = this.toTyped(def)\n if (asSimple != null) { // beware, may be false value\n a[sf.name] = asSimple\n }\n }\n }\n\n private asLooseGroup (a: ILooseObject, gf: ContainedGroupField): void {\n const def = gf.definition\n const name = def.noOfField ? def.noOfField.name : def.name\n const instances: ILooseObject | null = this.asInstances(name) ?? this.asInstances(def.name)\n if (instances) {\n a[def.name] = instances\n }\n }\n\n private binarySearch (tag: number): number {\n if (this.structure == null) return -1\n let forwards = this.sortedTagPosForwards\n if (!forwards) {\n const segment = this.segment\n if (segment.segmentView) {\n // fragmented component: use the collected tags from SegmentView\n forwards = this.sortedTagPosForwards = segment.segmentView.tags.slice()\n forwards.sort(TagPos.compare)\n } else {\n forwards = this.sortedTagPosForwards = this.structure.tags.tagPos.slice(segment.startPosition, segment.endPosition + 1)\n forwards.sort(TagPos.compare)\n }\n this.sortedTagPosBackwards = forwards.slice().reverse()\n }\n return TagPos.binarySearch(forwards, tag)\n }\n\n private stringify (getToken: (field: SimpleFieldDefinition, val: string, i: number, count: number, tp: TagPos) => string): string {\n const structure = this.structure\n const buffer: ElasticBuffer = new ElasticBuffer()\n const segment: SegmentDescription = this.segment\n if (structure == null) return ''\n const tags: Tags = structure.tags\n const count: number = segment.endPosition - segment.startPosition\n const simple: Map<string, SimpleFieldDefinition> = this.definitions.simple\n\n for (let i: number = segment.startPosition; i <= segment.endPosition; ++i) {\n const tagPos: TagPos = tags.tagPos[i]\n const field: SimpleFieldDefinition | undefined = simple.get(tagPos.tag.toString())\n const val: string | null = this.stringAtPosition(i) ?? ''\n // [0] 8 (BeginString) = FIX4.4\n const token = field ? getToken(field, val, i - segment.startPosition, count, tagPos) : `[${i}] ${tagPos.tag} (unknown) = ${val}, `\n buffer.writeString(token)\n }\n\n return buffer.toString()\n }\n}\n"]}
|
|
@@ -4,6 +4,7 @@ import { ISessionMsgFactory } from '../transport/session/session-msg-factory';
|
|
|
4
4
|
import { JsFixLoggerFactory } from './js-fix-logger-factory';
|
|
5
5
|
import { DependencyContainer } from 'tsyringe';
|
|
6
6
|
import { IFixSessionStoreFactory } from '../store/fix-session-store-factory';
|
|
7
|
+
import { ISessionRegistry } from '../transport/session/session-registry';
|
|
7
8
|
export interface IJsFixConfig {
|
|
8
9
|
factory: ISessionMsgFactory | null;
|
|
9
10
|
definitions: FixDefinitions;
|
|
@@ -13,6 +14,7 @@ export interface IJsFixConfig {
|
|
|
13
14
|
logFactory: JsFixLoggerFactory;
|
|
14
15
|
sessionContainer: DependencyContainer;
|
|
15
16
|
sessionStoreFactory?: IFixSessionStoreFactory;
|
|
17
|
+
sessionRegistry?: ISessionRegistry;
|
|
16
18
|
}
|
|
17
19
|
export declare class JsFixConfig implements IJsFixConfig {
|
|
18
20
|
readonly factory: ISessionMsgFactory | null;
|
|
@@ -22,5 +24,7 @@ export declare class JsFixConfig implements IJsFixConfig {
|
|
|
22
24
|
readonly logFactory: JsFixLoggerFactory;
|
|
23
25
|
logDelimiter: number;
|
|
24
26
|
sessionContainer: DependencyContainer;
|
|
27
|
+
sessionStoreFactory?: IFixSessionStoreFactory;
|
|
28
|
+
sessionRegistry?: ISessionRegistry;
|
|
25
29
|
constructor(factory: ISessionMsgFactory | null, definitions: FixDefinitions, description: ISessionDescription, delimiter?: number, logFactory?: JsFixLoggerFactory);
|
|
26
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"js-fix-config.js","sourceRoot":"","sources":["../../src/config/js-fix-config.ts"],"names":[],"mappings":";;;AAIA,2DAAqD;AACrD,6DAAwD;
|
|
1
|
+
{"version":3,"file":"js-fix-config.js","sourceRoot":"","sources":["../../src/config/js-fix-config.ts"],"names":[],"mappings":";;;AAIA,2DAAqD;AACrD,6DAAwD;AAqBxD,MAAa,WAAW;IAKtB,YACkB,OAAkC,EAClC,WAA2B,EAC3B,WAAgC,EAChC,YAAoB,wBAAU,CAAC,GAAG,EAClC,aAAiC,IAAI,mCAAe,EAAE;QAJtD,YAAO,GAAP,OAAO,CAA2B;QAClC,gBAAW,GAAX,WAAW,CAAgB;QAC3B,gBAAW,GAAX,WAAW,CAAqB;QAChC,cAAS,GAAT,SAAS,CAAyB;QAClC,eAAU,GAAV,UAAU,CAA4C;QATjE,iBAAY,GAAW,wBAAU,CAAC,IAAI,CAAA;IAU7C,CAAC;CACF;AAZD,kCAYC","sourcesContent":["import { FixDefinitions } from '../dictionary/definition'\nimport { ISessionDescription } from '../transport/session/session-description'\nimport { ISessionMsgFactory } from '../transport/session/session-msg-factory'\nimport { JsFixLoggerFactory } from './js-fix-logger-factory'\nimport { EmptyLogFactory } from './empty-log-factory'\nimport { AsciiChars } from '../buffer/ascii/ascii-chars'\nimport { DependencyContainer } from 'tsyringe'\nimport { IFixSessionStoreFactory } from '../store/fix-session-store-factory'\nimport { ISessionRegistry } from '../transport/session/session-registry'\n\nexport interface IJsFixConfig {\n factory: ISessionMsgFactory | null\n definitions: FixDefinitions\n description: ISessionDescription\n delimiter?: number\n logDelimiter?: number\n logFactory: JsFixLoggerFactory\n sessionContainer: DependencyContainer\n sessionStoreFactory?: IFixSessionStoreFactory\n /**\n * Tracks the live session per SessionId. Set by the acceptor listener so a\n * reconnecting counterparty replaces - rather than duplicates - its session.\n */\n sessionRegistry?: ISessionRegistry\n}\n\nexport class JsFixConfig implements IJsFixConfig {\n public logDelimiter: number = AsciiChars.Pipe\n public sessionContainer: DependencyContainer\n public sessionStoreFactory?: IFixSessionStoreFactory\n public sessionRegistry?: ISessionRegistry\n constructor (\n public readonly factory: ISessionMsgFactory | null,\n public readonly definitions: FixDefinitions,\n public readonly description: ISessionDescription,\n public readonly delimiter: number = AsciiChars.Soh,\n public readonly logFactory: JsFixLoggerFactory = new EmptyLogFactory()) {\n }\n}\n"]}
|
|
@@ -13,7 +13,7 @@ export declare class DictionaryValidator {
|
|
|
13
13
|
private readonly referencedComponents;
|
|
14
14
|
private readonly allFieldNames;
|
|
15
15
|
private readonly allComponentNames;
|
|
16
|
-
get errors():
|
|
16
|
+
get errors(): readonly ValidationError[];
|
|
17
17
|
get hasErrors(): boolean;
|
|
18
18
|
get hasWarnings(): boolean;
|
|
19
19
|
validate(doc: XDocument): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dictionary-validator.js","sourceRoot":"","sources":["../../../../src/dictionary/parser/quickfix/dictionary-validator.ts"],"names":[],"mappings":";;;AACA,yDAI2B;AAwB3B,MAAa,mBAAmB;IAAhC;QACmB,YAAO,GAAsB,EAAE,CAAA;QAG/B,iBAAY,GAAG,IAAI,GAAG,EAA+B,CAAA;QACrD,gBAAW,GAAG,IAAI,GAAG,EAA+B,CAAA;QACpD,qBAAgB,GAAG,IAAI,GAAG,EAAmC,CAAA;QAC7D,mBAAc,GAAG,IAAI,GAAG,E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CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EACf,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;YAC3B,CAAC;QACH,CAAC;QAED,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAChB,CAAC;CACF;AA3bD,kDA2bC","sourcesContent":["import { XDocument, XNode } from './x-element'\nimport {\n DictionaryValidationException,\n ValidationError,\n ValidationSeverity\n} from './validation-error'\n\ninterface FieldDefinitionInfo {\n readonly name: string\n readonly tag: number\n readonly type: string\n readonly lineNumber?: number\n}\n\ninterface ComponentDefinitionInfo {\n readonly name: string\n readonly lineNumber?: number\n}\n\ninterface MessageDefinitionInfo {\n readonly name: string\n readonly msgType: string\n readonly lineNumber?: number\n}\n\n/**\n * Validates FIX dictionary XML for common errors like duplicates, missing references, etc.\n * Port of C# DictionaryValidator — operates on an XDocument tree built by SaxTreeBuilder.\n */\nexport class DictionaryValidator {\n private readonly _errors: ValidationError[] = []\n\n // Track definitions — case-sensitive for exact matching\n private readonly fieldsByName = new Map<string, FieldDefinitionInfo>()\n private readonly fieldsByTag = new Map<number, FieldDefinitionInfo>()\n private readonly componentsByName = new Map<string, ComponentDefinitionInfo>()\n private readonly messagesByName = new Map<string, MessageDefinitionInfo>()\n private readonly messagesByMsgType = new Map<string, MessageDefinitionInfo>()\n\n // Case-insensitive lookup for \"did you mean\" suggestions\n private readonly fieldNamesCaseInsensitive = new Map<string, string>()\n private readonly componentNamesCaseInsensitive = new Map<string, string>()\n\n // Track what's referenced (to find unused definitions)\n private readonly referencedFields = new Set<string>()\n private readonly referencedComponents = new Set<string>()\n\n // All known names for \"did you mean\" suggestions\n private readonly allFieldNames: string[] = []\n private readonly allComponentNames: string[] = []\n\n get errors (): ReadonlyArray<ValidationError> {\n return this._errors\n }\n\n get hasErrors (): boolean {\n return this._errors.some(e => e.severity === ValidationSeverity.Error)\n }\n\n get hasWarnings (): boolean {\n return this._errors.some(e => e.severity === ValidationSeverity.Warning)\n }\n\n validate (doc: XDocument): void {\n // First pass: collect all definitions\n this.collectFieldDefinitions(doc)\n this.collectComponentDefinitions(doc)\n this.collectMessageDefinitions(doc)\n\n // Second pass: validate references\n this.validateHeader(doc)\n this.validateTrailer(doc)\n this.validateComponentReferences(doc)\n this.validateMessageReferences(doc)\n\n // Third pass: check for unused definitions (warnings only)\n this.checkUnusedDefinitions()\n }\n\n throwIfErrors (): void {\n if (this.hasErrors) {\n throw new DictionaryValidationException(this._errors)\n }\n }\n\n // ── Field Validation ──\n\n private collectFieldDefinitions (doc: XDocument): void {\n const fieldsNode = doc.firstDescendant('fields')\n if (!fieldsNode) {\n this.addError('MISSING_FIELDS', 'No <fields> section found in dictionary')\n return\n }\n\n for (const field of fieldsNode.elements('field')) {\n this.validateFieldDefinition(field)\n }\n }\n\n private validateFieldDefinition (field: XNode): void {\n const name = field.attribute('name')\n const numberStr = field.attribute('number')\n const type = field.attribute('type')\n const lineNumber = field.line\n\n if (!name) {\n this.addError('FIELD_NO_NAME', 'Field definition missing \\'name\\' attribute', undefined, undefined, lineNumber)\n return\n }\n\n const tag = numberStr != null ? parseInt(numberStr, 10) : NaN\n if (!numberStr || isNaN(tag)) {\n this.addError('FIELD_NO_TAG', `Field '${name}' missing or invalid 'number' attribute`, name, 'field', lineNumber)\n return\n }\n\n if (!type) {\n this.addWarning('FIELD_NO_TYPE', `Field '${name}' missing 'type' attribute, defaulting to STRING`, name, 'field', lineNumber)\n }\n\n this.allFieldNames.push(name)\n\n // Check for duplicate by name\n const existingByName = this.fieldsByName.get(name)\n if (existingByName) {\n this.addError('DUPLICATE_FIELD_NAME',\n `Duplicate field name '${name}' (tag ${tag}). Previously defined with tag ${existingByName.tag}`,\n name, 'field', lineNumber,\n existingByName.tag === tag ? 'Remove the duplicate definition' : 'Use unique field names')\n return\n }\n\n // Check for duplicate by tag\n const existingByTag = this.fieldsByTag.get(tag)\n if (existingByTag) {\n this.addError('DUPLICATE_FIELD_TAG',\n `Duplicate field tag ${tag} for '${name}'. Tag already used by field '${existingByTag.name}'`,\n name, 'field', lineNumber,\n 'Each tag number must be unique')\n return\n }\n\n const info: FieldDefinitionInfo = { name, tag, type: type ?? 'STRING', lineNumber }\n this.fieldsByName.set(name, info)\n this.fieldsByTag.set(tag, info)\n this.fieldNamesCaseInsensitive.set(name.toLowerCase(), name)\n\n this.validateFieldEnums(field, name, lineNumber)\n }\n\n private validateFieldEnums (field: XNode, fieldName: string, lineNumber?: number): void {\n const values = field.elements('value')\n if (values.length === 0) return\n\n const seenEnumKeys = new Set<string>()\n const seenEnumDescriptions = new Set<string>()\n\n for (const value of values) {\n const enumKey = value.attribute('enum')\n const description = value.attribute('description')\n const valueLine = value.line ?? lineNumber\n\n if (!enumKey) {\n this.addError('ENUM_NO_KEY', `Field '${fieldName}' has enum value without 'enum' attribute`,\n fieldName, 'field', valueLine)\n continue\n }\n\n if (!description) {\n this.addWarning('ENUM_NO_DESC', `Field '${fieldName}' enum '${enumKey}' has no description`,\n fieldName, 'field', valueLine)\n }\n\n if (seenEnumKeys.has(enumKey)) {\n this.addError('DUPLICATE_ENUM_KEY',\n `Field '${fieldName}' has duplicate enum key '${enumKey}'`,\n fieldName, 'field', valueLine)\n }\n seenEnumKeys.add(enumKey)\n\n if (description != null) {\n const descLower = description.toLowerCase()\n if (seenEnumDescriptions.has(descLower)) {\n this.addWarning('DUPLICATE_ENUM_DESC',\n `Field '${fieldName}' has duplicate enum description '${description}' which may cause naming conflicts`,\n fieldName, 'field', valueLine)\n }\n seenEnumDescriptions.add(descLower)\n }\n }\n }\n\n // ── Component Validation ──\n\n private collectComponentDefinitions (doc: XDocument): void {\n const componentsNode = doc.firstDescendant('components')\n if (!componentsNode) {\n // Components are optional\n return\n }\n\n for (const component of componentsNode.elements('component')) {\n this.validateComponentDefinition(component)\n }\n }\n\n private validateComponentDefinition (component: XNode): void {\n const name = component.attribute('name')\n const lineNumber = component.line\n\n if (!name) {\n this.addError('COMPONENT_NO_NAME', 'Component definition missing \\'name\\' attribute', undefined, undefined, lineNumber)\n return\n }\n\n this.allComponentNames.push(name)\n\n const existing = this.componentsByName.get(name)\n if (existing) {\n this.addError('DUPLICATE_COMPONENT',\n `Duplicate component name '${name}'`,\n name, 'component', lineNumber,\n `Previously defined at line ${existing.lineNumber ?? '?'}`)\n return\n }\n\n this.componentsByName.set(name, { name, lineNumber })\n this.componentNamesCaseInsensitive.set(name.toLowerCase(), name)\n\n this.validateFieldReferences(component, name, 'component')\n }\n\n // ── Message Validation ──\n\n private collectMessageDefinitions (doc: XDocument): void {\n const messagesNode = doc.firstDescendant('messages')\n if (!messagesNode) {\n this.addError('MISSING_MESSAGES', 'No <messages> section found in dictionary')\n return\n }\n\n for (const message of messagesNode.elements('message')) {\n this.validateMessageDefinition(message)\n }\n }\n\n private validateMessageDefinition (message: XNode): void {\n const name = message.attribute('name')\n const msgType = message.attribute('msgtype')\n const lineNumber = message.line\n\n if (!name) {\n this.addError('MESSAGE_NO_NAME', 'Message definition missing \\'name\\' attribute', undefined, undefined, lineNumber)\n return\n }\n\n if (!msgType) {\n this.addError('MESSAGE_NO_MSGTYPE', `Message '${name}' missing 'msgtype' attribute`,\n name, 'message', lineNumber)\n return\n }\n\n const existingByName = this.messagesByName.get(name)\n if (existingByName) {\n this.addError('DUPLICATE_MESSAGE_NAME',\n `Duplicate message name '${name}'`,\n name, 'message', lineNumber,\n `Previously defined at line ${existingByName.lineNumber ?? '?'}`)\n return\n }\n\n const existingByType = this.messagesByMsgType.get(msgType)\n if (existingByType) {\n this.addError('DUPLICATE_MESSAGE_TYPE',\n `Duplicate message type '${msgType}' for message '${name}'. Type already used by '${existingByType.name}'`,\n name, 'message', lineNumber)\n return\n }\n\n const info: MessageDefinitionInfo = { name, msgType, lineNumber }\n this.messagesByName.set(name, info)\n this.messagesByMsgType.set(msgType, info)\n\n this.validateFieldReferences(message, name, 'message')\n }\n\n // ── Reference Validation ──\n\n private validateHeader (doc: XDocument): void {\n const header = doc.firstDescendant('header')\n if (!header) {\n this.addError('MISSING_HEADER', 'No <header> section found in dictionary')\n return\n }\n this.validateFieldReferences(header, 'StandardHeader', 'header')\n }\n\n private validateTrailer (doc: XDocument): void {\n const trailer = doc.firstDescendant('trailer')\n if (!trailer) {\n this.addError('MISSING_TRAILER', 'No <trailer> section found in dictionary')\n return\n }\n this.validateFieldReferences(trailer, 'StandardTrailer', 'trailer')\n }\n\n private validateComponentReferences (doc: XDocument): void {\n const componentsNode = doc.firstDescendant('components')\n if (!componentsNode) return\n\n for (const component of componentsNode.elements('component')) {\n const name = component.attribute('name')\n if (!name) continue\n\n for (const compRef of component.descendants('component')) {\n this.validateComponentReference(compRef, name, 'component')\n }\n }\n }\n\n private validateMessageReferences (doc: XDocument): void {\n const messagesNode = doc.firstDescendant('messages')\n if (!messagesNode) return\n\n for (const message of messagesNode.elements('message')) {\n const name = message.attribute('name')\n if (!name) continue\n\n for (const compRef of message.descendants('component')) {\n this.validateComponentReference(compRef, name, 'message')\n }\n }\n }\n\n private validateFieldReferences (container: XNode, containerName: string, containerType: string): void {\n for (const fieldRef of container.elements('field')) {\n const fieldName = fieldRef.attribute('name')\n const lineNumber = fieldRef.line\n\n if (!fieldName) {\n this.addError('FIELD_REF_NO_NAME',\n `Field reference in ${containerType} '${containerName}' missing 'name' attribute`,\n containerName, containerType, lineNumber)\n continue\n }\n\n this.referencedFields.add(fieldName)\n\n if (!this.fieldsByName.has(fieldName)) {\n // Check for case mismatch first\n const correctCase = this.fieldNamesCaseInsensitive.get(fieldName.toLowerCase())\n const suggestion = correctCase ?? DictionaryValidator.findSimilar(fieldName, this.allFieldNames)\n\n this.addError('UNDEFINED_FIELD',\n `Field '${fieldName}' referenced in ${containerType} '${containerName}' is not defined`,\n fieldName, 'field reference', lineNumber,\n suggestion != null ? `Did you mean '${suggestion}'?` : 'Add the field to the <fields> section')\n }\n }\n\n // Recursively check groups\n for (const group of container.elements('group')) {\n const groupName = group.attribute('name') ?? 'unknown'\n this.referencedFields.add(groupName)\n\n if (groupName !== 'unknown' && !this.fieldsByName.has(groupName)) {\n const lineNumber = group.line\n const suggestion = DictionaryValidator.findSimilar(groupName, this.allFieldNames)\n\n this.addError('UNDEFINED_GROUP_FIELD',\n `Group '${groupName}' in ${containerType} '${containerName}' has no corresponding field definition (for the repeating count)`,\n groupName, 'group', lineNumber,\n suggestion != null ? `Did you mean '${suggestion}'?` : 'Add a NUMINGROUP field for this group')\n }\n\n this.validateFieldReferences(group, `${containerName}.${groupName}`, 'group')\n }\n }\n\n private validateComponentReference (compRef: XNode, containerName: string, containerType: string): void {\n const compName = compRef.attribute('name')\n const lineNumber = compRef.line\n\n if (!compName) {\n this.addError('COMPONENT_REF_NO_NAME',\n `Component reference in ${containerType} '${containerName}' missing 'name' attribute`,\n containerName, containerType, lineNumber)\n return\n }\n\n this.referencedComponents.add(compName)\n\n if (!this.componentsByName.has(compName) &&\n compName !== 'StandardHeader' && compName !== 'StandardTrailer') {\n const suggestion = DictionaryValidator.findSimilar(compName, this.allComponentNames)\n this.addError('UNDEFINED_COMPONENT',\n `Component '${compName}' referenced in ${containerType} '${containerName}' is not defined`,\n compName, 'component reference', lineNumber,\n suggestion != null ? `Did you mean '${suggestion}'?` : 'Add the component to the <components> section')\n }\n }\n\n private checkUnusedDefinitions (): void {\n for (const field of this.fieldsByName.values()) {\n if (!this.referencedFields.has(field.name)) {\n this.addWarning('UNUSED_FIELD',\n `Field '${field.name}' (tag ${field.tag}) is defined but never referenced`,\n field.name, 'field', field.lineNumber)\n }\n }\n\n for (const comp of this.componentsByName.values()) {\n if (!this.referencedComponents.has(comp.name)) {\n this.addWarning('UNUSED_COMPONENT',\n `Component '${comp.name}' is defined but never referenced`,\n comp.name, 'component', comp.lineNumber)\n }\n }\n }\n\n // ── Helpers ──\n\n private addError (code: string, message: string, elementName?: string,\n elementType?: string, lineNumber?: number, suggestion?: string): void {\n this._errors.push({ severity: ValidationSeverity.Error, code, message, elementName, elementType, lineNumber, suggestion })\n }\n\n private addWarning (code: string, message: string, elementName?: string,\n elementType?: string, lineNumber?: number, suggestion?: string): void {\n this._errors.push({ severity: ValidationSeverity.Warning, code, message, elementName, elementType, lineNumber, suggestion })\n }\n\n static findSimilar (input: string, candidates: string[]): string | null {\n let bestMatch: string | null = null\n let bestDistance = Infinity\n const maxDistance = Math.max(3, Math.floor(input.length / 2))\n const inputLower = input.toLowerCase()\n\n for (const candidate of candidates) {\n const distance = DictionaryValidator.levenshteinDistance(inputLower, candidate.toLowerCase())\n if (distance < bestDistance && distance <= maxDistance) {\n bestDistance = distance\n bestMatch = candidate\n }\n }\n\n return bestMatch\n }\n\n static levenshteinDistance (s1: string, s2: string): number {\n const n = s1.length\n const m = s2.length\n if (n === 0) return m\n if (m === 0) return n\n\n const d: number[][] = Array.from({ length: n + 1 }, () => new Array(m + 1).fill(0))\n\n for (let i = 0; i <= n; i++) d[i][0] = i\n for (let j = 0; j <= m; j++) d[0][j] = j\n\n for (let i = 1; i <= n; i++) {\n for (let j = 1; j <= m; j++) {\n const cost = s1[i - 1] === s2[j - 1] ? 0 : 1\n d[i][j] = Math.min(\n d[i - 1][j] + 1,\n d[i][j - 1] + 1,\n d[i - 1][j - 1] + cost)\n }\n }\n\n return d[n][m]\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dictionary-validator.js","sourceRoot":"","sources":["../../../../src/dictionary/parser/quickfix/dictionary-validator.ts"],"names":[],"mappings":";;;AACA,yDAI2B;AAwB3B,MAAa,mBAAmB;IAAhC;QACmB,YAAO,GAAsB,EAAE,CAAA;QAG/B,iBAAY,GAAG,IAAI,GAAG,EAA+B,CAAA;QACrD,gBAAW,GAAG,IAAI,GAAG,EAA+B,CAAA;QACpD,qBAAgB,GAAG,IAAI,GAAG,EAAmC,CAAA;QAC7D,mBAAc,GAAG,IAAI,GAAG,EAAiC,CAAA;QACzD,sBAAiB,GAAG,IAAI,GAAG,EAAiC,CAAA;QAG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AC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;YAC3B,CAAC;QACH,CAAC;QAED,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAChB,CAAC;CACF;AA3bD,kDA2bC","sourcesContent":["import { XDocument, XNode } from './x-element'\nimport {\n DictionaryValidationException,\n ValidationError,\n ValidationSeverity\n} from './validation-error'\n\ninterface FieldDefinitionInfo {\n readonly name: string\n readonly tag: number\n readonly type: string\n readonly lineNumber?: number\n}\n\ninterface ComponentDefinitionInfo {\n readonly name: string\n readonly lineNumber?: number\n}\n\ninterface MessageDefinitionInfo {\n readonly name: string\n readonly msgType: string\n readonly lineNumber?: number\n}\n\n/**\n * Validates FIX dictionary XML for common errors like duplicates, missing references, etc.\n * Port of C# DictionaryValidator — operates on an XDocument tree built by SaxTreeBuilder.\n */\nexport class DictionaryValidator {\n private readonly _errors: ValidationError[] = []\n\n // Track definitions — case-sensitive for exact matching\n private readonly fieldsByName = new Map<string, FieldDefinitionInfo>()\n private readonly fieldsByTag = new Map<number, FieldDefinitionInfo>()\n private readonly componentsByName = new Map<string, ComponentDefinitionInfo>()\n private readonly messagesByName = new Map<string, MessageDefinitionInfo>()\n private readonly messagesByMsgType = new Map<string, MessageDefinitionInfo>()\n\n // Case-insensitive lookup for \"did you mean\" suggestions\n private readonly fieldNamesCaseInsensitive = new Map<string, string>()\n private readonly componentNamesCaseInsensitive = new Map<string, string>()\n\n // Track what's referenced (to find unused definitions)\n private readonly referencedFields = new Set<string>()\n private readonly referencedComponents = new Set<string>()\n\n // All known names for \"did you mean\" suggestions\n private readonly allFieldNames: string[] = []\n private readonly allComponentNames: string[] = []\n\n get errors (): readonly ValidationError[] {\n return this._errors\n }\n\n get hasErrors (): boolean {\n return this._errors.some(e => e.severity === ValidationSeverity.Error)\n }\n\n get hasWarnings (): boolean {\n return this._errors.some(e => e.severity === ValidationSeverity.Warning)\n }\n\n validate (doc: XDocument): void {\n // First pass: collect all definitions\n this.collectFieldDefinitions(doc)\n this.collectComponentDefinitions(doc)\n this.collectMessageDefinitions(doc)\n\n // Second pass: validate references\n this.validateHeader(doc)\n this.validateTrailer(doc)\n this.validateComponentReferences(doc)\n this.validateMessageReferences(doc)\n\n // Third pass: check for unused definitions (warnings only)\n this.checkUnusedDefinitions()\n }\n\n throwIfErrors (): void {\n if (this.hasErrors) {\n throw new DictionaryValidationException(this._errors)\n }\n }\n\n // ── Field Validation ──\n\n private collectFieldDefinitions (doc: XDocument): void {\n const fieldsNode = doc.firstDescendant('fields')\n if (!fieldsNode) {\n this.addError('MISSING_FIELDS', 'No <fields> section found in dictionary')\n return\n }\n\n for (const field of fieldsNode.elements('field')) {\n this.validateFieldDefinition(field)\n }\n }\n\n private validateFieldDefinition (field: XNode): void {\n const name = field.attribute('name')\n const numberStr = field.attribute('number')\n const type = field.attribute('type')\n const lineNumber = field.line\n\n if (!name) {\n this.addError('FIELD_NO_NAME', 'Field definition missing \\'name\\' attribute', undefined, undefined, lineNumber)\n return\n }\n\n const tag = numberStr != null ? parseInt(numberStr, 10) : NaN\n if (!numberStr || isNaN(tag)) {\n this.addError('FIELD_NO_TAG', `Field '${name}' missing or invalid 'number' attribute`, name, 'field', lineNumber)\n return\n }\n\n if (!type) {\n this.addWarning('FIELD_NO_TYPE', `Field '${name}' missing 'type' attribute, defaulting to STRING`, name, 'field', lineNumber)\n }\n\n this.allFieldNames.push(name)\n\n // Check for duplicate by name\n const existingByName = this.fieldsByName.get(name)\n if (existingByName) {\n this.addError('DUPLICATE_FIELD_NAME',\n `Duplicate field name '${name}' (tag ${tag}). Previously defined with tag ${existingByName.tag}`,\n name, 'field', lineNumber,\n existingByName.tag === tag ? 'Remove the duplicate definition' : 'Use unique field names')\n return\n }\n\n // Check for duplicate by tag\n const existingByTag = this.fieldsByTag.get(tag)\n if (existingByTag) {\n this.addError('DUPLICATE_FIELD_TAG',\n `Duplicate field tag ${tag} for '${name}'. Tag already used by field '${existingByTag.name}'`,\n name, 'field', lineNumber,\n 'Each tag number must be unique')\n return\n }\n\n const info: FieldDefinitionInfo = { name, tag, type: type ?? 'STRING', lineNumber }\n this.fieldsByName.set(name, info)\n this.fieldsByTag.set(tag, info)\n this.fieldNamesCaseInsensitive.set(name.toLowerCase(), name)\n\n this.validateFieldEnums(field, name, lineNumber)\n }\n\n private validateFieldEnums (field: XNode, fieldName: string, lineNumber?: number): void {\n const values = field.elements('value')\n if (values.length === 0) return\n\n const seenEnumKeys = new Set<string>()\n const seenEnumDescriptions = new Set<string>()\n\n for (const value of values) {\n const enumKey = value.attribute('enum')\n const description = value.attribute('description')\n const valueLine = value.line ?? lineNumber\n\n if (!enumKey) {\n this.addError('ENUM_NO_KEY', `Field '${fieldName}' has enum value without 'enum' attribute`,\n fieldName, 'field', valueLine)\n continue\n }\n\n if (!description) {\n this.addWarning('ENUM_NO_DESC', `Field '${fieldName}' enum '${enumKey}' has no description`,\n fieldName, 'field', valueLine)\n }\n\n if (seenEnumKeys.has(enumKey)) {\n this.addError('DUPLICATE_ENUM_KEY',\n `Field '${fieldName}' has duplicate enum key '${enumKey}'`,\n fieldName, 'field', valueLine)\n }\n seenEnumKeys.add(enumKey)\n\n if (description != null) {\n const descLower = description.toLowerCase()\n if (seenEnumDescriptions.has(descLower)) {\n this.addWarning('DUPLICATE_ENUM_DESC',\n `Field '${fieldName}' has duplicate enum description '${description}' which may cause naming conflicts`,\n fieldName, 'field', valueLine)\n }\n seenEnumDescriptions.add(descLower)\n }\n }\n }\n\n // ── Component Validation ──\n\n private collectComponentDefinitions (doc: XDocument): void {\n const componentsNode = doc.firstDescendant('components')\n if (!componentsNode) {\n // Components are optional\n return\n }\n\n for (const component of componentsNode.elements('component')) {\n this.validateComponentDefinition(component)\n }\n }\n\n private validateComponentDefinition (component: XNode): void {\n const name = component.attribute('name')\n const lineNumber = component.line\n\n if (!name) {\n this.addError('COMPONENT_NO_NAME', 'Component definition missing \\'name\\' attribute', undefined, undefined, lineNumber)\n return\n }\n\n this.allComponentNames.push(name)\n\n const existing = this.componentsByName.get(name)\n if (existing) {\n this.addError('DUPLICATE_COMPONENT',\n `Duplicate component name '${name}'`,\n name, 'component', lineNumber,\n `Previously defined at line ${existing.lineNumber ?? '?'}`)\n return\n }\n\n this.componentsByName.set(name, { name, lineNumber })\n this.componentNamesCaseInsensitive.set(name.toLowerCase(), name)\n\n this.validateFieldReferences(component, name, 'component')\n }\n\n // ── Message Validation ──\n\n private collectMessageDefinitions (doc: XDocument): void {\n const messagesNode = doc.firstDescendant('messages')\n if (!messagesNode) {\n this.addError('MISSING_MESSAGES', 'No <messages> section found in dictionary')\n return\n }\n\n for (const message of messagesNode.elements('message')) {\n this.validateMessageDefinition(message)\n }\n }\n\n private validateMessageDefinition (message: XNode): void {\n const name = message.attribute('name')\n const msgType = message.attribute('msgtype')\n const lineNumber = message.line\n\n if (!name) {\n this.addError('MESSAGE_NO_NAME', 'Message definition missing \\'name\\' attribute', undefined, undefined, lineNumber)\n return\n }\n\n if (!msgType) {\n this.addError('MESSAGE_NO_MSGTYPE', `Message '${name}' missing 'msgtype' attribute`,\n name, 'message', lineNumber)\n return\n }\n\n const existingByName = this.messagesByName.get(name)\n if (existingByName) {\n this.addError('DUPLICATE_MESSAGE_NAME',\n `Duplicate message name '${name}'`,\n name, 'message', lineNumber,\n `Previously defined at line ${existingByName.lineNumber ?? '?'}`)\n return\n }\n\n const existingByType = this.messagesByMsgType.get(msgType)\n if (existingByType) {\n this.addError('DUPLICATE_MESSAGE_TYPE',\n `Duplicate message type '${msgType}' for message '${name}'. Type already used by '${existingByType.name}'`,\n name, 'message', lineNumber)\n return\n }\n\n const info: MessageDefinitionInfo = { name, msgType, lineNumber }\n this.messagesByName.set(name, info)\n this.messagesByMsgType.set(msgType, info)\n\n this.validateFieldReferences(message, name, 'message')\n }\n\n // ── Reference Validation ──\n\n private validateHeader (doc: XDocument): void {\n const header = doc.firstDescendant('header')\n if (!header) {\n this.addError('MISSING_HEADER', 'No <header> section found in dictionary')\n return\n }\n this.validateFieldReferences(header, 'StandardHeader', 'header')\n }\n\n private validateTrailer (doc: XDocument): void {\n const trailer = doc.firstDescendant('trailer')\n if (!trailer) {\n this.addError('MISSING_TRAILER', 'No <trailer> section found in dictionary')\n return\n }\n this.validateFieldReferences(trailer, 'StandardTrailer', 'trailer')\n }\n\n private validateComponentReferences (doc: XDocument): void {\n const componentsNode = doc.firstDescendant('components')\n if (!componentsNode) return\n\n for (const component of componentsNode.elements('component')) {\n const name = component.attribute('name')\n if (!name) continue\n\n for (const compRef of component.descendants('component')) {\n this.validateComponentReference(compRef, name, 'component')\n }\n }\n }\n\n private validateMessageReferences (doc: XDocument): void {\n const messagesNode = doc.firstDescendant('messages')\n if (!messagesNode) return\n\n for (const message of messagesNode.elements('message')) {\n const name = message.attribute('name')\n if (!name) continue\n\n for (const compRef of message.descendants('component')) {\n this.validateComponentReference(compRef, name, 'message')\n }\n }\n }\n\n private validateFieldReferences (container: XNode, containerName: string, containerType: string): void {\n for (const fieldRef of container.elements('field')) {\n const fieldName = fieldRef.attribute('name')\n const lineNumber = fieldRef.line\n\n if (!fieldName) {\n this.addError('FIELD_REF_NO_NAME',\n `Field reference in ${containerType} '${containerName}' missing 'name' attribute`,\n containerName, containerType, lineNumber)\n continue\n }\n\n this.referencedFields.add(fieldName)\n\n if (!this.fieldsByName.has(fieldName)) {\n // Check for case mismatch first\n const correctCase = this.fieldNamesCaseInsensitive.get(fieldName.toLowerCase())\n const suggestion = correctCase ?? DictionaryValidator.findSimilar(fieldName, this.allFieldNames)\n\n this.addError('UNDEFINED_FIELD',\n `Field '${fieldName}' referenced in ${containerType} '${containerName}' is not defined`,\n fieldName, 'field reference', lineNumber,\n suggestion != null ? `Did you mean '${suggestion}'?` : 'Add the field to the <fields> section')\n }\n }\n\n // Recursively check groups\n for (const group of container.elements('group')) {\n const groupName = group.attribute('name') ?? 'unknown'\n this.referencedFields.add(groupName)\n\n if (groupName !== 'unknown' && !this.fieldsByName.has(groupName)) {\n const lineNumber = group.line\n const suggestion = DictionaryValidator.findSimilar(groupName, this.allFieldNames)\n\n this.addError('UNDEFINED_GROUP_FIELD',\n `Group '${groupName}' in ${containerType} '${containerName}' has no corresponding field definition (for the repeating count)`,\n groupName, 'group', lineNumber,\n suggestion != null ? `Did you mean '${suggestion}'?` : 'Add a NUMINGROUP field for this group')\n }\n\n this.validateFieldReferences(group, `${containerName}.${groupName}`, 'group')\n }\n }\n\n private validateComponentReference (compRef: XNode, containerName: string, containerType: string): void {\n const compName = compRef.attribute('name')\n const lineNumber = compRef.line\n\n if (!compName) {\n this.addError('COMPONENT_REF_NO_NAME',\n `Component reference in ${containerType} '${containerName}' missing 'name' attribute`,\n containerName, containerType, lineNumber)\n return\n }\n\n this.referencedComponents.add(compName)\n\n if (!this.componentsByName.has(compName) &&\n compName !== 'StandardHeader' && compName !== 'StandardTrailer') {\n const suggestion = DictionaryValidator.findSimilar(compName, this.allComponentNames)\n this.addError('UNDEFINED_COMPONENT',\n `Component '${compName}' referenced in ${containerType} '${containerName}' is not defined`,\n compName, 'component reference', lineNumber,\n suggestion != null ? `Did you mean '${suggestion}'?` : 'Add the component to the <components> section')\n }\n }\n\n private checkUnusedDefinitions (): void {\n for (const field of this.fieldsByName.values()) {\n if (!this.referencedFields.has(field.name)) {\n this.addWarning('UNUSED_FIELD',\n `Field '${field.name}' (tag ${field.tag}) is defined but never referenced`,\n field.name, 'field', field.lineNumber)\n }\n }\n\n for (const comp of this.componentsByName.values()) {\n if (!this.referencedComponents.has(comp.name)) {\n this.addWarning('UNUSED_COMPONENT',\n `Component '${comp.name}' is defined but never referenced`,\n comp.name, 'component', comp.lineNumber)\n }\n }\n }\n\n // ── Helpers ──\n\n private addError (code: string, message: string, elementName?: string,\n elementType?: string, lineNumber?: number, suggestion?: string): void {\n this._errors.push({ severity: ValidationSeverity.Error, code, message, elementName, elementType, lineNumber, suggestion })\n }\n\n private addWarning (code: string, message: string, elementName?: string,\n elementType?: string, lineNumber?: number, suggestion?: string): void {\n this._errors.push({ severity: ValidationSeverity.Warning, code, message, elementName, elementType, lineNumber, suggestion })\n }\n\n static findSimilar (input: string, candidates: string[]): string | null {\n let bestMatch: string | null = null\n let bestDistance = Infinity\n const maxDistance = Math.max(3, Math.floor(input.length / 2))\n const inputLower = input.toLowerCase()\n\n for (const candidate of candidates) {\n const distance = DictionaryValidator.levenshteinDistance(inputLower, candidate.toLowerCase())\n if (distance < bestDistance && distance <= maxDistance) {\n bestDistance = distance\n bestMatch = candidate\n }\n }\n\n return bestMatch\n }\n\n static levenshteinDistance (s1: string, s2: string): number {\n const n = s1.length\n const m = s2.length\n if (n === 0) return m\n if (m === 0) return n\n\n const d: number[][] = Array.from({ length: n + 1 }, () => new Array(m + 1).fill(0))\n\n for (let i = 0; i <= n; i++) d[i][0] = i\n for (let j = 0; j <= m; j++) d[0][j] = j\n\n for (let i = 1; i <= n; i++) {\n for (let j = 1; j <= m; j++) {\n const cost = s1[i - 1] === s2[j - 1] ? 0 : 1\n d[i][j] = Math.min(\n d[i - 1][j] + 1,\n d[i][j - 1] + 1,\n d[i - 1][j - 1] + cost)\n }\n }\n\n return d[n][m]\n }\n}\n"]}
|
|
@@ -24,7 +24,7 @@ export declare class GraphNode {
|
|
|
24
24
|
readonly element: XNode;
|
|
25
25
|
private readonly _edges;
|
|
26
26
|
constructor(id: number, name: string, type: NodeElementType, element: XNode);
|
|
27
|
-
get edges():
|
|
27
|
+
get edges(): readonly Edge[];
|
|
28
28
|
makeEdge(tail: number): Edge;
|
|
29
29
|
isRequired(): boolean;
|
|
30
30
|
toString(): string;
|
|
@@ -81,8 +81,7 @@ class QuickFixGraphParser {
|
|
|
81
81
|
this.parseHeader(doc);
|
|
82
82
|
this.parseTrailer(doc);
|
|
83
83
|
this.parseMessages(doc);
|
|
84
|
-
|
|
85
|
-
const node = this.queue.shift();
|
|
84
|
+
for (let node = this.queue.shift(); node !== undefined; node = this.queue.shift()) {
|
|
86
85
|
this.work(node);
|
|
87
86
|
}
|
|
88
87
|
new index_visitor_1.IndexVisitor().compute(this.definitions);
|