jspurefix 5.11.1 → 5.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/README.md +13 -1
  2. package/dist/buffer/fixml/fixml-parser.js +1 -1
  3. package/dist/buffer/fixml/fixml-parser.js.map +1 -1
  4. package/dist/config/empty-log-factory.d.ts +2 -2
  5. package/dist/config/empty-log-factory.js +1 -1
  6. package/dist/config/empty-log-factory.js.map +1 -1
  7. package/dist/config/get-js-fx-logger.d.ts +2 -2
  8. package/dist/config/get-js-fx-logger.js.map +1 -1
  9. package/dist/config/js-fix-logger-factory.d.ts +2 -2
  10. package/dist/config/js-fix-logger-factory.js.map +1 -1
  11. package/dist/config/js-fix-logger.d.ts +9 -8
  12. package/dist/config/js-fix-logger.js +4 -4
  13. package/dist/config/js-fix-logger.js.map +1 -1
  14. package/dist/config/js-fix-winston-log-factory.d.ts +2 -2
  15. package/dist/config/js-fix-winston-log-factory.js +2 -2
  16. package/dist/config/js-fix-winston-log-factory.js.map +1 -1
  17. package/dist/config/winston-logger.d.ts +5 -2
  18. package/dist/config/winston-logger.js +57 -9
  19. package/dist/config/winston-logger.js.map +1 -1
  20. package/dist/dictionary/fragment-safety.d.ts +26 -0
  21. package/dist/dictionary/fragment-safety.js +154 -0
  22. package/dist/dictionary/fragment-safety.js.map +1 -0
  23. package/dist/dictionary/index.d.ts +1 -0
  24. package/dist/dictionary/index.js +1 -0
  25. package/dist/dictionary/index.js.map +1 -1
  26. package/dist/runtime/make-config.js +1 -1
  27. package/dist/runtime/make-config.js.map +1 -1
  28. package/dist/runtime/session-launcher.js +1 -1
  29. package/dist/runtime/session-launcher.js.map +1 -1
  30. package/dist/sample/http/oms/http-client.js +1 -1
  31. package/dist/sample/http/oms/http-client.js.map +1 -1
  32. package/dist/sample/http/oms/http-server.js +1 -1
  33. package/dist/sample/http/oms/http-server.js.map +1 -1
  34. package/dist/sample/tcp/qf-md/md-client.js +1 -1
  35. package/dist/sample/tcp/qf-md/md-client.js.map +1 -1
  36. package/dist/sample/tcp/qf-md/md-server.js +1 -1
  37. package/dist/sample/tcp/qf-md/md-server.js.map +1 -1
  38. package/dist/sample/tcp/recovering-skeleton/respawn-acceptor.js +1 -1
  39. package/dist/sample/tcp/recovering-skeleton/respawn-acceptor.js.map +1 -1
  40. package/dist/sample/tcp/recovering-skeleton/skeleton-client.js +1 -1
  41. package/dist/sample/tcp/recovering-skeleton/skeleton-client.js.map +1 -1
  42. package/dist/sample/tcp/recovering-skeleton/skeleton-server.js +1 -1
  43. package/dist/sample/tcp/recovering-skeleton/skeleton-server.js.map +1 -1
  44. package/dist/sample/tcp/skeleton/skeleton-session.js +1 -1
  45. package/dist/sample/tcp/skeleton/skeleton-session.js.map +1 -1
  46. package/dist/sample/tcp/trade-capture/trade-capture-client.js +1 -1
  47. package/dist/sample/tcp/trade-capture/trade-capture-client.js.map +1 -1
  48. package/dist/sample/tcp/trade-capture/trade-capture-server.js +1 -1
  49. package/dist/sample/tcp/trade-capture/trade-capture-server.js.map +1 -1
  50. package/dist/store/fix-msg-memory-store.js +1 -1
  51. package/dist/store/fix-msg-memory-store.js.map +1 -1
  52. package/dist/transport/ascii/ascii-msg-transmitter.js +1 -1
  53. package/dist/transport/ascii/ascii-msg-transmitter.js.map +1 -1
  54. package/dist/transport/ascii/ascii-session.js +1 -1
  55. package/dist/transport/ascii/ascii-session.js.map +1 -1
  56. package/dist/transport/http/http-acceptor-listener.js +1 -1
  57. package/dist/transport/http/http-acceptor-listener.js.map +1 -1
  58. package/dist/transport/http/http-acceptor.js +2 -2
  59. package/dist/transport/http/http-acceptor.js.map +1 -1
  60. package/dist/transport/http/http-initiator.js +1 -1
  61. package/dist/transport/http/http-initiator.js.map +1 -1
  62. package/dist/transport/http/http-json-sample-adapter.js +1 -1
  63. package/dist/transport/http/http-json-sample-adapter.js.map +1 -1
  64. package/dist/transport/session/fix-session.js +3 -3
  65. package/dist/transport/session/fix-session.js.map +1 -1
  66. package/dist/transport/session/session-registry.js +1 -1
  67. package/dist/transport/session/session-registry.js.map +1 -1
  68. package/dist/transport/tcp/recovering-tcp-initiator.js +1 -1
  69. package/dist/transport/tcp/recovering-tcp-initiator.js.map +1 -1
  70. package/dist/transport/tcp/tcp-acceptor-listener.js +2 -2
  71. package/dist/transport/tcp/tcp-acceptor-listener.js.map +1 -1
  72. package/dist/transport/tcp/tcp-acceptor.js +2 -2
  73. package/dist/transport/tcp/tcp-acceptor.js.map +1 -1
  74. package/dist/transport/tcp/tcp-initiator-connector.js +2 -2
  75. package/dist/transport/tcp/tcp-initiator-connector.js.map +1 -1
  76. package/dist/transport/tcp/tcp-initiator.js +1 -1
  77. package/dist/transport/tcp/tcp-initiator.js.map +1 -1
  78. package/docs/instrumentation.md +360 -0
  79. package/docs/scattered-components.md +280 -0
  80. package/jsfix.test_client.txt +62 -62
  81. package/jsfix.test_server.txt +72 -72
  82. package/package.json +1 -1
  83. package/src/buffer/fixml/fixml-parser.ts +1 -1
  84. package/src/config/empty-log-factory.ts +2 -2
  85. package/src/config/get-js-fx-logger.ts +2 -2
  86. package/src/config/js-fix-logger-factory.ts +8 -2
  87. package/src/config/js-fix-logger.ts +23 -8
  88. package/src/config/js-fix-winston-log-factory.ts +3 -3
  89. package/src/config/winston-logger.ts +93 -10
  90. package/src/dictionary/fragment-safety.ts +225 -0
  91. package/src/dictionary/index.ts +1 -0
  92. package/src/runtime/make-config.ts +1 -1
  93. package/src/runtime/session-launcher.ts +1 -1
  94. package/src/sample/http/oms/http-client.ts +1 -1
  95. package/src/sample/http/oms/http-server.ts +1 -1
  96. package/src/sample/tcp/qf-md/md-client.ts +1 -1
  97. package/src/sample/tcp/qf-md/md-server.ts +1 -1
  98. package/src/sample/tcp/recovering-skeleton/respawn-acceptor.ts +2 -1
  99. package/src/sample/tcp/recovering-skeleton/skeleton-client.ts +1 -1
  100. package/src/sample/tcp/recovering-skeleton/skeleton-server.ts +1 -1
  101. package/src/sample/tcp/skeleton/skeleton-session.ts +1 -1
  102. package/src/sample/tcp/trade-capture/trade-capture-client.ts +2 -1
  103. package/src/sample/tcp/trade-capture/trade-capture-server.ts +2 -1
  104. package/src/store/fix-msg-memory-store.ts +2 -1
  105. package/src/transport/ascii/ascii-msg-transmitter.ts +2 -1
  106. package/src/transport/ascii/ascii-session.ts +2 -1
  107. package/src/transport/http/http-acceptor-listener.ts +2 -1
  108. package/src/transport/http/http-acceptor.ts +2 -1
  109. package/src/transport/http/http-initiator.ts +2 -1
  110. package/src/transport/http/http-json-sample-adapter.ts +1 -1
  111. package/src/transport/session/fix-session.ts +2 -1
  112. package/src/transport/session/session-registry.ts +1 -1
  113. package/src/transport/tcp/recovering-tcp-initiator.ts +2 -1
  114. package/src/transport/tcp/tcp-acceptor-listener.ts +4 -2
  115. package/src/transport/tcp/tcp-acceptor.ts +2 -1
  116. package/src/transport/tcp/tcp-initiator-connector.ts +4 -2
  117. package/src/transport/tcp/tcp-initiator.ts +2 -1
package/README.md CHANGED
@@ -93,13 +93,16 @@ import {
93
93
 
94
94
  A minimal session subclasses `AsciiSession` and implements two callbacks: `onReady` (connection up, logon confirmed) and `onApplicationMsg` (a non-session message arrived).
95
95
 
96
+ The second argument to `logger()` binds structured fields to every line that logger writes, and `info`/`warning`/`debug`/`error` each take an optional bag of per-call fields. Both are optional and additive — the default console format renders exactly as it always has, and installing `WinstonLogger.ecsOptions()` instead emits one ECS-style JSON object per line for Filebeat. See [docs/instrumentation.md](docs/instrumentation.md).
97
+
96
98
  ```typescript
97
99
  class TradeCaptureClient extends AsciiSession {
98
100
  constructor (public readonly config: IJsFixConfig) {
99
101
  super(config)
100
102
  this.logReceivedMsgs = true
101
103
  this.fixLog = config.logFactory.plain(`jsfix.${config.description.application.name}.txt`)
102
- this.logger = config.logFactory.logger(`${this.me}:TradeCaptureClient`)
104
+ this.logger = config.logFactory.logger(`${this.me}:TradeCaptureClient`,
105
+ { component: 'TradeCaptureClient', app: this.me })
103
106
  }
104
107
 
105
108
  protected onReady (view: MsgView): void {
@@ -508,6 +511,13 @@ To add a custom dialect:
508
511
 
509
512
  See [jspf-md-demo](https://github.com/TimelordUK/jspf-md-demo) for a worked example.
510
513
 
514
+ A counterparty that emits a component's tags non-adjacently defeats the parser's positional
515
+ model, and the engine repairs the common case by describing such a component with its tags
516
+ rather than a range. `FragmentSafety.analyse(definitions)` reports whether a dictionary
517
+ lets that repair stay unambiguous — worth running against a house dialect. The
518
+ generalisation to arbitrarily nested scattering, and what it would cost, is in
519
+ [docs/scattered-components.md](docs/scattered-components.md).
520
+
511
521
  ## `jsfix` CLI — log parsing & stats
512
522
 
513
523
  The `jsfix-cmd` tool parses any FIX log given an appropriate dictionary.
@@ -567,6 +577,8 @@ Numbers below are illustrative — generated messages, single-threaded, parser-o
567
577
 
568
578
  † The SD and TC fixtures have shrunk since the older measurements were taken (SD was 229 fields / 2 466 chars, TC was 578 fields / 5 741 chars), so the prior numbers aren't comparable with the current fixture and have been dropped from the row. Re-running them on the older hardware would produce a clean third column. Ryzen measurements taken on Node 24 LTS, WSL2.
569
579
 
580
+ To measure a change to a hot path rather than the engine as a whole, see [docs/benchmarking.md](docs/benchmarking.md). Measuring a *live* session — throughput, sequence health, session state, at a cost low enough to leave switched on — is not yet possible; the design for it is in [docs/instrumentation.md](docs/instrumentation.md).
581
+
570
582
  ## Developing on jspurefix
571
583
 
572
584
  Clone and build:
@@ -36,7 +36,7 @@ let FiXmlParser = class FiXmlParser extends msg_parser_1.MsgParser {
36
36
  this.definitions = this.config.definitions;
37
37
  const description = config.description;
38
38
  const me = (_a = description === null || description === void 0 ? void 0 : description.application) === null || _a === void 0 ? void 0 : _a.name;
39
- this.logger = config.logFactory.logger(`${me}:FiXmlParser`);
39
+ this.logger = config.logFactory.logger(`${me}:FiXmlParser`, { component: 'FixmlParser', app: me });
40
40
  this.saxStream = require('sax').createStream(true, {});
41
41
  this.locations = new tags_1.Tags(maxMessageLocations);
42
42
  this.logger.info('subscribe to stream');
@@ -1 +1 @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,CAAA;IACb,CAAC;CACF,CAAA;AAhWY,kCAAW;sBAAX,WAAW;IADvB,IAAA,qBAAU,GAAE;IAYG,WAAA,IAAA,iBAAM,EAAC,oBAAQ,CAAC,YAAY,CAAC,CAAA;IACxC,WAAA,IAAA,iBAAM,EAAC,oBAAQ,CAAC,UAAU,CAAC,CAAA;IAC3B,WAAA,IAAA,iBAAM,EAAC,oBAAQ,CAAC,mBAAmB,CAAC,CAAA;6CADoB,iBAAQ;GAZxD,WAAW,CAgWvB","sourcesContent":["import { MsgParser } from '../msg-parser'\nimport { Tags } from '../tag/tags'\nimport { SAXStream } from '../../dictionary'\nimport { FixDefinitions, MessageDefinition } from '../../dictionary/definition'\nimport {\n ContainedField, ContainedComponentField,\n ContainedFieldType, ContainedGroupField,\n ContainedSimpleField, IContainedSet\n} from '../../dictionary/contained'\nimport { SegmentDescription } from '../segment/segment-description'\nimport { IJsFixConfig, IJsFixLogger } from '../../config'\nimport { MsgView } from '../msg-view'\nimport { Structure } from '../structure'\nimport { FixmlView } from './fixml-view'\nimport { Readable } from 'stream'\nimport { inject, injectable } from 'tsyringe'\nimport { DITokens } from '../../runtime/di-tokens'\nimport { ISaxNode } from '../../dictionary/sax-node'\nimport { SegmentType } from '../segment/segment-type'\n\n@injectable()\nexport class FiXmlParser extends MsgParser {\n private readonly locations: Tags\n private values: string[] = []\n private readonly saxStream: SAXStream\n private readonly definitions: FixDefinitions\n private readonly segments: SegmentDescription[] = []\n private readonly segmentStack: SegmentDescription[] = []\n private readonly logger: IJsFixLogger\n private last: SegmentDescription | null\n private raw: string | null\n\n constructor (@inject(DITokens.IJsFixConfig) public readonly config: IJsFixConfig,\n @inject(DITokens.readStream) public readonly readStream: Readable,\n @inject(DITokens.maxMessageLocations) public readonly maxMessageLocations: number = 10 * 1024) {\n super()\n this.definitions = this.config.definitions\n const description = config.description\n const me = description?.application?.name\n this.logger = config.logFactory.logger(`${me}:FiXmlParser`)\n this.saxStream = require('sax').createStream(true, {})\n this.locations = new Tags(maxMessageLocations)\n this.logger.info('subscribe to stream')\n this.subscribe()\n }\n\n private reset (): void {\n const segments = this.segments\n while (segments.length > 0) {\n segments.pop()\n }\n const stack = this.segmentStack\n this.last = null\n this.raw = null\n this.values = []\n this.locations.reset()\n while (stack.length) {\n stack.pop()\n }\n }\n\n private subscribe (): void {\n const writeStream = this.saxStream\n const readStream = this.readStream\n const instance = this\n readStream.pipe(writeStream).on('ready', () => {\n this.logger.info('stream close event')\n this.emit('close')\n })\n readStream.on('error', (e) => {\n this.logger.error(e)\n this.emit('error', e)\n })\n readStream.on('end', () => {\n this.logger.info('stream end event')\n this.emit('end')\n })\n writeStream.on('data', (i: Buffer) => {\n if (instance.last) {\n instance.emit('decoded', instance.last.name, i.toString())\n } else {\n this.raw = i.toString()\n }\n })\n\n writeStream.on('opentag', (node) => {\n const stack = this.segmentStack\n const saxNode: ISaxNode = node as ISaxNode\n switch (saxNode.name) {\n case 'FIXML':\n this.reset()\n break\n\n case 'Batch': {\n const locations = this.locations\n const ptr = locations.nextTagPos - 1\n const segment: SegmentDescription = new SegmentDescription(saxNode.name,\n -1,\n null,\n ptr,\n stack.length,\n SegmentType.Batch)\n segment.startPosition = 0\n stack.push(segment)\n break\n }\n\n case 'Hdr': {\n this.hdr(saxNode)\n break\n }\n\n default: {\n const stack = this.segmentStack\n const isBatch: boolean = stack.length === 1 && stack[0].type === SegmentType.Batch\n const isMsg: boolean = stack.length === 0\n if (isMsg) {\n // one single message\n this.msg(saxNode)\n } else if (isBatch) {\n // one message within a batch or it\n this.msgInBatch(saxNode)\n } else {\n // or it is a structure within a message\n this.element(saxNode)\n }\n }\n }\n })\n writeStream.on('closetag', (name: string) => {\n this.pop(name)\n })\n writeStream.on('error', (e: Error) => {\n this.emit('error', e)\n })\n }\n\n private hdr (saxNode: ISaxNode): void {\n const stack = this.segmentStack\n if (stack.length === 0) {\n throw new Error(`Hdr not expected before batch or message ${saxNode.name}`)\n }\n const peek: SegmentDescription = stack[stack.length - 1]\n switch (peek.type) {\n case SegmentType.Batch: {\n // manually handle this component\n const hdr = this.definitions.component.get('StandardHeader')\n if (hdr) {\n const segment: SegmentDescription | null = this.parseAttributes(saxNode.name, hdr, saxNode, SegmentType.Component)\n if (segment) {\n this.segmentStack.push(segment)\n }\n }\n break\n }\n\n case SegmentType.Msg: {\n this.element(saxNode)\n break\n }\n\n default:\n throw new Error(`Hdr not expected before batch or message ${saxNode.name}`)\n }\n }\n\n private msgInBatch (saxNode: ISaxNode): void {\n this.logger.info(` ${saxNode.name}: start batch`)\n const locations = this.locations\n const batch = this.segmentStack[0]\n const ptr = locations.nextTagPos\n if (!batch.delimiterPositions) {\n batch.startGroup(-1)\n }\n batch.addDelimiterPosition(ptr)\n this.logger.debug(` ${saxNode.name}: begin parse msg ${batch.delimiterPositions.length} in batch`)\n this.msg(saxNode, true)\n }\n\n private getView (): MsgView {\n const structure: Structure = new Structure(this.locations, this.segments)\n const last = structure.segments[structure.segments.length - 1]\n return new FixmlView(this.definitions, last, this.values, structure)\n }\n\n private pop (name: string): SegmentDescription | null {\n const locations = this.locations\n const stack = this.segmentStack\n const segments = this.segments\n while (stack.length > 0) {\n const pop = stack.pop()\n const ptr = locations.nextTagPos - 1\n pop?.end(segments.length, ptr, locations.tagPos[ptr].tag)\n if (pop) {\n segments[segments.length] = pop\n switch (pop.type) {\n case SegmentType.Msg: {\n // raise msg event\n const last = segments[segments.length - 1]\n this.last = last\n this.emit('msg', last.name, this.getView())\n if (this.raw) {\n this.emit('decoded', this.last.name, this.raw)\n this.raw = null\n }\n break\n }\n case SegmentType.Batch: {\n const last = segments[segments.length - 1]\n this.logger.debug(`emit batch with ${pop.delimiterPositions.length} elements`)\n this.emit('batch', last?.set?.abbreviation, this.getView())\n break\n }\n }\n if (pop.name === name) {\n return pop\n }\n }\n }\n return null\n }\n\n private startGroup (saxNode: ISaxNode, gf: ContainedGroupField): void {\n const locations = this.locations\n const stack: SegmentDescription[] = this.segmentStack\n const ptr = locations.nextTagPos\n const def = gf.definition\n const segment: SegmentDescription | null = this.parseAttributes(saxNode.name, def, saxNode, SegmentType.Component)\n if (segment) {\n const group: SegmentDescription = new SegmentDescription(def.name,\n locations.tagPos[ptr].tag,\n def,\n ptr,\n stack.length,\n SegmentType.Group)\n group.startGroup(locations.tagPos[ptr].tag)\n group.addDelimiterPosition(ptr)\n stack.push(group)\n stack.push(segment)\n }\n }\n\n private getNextField (saxNode: ISaxNode): ContainedField | null {\n const stack: SegmentDescription[] = this.segmentStack\n while (stack.length > 0) {\n const peek: SegmentDescription = stack[stack.length - 1]\n const field = peek?.set?.localNameToField.get(saxNode.name)\n if (field) {\n return field\n }\n // if this is a group of the same type as already on stack\n // take the field from the next level up\n if (peek.type === SegmentType.Group && stack.length > 1) {\n const contained = stack[stack.length - 2]?.set?.localNameToField.get(saxNode.name)\n if (contained instanceof ContainedGroupField) {\n if (contained.definition.name === peek.name) {\n // this is the same type for next instance in the same group.\n return contained\n }\n }\n }\n // then have ended previous group. Pop and return to see if this field lives on the parent\n const locations = this.locations\n const ptr = locations.nextTagPos - 1\n const pop = stack.pop()\n const segments = this.segments\n if (pop) {\n pop.end(segments.length, ptr, locations.tagPos[ptr].tag)\n segments[segments.length] = pop\n }\n }\n return null\n }\n\n private dispatch (saxNode: ISaxNode, field: ContainedField): void {\n switch (field.type) {\n case ContainedFieldType.Component: {\n const cf: ContainedComponentField = field as ContainedComponentField\n const segment: SegmentDescription | null = this.parseAttributes(saxNode.name, cf.definition, saxNode, SegmentType.Component)\n if (segment) {\n this.segmentStack.push(segment)\n }\n break\n }\n\n case ContainedFieldType.Group: {\n this.dispatchGroup(saxNode, field as ContainedGroupField)\n break\n }\n }\n }\n\n private dispatchGroup (saxNode: ISaxNode, gf: ContainedGroupField): void {\n const stack: SegmentDescription[] = this.segmentStack\n const peek: SegmentDescription = stack[stack.length - 1]\n switch (peek.type) {\n case SegmentType.Msg:\n case SegmentType.Component: {\n this.startGroup(saxNode, gf)\n break\n }\n\n case SegmentType.Group: {\n if (gf.name === saxNode.name) {\n const ptr = this.locations.nextTagPos\n peek.addDelimiterPosition(ptr)\n const a = this.parseAttributes(saxNode.name, gf.definition, saxNode, SegmentType.Component)\n if (a) {\n stack.push(a)\n }\n } else {\n throw new Error(`expected another group instance of ${gf.name} but got ${saxNode.name}`)\n }\n break\n }\n\n default:\n throw new Error(`dispatchGroup has field ${gf.name} peek type ${peek.type}`)\n }\n }\n\n private element (saxNode: ISaxNode): void {\n // may terminate a group and move fields\n const field = this.getNextField(saxNode)\n if (!field) {\n const stack: SegmentDescription[] = this.segmentStack\n const peek: SegmentDescription = stack[stack.length - 1]\n throw new Error(`field ${saxNode.name} not known in set ${peek?.set?.name}`)\n }\n this.dispatch(saxNode, field)\n }\n\n private msg (saxNode: ISaxNode, inBatch: boolean = false): void {\n this.logger.debug(`${saxNode.name}: begin parse msg`)\n const type: string = saxNode.name\n const def: MessageDefinition | undefined = this.definitions.message.get(type)\n if (!def) {\n throw new Error(`unknown message type ${type}`)\n }\n if (inBatch) {\n const batch = this.segmentStack[0]\n batch.set = def\n }\n const segment: SegmentDescription | null = this.parseAttributes(type, def, saxNode, SegmentType.Msg)\n if (segment) {\n this.segmentStack.push(segment)\n }\n }\n\n private parseAttributes (name: string, set: IContainedSet, saxNode: ISaxNode, type: SegmentType): SegmentDescription | null {\n const locations = this.locations\n const attributes = saxNode.attributes\n const values = this.values\n let ptr: number\n if (attributes) {\n const keys: string[] = Object.keys(attributes)\n ptr = keys.length > 0 ? locations.nextTagPos : locations.nextTagPos - 1\n for (let j: number = 0; j < keys.length; ++j) {\n const k: string = keys[j]\n const v: string = attributes[k]\n const field: ContainedSimpleField = set.localNameToField.get(k) as ContainedSimpleField\n if (!field) {\n this.logger.warning(`no field ${k} in set ${set.name}`)\n locations.store(j, 1, -1)\n } else {\n locations.store(j, 1, field.definition.tag)\n }\n values[values.length] = v\n }\n return new SegmentDescription(name, locations.tagPos[ptr].tag, set, ptr, this.segmentStack.length, type)\n }\n return null\n }\n}\n"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C,MAAM,EAAE,IAAI,CAAC,CAAA;QAC1G,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF,CAAA;AAhWY,kCAAW;sBAAX,WAAW;IADvB,IAAA,qBAAU,GAAE;IAYG,WAAA,IAAA,iBAAM,EAAC,oBAAQ,CAAC,YAAY,CAAC,CAAA;IACxC,WAAA,IAAA,iBAAM,EAAC,oBAAQ,CAAC,UAAU,CAAC,CAAA;IAC3B,WAAA,IAAA,iBAAM,EAAC,oBAAQ,CAAC,mBAAmB,CAAC,CAAA;6CADoB,iBAAQ;GAZxD,WAAW,CAgWvB","sourcesContent":["import { MsgParser } from '../msg-parser'\nimport { Tags } from '../tag/tags'\nimport { SAXStream } from '../../dictionary'\nimport { FixDefinitions, MessageDefinition } from '../../dictionary/definition'\nimport {\n ContainedField, ContainedComponentField,\n ContainedFieldType, ContainedGroupField,\n ContainedSimpleField, IContainedSet\n} from '../../dictionary/contained'\nimport { SegmentDescription } from '../segment/segment-description'\nimport { IJsFixConfig, IJsFixLogger } from '../../config'\nimport { MsgView } from '../msg-view'\nimport { Structure } from '../structure'\nimport { FixmlView } from './fixml-view'\nimport { Readable } from 'stream'\nimport { inject, injectable } from 'tsyringe'\nimport { DITokens } from '../../runtime/di-tokens'\nimport { ISaxNode } from '../../dictionary/sax-node'\nimport { SegmentType } from '../segment/segment-type'\n\n@injectable()\nexport class FiXmlParser extends MsgParser {\n private readonly locations: Tags\n private values: string[] = []\n private readonly saxStream: SAXStream\n private readonly definitions: FixDefinitions\n private readonly segments: SegmentDescription[] = []\n private readonly segmentStack: SegmentDescription[] = []\n private readonly logger: IJsFixLogger\n private last: SegmentDescription | null\n private raw: string | null\n\n constructor (@inject(DITokens.IJsFixConfig) public readonly config: IJsFixConfig,\n @inject(DITokens.readStream) public readonly readStream: Readable,\n @inject(DITokens.maxMessageLocations) public readonly maxMessageLocations: number = 10 * 1024) {\n super()\n this.definitions = this.config.definitions\n const description = config.description\n const me = description?.application?.name\n this.logger = config.logFactory.logger(`${me}:FiXmlParser`, { component: 'FixmlParser', app: me })\n this.saxStream = require('sax').createStream(true, {})\n this.locations = new Tags(maxMessageLocations)\n this.logger.info('subscribe to stream')\n this.subscribe()\n }\n\n private reset (): void {\n const segments = this.segments\n while (segments.length > 0) {\n segments.pop()\n }\n const stack = this.segmentStack\n this.last = null\n this.raw = null\n this.values = []\n this.locations.reset()\n while (stack.length) {\n stack.pop()\n }\n }\n\n private subscribe (): void {\n const writeStream = this.saxStream\n const readStream = this.readStream\n const instance = this\n readStream.pipe(writeStream).on('ready', () => {\n this.logger.info('stream close event')\n this.emit('close')\n })\n readStream.on('error', (e) => {\n this.logger.error(e)\n this.emit('error', e)\n })\n readStream.on('end', () => {\n this.logger.info('stream end event')\n this.emit('end')\n })\n writeStream.on('data', (i: Buffer) => {\n if (instance.last) {\n instance.emit('decoded', instance.last.name, i.toString())\n } else {\n this.raw = i.toString()\n }\n })\n\n writeStream.on('opentag', (node) => {\n const stack = this.segmentStack\n const saxNode: ISaxNode = node as ISaxNode\n switch (saxNode.name) {\n case 'FIXML':\n this.reset()\n break\n\n case 'Batch': {\n const locations = this.locations\n const ptr = locations.nextTagPos - 1\n const segment: SegmentDescription = new SegmentDescription(saxNode.name,\n -1,\n null,\n ptr,\n stack.length,\n SegmentType.Batch)\n segment.startPosition = 0\n stack.push(segment)\n break\n }\n\n case 'Hdr': {\n this.hdr(saxNode)\n break\n }\n\n default: {\n const stack = this.segmentStack\n const isBatch: boolean = stack.length === 1 && stack[0].type === SegmentType.Batch\n const isMsg: boolean = stack.length === 0\n if (isMsg) {\n // one single message\n this.msg(saxNode)\n } else if (isBatch) {\n // one message within a batch or it\n this.msgInBatch(saxNode)\n } else {\n // or it is a structure within a message\n this.element(saxNode)\n }\n }\n }\n })\n writeStream.on('closetag', (name: string) => {\n this.pop(name)\n })\n writeStream.on('error', (e: Error) => {\n this.emit('error', e)\n })\n }\n\n private hdr (saxNode: ISaxNode): void {\n const stack = this.segmentStack\n if (stack.length === 0) {\n throw new Error(`Hdr not expected before batch or message ${saxNode.name}`)\n }\n const peek: SegmentDescription = stack[stack.length - 1]\n switch (peek.type) {\n case SegmentType.Batch: {\n // manually handle this component\n const hdr = this.definitions.component.get('StandardHeader')\n if (hdr) {\n const segment: SegmentDescription | null = this.parseAttributes(saxNode.name, hdr, saxNode, SegmentType.Component)\n if (segment) {\n this.segmentStack.push(segment)\n }\n }\n break\n }\n\n case SegmentType.Msg: {\n this.element(saxNode)\n break\n }\n\n default:\n throw new Error(`Hdr not expected before batch or message ${saxNode.name}`)\n }\n }\n\n private msgInBatch (saxNode: ISaxNode): void {\n this.logger.info(` ${saxNode.name}: start batch`)\n const locations = this.locations\n const batch = this.segmentStack[0]\n const ptr = locations.nextTagPos\n if (!batch.delimiterPositions) {\n batch.startGroup(-1)\n }\n batch.addDelimiterPosition(ptr)\n this.logger.debug(` ${saxNode.name}: begin parse msg ${batch.delimiterPositions.length} in batch`)\n this.msg(saxNode, true)\n }\n\n private getView (): MsgView {\n const structure: Structure = new Structure(this.locations, this.segments)\n const last = structure.segments[structure.segments.length - 1]\n return new FixmlView(this.definitions, last, this.values, structure)\n }\n\n private pop (name: string): SegmentDescription | null {\n const locations = this.locations\n const stack = this.segmentStack\n const segments = this.segments\n while (stack.length > 0) {\n const pop = stack.pop()\n const ptr = locations.nextTagPos - 1\n pop?.end(segments.length, ptr, locations.tagPos[ptr].tag)\n if (pop) {\n segments[segments.length] = pop\n switch (pop.type) {\n case SegmentType.Msg: {\n // raise msg event\n const last = segments[segments.length - 1]\n this.last = last\n this.emit('msg', last.name, this.getView())\n if (this.raw) {\n this.emit('decoded', this.last.name, this.raw)\n this.raw = null\n }\n break\n }\n case SegmentType.Batch: {\n const last = segments[segments.length - 1]\n this.logger.debug(`emit batch with ${pop.delimiterPositions.length} elements`)\n this.emit('batch', last?.set?.abbreviation, this.getView())\n break\n }\n }\n if (pop.name === name) {\n return pop\n }\n }\n }\n return null\n }\n\n private startGroup (saxNode: ISaxNode, gf: ContainedGroupField): void {\n const locations = this.locations\n const stack: SegmentDescription[] = this.segmentStack\n const ptr = locations.nextTagPos\n const def = gf.definition\n const segment: SegmentDescription | null = this.parseAttributes(saxNode.name, def, saxNode, SegmentType.Component)\n if (segment) {\n const group: SegmentDescription = new SegmentDescription(def.name,\n locations.tagPos[ptr].tag,\n def,\n ptr,\n stack.length,\n SegmentType.Group)\n group.startGroup(locations.tagPos[ptr].tag)\n group.addDelimiterPosition(ptr)\n stack.push(group)\n stack.push(segment)\n }\n }\n\n private getNextField (saxNode: ISaxNode): ContainedField | null {\n const stack: SegmentDescription[] = this.segmentStack\n while (stack.length > 0) {\n const peek: SegmentDescription = stack[stack.length - 1]\n const field = peek?.set?.localNameToField.get(saxNode.name)\n if (field) {\n return field\n }\n // if this is a group of the same type as already on stack\n // take the field from the next level up\n if (peek.type === SegmentType.Group && stack.length > 1) {\n const contained = stack[stack.length - 2]?.set?.localNameToField.get(saxNode.name)\n if (contained instanceof ContainedGroupField) {\n if (contained.definition.name === peek.name) {\n // this is the same type for next instance in the same group.\n return contained\n }\n }\n }\n // then have ended previous group. Pop and return to see if this field lives on the parent\n const locations = this.locations\n const ptr = locations.nextTagPos - 1\n const pop = stack.pop()\n const segments = this.segments\n if (pop) {\n pop.end(segments.length, ptr, locations.tagPos[ptr].tag)\n segments[segments.length] = pop\n }\n }\n return null\n }\n\n private dispatch (saxNode: ISaxNode, field: ContainedField): void {\n switch (field.type) {\n case ContainedFieldType.Component: {\n const cf: ContainedComponentField = field as ContainedComponentField\n const segment: SegmentDescription | null = this.parseAttributes(saxNode.name, cf.definition, saxNode, SegmentType.Component)\n if (segment) {\n this.segmentStack.push(segment)\n }\n break\n }\n\n case ContainedFieldType.Group: {\n this.dispatchGroup(saxNode, field as ContainedGroupField)\n break\n }\n }\n }\n\n private dispatchGroup (saxNode: ISaxNode, gf: ContainedGroupField): void {\n const stack: SegmentDescription[] = this.segmentStack\n const peek: SegmentDescription = stack[stack.length - 1]\n switch (peek.type) {\n case SegmentType.Msg:\n case SegmentType.Component: {\n this.startGroup(saxNode, gf)\n break\n }\n\n case SegmentType.Group: {\n if (gf.name === saxNode.name) {\n const ptr = this.locations.nextTagPos\n peek.addDelimiterPosition(ptr)\n const a = this.parseAttributes(saxNode.name, gf.definition, saxNode, SegmentType.Component)\n if (a) {\n stack.push(a)\n }\n } else {\n throw new Error(`expected another group instance of ${gf.name} but got ${saxNode.name}`)\n }\n break\n }\n\n default:\n throw new Error(`dispatchGroup has field ${gf.name} peek type ${peek.type}`)\n }\n }\n\n private element (saxNode: ISaxNode): void {\n // may terminate a group and move fields\n const field = this.getNextField(saxNode)\n if (!field) {\n const stack: SegmentDescription[] = this.segmentStack\n const peek: SegmentDescription = stack[stack.length - 1]\n throw new Error(`field ${saxNode.name} not known in set ${peek?.set?.name}`)\n }\n this.dispatch(saxNode, field)\n }\n\n private msg (saxNode: ISaxNode, inBatch: boolean = false): void {\n this.logger.debug(`${saxNode.name}: begin parse msg`)\n const type: string = saxNode.name\n const def: MessageDefinition | undefined = this.definitions.message.get(type)\n if (!def) {\n throw new Error(`unknown message type ${type}`)\n }\n if (inBatch) {\n const batch = this.segmentStack[0]\n batch.set = def\n }\n const segment: SegmentDescription | null = this.parseAttributes(type, def, saxNode, SegmentType.Msg)\n if (segment) {\n this.segmentStack.push(segment)\n }\n }\n\n private parseAttributes (name: string, set: IContainedSet, saxNode: ISaxNode, type: SegmentType): SegmentDescription | null {\n const locations = this.locations\n const attributes = saxNode.attributes\n const values = this.values\n let ptr: number\n if (attributes) {\n const keys: string[] = Object.keys(attributes)\n ptr = keys.length > 0 ? locations.nextTagPos : locations.nextTagPos - 1\n for (let j: number = 0; j < keys.length; ++j) {\n const k: string = keys[j]\n const v: string = attributes[k]\n const field: ContainedSimpleField = set.localNameToField.get(k) as ContainedSimpleField\n if (!field) {\n this.logger.warning(`no field ${k} in set ${set.name}`)\n locations.store(j, 1, -1)\n } else {\n locations.store(j, 1, field.definition.tag)\n }\n values[values.length] = v\n }\n return new SegmentDescription(name, locations.tagPos[ptr].tag, set, ptr, this.segmentStack.length, type)\n }\n return null\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
- import { IJsFixLogger } from './js-fix-logger';
1
+ import { IJsFixLogger, JsFixLogFields } from './js-fix-logger';
2
2
  import { JsFixLoggerFactory } from './js-fix-logger-factory';
3
3
  export declare class EmptyLogFactory extends JsFixLoggerFactory {
4
- logger(type: string): IJsFixLogger;
4
+ logger(type: string, _?: JsFixLogFields): IJsFixLogger;
5
5
  plain(fileName: string, maxSize?: number): IJsFixLogger;
6
6
  }
@@ -4,7 +4,7 @@ exports.EmptyLogFactory = void 0;
4
4
  const js_fix_logger_1 = require("./js-fix-logger");
5
5
  const js_fix_logger_factory_1 = require("./js-fix-logger-factory");
6
6
  class EmptyLogFactory extends js_fix_logger_factory_1.JsFixLoggerFactory {
7
- logger(type) {
7
+ logger(type, _) {
8
8
  return new js_fix_logger_1.EmptyLogger(type);
9
9
  }
10
10
  plain(fileName, maxSize) {
@@ -1 +1 @@
1
- {"version":3,"file":"empty-log-factory.js","sourceRoot":"","sources":["../../src/config/empty-log-factory.ts"],"names":[],"mappings":";;;AAAA,mDAA2D;AAC3D,mEAA4D;AAE5D,MAAa,eAAgB,SAAQ,0CAAkB;IAC9C,MAAM,CAAE,IAAY;QACzB,OAAO,IAAI,2BAAW,CAAC,IAAI,CAAC,CAAA;IAC9B,CAAC;IAEM,KAAK,CAAE,QAAgB,EAAE,OAAgB;QAC9C,OAAO,IAAI,2BAAW,EAAE,CAAA;IAC1B,CAAC;CACF;AARD,0CAQC","sourcesContent":["import { EmptyLogger, IJsFixLogger } from './js-fix-logger'\nimport { JsFixLoggerFactory } from './js-fix-logger-factory'\n\nexport class EmptyLogFactory extends JsFixLoggerFactory {\n public logger (type: string): IJsFixLogger {\n return new EmptyLogger(type)\n }\n\n public plain (fileName: string, maxSize?: number): IJsFixLogger {\n return new EmptyLogger()\n }\n}\n"]}
1
+ {"version":3,"file":"empty-log-factory.js","sourceRoot":"","sources":["../../src/config/empty-log-factory.ts"],"names":[],"mappings":";;;AAAA,mDAA2E;AAC3E,mEAA4D;AAE5D,MAAa,eAAgB,SAAQ,0CAAkB;IAC9C,MAAM,CAAE,IAAY,EAAE,CAAkB;QAC7C,OAAO,IAAI,2BAAW,CAAC,IAAI,CAAC,CAAA;IAC9B,CAAC;IAEM,KAAK,CAAE,QAAgB,EAAE,OAAgB;QAC9C,OAAO,IAAI,2BAAW,EAAE,CAAA;IAC1B,CAAC;CACF;AARD,0CAQC","sourcesContent":["import { EmptyLogger, IJsFixLogger, JsFixLogFields } from './js-fix-logger'\nimport { JsFixLoggerFactory } from './js-fix-logger-factory'\n\nexport class EmptyLogFactory extends JsFixLoggerFactory {\n public logger (type: string, _?: JsFixLogFields): IJsFixLogger {\n return new EmptyLogger(type)\n }\n\n public plain (fileName: string, maxSize?: number): IJsFixLogger {\n return new EmptyLogger()\n }\n}\n"]}
@@ -1,2 +1,2 @@
1
- import { IJsFixLogger } from './js-fix-logger';
2
- export type GetJsFixLogger = (type: string) => IJsFixLogger;
1
+ import { IJsFixLogger, JsFixLogFields } from './js-fix-logger';
2
+ export type GetJsFixLogger = (type: string, context?: JsFixLogFields) => IJsFixLogger;
@@ -1 +1 @@
1
- {"version":3,"file":"get-js-fx-logger.js","sourceRoot":"","sources":["../../src/config/get-js-fx-logger.ts"],"names":[],"mappings":"","sourcesContent":["import { IJsFixLogger } from './js-fix-logger'\n\nexport type GetJsFixLogger = (type: string) => IJsFixLogger\n"]}
1
+ {"version":3,"file":"get-js-fx-logger.js","sourceRoot":"","sources":["../../src/config/get-js-fx-logger.ts"],"names":[],"mappings":"","sourcesContent":["import { IJsFixLogger, JsFixLogFields } from './js-fix-logger'\n\nexport type GetJsFixLogger = (type: string, context?: JsFixLogFields) => IJsFixLogger\n"]}
@@ -1,5 +1,5 @@
1
- import { IJsFixLogger } from './js-fix-logger';
1
+ import { IJsFixLogger, JsFixLogFields } from './js-fix-logger';
2
2
  export declare abstract class JsFixLoggerFactory {
3
- abstract logger(type: string): IJsFixLogger;
3
+ abstract logger(type: string, context?: JsFixLogFields): IJsFixLogger;
4
4
  abstract plain(fileName: string, maxSize?: number): IJsFixLogger;
5
5
  }
@@ -1 +1 @@
1
- {"version":3,"file":"js-fix-logger-factory.js","sourceRoot":"","sources":["../../src/config/js-fix-logger-factory.ts"],"names":[],"mappings":";;;AAEA,MAAsB,kBAAkB;CAGvC;AAHD,gDAGC","sourcesContent":["import { IJsFixLogger } from './js-fix-logger'\n\nexport abstract class JsFixLoggerFactory {\n public abstract logger (type: string): IJsFixLogger\n public abstract plain (fileName: string, maxSize?: number): IJsFixLogger\n}\n"]}
1
+ {"version":3,"file":"js-fix-logger-factory.js","sourceRoot":"","sources":["../../src/config/js-fix-logger-factory.ts"],"names":[],"mappings":";;;AAEA,MAAsB,kBAAkB;CASvC;AATD,gDASC","sourcesContent":["import { IJsFixLogger, JsFixLogFields } from './js-fix-logger'\n\nexport abstract class JsFixLoggerFactory {\n /**\n * @param type the legacy display name, e.g. 'me:peer:FixSession'. it is what the\n * console format renders between brackets, so it is passed verbatim and unchanged\n * @param context fields bound to every line this logger writes. an implementation\n * written before this argument existed keeps compiling and simply ignores it\n */\n public abstract logger (type: string, context?: JsFixLogFields): IJsFixLogger\n public abstract plain (fileName: string, maxSize?: number): IJsFixLogger\n}\n"]}
@@ -1,15 +1,16 @@
1
+ export type JsFixLogFields = Record<string, unknown>;
1
2
  export interface IJsFixLogger {
2
- info: (message: string) => void;
3
- warning: (message: string) => void;
4
- debug: (message: string) => void;
5
- error: (e: Error) => void;
3
+ info: (message: string, fields?: JsFixLogFields) => void;
4
+ warning: (message: string, fields?: JsFixLogFields) => void;
5
+ debug: (message: string, fields?: JsFixLogFields) => void;
6
+ error: (e: Error, fields?: JsFixLogFields) => void;
6
7
  }
7
8
  export declare class EmptyLogger implements IJsFixLogger {
8
9
  readonly type: string;
9
10
  constructor(type?: string);
10
- info(_: string): void;
11
- warning(_: string): void;
12
- debug(_: string): void;
13
- error(_: Error): void;
11
+ info(_: string, __?: JsFixLogFields): void;
12
+ warning(_: string, __?: JsFixLogFields): void;
13
+ debug(_: string, __?: JsFixLogFields): void;
14
+ error(_: Error, __?: JsFixLogFields): void;
14
15
  }
15
16
  export declare function makeEmptyLogger(type: string): IJsFixLogger;
@@ -6,13 +6,13 @@ class EmptyLogger {
6
6
  constructor(type = '') {
7
7
  this.type = type;
8
8
  }
9
- info(_) {
9
+ info(_, __) {
10
10
  }
11
- warning(_) {
11
+ warning(_, __) {
12
12
  }
13
- debug(_) {
13
+ debug(_, __) {
14
14
  }
15
- error(_) {
15
+ error(_, __) {
16
16
  }
17
17
  }
18
18
  exports.EmptyLogger = EmptyLogger;
@@ -1 +1 @@
1
- {"version":3,"file":"js-fix-logger.js","sourceRoot":"","sources":["../../src/config/js-fix-logger.ts"],"names":[],"mappings":";;;AA4BA,0CAEC;AAvBD,MAAa,WAAW;IACtB,YAA6B,OAAe,EAAE;QAAjB,SAAI,GAAJ,IAAI,CAAa;IAC9C,CAAC;IAEM,IAAI,CAAE,CAAS;IAEtB,CAAC;IAEM,OAAO,CAAE,CAAS;IAEzB,CAAC;IAEM,KAAK,CAAE,CAAS;IAEvB,CAAC;IAEM,KAAK,CAAE,CAAQ;IAEtB,CAAC;CACF;AAnBD,kCAmBC;AAED,SAAgB,eAAe,CAAE,IAAY;IAC3C,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,CAAA;AAC9B,CAAC","sourcesContent":["export interface IJsFixLogger {\n info: (message: string) => void\n warning: (message: string) => void\n debug: (message: string) => void\n error: (e: Error) => void\n}\n\nexport class EmptyLogger implements IJsFixLogger {\n constructor (public readonly type: string = '') {\n }\n\n public info (_: string): void {\n // nothing\n }\n\n public warning (_: string): void {\n // nothing\n }\n\n public debug (_: string): void {\n // nothing\n }\n\n public error (_: Error): void {\n // nothing\n }\n}\n\nexport function makeEmptyLogger (type: string): IJsFixLogger {\n return new EmptyLogger(type)\n}\n"]}
1
+ {"version":3,"file":"js-fix-logger.js","sourceRoot":"","sources":["../../src/config/js-fix-logger.ts"],"names":[],"mappings":";;;AA2CA,0CAEC;AAvBD,MAAa,WAAW;IACtB,YAA6B,OAAe,EAAE;QAAjB,SAAI,GAAJ,IAAI,CAAa;IAC9C,CAAC;IAEM,IAAI,CAAE,CAAS,EAAE,EAAmB;IAE3C,CAAC;IAEM,OAAO,CAAE,CAAS,EAAE,EAAmB;IAE9C,CAAC;IAEM,KAAK,CAAE,CAAS,EAAE,EAAmB;IAE5C,CAAC;IAEM,KAAK,CAAE,CAAQ,EAAE,EAAmB;IAE3C,CAAC;CACF;AAnBD,kCAmBC;AAED,SAAgB,eAAe,CAAE,IAAY;IAC3C,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,CAAA;AAC9B,CAAC","sourcesContent":["/**\n * structured fields carried alongside a log message.\n *\n * two kinds travel through the same shape. *context* is bound once when a logger is made\n * and repeats on every line it writes - the component, the application, the counterparty.\n * *fields* are supplied per call and carry a value worth aggregating on - a msgType, a\n * sequence number, a byte count.\n *\n * they are deliberately kept as a bag rather than spread into the log record, so a caller\n * passing { message: ... } cannot clobber the real message, and so the choice of how to\n * render them belongs to the formatter rather than the engine. see\n * docs/instrumentation.md.\n */\nexport type JsFixLogFields = Record<string, unknown>\n\nexport interface IJsFixLogger {\n info: (message: string, fields?: JsFixLogFields) => void\n warning: (message: string, fields?: JsFixLogFields) => void\n debug: (message: string, fields?: JsFixLogFields) => void\n error: (e: Error, fields?: JsFixLogFields) => void\n}\n\nexport class EmptyLogger implements IJsFixLogger {\n constructor (public readonly type: string = '') {\n }\n\n public info (_: string, __?: JsFixLogFields): void {\n // nothing\n }\n\n public warning (_: string, __?: JsFixLogFields): void {\n // nothing\n }\n\n public debug (_: string, __?: JsFixLogFields): void {\n // nothing\n }\n\n public error (_: Error, __?: JsFixLogFields): void {\n // nothing\n }\n}\n\nexport function makeEmptyLogger (type: string): IJsFixLogger {\n return new EmptyLogger(type)\n}\n"]}
@@ -1,9 +1,9 @@
1
- import { IJsFixLogger } from './js-fix-logger';
1
+ import { IJsFixLogger, JsFixLogFields } from './js-fix-logger';
2
2
  import { JsFixLoggerFactory } from './js-fix-logger-factory';
3
3
  export declare class JsFixWinstonLogFactory extends JsFixLoggerFactory {
4
4
  readonly options: any;
5
5
  private readonly wl;
6
6
  constructor(options?: any);
7
- logger(type: string): IJsFixLogger;
7
+ logger(type: string, context?: JsFixLogFields): IJsFixLogger;
8
8
  plain(fileName: string, maxSize?: number): IJsFixLogger;
9
9
  }
@@ -9,8 +9,8 @@ class JsFixWinstonLogFactory extends js_fix_logger_factory_1.JsFixLoggerFactory
9
9
  this.options = options;
10
10
  this.wl = new winston_logger_1.WinstonLogger(options);
11
11
  }
12
- logger(type) {
13
- return this.wl.make(type);
12
+ logger(type, context) {
13
+ return this.wl.make(type, context);
14
14
  }
15
15
  plain(fileName, maxSize) {
16
16
  return this.wl.plain(fileName, maxSize);
@@ -1 +1 @@
1
- {"version":3,"file":"js-fix-winston-log-factory.js","sourceRoot":"","sources":["../../src/config/js-fix-winston-log-factory.ts"],"names":[],"mappings":";;;AACA,qDAAgD;AAChD,mEAA4D;AAE5D,MAAa,sBAAuB,SAAQ,0CAAkB;IAG5D,YAA6B,UAAe,8BAAa,CAAC,cAAc,EAAE;QACxE,KAAK,EAAE,CAAA;QADoB,YAAO,GAAP,OAAO,CAAsC;QAExE,IAAI,CAAC,EAAE,GAAG,IAAI,8BAAa,CAAC,OAAO,CAAC,CAAA;IACtC,CAAC;IAEM,MAAM,CAAE,IAAY;QACzB,OAAO,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAEM,KAAK,CAAE,QAAgB,EAAE,OAAgB;QAC9C,OAAO,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IACzC,CAAC;CACF;AAfD,wDAeC","sourcesContent":["import { IJsFixLogger } from './js-fix-logger'\nimport { WinstonLogger } from './winston-logger'\nimport { JsFixLoggerFactory } from './js-fix-logger-factory'\n\nexport class JsFixWinstonLogFactory extends JsFixLoggerFactory {\n private readonly wl: WinstonLogger\n\n constructor (public readonly options: any = WinstonLogger.consoleOptions()) {\n super()\n this.wl = new WinstonLogger(options)\n }\n\n public logger (type: string): IJsFixLogger {\n return this.wl.make(type)\n }\n\n public plain (fileName: string, maxSize?: number): IJsFixLogger {\n return this.wl.plain(fileName, maxSize)\n }\n}\n"]}
1
+ {"version":3,"file":"js-fix-winston-log-factory.js","sourceRoot":"","sources":["../../src/config/js-fix-winston-log-factory.ts"],"names":[],"mappings":";;;AACA,qDAAgD;AAChD,mEAA4D;AAE5D,MAAa,sBAAuB,SAAQ,0CAAkB;IAG5D,YAA6B,UAAe,8BAAa,CAAC,cAAc,EAAE;QACxE,KAAK,EAAE,CAAA;QADoB,YAAO,GAAP,OAAO,CAAsC;QAExE,IAAI,CAAC,EAAE,GAAG,IAAI,8BAAa,CAAC,OAAO,CAAC,CAAA;IACtC,CAAC;IAEM,MAAM,CAAE,IAAY,EAAE,OAAwB;QACnD,OAAO,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IACpC,CAAC;IAEM,KAAK,CAAE,QAAgB,EAAE,OAAgB;QAC9C,OAAO,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IACzC,CAAC;CACF;AAfD,wDAeC","sourcesContent":["import { IJsFixLogger, JsFixLogFields } from './js-fix-logger'\nimport { WinstonLogger } from './winston-logger'\nimport { JsFixLoggerFactory } from './js-fix-logger-factory'\n\nexport class JsFixWinstonLogFactory extends JsFixLoggerFactory {\n private readonly wl: WinstonLogger\n\n constructor (public readonly options: any = WinstonLogger.consoleOptions()) {\n super()\n this.wl = new WinstonLogger(options)\n }\n\n public logger (type: string, context?: JsFixLogFields): IJsFixLogger {\n return this.wl.make(type, context)\n }\n\n public plain (fileName: string, maxSize?: number): IJsFixLogger {\n return this.wl.plain(fileName, maxSize)\n }\n}\n"]}
@@ -1,12 +1,15 @@
1
- import { IJsFixLogger } from './js-fix-logger';
1
+ import { IJsFixLogger, JsFixLogFields } from './js-fix-logger';
2
2
  export declare class WinstonLogger {
3
3
  readonly options: any;
4
4
  static readonly appFormat: any;
5
5
  static readonly plainFormat: any;
6
+ static readonly ecsFormat: any;
6
7
  private readonly appLogger;
7
8
  constructor(options?: any);
8
9
  static consoleOptions(level?: string): any;
10
+ static ecsOptions(level?: string): any;
11
+ static ecsFileOptions(fileName: string, level?: string, maxSize?: number): any;
9
12
  static fileOptions(fileName: string, level?: string, maxSize?: number, format?: any): any;
10
13
  plain(fileName: string, maxSize?: number): IJsFixLogger;
11
- make(type: string): IJsFixLogger;
14
+ make(type: string, context?: JsFixLogFields): IJsFixLogger;
12
15
  }
@@ -17,6 +17,18 @@ class WinstonLogger {
17
17
  ]
18
18
  };
19
19
  }
20
+ static ecsOptions(level = 'debug') {
21
+ return {
22
+ format: combine(timestamp(), WinstonLogger.ecsFormat(), format.json()),
23
+ level,
24
+ transports: [
25
+ new transports.Console()
26
+ ]
27
+ };
28
+ }
29
+ static ecsFileOptions(fileName, level = 'debug', maxSize = 50 * 1024 * 1024) {
30
+ return WinstonLogger.fileOptions(fileName, level, maxSize, combine(timestamp(), WinstonLogger.ecsFormat(), format.json()));
31
+ }
20
32
  static fileOptions(fileName, level = 'debug', maxSize = 50 * 1024 * 1024, format = combine(timestamp(), WinstonLogger.appFormat)) {
21
33
  return {
22
34
  format,
@@ -60,31 +72,40 @@ class WinstonLogger {
60
72
  }
61
73
  };
62
74
  }
63
- make(type) {
75
+ make(type, context) {
64
76
  const logger = this.appLogger;
65
77
  return {
66
- info: function (msg) {
78
+ info: function (msg, fields) {
67
79
  logger.info({
68
80
  type,
69
- message: msg
81
+ message: msg,
82
+ context,
83
+ fields
70
84
  });
71
85
  },
72
- debug: function (msg) {
86
+ debug: function (msg, fields) {
73
87
  logger.debug({
74
88
  type,
75
- message: msg
89
+ message: msg,
90
+ context,
91
+ fields
76
92
  });
77
93
  },
78
- warning: function (msg) {
94
+ warning: function (msg, fields) {
79
95
  logger.warn({
80
96
  type,
81
- message: msg
97
+ message: msg,
98
+ context,
99
+ fields
82
100
  });
83
101
  },
84
- error: function (e) {
102
+ error: function (e, fields) {
85
103
  logger.error({
86
104
  type,
87
- message: `${e.message} : ${e.stack}`
105
+ message: `${e.message} : ${e.stack}`,
106
+ err: e,
107
+ context,
108
+ fields
88
109
  });
89
110
  }
90
111
  };
@@ -97,4 +118,31 @@ WinstonLogger.appFormat = printf((info) => {
97
118
  WinstonLogger.plainFormat = printf((info) => {
98
119
  return `${info.message}`;
99
120
  });
121
+ WinstonLogger.ecsFormat = format((info) => {
122
+ var _a, _b;
123
+ const context = (_a = info.context) !== null && _a !== void 0 ? _a : {};
124
+ const fields = (_b = info.fields) !== null && _b !== void 0 ? _b : {};
125
+ const err = info.err;
126
+ delete info.context;
127
+ delete info.fields;
128
+ delete info.err;
129
+ delete info.type;
130
+ info['@timestamp'] = info.timestamp;
131
+ info['log.level'] = info.level;
132
+ info['service.name'] = 'jspurefix';
133
+ delete info.timestamp;
134
+ delete info.level;
135
+ if (err) {
136
+ info['error.message'] = err.message;
137
+ info['error.stack_trace'] = err.stack;
138
+ info.message = err.message;
139
+ }
140
+ for (const key of Object.keys(context)) {
141
+ info[`fix.${key}`] = context[key];
142
+ }
143
+ for (const key of Object.keys(fields)) {
144
+ info[`fix.${key}`] = fields[key];
145
+ }
146
+ return info;
147
+ });
100
148
  //# sourceMappingURL=winston-logger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"winston-logger.js","sourceRoot":"","sources":["../../src/config/winston-logger.ts"],"names":[],"mappings":";;;AAEA,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;AAC/D,MAAM,EAAE,OAAO,EAAE,SAAS,E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C,CAAC,IAAS,EAAE,EAAE;IACxD,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAA;AAC1B,CAAC,CAAC,CAAA","sourcesContent":["import { IJsFixLogger } from './js-fix-logger'\nimport { Logger } from 'winston'\nconst { createLogger, format, transports } = require('winston')\nconst { combine, timestamp, printf } = format\n\nexport class WinstonLogger {\n public static readonly appFormat = printf((info: any) => {\n return `${info.timestamp} [${info.type}] ${info.level}: ${info.message}`\n })\n\n public static readonly plainFormat = printf((info: any) => {\n return `${info.message}`\n })\n\n private readonly appLogger: Logger\n\n constructor (public readonly options: any = WinstonLogger.consoleOptions()) {\n this.appLogger = createLogger(options)\n }\n\n public static consoleOptions (level: string = 'debug'): any {\n return {\n format: combine(\n timestamp(),\n WinstonLogger.appFormat\n ),\n level,\n transports: [\n new transports.Console()\n ]\n }\n }\n\n public static fileOptions (fileName: string, level: string = 'debug', maxSize: number = 50 * 1024 * 1024, format: any = combine(\n timestamp(),\n WinstonLogger.appFormat\n )): any {\n return {\n format,\n level,\n transports: [\n new transports.File({\n filename: fileName,\n maxsize: maxSize\n })\n ]\n }\n }\n\n public plain (fileName: string, maxSize: number = 10 * 1024 * 1024): IJsFixLogger {\n const txtLogger: Logger = createLogger({\n format: WinstonLogger.plainFormat,\n level: 'info',\n transports: [\n new transports.File({\n filename: fileName,\n maxsize: maxSize\n })\n ]\n })\n\n return {\n log: function (txt: string) {\n txtLogger.info({\n type: 'info',\n message: txt\n })\n },\n\n info: function (msg: string): void {\n (this as any).log(msg)\n },\n debug: function (msg: string): void {\n (this as any).log(msg)\n },\n warning: function (msg: string): void {\n (this as any).log(msg)\n },\n error: function (): void {\n // nothing\n }\n } as IJsFixLogger\n }\n\n public make (type: string): IJsFixLogger {\n const logger = this.appLogger\n return {\n info: function (msg: string): void {\n logger.info({\n type,\n message: msg\n })\n },\n debug: function (msg: string): void {\n logger.debug({\n type,\n message: msg\n })\n },\n warning: function (msg: string): void {\n logger.warn({\n type,\n message: msg\n })\n },\n error: function (e: Error): void {\n logger.error({\n type,\n message: `${e.message} : ${e.stack}`\n })\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"winston-logger.js","sourceRoot":"","sources":["../../src/config/winston-logger.ts"],"names":[],"mappings":";;;AAEA,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;AAC/D,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;AAE7C,MAAa,aAAa;IAyDxB,YAA6B,UAAe,aAAa,CAAC,cAAc,EAAE;QAA7C,YAAO,GAAP,OAAO,CAAsC;QACxE,IAAI,CAAC,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC,CAAA;IACxC,CAAC;IAEM,MAAM,CAAC,cAAc,CAAE,QAAgB,OAAO;QACnD,OAAO;YACL,MAAM,EAAE,OAAO,CACb,SAAS,EAAE,EACX,aAAa,CAAC,SAAS,CACxB;YACD,KAAK;YACL,UAAU,EAAE;gBACV,IAAI,UAAU,CAAC,OAAO,EAAE;aACzB;SACF,CAAA;IACH,CAAC;IAMM,MAAM,CAAC,UAAU,CAAE,QAAgB,OAAO;QAC/C,OAAO;YACL,MAAM,EAAE,OAAO,CACb,SAAS,EAAE,EACX,aAAa,CAAC,SAAS,EAAE,EACzB,MAAM,CAAC,IAAI,EAAE,CACd;YACD,KAAK;YACL,UAAU,EAAE;gBACV,IAAI,UAAU,CAAC,OAAO,EAAE;aACzB;SACF,CAAA;IACH,CAAC;IAEM,MAAM,CAAC,cAAc,CAAE,QAAgB,EAAE,QAAgB,OAAO,EAAE,UAAkB,EAAE,GAAG,IAAI,GAAG,IAAI;QACzG,OAAO,aAAa,CAAC,WAAW,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAChE,SAAS,EAAE,EACX,aAAa,CAAC,SAAS,EAAE,EACzB,MAAM,CAAC,IAAI,EAAE,CACd,CAAC,CAAA;IACJ,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;IAClC,MAAM,MAAM,GAAG,MAAA,IAAI,CAAC,MAAM,mCAAI,EAAE,CAAA;IAChC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAA;IACpB,OAAO,IAAI,CAAC,OAAO,CAAA;IACnB,OAAO,IAAI,CAAC,MAAM,CAAA;IAClB,OAAO,IAAI,CAAC,GAAG,CAAA;IAEf,OAAO,IAAI,CAAC,IAAI,CAAA;IAChB,IAAI,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,SAAS,CAAA;IACnC,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,KAAK,CAAA;IAC9B,IAAI,CAAC,cAAc,CAAC,GAAG,WAAW,CAAA;IAClC,OAAO,IAAI,CAAC,SAAS,CAAA;IAIrB,OAAO,IAAI,CAAC,KAAK,CAAA;IACjB,IAAI,GAAG,EAAE,CAAC;QACR,IAAI,CAAC,eAAe,CAAC,GAAG,GAAG,CAAC,OAAO,CAAA;QACnC,IAAI,CAAC,mBAAmB,CAAC,GAAG,GAAG,CAAC,KAAK,CAAA;QAIrC,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,CAAA;IAC5B,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;IACnC,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;IAClC,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAC,CAAA","sourcesContent":["import { IJsFixLogger, JsFixLogFields } from './js-fix-logger'\nimport { Logger } from 'winston'\nconst { createLogger, format, transports } = require('winston')\nconst { combine, timestamp, printf } = format\n\nexport class WinstonLogger {\n /**\n * the format this engine has emitted since it shipped. it names exactly four fields, so\n * the context and fields bags added later are invisible to it and the rendered line is\n * unchanged - which is the whole reason they travel as separate keys. covered by a\n * golden output test; do not widen it.\n */\n public static readonly appFormat = printf((info: any) => {\n return `${info.timestamp} [${info.type}] ${info.level}: ${info.message}`\n })\n\n public static readonly plainFormat = printf((info: any) => {\n return `${info.message}`\n })\n\n /**\n * flattens the context and fields bags to ECS style names for Filebeat and friends.\n *\n * this MUST mutate info rather than return a fresh object - a new object loses\n * Symbol.for('level') and winston then discards the record with no output and no error.\n */\n public static readonly ecsFormat = format((info: any) => {\n const context = info.context ?? {}\n const fields = info.fields ?? {}\n const err = info.err\n delete info.context\n delete info.fields\n delete info.err\n // the legacy display name is redundant once component and app are real fields\n delete info.type\n info['@timestamp'] = info.timestamp\n info['log.level'] = info.level\n info['service.name'] = 'jspurefix'\n delete info.timestamp\n // winston sets its own level, and emitting it beside the ECS name puts the same\n // value on every line twice. the transport filters on Symbol.for('level'), not\n // this property, so dropping it changes nothing about what gets logged\n delete info.level\n if (err) {\n info['error.message'] = err.message\n info['error.stack_trace'] = err.stack\n // the record composed for the console carries the stack inside the message,\n // because that is what has always been rendered there. here the stack has a\n // field of its own, so repeating it in the message only doubles the line\n info.message = err.message\n }\n for (const key of Object.keys(context)) {\n info[`fix.${key}`] = context[key]\n }\n for (const key of Object.keys(fields)) {\n info[`fix.${key}`] = fields[key]\n }\n return info\n })\n\n private readonly appLogger: Logger\n\n constructor (public readonly options: any = WinstonLogger.consoleOptions()) {\n this.appLogger = createLogger(options)\n }\n\n public static consoleOptions (level: string = 'debug'): any {\n return {\n format: combine(\n timestamp(),\n WinstonLogger.appFormat\n ),\n level,\n transports: [\n new transports.Console()\n ]\n }\n }\n\n /**\n * one JSON object per line, ECS style names, ready to be harvested. opt in - the\n * console default is deliberately left alone so an upgrade does not move anyone's logs.\n */\n public static ecsOptions (level: string = 'debug'): any {\n return {\n format: combine(\n timestamp(),\n WinstonLogger.ecsFormat(),\n format.json()\n ),\n level,\n transports: [\n new transports.Console()\n ]\n }\n }\n\n public static ecsFileOptions (fileName: string, level: string = 'debug', maxSize: number = 50 * 1024 * 1024): any {\n return WinstonLogger.fileOptions(fileName, level, maxSize, combine(\n timestamp(),\n WinstonLogger.ecsFormat(),\n format.json()\n ))\n }\n\n public static fileOptions (fileName: string, level: string = 'debug', maxSize: number = 50 * 1024 * 1024, format: any = combine(\n timestamp(),\n WinstonLogger.appFormat\n )): any {\n return {\n format,\n level,\n transports: [\n new transports.File({\n filename: fileName,\n maxsize: maxSize\n })\n ]\n }\n }\n\n public plain (fileName: string, maxSize: number = 10 * 1024 * 1024): IJsFixLogger {\n const txtLogger: Logger = createLogger({\n format: WinstonLogger.plainFormat,\n level: 'info',\n transports: [\n new transports.File({\n filename: fileName,\n maxsize: maxSize\n })\n ]\n })\n\n return {\n log: function (txt: string) {\n txtLogger.info({\n type: 'info',\n message: txt\n })\n },\n\n info: function (msg: string): void {\n (this as any).log(msg)\n },\n debug: function (msg: string): void {\n (this as any).log(msg)\n },\n warning: function (msg: string): void {\n (this as any).log(msg)\n },\n error: function (): void {\n // nothing\n }\n } as IJsFixLogger\n }\n\n public make (type: string, context?: JsFixLogFields): IJsFixLogger {\n const logger = this.appLogger\n return {\n info: function (msg: string, fields?: JsFixLogFields): void {\n logger.info({\n type,\n message: msg,\n context,\n fields\n })\n },\n debug: function (msg: string, fields?: JsFixLogFields): void {\n logger.debug({\n type,\n message: msg,\n context,\n fields\n })\n },\n warning: function (msg: string, fields?: JsFixLogFields): void {\n logger.warn({\n type,\n message: msg,\n context,\n fields\n })\n },\n error: function (e: Error, fields?: JsFixLogFields): void {\n logger.error({\n type,\n // composed exactly as it always has been, so the console line does not move.\n // the ecs format lifts error.message and error.stack_trace off err instead\n message: `${e.message} : ${e.stack}`,\n err: e,\n context,\n fields\n })\n }\n }\n }\n}\n"]}
@@ -0,0 +1,26 @@
1
+ import { IContainedSet } from './contained';
2
+ import { FixDefinitions } from './definition';
3
+ export declare enum FragmentSafetyCode {
4
+ SiblingTagCollision = "sibling-tag-collision",
5
+ UnclaimableComponent = "unclaimable-component"
6
+ }
7
+ export interface IFragmentSafetyFinding {
8
+ readonly code: FragmentSafetyCode;
9
+ readonly path: string;
10
+ readonly set: string;
11
+ readonly tag: number;
12
+ readonly owners: string[];
13
+ }
14
+ export declare function describeFinding(f: IFragmentSafetyFinding): string;
15
+ export declare class FragmentSafety {
16
+ private readonly findings;
17
+ private readonly analysed;
18
+ private readonly owned;
19
+ ownTags(set: IContainedSet): number[];
20
+ static analyse(definitions: FixDefinitions): IFragmentSafetyFinding[];
21
+ static analyseSet(set: IContainedSet, path?: string): IFragmentSafetyFinding[];
22
+ private walk;
23
+ private checkClaimable;
24
+ private checkSiblings;
25
+ private claimsOf;
26
+ }