jspurefix 3.4.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/appveyor.yml +1 -1
- package/dist/buffer/ascii/ascii-encoder.d.ts +2 -2
- package/dist/buffer/ascii/ascii-encoder.js +1 -1
- package/dist/buffer/ascii/ascii-encoder.js.map +1 -1
- package/dist/buffer/ascii/ascii-parser-state.d.ts +3 -2
- package/dist/buffer/ascii/ascii-parser-state.js +1 -2
- package/dist/buffer/ascii/ascii-parser-state.js.map +1 -1
- package/dist/buffer/ascii/ascii-parser.d.ts +1 -1
- package/dist/buffer/ascii/ascii-parser.js +5 -4
- package/dist/buffer/ascii/ascii-parser.js.map +1 -1
- package/dist/buffer/ascii/ascii-segment-parser.js.map +1 -1
- package/dist/buffer/ascii/ascii-view.d.ts +4 -3
- package/dist/buffer/ascii/ascii-view.js +8 -5
- package/dist/buffer/ascii/ascii-view.js.map +1 -1
- package/dist/buffer/encode-proxy.js +1 -1
- package/dist/buffer/encode-proxy.js.map +1 -1
- package/dist/buffer/fixml/fixml-encoder.d.ts +2 -2
- package/dist/buffer/fixml/fixml-encoder.js +1 -1
- package/dist/buffer/fixml/fixml-encoder.js.map +1 -1
- package/dist/buffer/fixml/fixml-parser.js +2 -2
- package/dist/buffer/fixml/fixml-parser.js.map +1 -1
- package/dist/buffer/fixml/fixml-view.d.ts +3 -2
- package/dist/buffer/fixml/fixml-view.js +5 -4
- package/dist/buffer/fixml/fixml-view.js.map +1 -1
- package/dist/buffer/msg-encoder.d.ts +2 -2
- package/dist/buffer/msg-encoder.js.map +1 -1
- package/dist/buffer/msg-view.d.ts +8 -6
- package/dist/buffer/msg-view.js +10 -8
- package/dist/buffer/msg-view.js.map +1 -1
- package/dist/buffer/segment/segment-description.d.ts +3 -3
- package/dist/buffer/segment/segment-description.js.map +1 -1
- package/dist/buffer/tag/tags.d.ts +2 -5
- package/dist/buffer/tag/tags.js +4 -5
- package/dist/buffer/tag/tags.js.map +1 -1
- package/dist/collections/collection.d.ts +0 -1
- package/dist/collections/collection.js.map +1 -1
- package/dist/collections/index.d.ts +0 -1
- package/dist/collections/index.js +0 -17
- package/dist/collections/index.js.map +1 -1
- package/dist/config/js-fix-config.d.ts +2 -1
- package/dist/config/js-fix-config.js +3 -3
- package/dist/config/js-fix-config.js.map +1 -1
- package/dist/dictionary/compiler/compiler-type.d.ts +3 -3
- package/dist/dictionary/compiler/compiler-type.js.map +1 -1
- package/dist/dictionary/compiler/enum-compiler.js +2 -2
- package/dist/dictionary/compiler/enum-compiler.js.map +1 -1
- package/dist/dictionary/compiler/msg-compiler.d.ts +1 -2
- package/dist/dictionary/compiler/msg-compiler.js +6 -7
- package/dist/dictionary/compiler/msg-compiler.js.map +1 -1
- package/dist/dictionary/contained/contained-component-field.d.ts +1 -1
- package/dist/dictionary/contained/contained-component-field.js.map +1 -1
- package/dist/dictionary/contained/contained-field-set.d.ts +9 -20
- package/dist/dictionary/contained/contained-field-set.js +16 -149
- package/dist/dictionary/contained/contained-field-set.js.map +1 -1
- package/dist/dictionary/contained/contained-group-field.d.ts +1 -1
- package/dist/dictionary/contained/contained-group-field.js.map +1 -1
- package/dist/dictionary/contained/contained-set-builder.d.ts +15 -0
- package/dist/dictionary/contained/contained-set-builder.js +142 -0
- package/dist/dictionary/contained/contained-set-builder.js.map +1 -0
- package/dist/dictionary/contained/contained-set.d.ts +32 -0
- package/dist/{types/FIX.5.0SP2/quickfix/xm_lnon_fix.js → dictionary/contained/contained-set.js} +1 -1
- package/dist/dictionary/contained/contained-set.js.map +1 -0
- package/dist/dictionary/contained/contained-simple-field.d.ts +1 -1
- package/dist/dictionary/contained/contained-simple-field.js.map +1 -1
- package/dist/dictionary/contained/index.d.ts +4 -1
- package/dist/dictionary/contained/index.js +4 -1
- package/dist/dictionary/contained/index.js.map +1 -1
- package/dist/dictionary/definition/category-simple-set.d.ts +1 -2
- package/dist/dictionary/definition/category-simple-set.js +1 -2
- package/dist/dictionary/definition/category-simple-set.js.map +1 -1
- package/dist/dictionary/definition/component-field-definition.d.ts +1 -1
- package/dist/dictionary/definition/component-field-definition.js +2 -2
- package/dist/dictionary/definition/component-field-definition.js.map +1 -1
- package/dist/dictionary/definition/fix-definitions.d.ts +8 -9
- package/dist/dictionary/definition/fix-definitions.js +22 -20
- package/dist/dictionary/definition/fix-definitions.js.map +1 -1
- package/dist/dictionary/definition/group-field-definition.d.ts +1 -1
- package/dist/dictionary/definition/group-field-definition.js +2 -2
- package/dist/dictionary/definition/group-field-definition.js.map +1 -1
- package/dist/dictionary/definition/message-definition.d.ts +1 -1
- package/dist/dictionary/definition/message-definition.js +2 -2
- package/dist/dictionary/definition/message-definition.js.map +1 -1
- package/dist/dictionary/definition/simple-field-definition.d.ts +2 -3
- package/dist/dictionary/definition/simple-field-definition.js +6 -7
- package/dist/dictionary/definition/simple-field-definition.js.map +1 -1
- package/dist/dictionary/parser/fix-repository/repository.js +20 -20
- package/dist/dictionary/parser/fix-repository/repository.js.map +1 -1
- package/dist/dictionary/parser/fixml/components-parser.js +18 -16
- package/dist/dictionary/parser/fixml/components-parser.js.map +1 -1
- package/dist/dictionary/parser/fixml/fields-parser.js +2 -3
- package/dist/dictionary/parser/fixml/fields-parser.js.map +1 -1
- package/dist/dictionary/parser/fixml/include-graph.js +8 -9
- package/dist/dictionary/parser/fixml/include-graph.js.map +1 -1
- package/dist/dictionary/parser/quickfix/field-definition-parser.js.map +1 -1
- package/dist/dictionary/parser/quickfix/message-parser.js +2 -1
- package/dist/dictionary/parser/quickfix/message-parser.js.map +1 -1
- package/dist/dictionary/parser/quickfix/node-parser.js +3 -2
- package/dist/dictionary/parser/quickfix/node-parser.js.map +1 -1
- package/dist/dictionary/parser/quickfix/parse-context.d.ts +3 -3
- package/dist/dictionary/parser/quickfix/parse-context.js.map +1 -1
- package/dist/dictionary/parser/quickfix/parse-progress.d.ts +1 -2
- package/dist/dictionary/parser/quickfix/parse-progress.js +2 -3
- package/dist/dictionary/parser/quickfix/parse-progress.js.map +1 -1
- package/dist/dictionary/parser/quickfix/quick-fix-xml-file-builder.js +4 -5
- package/dist/dictionary/parser/quickfix/quick-fix-xml-file-builder.js.map +1 -1
- package/dist/dictionary/parser/quickfix/quick-fix-xml-file-parser.js +6 -6
- package/dist/dictionary/parser/quickfix/quick-fix-xml-file-parser.js.map +1 -1
- package/dist/dictionary/parser/quickfix/quick-fix-xml-formatter.d.ts +1 -1
- package/dist/dictionary/parser/quickfix/quick-fix-xml-formatter.js.map +1 -1
- package/dist/dictionary/set-reduce.d.ts +2 -2
- package/dist/dictionary/set-reduce.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/jsfix-cmd.js +4 -5
- package/dist/jsfix-cmd.js.map +1 -1
- package/dist/sample/tcp/recovering-skeleton/respawn-acceptor.js +7 -8
- package/dist/sample/tcp/recovering-skeleton/respawn-acceptor.js.map +1 -1
- package/dist/sample/tcp/trade-capture/trade-capture-client.js +3 -4
- package/dist/sample/tcp/trade-capture/trade-capture-client.js.map +1 -1
- package/dist/sample/tcp/trade-capture/trade-capture-server.js.map +1 -1
- package/dist/store/fix-msg-ascii-store-resend.d.ts +4 -3
- package/dist/store/fix-msg-ascii-store-resend.js +21 -5
- package/dist/store/fix-msg-ascii-store-resend.js.map +1 -1
- package/dist/store/fix-msg-memory-store.js +3 -4
- package/dist/store/fix-msg-memory-store.js.map +1 -1
- package/dist/store/fix-msg-store-record.js.map +1 -1
- package/dist/test/ascii/ascii-encoder.test.js.map +1 -1
- package/dist/test/ascii/ascii-store-replay.test.js +14 -1
- package/dist/test/ascii/ascii-store-replay.test.js.map +1 -1
- package/dist/test/ascii/fix-log-replay.test.js.map +1 -1
- package/dist/test/ascii/fix-repo-dict.test.js.map +1 -1
- package/dist/test/ascii/qf-50sp0-dict.test.js +7 -7
- package/dist/test/ascii/qf-50sp0-dict.test.js.map +1 -1
- package/dist/test/ascii/qf-50sp2-dict.test.js +5 -2
- package/dist/test/ascii/qf-50sp2-dict.test.js.map +1 -1
- package/dist/test/ascii/session.test.js +64 -15
- package/dist/test/ascii/session.test.js.map +1 -1
- package/dist/test/env/encoder-test.d.ts +3 -3
- package/dist/test/env/encoder-test.js.map +1 -1
- package/dist/test/env/set-constraint-helper.d.ts +4 -4
- package/dist/test/env/set-constraint-helper.js.map +1 -1
- package/dist/transport/ascii/ascii-msg-transmitter.js.map +1 -1
- package/dist/transport/ascii/ascii-session.js +5 -2
- package/dist/transport/ascii/ascii-session.js.map +1 -1
- package/dist/transport/fixml/fixml-session.js.map +1 -1
- package/dist/transport/http/http-acceptor.js +3 -4
- package/dist/transport/http/http-acceptor.js.map +1 -1
- package/dist/transport/http/http-json-sample-adapter.js +3 -4
- package/dist/transport/http/http-json-sample-adapter.js.map +1 -1
- package/dist/transport/session/dynamic-session-manager.d.ts +8 -0
- package/dist/transport/session/dynamic-session-manager.js +15 -0
- package/dist/transport/session/dynamic-session-manager.js.map +1 -0
- package/dist/transport/session/session-description.d.ts +9 -7
- package/dist/transport/session/session-description.js.map +1 -1
- package/dist/util/json-helper.d.ts +2 -2
- package/dist/util/json-helper.js.map +1 -1
- package/dist/util/message-generator.js +1 -1
- package/dist/util/message-generator.js.map +1 -1
- package/package.json +21 -21
- package/src/buffer/ascii/ascii-encoder.ts +7 -7
- package/src/buffer/ascii/ascii-parser-state.ts +4 -4
- package/src/buffer/ascii/ascii-parser.ts +6 -5
- package/src/buffer/ascii/ascii-segment-parser.ts +2 -2
- package/src/buffer/ascii/ascii-view.ts +9 -7
- package/src/buffer/encode-proxy.ts +9 -9
- package/src/buffer/fixml/fixml-encoder.ts +14 -10
- package/src/buffer/fixml/fixml-parser.ts +5 -5
- package/src/buffer/fixml/fixml-view.ts +5 -5
- package/src/buffer/msg-encoder.ts +3 -3
- package/src/buffer/msg-view.ts +18 -18
- package/src/buffer/segment/segment-description.ts +2 -2
- package/src/buffer/tag/tags.ts +4 -6
- package/src/collections/collection.ts +0 -1
- package/src/collections/index.ts +1 -1
- package/src/config/js-fix-config.ts +3 -2
- package/src/dictionary/compiler/compiler-type.ts +8 -2
- package/src/dictionary/compiler/enum-compiler.ts +2 -2
- package/src/dictionary/compiler/msg-compiler.ts +11 -12
- package/src/dictionary/contained/contained-component-field.ts +1 -1
- package/src/dictionary/contained/contained-field-set.ts +21 -176
- package/src/dictionary/contained/contained-group-field.ts +1 -1
- package/src/dictionary/contained/contained-set-builder.ts +164 -0
- package/src/dictionary/contained/contained-set.ts +83 -0
- package/src/dictionary/contained/contained-simple-field.ts +1 -1
- package/src/dictionary/contained/index.ts +4 -1
- package/src/dictionary/definition/category-simple-set.ts +1 -2
- package/src/dictionary/definition/component-field-definition.ts +1 -1
- package/src/dictionary/definition/fix-definitions.ts +28 -26
- package/src/dictionary/definition/group-field-definition.ts +1 -1
- package/src/dictionary/definition/message-definition.ts +6 -6
- package/src/dictionary/definition/simple-field-definition.ts +9 -10
- package/src/dictionary/parser/fix-repository/repository.ts +47 -40
- package/src/dictionary/parser/fixml/components-parser.ts +41 -38
- package/src/dictionary/parser/fixml/fields-parser.ts +3 -4
- package/src/dictionary/parser/fixml/include-graph.ts +13 -14
- package/src/dictionary/parser/quickfix/field-definition-parser.ts +5 -5
- package/src/dictionary/parser/quickfix/message-parser.ts +7 -5
- package/src/dictionary/parser/quickfix/node-parser.ts +13 -6
- package/src/dictionary/parser/quickfix/parse-context.ts +2 -2
- package/src/dictionary/parser/quickfix/parse-progress.ts +2 -3
- package/src/dictionary/parser/quickfix/quick-fix-xml-file-builder.ts +4 -5
- package/src/dictionary/parser/quickfix/quick-fix-xml-file-parser.ts +10 -12
- package/src/dictionary/parser/quickfix/quick-fix-xml-formatter.ts +1 -1
- package/src/dictionary/set-reduce.ts +3 -3
- package/src/index.ts +0 -1
- package/src/jsfix-cmd.ts +5 -6
- package/src/sample/tcp/recovering-skeleton/respawn-acceptor.ts +7 -8
- package/src/sample/tcp/trade-capture/trade-capture-client.ts +4 -5
- package/src/sample/tcp/trade-capture/trade-capture-server.ts +1 -1
- package/src/store/fix-msg-ascii-store-resend.ts +64 -8
- package/src/store/fix-msg-memory-store.ts +3 -4
- package/src/store/fix-msg-store-record.ts +1 -1
- package/src/transport/ascii/ascii-msg-transmitter.ts +6 -6
- package/src/transport/ascii/ascii-session.ts +11 -7
- package/src/transport/fixml/fixml-session.ts +3 -3
- package/src/transport/http/http-acceptor.ts +4 -5
- package/src/transport/http/http-json-sample-adapter.ts +3 -4
- package/src/transport/session/dynamic-session-manager.ts +16 -0
- package/src/transport/session/session-description.ts +10 -7
- package/src/util/json-helper.ts +3 -3
- package/src/util/message-generator.ts +4 -4
- package/dist/collections/dictionary.d.ts +0 -15
- package/dist/collections/dictionary.js +0 -57
- package/dist/collections/dictionary.js.map +0 -1
- package/dist/types/FIX.5.0SP2/quickfix/execution_acknowledgement.d.ts +0 -31
- package/dist/types/FIX.5.0SP2/quickfix/execution_acknowledgement.js +0 -3
- package/dist/types/FIX.5.0SP2/quickfix/execution_acknowledgement.js.map +0 -1
- package/dist/types/FIX.5.0SP2/quickfix/mass_quote_acknowledgement.d.ts +0 -26
- package/dist/types/FIX.5.0SP2/quickfix/mass_quote_acknowledgement.js +0 -3
- package/dist/types/FIX.5.0SP2/quickfix/mass_quote_acknowledgement.js.map +0 -1
- package/dist/types/FIX.5.0SP2/quickfix/set/hop_grp.d.ts +0 -5
- package/dist/types/FIX.5.0SP2/quickfix/set/hop_grp.js +0 -3
- package/dist/types/FIX.5.0SP2/quickfix/set/hop_grp.js.map +0 -1
- package/dist/types/FIX.5.0SP2/quickfix/set/msg_type_grp.d.ts +0 -8
- package/dist/types/FIX.5.0SP2/quickfix/set/msg_type_grp.js +0 -3
- package/dist/types/FIX.5.0SP2/quickfix/set/msg_type_grp.js.map +0 -1
- package/dist/types/FIX.5.0SP2/quickfix/set/not_affected_orders_grp.d.ts +0 -4
- package/dist/types/FIX.5.0SP2/quickfix/set/not_affected_orders_grp.js +0 -3
- package/dist/types/FIX.5.0SP2/quickfix/set/not_affected_orders_grp.js.map +0 -1
- package/dist/types/FIX.5.0SP2/quickfix/xm_lnon_fix.d.ts +0 -6
- package/dist/types/FIX.5.0SP2/quickfix/xm_lnon_fix.js.map +0 -1
- package/src/collections/dictionary.ts +0 -62
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-generator.js","sourceRoot":"","sources":["../../src/util/message-generator.ts"],"names":[],"mappings":";;;AAGA,8CAAyC;AACzC,qDAAgD;AAEhD,MAAa,gBAAgB;IAI3B,YAA6B,KAAe,EAAkB,WAA2B;QAA5D,UAAK,GAAL,KAAK,CAAU;QAAkB,gBAAW,GAAX,WAAW,CAAgB;QAHjF,SAAI,GAAW,CAAC,CAAA;QAChB,WAAM,GAAW,CAAC,CAAA;IAG1B,CAAC;IAEM,MAAM,CAAC,aAAa,CAAE,KAA4B;QACvD,MAAM,OAAO,GAAY,KAAK,CAAC,OAAO,CAAA;QACtC,MAAM,IAAI,GAAa,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;QACzC,MAAM,MAAM,GAAW,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;QACpE,QAAQ,OAAO,EAAE,CAAC;YAChB,KAAK,kBAAO,CAAC,GAAG,CAAC,CAAC,CAAC;gBACjB,OAAO,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;YAC7B,CAAC;YACD,KAAK,kBAAO,CAAC,KAAK,CAAC,CAAC,CAAC;gBACnB,OAAO,UAAU,CAAC,MAAM,CAAC,CAAA;YAC3B,CAAC;YACD,KAAK,kBAAO,CAAC,OAAO,CAAC,CAAC,CAAC;gBACrB,OAAO,MAAM,KAAK,GAAG,CAAA;YACvB,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACR,OAAO,MAAM,CAAA;YACf,CAAC;QACH,CAAC;IACH,CAAC;IAEO,MAAM,CAAC,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AAA;YAClD,CAAC;QACH,CAAC;IACH,CAAC;IAEO,UAAU;QAChB,MAAM,KAAK,GAAa,IAAI,CAAC,KAAK,CAAA;QAClC,MAAM,CAAC,GAAW,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;QACpC,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;YAC/B,IAAI,CAAC,IAAI,GAAG,CAAC,CAAA;QACf,CAAC;QACD,OAAO,CAAC,CAAA;IACV,CAAC;CACF;AAzKD,4CAyKC","sourcesContent":["import { ILooseObject } from '../collections/collection'\r\nimport { ContainedComponentField, ContainedGroupField, ContainedFieldSet, ContainedSimpleField } from '../dictionary/contained'\r\nimport { FixDefinitions, MessageDefinition, SimpleFieldDefinition } from '../dictionary/definition'\r\nimport { SetReduce } from '../dictionary'\r\nimport { TagType } from '../buffer/tag/tag-type'\r\n\r\nexport class MessageGenerator {\r\n private word: number = 0\r\n private length: number = 0\r\n\r\n constructor (public readonly words: string[], public readonly definitions: FixDefinitions) {\r\n }\r\n\r\n public static getRandomEnum (field: SimpleFieldDefinition): any {\r\n const tagType: TagType = field.tagType\r\n const keys: string[] = field.enums.keys()\r\n const choice: string = keys[Math.floor(Math.random() * keys.length)]\r\n switch (tagType) {\r\n case TagType.Int: {\r\n return parseInt(choice, 10)\r\n }\r\n case TagType.Float: {\r\n return parseFloat(choice)\r\n }\r\n case TagType.Boolean: {\r\n return choice === 'Y'\r\n }\r\n default: {\r\n return choice\r\n }\r\n }\r\n }\r\n\r\n private static randomIntFromInterval (min: number, max: number): number {\r\n return Math.floor(Math.random() * (max - min + 1) + min)\r\n }\r\n\r\n private static makeRandomString (len: number): string {\r\n let text: string = ''\r\n const possible: string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'\r\n\r\n for (let i: number = 0; i < len; i++) {\r\n text += possible.charAt(Math.floor(Math.random() * possible.length))\r\n }\r\n\r\n return text\r\n }\r\n\r\n private static makeBuffer (len: number): Buffer {\r\n return Buffer.from(MessageGenerator.makeRandomString(len))\r\n }\r\n\r\n public generate (msgType: string, density?: number, repeatGroups: boolean = true): ILooseObject {\r\n if (!density) {\r\n density = 1.0\r\n }\r\n density = Math.max(0.2, density)\r\n density = Math.min(1.0, density)\r\n const def: MessageDefinition | null = this.definitions.message.get(msgType)\r\n if (!def) {\r\n throw new Error(`definitions do not contain type ${msgType}`)\r\n }\r\n return this.toObject(def, density, repeatGroups)\r\n }\r\n\r\n private toObject (set: ContainedFieldSet, density: number, repeatGroups: boolean): ILooseObject {\r\n const reducer = new SetReduce<ILooseObject>()\r\n return reducer.reduce(set, {\r\n simple: (a: ILooseObject, sf: ContainedSimpleField) => {\r\n const tag: number = sf.definition.tag\r\n const include = tag === set.firstSimple?.definition.tag || this.length > 0 || Math.random() <= density\r\n if (include) {\r\n const val: any = sf.definition.isEnum() ? MessageGenerator.getRandomEnum(sf.definition) : this.createSimple(sf)\r\n if (val != null) {\r\n a[sf.name] = val\r\n }\r\n }\r\n },\r\n component: (a: ILooseObject, cf: ContainedComponentField) => {\r\n if (cf.name !== 'StandardHeader' && cf.name !== 'StandardTrailer') {\r\n a[cf.name] = this.toObject(cf.definition, density, repeatGroups)\r\n }\r\n },\r\n group: (a: ILooseObject, gf: ContainedGroupField) => {\r\n if (repeatGroups) {\r\n const numberGroups: number = MessageGenerator.randomIntFromInterval(1, 3)\r\n const arr: ILooseObject[] = new Array(numberGroups)\r\n a[gf.name] = arr\r\n for (let j: number = 0; j < numberGroups; ++j) {\r\n arr[j] = this.toObject(gf.definition, density, repeatGroups)\r\n }\r\n }\r\n }\r\n }, {})\r\n }\r\n\r\n private createSimple (field: ContainedSimpleField): any {\r\n const tagType: TagType = field.definition.tagType\r\n switch (tagType) {\r\n case TagType.String: {\r\n return this.nextString()\r\n }\r\n\r\n case TagType.Float: {\r\n this.length = 0\r\n const sign = MessageGenerator.randomIntFromInterval(1, 10) <= 5 ? 1 : -1\r\n const num = sign * MessageGenerator.randomIntFromInterval(1, 100000)\r\n const raised = MessageGenerator.randomIntFromInterval(1, 8)\r\n const r = num * Math.pow(10, -1 * raised)\r\n // console.log(`sign = ${sign} num = ${num} raised = ${raised} r = ${r} ret = ${ret}`)\r\n return Math.round(r * 1e7) / 1e7\r\n }\r\n\r\n case TagType.Int: {\r\n this.length = 0\r\n return MessageGenerator.randomIntFromInterval(1, 100000)\r\n }\r\n\r\n case TagType.Length: {\r\n this.length = MessageGenerator.randomIntFromInterval(5, 20)\r\n return this.length\r\n }\r\n\r\n case TagType.Boolean: {\r\n this.length = 0\r\n return MessageGenerator.randomIntFromInterval(1, 2) === 1\r\n }\r\n\r\n case TagType.UtcDateOnly: {\r\n this.length = 0\r\n const now: Date = new Date()\r\n return new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate()\r\n , 0, 0, 0, 0))\r\n }\r\n\r\n case TagType.UtcTimeOnly: {\r\n this.length = 0\r\n const s: Date = new Date()\r\n return new Date(Date.UTC(0, 0, 0, s.getUTCHours(), s.getUTCMinutes(),\r\n s.getUTCSeconds(), s.getUTCMilliseconds()))\r\n }\r\n\r\n case TagType.UtcTimestamp: {\r\n this.length = 0\r\n const now: Date = new Date()\r\n return new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(),\r\n now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds()))\r\n }\r\n\r\n case TagType.LocalDate: {\r\n const now = new Date()\r\n return new Date(now.getFullYear(), now.getMonth(), now.getDate()\r\n , 0, 0, 0, 0)\r\n }\r\n\r\n case TagType.RawData: {\r\n const length = this.length\r\n this.length = 0\r\n return length > 0 ? MessageGenerator.makeBuffer(length) : null\r\n }\r\n\r\n default: {\r\n throw new Error(`cannot manage type ${tagType}`)\r\n }\r\n }\r\n }\r\n\r\n private nextString (): string {\r\n const words: string[] = this.words\r\n const w: string = words[this.word++]\r\n if (this.word === words.length) {\r\n this.word = 0\r\n }\r\n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I,CAAC,IAAI,EAAE,CAAC,CAAA;QACpC,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;YAC/B,IAAI,CAAC,IAAI,GAAG,CAAC,CAAA;QACf,CAAC;QACD,OAAO,CAAC,CAAA;IACV,CAAC;CACF;AAzKD,4CAyKC","sourcesContent":["import { ILooseObject } from '../collections/collection'\r\nimport { ContainedComponentField, ContainedGroupField, IContainedSet, ContainedSimpleField } from '../dictionary/contained'\r\nimport { FixDefinitions, MessageDefinition, SimpleFieldDefinition } from '../dictionary/definition'\r\nimport { SetReduce } from '../dictionary'\r\nimport { TagType } from '../buffer/tag/tag-type'\r\n\r\nexport class MessageGenerator {\r\n private word: number = 0\r\n private length: number = 0\r\n\r\n constructor (public readonly words: string[], public readonly definitions: FixDefinitions) {\r\n }\r\n\r\n public static getRandomEnum (field: SimpleFieldDefinition): any {\r\n const tagType: TagType = field.tagType\r\n const keys: string[] = Array.from(field.enums.keys())\r\n const choice: string = keys[Math.floor(Math.random() * keys.length)]\r\n switch (tagType) {\r\n case TagType.Int: {\r\n return parseInt(choice, 10)\r\n }\r\n case TagType.Float: {\r\n return parseFloat(choice)\r\n }\r\n case TagType.Boolean: {\r\n return choice === 'Y'\r\n }\r\n default: {\r\n return choice\r\n }\r\n }\r\n }\r\n\r\n private static randomIntFromInterval (min: number, max: number): number {\r\n return Math.floor(Math.random() * (max - min + 1) + min)\r\n }\r\n\r\n private static makeRandomString (len: number): string {\r\n let text: string = ''\r\n const possible: string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'\r\n\r\n for (let i: number = 0; i < len; i++) {\r\n text += possible.charAt(Math.floor(Math.random() * possible.length))\r\n }\r\n\r\n return text\r\n }\r\n\r\n private static makeBuffer (len: number): Buffer {\r\n return Buffer.from(MessageGenerator.makeRandomString(len))\r\n }\r\n\r\n public generate (msgType: string, density?: number, repeatGroups: boolean = true): ILooseObject {\r\n if (!density) {\r\n density = 1.0\r\n }\r\n density = Math.max(0.2, density)\r\n density = Math.min(1.0, density)\r\n const def: MessageDefinition | undefined = this.definitions.message.get(msgType)\r\n if (!def) {\r\n throw new Error(`definitions do not contain type ${msgType}`)\r\n }\r\n return this.toObject(def, density, repeatGroups)\r\n }\r\n\r\n private toObject (set: IContainedSet, density: number, repeatGroups: boolean): ILooseObject {\r\n const reducer = new SetReduce<ILooseObject>()\r\n return reducer.reduce(set, {\r\n simple: (a: ILooseObject, sf: ContainedSimpleField) => {\r\n const tag: number = sf.definition.tag\r\n const include = tag === set.firstSimple?.definition.tag || this.length > 0 || Math.random() <= density\r\n if (include) {\r\n const val: any = sf.definition.isEnum() ? MessageGenerator.getRandomEnum(sf.definition) : this.createSimple(sf)\r\n if (val != null) {\r\n a[sf.name] = val\r\n }\r\n }\r\n },\r\n component: (a: ILooseObject, cf: ContainedComponentField) => {\r\n if (cf.name !== 'StandardHeader' && cf.name !== 'StandardTrailer') {\r\n a[cf.name] = this.toObject(cf.definition, density, repeatGroups)\r\n }\r\n },\r\n group: (a: ILooseObject, gf: ContainedGroupField) => {\r\n if (repeatGroups) {\r\n const numberGroups: number = MessageGenerator.randomIntFromInterval(1, 3)\r\n const arr: ILooseObject[] = new Array(numberGroups)\r\n a[gf.name] = arr\r\n for (let j: number = 0; j < numberGroups; ++j) {\r\n arr[j] = this.toObject(gf.definition, density, repeatGroups)\r\n }\r\n }\r\n }\r\n }, {})\r\n }\r\n\r\n private createSimple (field: ContainedSimpleField): any {\r\n const tagType: TagType = field.definition.tagType\r\n switch (tagType) {\r\n case TagType.String: {\r\n return this.nextString()\r\n }\r\n\r\n case TagType.Float: {\r\n this.length = 0\r\n const sign = MessageGenerator.randomIntFromInterval(1, 10) <= 5 ? 1 : -1\r\n const num = sign * MessageGenerator.randomIntFromInterval(1, 100000)\r\n const raised = MessageGenerator.randomIntFromInterval(1, 8)\r\n const r = num * Math.pow(10, -1 * raised)\r\n // console.log(`sign = ${sign} num = ${num} raised = ${raised} r = ${r} ret = ${ret}`)\r\n return Math.round(r * 1e7) / 1e7\r\n }\r\n\r\n case TagType.Int: {\r\n this.length = 0\r\n return MessageGenerator.randomIntFromInterval(1, 100000)\r\n }\r\n\r\n case TagType.Length: {\r\n this.length = MessageGenerator.randomIntFromInterval(5, 20)\r\n return this.length\r\n }\r\n\r\n case TagType.Boolean: {\r\n this.length = 0\r\n return MessageGenerator.randomIntFromInterval(1, 2) === 1\r\n }\r\n\r\n case TagType.UtcDateOnly: {\r\n this.length = 0\r\n const now: Date = new Date()\r\n return new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate()\r\n , 0, 0, 0, 0))\r\n }\r\n\r\n case TagType.UtcTimeOnly: {\r\n this.length = 0\r\n const s: Date = new Date()\r\n return new Date(Date.UTC(0, 0, 0, s.getUTCHours(), s.getUTCMinutes(),\r\n s.getUTCSeconds(), s.getUTCMilliseconds()))\r\n }\r\n\r\n case TagType.UtcTimestamp: {\r\n this.length = 0\r\n const now: Date = new Date()\r\n return new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(),\r\n now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds()))\r\n }\r\n\r\n case TagType.LocalDate: {\r\n const now = new Date()\r\n return new Date(now.getFullYear(), now.getMonth(), now.getDate()\r\n , 0, 0, 0, 0)\r\n }\r\n\r\n case TagType.RawData: {\r\n const length = this.length\r\n this.length = 0\r\n return length > 0 ? MessageGenerator.makeBuffer(length) : null\r\n }\r\n\r\n default: {\r\n throw new Error(`cannot manage type ${tagType}`)\r\n }\r\n }\r\n }\r\n\r\n private nextString (): string {\r\n const words: string[] = this.words\r\n const w: string = words[this.word++]\r\n if (this.word === words.length) {\r\n this.word = 0\r\n }\r\n return w\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jspurefix",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "pure node js fix engine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -75,42 +75,42 @@
|
|
|
75
75
|
"license": "MIT",
|
|
76
76
|
"dependencies": {
|
|
77
77
|
"align-text": "^1.0.2",
|
|
78
|
-
"axios": "^1.
|
|
79
|
-
"express": "^4.
|
|
78
|
+
"axios": "^1.7.5",
|
|
79
|
+
"express": "^4.19.2",
|
|
80
80
|
"lodash": "^4.17.21",
|
|
81
|
-
"mathjs": "^
|
|
81
|
+
"mathjs": "^13.0.3",
|
|
82
82
|
"minimist": "^1.2.8",
|
|
83
83
|
"minimist-options": "^4.1.0",
|
|
84
|
-
"moment": "^2.
|
|
84
|
+
"moment": "^2.30.1",
|
|
85
85
|
"node-fs-extra": "^0.8.2",
|
|
86
|
-
"reflect-metadata": "^0.
|
|
87
|
-
"sax": "^1.
|
|
86
|
+
"reflect-metadata": "^0.2.2",
|
|
87
|
+
"sax": "^1.4.1",
|
|
88
88
|
"tsyringe": "^4.8.0",
|
|
89
89
|
"uuid": "^9.0.1",
|
|
90
|
-
"winston": "^3.
|
|
90
|
+
"winston": "^3.14.2",
|
|
91
91
|
"word-wrap": "^1.2.5",
|
|
92
|
-
"yauzl": "^
|
|
92
|
+
"yauzl": "^3.1.3"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
95
|
"@types/express": "^4.17.21",
|
|
96
|
-
"@types/express-serve-static-core": "^4.
|
|
97
|
-
"@types/jest": "^29.5.
|
|
98
|
-
"@types/lodash": "^4.
|
|
99
|
-
"@types/mathjs": "^9.4.
|
|
96
|
+
"@types/express-serve-static-core": "^4.19.5",
|
|
97
|
+
"@types/jest": "^29.5.12",
|
|
98
|
+
"@types/lodash": "^4.17.7",
|
|
99
|
+
"@types/mathjs": "^9.4.2",
|
|
100
100
|
"@types/minimist": "^1.2.5",
|
|
101
|
-
"@types/node": "^
|
|
101
|
+
"@types/node": "^22.5.0",
|
|
102
102
|
"@types/request-promise-native": "^1.0.21",
|
|
103
103
|
"@types/sax": "^1.2.7",
|
|
104
104
|
"@types/uuid": "^9.0.7",
|
|
105
105
|
"@types/winston": "^2.4.4",
|
|
106
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
107
|
-
"@typescript-eslint/parser": "^6.
|
|
108
|
-
"eslint": "^8.
|
|
109
|
-
"eslint-config-standard-with-typescript": "^
|
|
106
|
+
"@typescript-eslint/eslint-plugin": "^6.19.0",
|
|
107
|
+
"@typescript-eslint/parser": "^6.19.0",
|
|
108
|
+
"eslint": "^8.56.0",
|
|
109
|
+
"eslint-config-standard-with-typescript": "^43.0.1",
|
|
110
110
|
"jest": "^29.7.0",
|
|
111
|
-
"madge": "^
|
|
111
|
+
"madge": "^8.0.0",
|
|
112
112
|
"standard": "^17.1.0",
|
|
113
|
-
"ts-jest": "^29.
|
|
114
|
-
"typescript": "^5.
|
|
113
|
+
"ts-jest": "^29.2.5",
|
|
114
|
+
"typescript": "^5.5.4"
|
|
115
115
|
}
|
|
116
116
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ILooseObject } from '../../collections/collection'
|
|
2
2
|
import {
|
|
3
3
|
ContainedGroupField, ContainedSimpleField,
|
|
4
|
-
|
|
4
|
+
IContainedSet, ContainedField,
|
|
5
5
|
ContainedComponentField, FieldsDispatch
|
|
6
6
|
} from '../../dictionary/contained'
|
|
7
7
|
import { SimpleFieldDefinition, FixDefinitions } from '../../dictionary/definition'
|
|
@@ -26,7 +26,7 @@ export class AsciiEncoder extends MsgEncoder {
|
|
|
26
26
|
public readonly delimiter: number = AsciiChars.Soh,
|
|
27
27
|
public readonly logDelimiter: number = AsciiChars.Pipe) {
|
|
28
28
|
super(definitions)
|
|
29
|
-
this.tags = new Tags(
|
|
29
|
+
this.tags = new Tags()
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
public trim (): Buffer {
|
|
@@ -51,12 +51,12 @@ export class AsciiEncoder extends MsgEncoder {
|
|
|
51
51
|
this.tags.reset()
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
public encodeSet (objectToEncode: ILooseObject, set:
|
|
54
|
+
public encodeSet (objectToEncode: ILooseObject, set: IContainedSet): void {
|
|
55
55
|
const summary: AsciiEncodeSetSummary = new AsciiEncodeSetSummary()
|
|
56
56
|
this.encodeObject(objectToEncode, set, summary)
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
private encodeObject (objectToEncode: ILooseObject, set:
|
|
59
|
+
private encodeObject (objectToEncode: ILooseObject, set: IContainedSet, state: AsciiEncodeSetSummary): void {
|
|
60
60
|
const fields: ContainedField[] = this.getFields(set, objectToEncode)
|
|
61
61
|
this.dispatcher.dispatchFields(fields, {
|
|
62
62
|
simple: (sf: ContainedSimpleField) => {
|
|
@@ -83,11 +83,11 @@ export class AsciiEncoder extends MsgEncoder {
|
|
|
83
83
|
})
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
private getFields (set:
|
|
86
|
+
private getFields (set: IContainedSet, o: ILooseObject): ContainedField[] {
|
|
87
87
|
const keys: string[] = Object.keys(o)
|
|
88
88
|
let j: number = 0
|
|
89
89
|
const fields: ContainedField[] = keys.reduce((a: ContainedField[], current: string) => {
|
|
90
|
-
const field
|
|
90
|
+
const field = set.localNameToField.get(current)
|
|
91
91
|
if (field) {
|
|
92
92
|
a[j++] = field
|
|
93
93
|
}
|
|
@@ -140,7 +140,7 @@ export class AsciiEncoder extends MsgEncoder {
|
|
|
140
140
|
buffer.writeChar(delimiter)
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
private encodeSimple (o: ILooseObject, set:
|
|
143
|
+
private encodeSimple (o: ILooseObject, set: IContainedSet, sf: ContainedSimpleField, val: any): void {
|
|
144
144
|
const definition = sf.definition
|
|
145
145
|
const tag: number = definition.tag
|
|
146
146
|
const buffer = this.buffer
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Tags } from '../tag/tags'
|
|
2
|
-
import { MessageDefinition } from '../../dictionary/definition'
|
|
2
|
+
import { FixDefinitions, MessageDefinition } from '../../dictionary/definition'
|
|
3
3
|
import { ElasticBuffer } from '../elastic-buffer'
|
|
4
4
|
import { ParseState } from './parse-state'
|
|
5
5
|
import { inject, injectable } from 'tsyringe'
|
|
@@ -7,7 +7,7 @@ import { DITokens } from '../../runtime/di-tokens'
|
|
|
7
7
|
|
|
8
8
|
@injectable()
|
|
9
9
|
export class AsciiParserState {
|
|
10
|
-
public message: MessageDefinition |
|
|
10
|
+
public message: MessageDefinition | undefined
|
|
11
11
|
public locations: Tags
|
|
12
12
|
public parseState: ParseState
|
|
13
13
|
public bodyLen: number
|
|
@@ -19,6 +19,7 @@ export class AsciiParserState {
|
|
|
19
19
|
public currentTag: number
|
|
20
20
|
public rawDataLen: number
|
|
21
21
|
public rawDataRead: number
|
|
22
|
+
public definitions: FixDefinitions
|
|
22
23
|
public msgType: string | null
|
|
23
24
|
|
|
24
25
|
constructor (@inject(DITokens.ParseBuffer) public readonly elasticBuffer: ElasticBuffer) {
|
|
@@ -126,7 +127,7 @@ export class AsciiParserState {
|
|
|
126
127
|
throw new Error(`MsgTag: not expected at position [${nextTagPos}]`)
|
|
127
128
|
}
|
|
128
129
|
this.msgType = buffer.getString(equalPos + 1, valueEndPos)
|
|
129
|
-
this.message =
|
|
130
|
+
this.message = this.definitions.message.get(this.msgType)
|
|
130
131
|
break
|
|
131
132
|
}
|
|
132
133
|
|
|
@@ -181,7 +182,6 @@ export class AsciiParserState {
|
|
|
181
182
|
this.rawDataRead = 0
|
|
182
183
|
this.rawDataLen = 0
|
|
183
184
|
this.bodyLen = 0
|
|
184
|
-
this.message = null
|
|
185
185
|
this.msgType = null
|
|
186
186
|
}
|
|
187
187
|
}
|
|
@@ -10,7 +10,7 @@ import { Readable } from 'stream'
|
|
|
10
10
|
import { ElasticBuffer } from '../elastic-buffer'
|
|
11
11
|
import { SegmentDescription } from '../segment/segment-description'
|
|
12
12
|
import { ParseState } from './parse-state'
|
|
13
|
-
import { IJsFixConfig } from '../../config'
|
|
13
|
+
import { IJsFixConfig } from '../../config/js-fix-config'
|
|
14
14
|
import { inject, injectable } from 'tsyringe'
|
|
15
15
|
import { DITokens } from '../../runtime/di-tokens'
|
|
16
16
|
import { SegmentType } from '../segment/segment-type'
|
|
@@ -35,11 +35,11 @@ export class AsciiParser extends MsgParser {
|
|
|
35
35
|
|
|
36
36
|
this.delimiter = config.delimiter ?? AsciiChars.Soh
|
|
37
37
|
this.writeDelimiter = config.logDelimiter ?? AsciiChars.Pipe
|
|
38
|
-
const definitions = config.definitions
|
|
39
38
|
this.id = AsciiParser.nextId++
|
|
40
39
|
this.segmentParser = config.sessionContainer.resolve<AsciiSegmentParser>(AsciiSegmentParser)
|
|
41
40
|
this.state = config.sessionContainer.resolve<AsciiParserState>(AsciiParserState)
|
|
42
|
-
this.state.locations = new Tags(
|
|
41
|
+
this.state.locations = new Tags(this.receivingBuffer.size / 10)
|
|
42
|
+
this.state.definitions = this.config.definitions
|
|
43
43
|
this.state.beginMessage()
|
|
44
44
|
if (readStream !== null) {
|
|
45
45
|
this.subscribe()
|
|
@@ -181,6 +181,7 @@ export class AsciiParser extends MsgParser {
|
|
|
181
181
|
const locations = state.locations
|
|
182
182
|
const source = this.receivingBuffer
|
|
183
183
|
const delimiter = this.delimiter
|
|
184
|
+
const definitions = this.config.definitions
|
|
184
185
|
const replace = this.writeDelimiter
|
|
185
186
|
const msgType = state.msgType ?? null
|
|
186
187
|
if (!msgType) return null
|
|
@@ -189,7 +190,7 @@ export class AsciiParser extends MsgParser {
|
|
|
189
190
|
const structure: Structure | null = this.segmentParser.parse(msgType, locations,
|
|
190
191
|
locations.nextTagPos - 1)
|
|
191
192
|
if (!structure) return null
|
|
192
|
-
return new AsciiView(structure.msg(),
|
|
193
|
+
return new AsciiView(definitions, structure.msg(),
|
|
193
194
|
source,
|
|
194
195
|
structure,
|
|
195
196
|
ptr,
|
|
@@ -207,6 +208,6 @@ export class AsciiParser extends MsgParser {
|
|
|
207
208
|
const structure = new Structure(locations, [])
|
|
208
209
|
const segment = new SegmentDescription('unknown', locations.tagPos[0].tag, null, 0, 1, SegmentType.Unknown)
|
|
209
210
|
segment.endPosition = locations.nextTagPos - 1
|
|
210
|
-
return new AsciiView(segment, source, structure, ptr, delimiter, replace)
|
|
211
|
+
return new AsciiView(this.config.definitions, segment, source, structure, ptr, delimiter, replace)
|
|
211
212
|
}
|
|
212
213
|
}
|
|
@@ -28,7 +28,7 @@ export class AsciiSegmentParser {
|
|
|
28
28
|
public parse (msgType: string, tags: Tags, last: number): Structure | null {
|
|
29
29
|
// completed segments in that they are fully parsed
|
|
30
30
|
const segments: SegmentDescription[] = []
|
|
31
|
-
const msgDefinition: MessageDefinition |
|
|
31
|
+
const msgDefinition: MessageDefinition | undefined = this.definitions.message.get(msgType)
|
|
32
32
|
if (!msgDefinition) {
|
|
33
33
|
return null
|
|
34
34
|
}
|
|
@@ -58,7 +58,7 @@ export class AsciiSegmentParser {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
function summarise ():
|
|
61
|
+
function summarise (): AsciiSegmentParserSummary {
|
|
62
62
|
return <AsciiSegmentParserSummary>{
|
|
63
63
|
msgType,
|
|
64
64
|
tags: tags.clone().tagPos,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SimpleFieldDefinition } from '../../dictionary/definition'
|
|
1
|
+
import { FixDefinitions, SimpleFieldDefinition } from '../../dictionary/definition'
|
|
2
2
|
import { SegmentDescription } from '../segment/segment-description'
|
|
3
3
|
import { Structure } from '../structure'
|
|
4
4
|
import { MsgView } from '../msg-view'
|
|
@@ -11,13 +11,13 @@ import { TagType } from '../tag/tag-type'
|
|
|
11
11
|
|
|
12
12
|
export class AsciiView extends MsgView {
|
|
13
13
|
private readonly timeFormatter: ITimeFormatter = new TimeFormatter(this.buffer)
|
|
14
|
-
constructor (public readonly segment: SegmentDescription,
|
|
14
|
+
constructor (public readonly definitions: FixDefinitions, public readonly segment: SegmentDescription,
|
|
15
15
|
public readonly buffer: ElasticBuffer,
|
|
16
16
|
public readonly structure: Structure | null,
|
|
17
17
|
public readonly ptr: number,
|
|
18
18
|
public readonly delimiter: number,
|
|
19
19
|
public readonly writeDelimiter: number) {
|
|
20
|
-
super(segment, structure)
|
|
20
|
+
super(definitions, segment, structure)
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
// if the view is to be kept beyond the event on which it arrives, must be cloned
|
|
@@ -26,11 +26,12 @@ export class AsciiView extends MsgView {
|
|
|
26
26
|
const buffer = this.buffer.clone()
|
|
27
27
|
const segment = this.segment
|
|
28
28
|
const delimiter = this.delimiter
|
|
29
|
+
const definitions = this.definitions
|
|
29
30
|
const writeDelimiter = this.writeDelimiter
|
|
30
31
|
if (structure) {
|
|
31
|
-
return new AsciiView(segment, buffer, new Structure(structure.tags.clone(), structure.segments), this.ptr, delimiter, writeDelimiter)
|
|
32
|
+
return new AsciiView(definitions, segment, buffer, new Structure(structure.tags.clone(), structure.segments), this.ptr, delimiter, writeDelimiter)
|
|
32
33
|
}
|
|
33
|
-
return new AsciiView(segment, buffer, null, this.ptr, delimiter, writeDelimiter)
|
|
34
|
+
return new AsciiView(definitions, segment, buffer, null, this.ptr, delimiter, writeDelimiter)
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
private replaceDelimiter (viewBuffer: Buffer, replaceDelimiter?: number): void {
|
|
@@ -71,7 +72,7 @@ export class AsciiView extends MsgView {
|
|
|
71
72
|
return cs % 256
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
protected toTyped (field: SimpleFieldDefinition):
|
|
75
|
+
protected toTyped (field: SimpleFieldDefinition): (boolean | string | number | Date | Buffer | null) {
|
|
75
76
|
const position: number = this.getPosition(field.tag)
|
|
76
77
|
if (position >= 0) {
|
|
77
78
|
switch (field.tagType) {
|
|
@@ -117,10 +118,11 @@ export class AsciiView extends MsgView {
|
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
120
|
}
|
|
121
|
+
return null
|
|
120
122
|
}
|
|
121
123
|
|
|
122
124
|
protected create (singleton: SegmentDescription): MsgView {
|
|
123
|
-
return new AsciiView(singleton,
|
|
125
|
+
return new AsciiView(this.definitions, singleton,
|
|
124
126
|
this.buffer,
|
|
125
127
|
this.structure,
|
|
126
128
|
this.ptr,
|
|
@@ -3,7 +3,7 @@ import { FixDefinitions, MessageDefinition, SimpleFieldDefinition } from '../dic
|
|
|
3
3
|
import {
|
|
4
4
|
ContainedComponentField,
|
|
5
5
|
ContainedField,
|
|
6
|
-
|
|
6
|
+
IContainedSet,
|
|
7
7
|
ContainedFieldType,
|
|
8
8
|
ContainedGroupField,
|
|
9
9
|
ContainedSimpleField
|
|
@@ -17,7 +17,7 @@ export class EncodeProxy {
|
|
|
17
17
|
private static SimpleFieldCheck (field: ContainedSimpleField, val: any): void {
|
|
18
18
|
const definition: SimpleFieldDefinition = field.definition
|
|
19
19
|
if (definition.isEnum()) {
|
|
20
|
-
const resolved: boolean = definition.containsEnum(val)
|
|
20
|
+
const resolved: boolean = definition.containsEnum(String(val))
|
|
21
21
|
if (!resolved) {
|
|
22
22
|
throw new Error(`enum field ${field.name} does not support "${val}"`)
|
|
23
23
|
}
|
|
@@ -59,7 +59,7 @@ export class EncodeProxy {
|
|
|
59
59
|
case TagType.Int:
|
|
60
60
|
case TagType.Float:
|
|
61
61
|
case TagType.Length: {
|
|
62
|
-
if (isNaN(val)) {
|
|
62
|
+
if (isNaN(val as number)) {
|
|
63
63
|
throw new Error(`field ${field.name} expects number but receives "${typeof val}"`)
|
|
64
64
|
}
|
|
65
65
|
break
|
|
@@ -80,17 +80,17 @@ export class EncodeProxy {
|
|
|
80
80
|
if (!isComplex) {
|
|
81
81
|
throw new Error(`type ${field.name} is a component but is given type "${typeof val}"`)
|
|
82
82
|
}
|
|
83
|
-
return EncodeProxy.checkProperties(new Proxy({}, EncodeProxy.handler(field.definition)), val)
|
|
83
|
+
return EncodeProxy.checkProperties(new Proxy({}, EncodeProxy.handler(field.definition)), val as ILooseObject)
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
private static GroupFieldCheck (field: ContainedGroupField, val: any): object {
|
|
87
|
-
const accepted: boolean = Array.isArray(val) || !isNaN(val)
|
|
87
|
+
const accepted: boolean = Array.isArray(val) || !isNaN(val as number)
|
|
88
88
|
if (!accepted) {
|
|
89
89
|
throw new Error(`type ${field.name} is a group and needs array or number, not "${typeof val}"`)
|
|
90
90
|
}
|
|
91
91
|
const gf: ContainedComponentField = field as ContainedComponentField
|
|
92
92
|
const j: number = val
|
|
93
|
-
const isNumber: boolean = !isNaN(val)
|
|
93
|
+
const isNumber: boolean = !isNaN(val as number)
|
|
94
94
|
if (isNumber) {
|
|
95
95
|
const arr: ILooseObject[] = new Array(j)
|
|
96
96
|
for (let i: number = 0; i < j; ++i) {
|
|
@@ -106,10 +106,10 @@ export class EncodeProxy {
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
private static handler (set:
|
|
109
|
+
private static handler (set: IContainedSet): Object {
|
|
110
110
|
return {
|
|
111
111
|
set (target: ILooseObject, prop: string, val: any): boolean {
|
|
112
|
-
const field: ContainedField |
|
|
112
|
+
const field: ContainedField | undefined = set.localNameToField.get(prop)
|
|
113
113
|
if (!field) {
|
|
114
114
|
throw new Error(`type ${set.name} has no field named ${prop}`)
|
|
115
115
|
}
|
|
@@ -140,7 +140,7 @@ export class EncodeProxy {
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
public wrap (msgName: string): ILooseObject {
|
|
143
|
-
const msg: MessageDefinition |
|
|
143
|
+
const msg: MessageDefinition | undefined = this.definitions.message.get(msgName)
|
|
144
144
|
if (!msg) {
|
|
145
145
|
throw new Error(`no message defined for type ${msgName}`)
|
|
146
146
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { ILooseObject } from '../../collections/collection'
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
IContainedSet,
|
|
4
|
+
ContainedField,
|
|
5
|
+
ContainedGroupField,
|
|
6
|
+
ContainedComponentField,
|
|
7
|
+
ContainedSimpleField,
|
|
8
|
+
FieldsDispatch
|
|
5
9
|
} from '../../dictionary/contained'
|
|
6
10
|
import { AsciiChars } from '../ascii'
|
|
7
11
|
import { MsgEncoder } from '../msg-encoder'
|
|
@@ -66,7 +70,7 @@ export class FixmlEncoder extends MsgEncoder {
|
|
|
66
70
|
return ''
|
|
67
71
|
}
|
|
68
72
|
|
|
69
|
-
public encodeSet (o: ILooseObject, set:
|
|
73
|
+
public encodeSet (o: ILooseObject, set: IContainedSet): void {
|
|
70
74
|
const batch: ILooseObject[] = o.Batch
|
|
71
75
|
const toWrite: ILooseObject[] = batch || [o]
|
|
72
76
|
const depth = batch ? 1 : 0
|
|
@@ -91,11 +95,11 @@ export class FixmlEncoder extends MsgEncoder {
|
|
|
91
95
|
buffer.writeString(this.endDoc)
|
|
92
96
|
}
|
|
93
97
|
|
|
94
|
-
private batchStart (o: ILooseObject, set:
|
|
98
|
+
private batchStart (o: ILooseObject, set: IContainedSet, depth: number): void {
|
|
95
99
|
const buffer = this.buffer
|
|
96
100
|
const indent: string = '\t'
|
|
97
101
|
const beginBatch = this.beginBatch
|
|
98
|
-
const hdr = o.StandardHeader
|
|
102
|
+
const hdr: ILooseObject = o.StandardHeader
|
|
99
103
|
const eol = this.eol
|
|
100
104
|
buffer.writeString(`${indent}${beginBatch}`)
|
|
101
105
|
if (hdr) {
|
|
@@ -105,7 +109,7 @@ export class FixmlEncoder extends MsgEncoder {
|
|
|
105
109
|
}
|
|
106
110
|
}
|
|
107
111
|
|
|
108
|
-
private toXml (o: ILooseObject, name: string, set:
|
|
112
|
+
private toXml (o: ILooseObject, name: string, set: IContainedSet, depth: number): void {
|
|
109
113
|
const buffer = this.buffer
|
|
110
114
|
const selfClose: string = '/>'
|
|
111
115
|
const close: string = '>'
|
|
@@ -128,11 +132,11 @@ export class FixmlEncoder extends MsgEncoder {
|
|
|
128
132
|
}
|
|
129
133
|
}
|
|
130
134
|
|
|
131
|
-
private getPopulatedFields (set:
|
|
135
|
+
private getPopulatedFields (set: IContainedSet, o: ILooseObject): ContainedField[] {
|
|
132
136
|
const keys: string[] = Object.keys(o)
|
|
133
137
|
const fields: ContainedField[] = keys.reduce((a: ContainedField[], current: string) => {
|
|
134
|
-
const field: ContainedField |
|
|
135
|
-
if (field && !set.nameToLocalAttribute.
|
|
138
|
+
const field: ContainedField | undefined = set.localNameToField.get(current)
|
|
139
|
+
if (field && !set.nameToLocalAttribute.has(current)) {
|
|
136
140
|
a.push(field)
|
|
137
141
|
}
|
|
138
142
|
return a
|
|
@@ -153,7 +157,7 @@ export class FixmlEncoder extends MsgEncoder {
|
|
|
153
157
|
buffer.writeChar(AsciiChars.Dq)
|
|
154
158
|
}
|
|
155
159
|
|
|
156
|
-
private attributes (o: ILooseObject, set:
|
|
160
|
+
private attributes (o: ILooseObject, set: IContainedSet, depth: number, attributePerLine: boolean): void {
|
|
157
161
|
const newLine = this.eol
|
|
158
162
|
const indent: string = '\t'.repeat(depth + 1)
|
|
159
163
|
const attributes = set.localAttribute
|
|
@@ -5,7 +5,7 @@ import { FixDefinitions, MessageDefinition } from '../../dictionary/definition'
|
|
|
5
5
|
import {
|
|
6
6
|
ContainedField, ContainedComponentField,
|
|
7
7
|
ContainedFieldType, ContainedGroupField,
|
|
8
|
-
ContainedSimpleField,
|
|
8
|
+
ContainedSimpleField, IContainedSet
|
|
9
9
|
} from '../../dictionary/contained'
|
|
10
10
|
import { SegmentDescription } from '../segment/segment-description'
|
|
11
11
|
import { IJsFixConfig, IJsFixLogger } from '../../config'
|
|
@@ -39,7 +39,7 @@ export class FiXmlParser extends MsgParser {
|
|
|
39
39
|
const me = description?.application?.name
|
|
40
40
|
this.logger = config.logFactory.logger(`${me}:FiXmlParser`)
|
|
41
41
|
this.saxStream = require('sax').createStream(true, {})
|
|
42
|
-
this.locations = new Tags(
|
|
42
|
+
this.locations = new Tags(maxMessageLocations)
|
|
43
43
|
this.logger.info('subscribe to stream')
|
|
44
44
|
this.subscribe()
|
|
45
45
|
}
|
|
@@ -180,7 +180,7 @@ export class FiXmlParser extends MsgParser {
|
|
|
180
180
|
private getView (): MsgView {
|
|
181
181
|
const structure: Structure = new Structure(this.locations, this.segments)
|
|
182
182
|
const last = structure.segments[structure.segments.length - 1]
|
|
183
|
-
return new FixmlView(last, this.values, structure)
|
|
183
|
+
return new FixmlView(this.definitions, last, this.values, structure)
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
private pop (name: string): SegmentDescription | null {
|
|
@@ -333,7 +333,7 @@ export class FiXmlParser extends MsgParser {
|
|
|
333
333
|
private msg (saxNode: ISaxNode, inBatch: boolean = false): void {
|
|
334
334
|
this.logger.debug(`${saxNode.name}: begin parse msg`)
|
|
335
335
|
const type: string = saxNode.name
|
|
336
|
-
const def: MessageDefinition |
|
|
336
|
+
const def: MessageDefinition | undefined = this.definitions.message.get(type)
|
|
337
337
|
if (!def) {
|
|
338
338
|
throw new Error(`unknown message type ${type}`)
|
|
339
339
|
}
|
|
@@ -347,7 +347,7 @@ export class FiXmlParser extends MsgParser {
|
|
|
347
347
|
}
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
-
private parseAttributes (name: string, set:
|
|
350
|
+
private parseAttributes (name: string, set: IContainedSet, saxNode: ISaxNode, type: SegmentType): SegmentDescription | null {
|
|
351
351
|
const locations = this.locations
|
|
352
352
|
const attributes = saxNode.attributes
|
|
353
353
|
const values = this.values
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MsgView } from '../msg-view'
|
|
2
|
-
import { SimpleFieldDefinition } from '../../dictionary/definition'
|
|
2
|
+
import { FixDefinitions, SimpleFieldDefinition } from '../../dictionary/definition'
|
|
3
3
|
import { Structure } from '../structure'
|
|
4
4
|
import { SegmentDescription } from '../segment/segment-description'
|
|
5
5
|
import { AsciiChars } from '../ascii/'
|
|
@@ -7,10 +7,10 @@ import * as moment from 'moment'
|
|
|
7
7
|
import { TagType } from '../tag/tag-type'
|
|
8
8
|
|
|
9
9
|
export class FixmlView extends MsgView {
|
|
10
|
-
constructor (public readonly segment: SegmentDescription,
|
|
10
|
+
constructor (public definitions: FixDefinitions, public readonly segment: SegmentDescription,
|
|
11
11
|
public readonly values: string[],
|
|
12
12
|
public readonly structure: Structure) {
|
|
13
|
-
super(segment, structure)
|
|
13
|
+
super(definitions, segment, structure)
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
private static getTimestamp (s: string, useUtc: boolean): Date {
|
|
@@ -37,7 +37,7 @@ export class FixmlView extends MsgView {
|
|
|
37
37
|
|
|
38
38
|
// if the view is to be kept beyond the event on which it arrives, must be cloned
|
|
39
39
|
public clone (): MsgView {
|
|
40
|
-
return new FixmlView(this.segment, this.values, new Structure(this.structure.tags.clone(), this.structure.segments))
|
|
40
|
+
return new FixmlView(this.definitions, this.segment, this.values, new Structure(this.structure.tags.clone(), this.structure.segments))
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
public checksum (): number {
|
|
@@ -45,7 +45,7 @@ export class FixmlView extends MsgView {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
protected create (singleton: SegmentDescription): FixmlView {
|
|
48
|
-
return new FixmlView(singleton,
|
|
48
|
+
return new FixmlView(this.definitions, singleton,
|
|
49
49
|
this.values,
|
|
50
50
|
this.structure)
|
|
51
51
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ILooseObject } from '../collections/collection'
|
|
2
2
|
import { FixDefinitions } from '../dictionary/definition'
|
|
3
|
-
import {
|
|
3
|
+
import { IContainedSet } from '../dictionary/contained'
|
|
4
4
|
import * as events from 'events'
|
|
5
5
|
|
|
6
6
|
export abstract class MsgEncoder extends events.EventEmitter {
|
|
@@ -9,7 +9,7 @@ export abstract class MsgEncoder extends events.EventEmitter {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
public encode (o: ILooseObject, name: string): void {
|
|
12
|
-
const set:
|
|
12
|
+
const set: IContainedSet | undefined = this.definitions.message.get(name) ??
|
|
13
13
|
this.definitions.component.get(name)
|
|
14
14
|
if (!set) {
|
|
15
15
|
return
|
|
@@ -19,5 +19,5 @@ export abstract class MsgEncoder extends events.EventEmitter {
|
|
|
19
19
|
|
|
20
20
|
public abstract reset (): void
|
|
21
21
|
public abstract trim (): Buffer
|
|
22
|
-
public abstract encodeSet (o: ILooseObject, set:
|
|
22
|
+
public abstract encodeSet (o: ILooseObject, set: IContainedSet): void
|
|
23
23
|
}
|