jspurefix 5.3.0 → 5.5.4
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/BACKPORT_PLAN.md +120 -10
- package/DEMO_PORT_PLAN.md +286 -0
- package/dist/dictionary/parser/quickfix/dictionary-validator.d.ts +39 -0
- package/dist/dictionary/parser/quickfix/dictionary-validator.js +321 -0
- package/dist/dictionary/parser/quickfix/dictionary-validator.js.map +1 -0
- package/dist/dictionary/parser/quickfix/index-visitor.d.ts +10 -0
- package/dist/dictionary/parser/quickfix/index-visitor.js +68 -0
- package/dist/dictionary/parser/quickfix/index-visitor.js.map +1 -0
- package/dist/dictionary/parser/quickfix/index.d.ts +7 -0
- package/dist/dictionary/parser/quickfix/index.js +7 -0
- package/dist/dictionary/parser/quickfix/index.js.map +1 -1
- package/dist/dictionary/parser/quickfix/quick-fix-graph-file-parser.d.ts +13 -0
- package/dist/dictionary/parser/quickfix/quick-fix-graph-file-parser.js +65 -0
- package/dist/dictionary/parser/quickfix/quick-fix-graph-file-parser.js.map +1 -0
- package/dist/dictionary/parser/quickfix/quick-fix-graph-parser.d.ts +73 -0
- package/dist/dictionary/parser/quickfix/quick-fix-graph-parser.js +363 -0
- package/dist/dictionary/parser/quickfix/quick-fix-graph-parser.js.map +1 -0
- package/dist/dictionary/parser/quickfix/sax-tree-builder.d.ts +5 -0
- package/dist/dictionary/parser/quickfix/sax-tree-builder.js +103 -0
- package/dist/dictionary/parser/quickfix/sax-tree-builder.js.map +1 -0
- package/dist/dictionary/parser/quickfix/validation-error.d.ts +17 -0
- package/dist/dictionary/parser/quickfix/validation-error.js +32 -0
- package/dist/dictionary/parser/quickfix/validation-error.js.map +1 -0
- package/dist/dictionary/parser/quickfix/x-element.d.ts +26 -0
- package/dist/dictionary/parser/quickfix/x-element.js +82 -0
- package/dist/dictionary/parser/quickfix/x-element.js.map +1 -0
- package/dist/store/fix-msg-ascii-store-resend.js +6 -0
- package/dist/store/fix-msg-ascii-store-resend.js.map +1 -1
- package/dist/store/store-config.d.ts +1 -0
- package/dist/store/store-config.js.map +1 -1
- package/dist/transport/ascii/ascii-session.js +3 -0
- package/dist/transport/ascii/ascii-session.js.map +1 -1
- package/dist/util/definition-factory.js +1 -1
- package/dist/util/definition-factory.js.map +1 -1
- package/jsfix.test_client.txt +67 -67
- package/jsfix.test_server.txt +64 -64
- package/package.json +6 -6
- package/src/dictionary/parser/quickfix/dictionary-validator.ts +473 -0
- package/src/dictionary/parser/quickfix/index-visitor.ts +100 -0
- package/src/dictionary/parser/quickfix/index.ts +7 -0
- package/src/dictionary/parser/quickfix/quick-fix-graph-file-parser.ts +63 -0
- package/src/dictionary/parser/quickfix/quick-fix-graph-parser.ts +450 -0
- package/src/dictionary/parser/quickfix/sax-tree-builder.ts +112 -0
- package/src/dictionary/parser/quickfix/validation-error.ts +34 -0
- package/src/dictionary/parser/quickfix/x-element.ts +115 -0
- package/src/store/fix-msg-ascii-store-resend.ts +8 -0
- package/src/store/store-config.ts +1 -0
- package/src/transport/ascii/ascii-session.ts +4 -0
- package/src/util/definition-factory.ts +2 -2
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DictionaryValidationException = exports.ValidationSeverity = void 0;
|
|
4
|
+
var ValidationSeverity;
|
|
5
|
+
(function (ValidationSeverity) {
|
|
6
|
+
ValidationSeverity["Warning"] = "Warning";
|
|
7
|
+
ValidationSeverity["Error"] = "Error";
|
|
8
|
+
})(ValidationSeverity || (exports.ValidationSeverity = ValidationSeverity = {}));
|
|
9
|
+
class DictionaryValidationException extends Error {
|
|
10
|
+
constructor(errors) {
|
|
11
|
+
const errorCount = errors.filter(e => e.severity === ValidationSeverity.Error).length;
|
|
12
|
+
const warningCount = errors.filter(e => e.severity === ValidationSeverity.Warning).length;
|
|
13
|
+
const header = `FIX dictionary validation failed with ${errorCount} error(s) and ${warningCount} warning(s):`;
|
|
14
|
+
const details = errors
|
|
15
|
+
.filter(e => e.severity === ValidationSeverity.Error)
|
|
16
|
+
.slice(0, 20)
|
|
17
|
+
.map(e => {
|
|
18
|
+
let line = ` [${e.code}] ${e.message}`;
|
|
19
|
+
if (e.lineNumber != null)
|
|
20
|
+
line += ` (line ${e.lineNumber})`;
|
|
21
|
+
if (e.suggestion)
|
|
22
|
+
line += ` — ${e.suggestion}`;
|
|
23
|
+
return line;
|
|
24
|
+
})
|
|
25
|
+
.join('\n');
|
|
26
|
+
super(`${header}\n${details}`);
|
|
27
|
+
this.errors = errors;
|
|
28
|
+
this.name = 'DictionaryValidationException';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.DictionaryValidationException = DictionaryValidationException;
|
|
32
|
+
//# sourceMappingURL=validation-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation-error.js","sourceRoot":"","sources":["../../../../src/dictionary/parser/quickfix/validation-error.ts"],"names":[],"mappings":";;;AAAA,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,yCAAmB,CAAA;IACnB,qCAAe,CAAA;AACjB,CAAC,EAHW,kBAAkB,kCAAlB,kBAAkB,QAG7B;AAYD,MAAa,6BAA8B,SAAQ,KAAK;IACtD,YAA6B,MAAsC;QACjE,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,kBAAkB,CAAC,KAAK,CAAC,CAAC,MAAM,CAAA;QACrF,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,kBAAkB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAA;QACzF,MAAM,MAAM,GAAG,yCAAyC,UAAU,iBAAiB,YAAY,cAAc,CAAA;QAC7G,MAAM,OAAO,GAAG,MAAM;aACnB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,kBAAkB,CAAC,KAAK,CAAC;aACpD,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;aACZ,GAAG,CAAC,CAAC,CAAC,EAAE;YACP,IAAI,IAAI,GAAG,MAAM,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,EAAE,CAAA;YACvC,IAAI,CAAC,CAAC,UAAU,IAAI,IAAI;gBAAE,IAAI,IAAI,UAAU,CAAC,CAAC,UAAU,GAAG,CAAA;YAC3D,IAAI,CAAC,CAAC,UAAU;gBAAE,IAAI,IAAI,MAAM,CAAC,CAAC,UAAU,EAAE,CAAA;YAC9C,OAAO,IAAI,CAAA;QACb,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,CAAA;QACb,KAAK,CAAC,GAAG,MAAM,KAAK,OAAO,EAAE,CAAC,CAAA;QAdH,WAAM,GAAN,MAAM,CAAgC;QAejE,IAAI,CAAC,IAAI,GAAG,+BAA+B,CAAA;IAC7C,CAAC;CACF;AAlBD,sEAkBC","sourcesContent":["export enum ValidationSeverity {\n Warning = 'Warning',\n Error = 'Error'\n}\n\nexport interface ValidationError {\n readonly severity: ValidationSeverity\n readonly code: string\n readonly message: string\n readonly elementName?: string\n readonly elementType?: string\n readonly lineNumber?: number\n readonly suggestion?: string\n}\n\nexport class DictionaryValidationException extends Error {\n constructor (public readonly errors: ReadonlyArray<ValidationError>) {\n const errorCount = errors.filter(e => e.severity === ValidationSeverity.Error).length\n const warningCount = errors.filter(e => e.severity === ValidationSeverity.Warning).length\n const header = `FIX dictionary validation failed with ${errorCount} error(s) and ${warningCount} warning(s):`\n const details = errors\n .filter(e => e.severity === ValidationSeverity.Error)\n .slice(0, 20)\n .map(e => {\n let line = ` [${e.code}] ${e.message}`\n if (e.lineNumber != null) line += ` (line ${e.lineNumber})`\n if (e.suggestion) line += ` — ${e.suggestion}`\n return line\n })\n .join('\\n')\n super(`${header}\\n${details}`)\n this.name = 'DictionaryValidationException'\n }\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface XElement {
|
|
2
|
+
readonly name: string;
|
|
3
|
+
readonly attributes: Record<string, string>;
|
|
4
|
+
readonly children: XElement[];
|
|
5
|
+
readonly line?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class XNode {
|
|
8
|
+
readonly element: XElement;
|
|
9
|
+
constructor(element: XElement);
|
|
10
|
+
attribute(name: string): string | undefined;
|
|
11
|
+
elements(name?: string): XNode[];
|
|
12
|
+
firstElement(name: string): XNode | undefined;
|
|
13
|
+
descendants(name: string): XNode[];
|
|
14
|
+
firstDescendant(name: string): XNode | undefined;
|
|
15
|
+
requiredAttribute(name: string): string;
|
|
16
|
+
get name(): string;
|
|
17
|
+
get line(): number | undefined;
|
|
18
|
+
private collectDescendants;
|
|
19
|
+
private findDescendant;
|
|
20
|
+
}
|
|
21
|
+
export declare class XDocument {
|
|
22
|
+
readonly root: XNode;
|
|
23
|
+
constructor(rootElement: XElement);
|
|
24
|
+
descendants(name: string): XNode[];
|
|
25
|
+
firstDescendant(name: string): XNode | undefined;
|
|
26
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XDocument = exports.XNode = void 0;
|
|
4
|
+
class XNode {
|
|
5
|
+
constructor(element) {
|
|
6
|
+
this.element = element;
|
|
7
|
+
}
|
|
8
|
+
attribute(name) {
|
|
9
|
+
return this.element.attributes[name];
|
|
10
|
+
}
|
|
11
|
+
elements(name) {
|
|
12
|
+
const children = name
|
|
13
|
+
? this.element.children.filter(c => c.name === name)
|
|
14
|
+
: this.element.children;
|
|
15
|
+
return children.map(c => new XNode(c));
|
|
16
|
+
}
|
|
17
|
+
firstElement(name) {
|
|
18
|
+
const child = this.element.children.find(c => c.name === name);
|
|
19
|
+
return child ? new XNode(child) : undefined;
|
|
20
|
+
}
|
|
21
|
+
descendants(name) {
|
|
22
|
+
const result = [];
|
|
23
|
+
this.collectDescendants(this.element, name, result);
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
firstDescendant(name) {
|
|
27
|
+
return this.findDescendant(this.element, name);
|
|
28
|
+
}
|
|
29
|
+
requiredAttribute(name) {
|
|
30
|
+
var _a;
|
|
31
|
+
const val = this.element.attributes[name];
|
|
32
|
+
if (val === undefined) {
|
|
33
|
+
throw new Error(`missing required attribute '${name}' on <${this.element.name}> at line ${(_a = this.element.line) !== null && _a !== void 0 ? _a : '?'}`);
|
|
34
|
+
}
|
|
35
|
+
return val;
|
|
36
|
+
}
|
|
37
|
+
get name() {
|
|
38
|
+
return this.element.name;
|
|
39
|
+
}
|
|
40
|
+
get line() {
|
|
41
|
+
return this.element.line;
|
|
42
|
+
}
|
|
43
|
+
collectDescendants(el, name, result) {
|
|
44
|
+
for (const child of el.children) {
|
|
45
|
+
if (child.name === name) {
|
|
46
|
+
result.push(new XNode(child));
|
|
47
|
+
}
|
|
48
|
+
this.collectDescendants(child, name, result);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
findDescendant(el, name) {
|
|
52
|
+
for (const child of el.children) {
|
|
53
|
+
if (child.name === name) {
|
|
54
|
+
return new XNode(child);
|
|
55
|
+
}
|
|
56
|
+
const found = this.findDescendant(child, name);
|
|
57
|
+
if (found)
|
|
58
|
+
return found;
|
|
59
|
+
}
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.XNode = XNode;
|
|
64
|
+
class XDocument {
|
|
65
|
+
constructor(rootElement) {
|
|
66
|
+
this.root = new XNode(rootElement);
|
|
67
|
+
}
|
|
68
|
+
descendants(name) {
|
|
69
|
+
const result = [];
|
|
70
|
+
if (this.root.name === name)
|
|
71
|
+
result.push(this.root);
|
|
72
|
+
result.push(...this.root.descendants(name));
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
firstDescendant(name) {
|
|
76
|
+
if (this.root.name === name)
|
|
77
|
+
return this.root;
|
|
78
|
+
return this.root.firstDescendant(name);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.XDocument = XDocument;
|
|
82
|
+
//# sourceMappingURL=x-element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"x-element.js","sourceRoot":"","sources":["../../../../src/dictionary/parser/quickfix/x-element.ts"],"names":[],"mappings":";;;AAgBA,MAAa,KAAK;IAChB,YAA6B,OAAiB;QAAjB,YAAO,GAAP,OAAO,CAAU;IAAG,CAAC;IAGlD,SAAS,CAAE,IAAY;QACrB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IACtC,CAAC;IAGD,QAAQ,CAAE,IAAa;QACrB,MAAM,QAAQ,GAAG,IAAI;YACnB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC;YACpD,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAA;QACzB,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IACxC,CAAC;IAGD,YAAY,CAAE,IAAY;QACxB,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAA;QAC9D,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAC7C,CAAC;IAGD,WAAW,CAAE,IAAY;QACvB,MAAM,MAAM,GAAY,EAAE,CAAA;QAC1B,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;QACnD,OAAO,MA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I,CAAC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;YAC9C,IAAI,KAAK;gBAAE,OAAO,KAAK,CAAA;QACzB,CAAC;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;CACF;AAxED,sBAwEC;AAMD,MAAa,SAAS;IAGpB,YAAa,WAAqB;QAChC,IAAI,CAAC,IAAI,GAAG,IAAI,KAAK,CAAC,WAAW,CAAC,CAAA;IACpC,CAAC;IAGD,WAAW,CAAE,IAAY;QACvB,MAAM,MAAM,GAAY,EAAE,CAAA;QAC1B,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI;YAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACnD,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAA;QAC3C,OAAO,MAAM,CAAA;IACf,CAAC;IAGD,eAAe,CAAE,IAAY;QAC3B,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC,IAAI,CAAA;QAC7C,OAAO,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAA;IACxC,CAAC;CACF;AApBD,8BAoBC","sourcesContent":["/**\n * Lightweight in-memory XML element tree — provides DOM-like random access\n * over XML parsed by SAX. Mirrors the C# XDocument/XElement API surface\n * used by QuickFixXmlFileParser and DictionaryValidator.\n */\nexport interface XElement {\n readonly name: string\n readonly attributes: Record<string, string>\n readonly children: XElement[]\n readonly line?: number\n}\n\n/**\n * Query helper wrapping an XElement tree with C#-style traversal methods.\n * Mirrors XDocument/XElement LINQ-to-XML API used in cspurefix.\n */\nexport class XNode {\n constructor (public readonly element: XElement) {}\n\n /** Attribute value by name, or undefined if not present. */\n attribute (name: string): string | undefined {\n return this.element.attributes[name]\n }\n\n /** Direct children with the given tag name. */\n elements (name?: string): XNode[] {\n const children = name\n ? this.element.children.filter(c => c.name === name)\n : this.element.children\n return children.map(c => new XNode(c))\n }\n\n /** First direct child with the given tag name, or undefined. */\n firstElement (name: string): XNode | undefined {\n const child = this.element.children.find(c => c.name === name)\n return child ? new XNode(child) : undefined\n }\n\n /** All descendants (recursive) with the given tag name. */\n descendants (name: string): XNode[] {\n const result: XNode[] = []\n this.collectDescendants(this.element, name, result)\n return result\n }\n\n /** First descendant with the given tag name, or undefined. */\n firstDescendant (name: string): XNode | undefined {\n return this.findDescendant(this.element, name)\n }\n\n /** Shorthand: attribute value, throwing if missing. */\n requiredAttribute (name: string): string {\n const val = this.element.attributes[name]\n if (val === undefined) {\n throw new Error(`missing required attribute '${name}' on <${this.element.name}> at line ${this.element.line ?? '?'}`)\n }\n return val\n }\n\n /** The element's tag name. */\n get name (): string {\n return this.element.name\n }\n\n /** The element's source line number, if available. */\n get line (): number | undefined {\n return this.element.line\n }\n\n private collectDescendants (el: XElement, name: string, result: XNode[]): void {\n for (const child of el.children) {\n if (child.name === name) {\n result.push(new XNode(child))\n }\n this.collectDescendants(child, name, result)\n }\n }\n\n private findDescendant (el: XElement, name: string): XNode | undefined {\n for (const child of el.children) {\n if (child.name === name) {\n return new XNode(child)\n }\n const found = this.findDescendant(child, name)\n if (found) return found\n }\n return undefined\n }\n}\n\n/**\n * Parsed XML document — wraps the root element with query methods.\n * Equivalent to C# XDocument.\n */\nexport class XDocument {\n public readonly root: XNode\n\n constructor (rootElement: XElement) {\n this.root = new XNode(rootElement)\n }\n\n /** All descendants of the root with the given tag name (including the root itself if it matches). */\n descendants (name: string): XNode[] {\n const result: XNode[] = []\n if (this.root.name === name) result.push(this.root)\n result.push(...this.root.descendants(name))\n return result\n }\n\n /** First descendant of the root with the given tag name (including the root itself if it matches). */\n firstDescendant (name: string): XNode | undefined {\n if (this.root.name === name) return this.root\n return this.root.firstDescendant(name)\n }\n}\n"]}
|
|
@@ -22,6 +22,12 @@ class FixMsgAsciiStoreResend {
|
|
|
22
22
|
}
|
|
23
23
|
getResendRequest(startSeq, endSeq) {
|
|
24
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
var _a;
|
|
26
|
+
if (((_a = this.config.description.store) === null || _a === void 0 ? void 0 : _a.resendGapFillOnly) === true) {
|
|
27
|
+
const gapFillOnly = [];
|
|
28
|
+
this.gap(startSeq, endSeq + 1, gapFillOnly);
|
|
29
|
+
return gapFillOnly;
|
|
30
|
+
}
|
|
25
31
|
return yield new Promise((resolve, reject) => {
|
|
26
32
|
this.store.getSeqNumRange(startSeq, endSeq).then(res => {
|
|
27
33
|
resolve(this.inflateRange(startSeq, endSeq, res));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fix-msg-ascii-store-resend.js","sourceRoot":"","sources":["../../src/store/fix-msg-ascii-store-resend.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,iEAA8E;AAE9E,oCAAkC;AAClC,sCAAkD;AAClD,2CAA6C;AAG7C,MAAa,sBAAsB;IAEjC,YAA6B,KAAmB,EAAkB,MAAoB;QAAzD,UAAK,GAAL,KAAK,CAAc;QAAkB,WAAM,GAAN,MAAM,CAAc;QACpF,IAAI,CAAC,MAAM,GAAG,IAAI,mBAAW,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,sBAAa,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAA;IACjF,CAAC;IAEY,gBAAgB,CAAE,QAAgB,EAAE,MAAc
|
|
1
|
+
{"version":3,"file":"fix-msg-ascii-store-resend.js","sourceRoot":"","sources":["../../src/store/fix-msg-ascii-store-resend.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,iEAA8E;AAE9E,oCAAkC;AAClC,sCAAkD;AAClD,2CAA6C;AAG7C,MAAa,sBAAsB;IAEjC,YAA6B,KAAmB,EAAkB,MAAoB;QAAzD,UAAK,GAAL,KAAK,CAAc;QAAkB,WAAM,GAAN,MAAM,CAAc;QACpF,IAAI,CAAC,MAAM,GAAG,IAAI,mBAAW,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AS;SACzC,CACF,CAAA;QACD,aAAa,CAAC,GAAG,mCACZ,aAAa,CAAC,GAAG,KACpB,cAAc,EAAE,MAAM,GACvB,CAAA;QACD,OAAO,aAAa,CAAA;IACtB,CAAC;CACF;AA9ID,wDA8IC","sourcesContent":["import { IFixMsgStore } from './fix-msg-store'\nimport { FixMsgStoreRecord, IFixMsgStoreRecord } from './fix-msg-store-record'\nimport { IJsFixConfig } from '../config'\nimport { MsgType } from '../types'\nimport { ElasticBuffer, MsgView } from '../buffer'\nimport { AsciiParser } from '../buffer/ascii'\nimport { ISequenceReset, IStandardHeader } from '../types/FIX4.4/repo'\n\nexport class FixMsgAsciiStoreResend {\n parser: AsciiParser\n constructor (public readonly store: IFixMsgStore, public readonly config: IJsFixConfig) {\n this.parser = new AsciiParser(this.config, null, new ElasticBuffer(160 * 1024))\n }\n\n public async getResendRequest (startSeq: number, endSeq: number): Promise<IFixMsgStoreRecord[]> {\n // Safety feature: If ResendGapFillOnly is enabled, ALWAYS send GapFill instead of\n // replaying stored messages. This prevents accidental duplicate order execution.\n if (this.config.description.store?.resendGapFillOnly === true) {\n const gapFillOnly: IFixMsgStoreRecord[] = []\n this.gap(startSeq, endSeq + 1, gapFillOnly)\n return gapFillOnly\n }\n\n // need to cover request from start to end where any missing numbers are\n // included as gaps to allow vector of messages to be sent by the session\n // on a request\n\n return await new Promise((resolve, reject) => {\n this.store.getSeqNumRange(startSeq, endSeq).then(res => {\n resolve(this.inflateRange(startSeq, endSeq, res))\n }).catch(e => {\n reject(e)\n })\n })\n }\n\n private inflateRange (startSeq: number, endSeq: number, input: IFixMsgStoreRecord[]): IFixMsgStoreRecord[] {\n const toResend: IFixMsgStoreRecord[] = []\n // If no records for this given sequence number range, returns a single gap fill\n if (input.length === 0) {\n this.gap(startSeq, endSeq + 1, toResend)\n return toResend\n }\n\n let expected = startSeq\n for (let i = 0; i < input.length; ++i) {\n const record = this.prepareRecordForRetransmission(input[i])\n const seqNum = record.seqNum\n const toGap = seqNum - expected\n if (toGap > 0) {\n this.gap(expected, seqNum, toResend)\n }\n expected = seqNum + 1\n if (record.encoded) {\n this.inflate(record)\n }\n toResend.push(record)\n }\n if (endSeq - expected > 0) {\n this.gap(expected, endSeq + 1, toResend)\n }\n return toResend\n }\n\n private gap (beginGap: number, newSeq: number, arr: IFixMsgStoreRecord[]): void {\n if (beginGap > 0) {\n arr.push(this.sequenceResetGap(beginGap, newSeq))\n }\n }\n\n // if records were sent as encoded text then inflate back to object\n // so can be resent or examined\n\n private inflate (record: IFixMsgStoreRecord): void {\n if (record.obj) return\n if (!record.encoded) return\n const parser = this.parser\n parser.on('error', (_: Error) => {\n record.obj = null\n })\n parser.on('msg', (view: MsgView) => {\n record.obj = view.toObject()\n })\n // inline parse\n parser.parseText(record.encoded)\n }\n\n /**\n * A continuous sequence of messages not being retransmitted should be skipped over using a\n * single SequenceReset(35=4) message with GapFillFlag(123) set to “Y” and MsgSeqNum(34) set\n * to the sequence number of the first skipped message and NewSeqNo(36) must always be set\n * to the value of the next sequence number to be expected by the peer immediately following\n * the messages being skipped.\n */\n private sequenceResetGap (startGap: number, newSeq: number): IFixMsgStoreRecord {\n const factory = this.config.factory\n const gapFill: ISequenceReset = factory?.sequenceReset(newSeq, true) as ISequenceReset\n gapFill.StandardHeader = factory?.header(MsgType.SequenceReset, startGap, new Date()) as IStandardHeader\n gapFill.StandardHeader.PossDupFlag = true\n\n return new FixMsgStoreRecord(\n MsgType.SequenceReset,\n new Date(),\n startGap,\n gapFill,\n null\n )\n }\n\n /**\n * Prepares the FIX message as response to ResendRequest (2).\n *\n * The FIX session processor retransmitting a message with the PossDupFlag(43) set to \"Y\" must modify the following fields:\n *\n * SendingTime(52) set to the current sending time\n * OrigSendingTime(122) set to the SendingTime(52) from the original message\n * Recalculate the BodyLength(9)\n * Recalculate the CheckSum(10)\n *\n * If the message is encrypted, SecureDataLen(90) and SecureData(91) may also require re-encryption and re-encoding\n *\n * @see https://www.fixtrading.org/standards/fix-session-layer-online/#message-recovery\n *\n * @param originalRecord the FIX message to be retransmitted as possible duplicate\n * @returns the FIX message ready to be retransmitted\n */\n private prepareRecordForRetransmission (originalRecord: IFixMsgStoreRecord): IFixMsgStoreRecord {\n const retransmitted = originalRecord.clone() // We don't want to accidently change any fields of the original record\n\n const factory = this.config.factory\n if (!retransmitted.obj) {\n retransmitted.obj = {}\n }\n\n // Rebuilds header with the updated fields\n const header = factory?.header(\n retransmitted.msgType,\n retransmitted.seqNum,\n new Date(), // SendingTime(52)\n {\n PossDupFlag: true,\n OrigSendingTime: retransmitted.timestamp\n }\n )\n retransmitted.obj = {\n ...retransmitted.obj,\n StandardHeader: header\n }\n return retransmitted\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store-config.js","sourceRoot":"","sources":["../../src/store/store-config.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Configuration for session message store.\n * Add to session description JSON to enable persistent storage.\n *\n * Examples:\n * \"store\": { \"type\": \"memory\" } — explicit in-memory (default)\n * \"store\": { \"type\": \"file\" } — file store in ./store directory\n * \"store\": { \"type\": \"file\", \"directory\": \"/var/fix/sessions\" }\n *\n * Omitting the store block entirely uses in-memory storage.\n */\nexport interface StoreConfig {\n readonly type: 'memory' | 'file'\n readonly directory?: string\n}\n"]}
|
|
1
|
+
{"version":3,"file":"store-config.js","sourceRoot":"","sources":["../../src/store/store-config.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Configuration for session message store.\n * Add to session description JSON to enable persistent storage.\n *\n * Examples:\n * \"store\": { \"type\": \"memory\" } — explicit in-memory (default)\n * \"store\": { \"type\": \"file\" } — file store in ./store directory\n * \"store\": { \"type\": \"file\", \"directory\": \"/var/fix/sessions\" }\n *\n * Omitting the store block entirely uses in-memory storage.\n */\nexport interface StoreConfig {\n readonly type: 'memory' | 'file'\n readonly directory?: string\n readonly resendGapFillOnly?: boolean\n}\n"]}
|
|
@@ -226,6 +226,9 @@ class AsciiSession extends fix_session_1.FixSession {
|
|
|
226
226
|
this.sessionStore.put(record).catch((e) => {
|
|
227
227
|
this.sessionLogger.warning(`failed to store message seq=${seqNum}: ${e.message}`);
|
|
228
228
|
});
|
|
229
|
+
this.sessionStore.setSenderSeqNum(seqNum + 1).catch((e) => {
|
|
230
|
+
this.sessionLogger.warning(`failed to update sender seq: ${e.message}`);
|
|
231
|
+
});
|
|
229
232
|
}
|
|
230
233
|
}
|
|
231
234
|
static createStoreFactory(storeConfig) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ascii-session.js","sourceRoot":"","sources":["../../../src/transport/ascii/ascii-session.ts"],"names":[],"mappings":";;;AACA,uCAAkE;AAElE,wDAAmD;AACnD,uCAKoB;AACpB,gCAAqC;AACrC,gDAA2C;AAE3C,oEAA+D;AAC/D,0FAAoF;AACpF,oDAAsD;AACtD,8EAAoE;AAIpE,MAAsB,YAAa,SAAQ,wBAAU;IAQnD,YAAuC,MAAoB;;QACzD,KAAK,CAAC,MAAM,CAAC,CAAA;QADwB,WAAM,GAAN,MAAM,CAAc;QAPpD,cAAS,GAAY,IAAI,CAAA;QACtB,UAAK,GAAwB,IAAI,CAAA;QAQzC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,GAAG,eAAO,CAAC,MAAM,CAAA;QAChE,IAAI,CAAC,gBAAgB,GAAG,eAAO,CAAC,KAAK,CAAA;QACrC,IAAI,CAAC,KAAK,GAAG,IAAI,yBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QACrF,IAAI,CAAC,QAAQ,GAAG,IAAI,8BAAsB,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QAInE,MAAM,YAAY,GAAG,MAAA,MAAM,CAAC,mBAAmB,mCAAI,YAAY,CAAC,kBAAkB,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;QAC5G,IAAI,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AAC;YAED;gBACE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;QACxC,CAAC;IACH,CAAC;;AArjBH,oCAsjBC;AAvSyB,4BAAe,GAAG,GAAG,AAAN,CAAM;AACrB,uCAA0B,GAAG,CAAC,AAAJ,CAAI","sourcesContent":["import { MsgView } from '../../buffer'\nimport { MsgTag, MsgType, SessionRejectReason } from '../../types'\nimport { IJsFixConfig } from '../../config'\nimport { FixSession } from '../session/fix-session'\nimport {\n FixMsgAsciiStoreResend, FixMsgMemoryStore, FixMsgStoreRecord,\n IFixMsgStore, IFixMsgStoreRecord,\n IFixSessionStore, IFixSessionStoreFactory,\n MemorySessionStoreFactory, FileSessionStoreFactory, SessionId\n} from '../../store'\nimport { SessionState } from '../tcp'\nimport { TickAction } from '../tick-action'\nimport { IMsgApplication } from '../msg-application'\nimport { SegmentType } from '../../buffer/segment/segment-type'\nimport { SessionSequenceCoordinator } from '../session/session-sequence-coordinator'\nimport { DefaultFixClock } from '../session/fix-clock'\nimport { ResendActionType } from '../session/resend-request-manager'\nimport { AsciiMsgTransmitter } from './ascii-msg-transmitter'\nimport { ILooseObject } from '../../collections/collection'\n\nexport abstract class AsciiSession extends FixSession {\n public heartbeat: boolean = true\n protected store: IFixMsgStore | null = null\n protected resender: FixMsgAsciiStoreResend\n protected readonly coordinator: SessionSequenceCoordinator\n protected readonly sessionStore: IFixSessionStore\n protected readonly sessionId: SessionId\n\n protected constructor (public readonly config: IJsFixConfig) {\n super(config)\n this.requestLogoutType = this.respondLogoutType = MsgType.Logout\n this.requestLogonType = MsgType.Logon\n this.store = new FixMsgMemoryStore(this.config.description.SenderCompId, this.config)\n this.resender = new FixMsgAsciiStoreResend(this.store, this.config)\n\n // Create session store from factory.\n // Priority: programmatic config > JSON store config > default in-memory\n const storeFactory = config.sessionStoreFactory ?? AsciiSession.createStoreFactory(config.description.store)\n this.sessionId = new SessionId(\n config.description.BeginString,\n config.description.SenderCompId,\n config.description.TargetCompID\n )\n this.sessionStore = storeFactory.create(this.sessionId)\n\n const clock = new DefaultFixClock()\n this.coordinator = new SessionSequenceCoordinator(this.sessionStore, clock)\n const lastReceivedSeqNum = config.description.LastReceivedSeqNum ?? 0\n this.coordinator.initializeFromConfig(undefined, lastReceivedSeqNum + 1)\n }\n\n private checkSeqNo (msgType: string, view: MsgView): boolean {\n switch (msgType) {\n case MsgType.SequenceReset: {\n return true\n }\n\n case MsgType.Logon: {\n // If peer sends ResetSeqNumFlag=Y, accept any sequence number.\n // PeerLogon handles the full sequence reset.\n if (view.getTyped(MsgTag.ResetSeqNumFlag) === true) {\n this.sessionLogger.info('logon with ResetSeqNumFlag=Y, accepting regardless of sequence')\n const seqNo = view.getTyped(MsgTag.MsgSeqNum) as number\n this.sessionState.lastPeerMsgSeqNum = seqNo\n this.coordinator.onMessageReceived(seqNo, false)\n return true\n }\n }\n // falls through\n\n default: {\n const state = this.sessionState\n const lastSeq: number = state.lastPeerMsgSeqNum\n const seqNo: number = view.getTyped(MsgTag.MsgSeqNum) as number\n let ret: boolean = false\n const seqDelta: number = seqNo - lastSeq\n if (seqDelta <= 0) {\n // Check if this is a PossDupFlag=Y message (resend replay) before rejecting.\n // PossDupFlag messages have old sequence numbers and bypass normal checks.\n const possDupFlag = view.getTyped(MsgTag.PossDupFlag) as boolean | undefined\n if (possDupFlag === true) {\n this.sessionLogger.debug(`message '${msgType}' has PossDupFlag=Y, bypassing sequence check`)\n this.coordinator.onMessageReceived(seqNo, true)\n return true\n }\n // Check if this is a delayed message that fills a pending gap range.\n const pendingRequests = this.coordinator.pendingResendRequests\n const inPendingGapRange = pendingRequests.some(p => seqNo >= p.begin && seqNo <= p.end)\n if (inPendingGapRange) {\n this.sessionLogger.info(`accepting delayed message seq ${seqNo} (in pending gap range)`)\n this.coordinator.onMessageReceived(seqNo, false)\n return true\n }\n // serious problem ... drop immediately\n this.sessionLogger.warning(`terminate as seqDelta (${seqDelta}) < 0 lastSeq = ${lastSeq} seqNo = ${seqNo}`)\n this.stop()\n } else if (seqDelta > 1) {\n // resend request required as have missed messages.\n const expectedSeq = lastSeq + 1\n\n // We process a Logon beforehand to confirm the connection even we out of sync\n if (msgType === MsgType.Logon) {\n this.peerLogon(view)\n }\n // If the out of sync message is a resend request itself, then we handle it first in order\n // to avoid triggering an endless loop of both sides sending resend requests in response to resend requests.\n if (msgType === MsgType.ResendRequest) {\n this.onResendRequest(view)\n }\n\n // Use coordinator to determine what action to take for the gap\n const action = this.coordinator.onGapDetected(expectedSeq, seqNo)\n this.sessionLogger.info(`gap action: ${action}`)\n\n switch (action.type) {\n case ResendActionType.SendResendRequest: {\n if (action.begin != null && action.end != null) {\n this.sendResendRequest(lastSeq, seqNo)\n this.coordinator.recordResendRequestSent(action.begin, action.end)\n }\n break\n }\n case ResendActionType.Wait: {\n this.sessionLogger.info(`waiting for existing resend request: ${action.reason}`)\n break\n }\n case ResendActionType.SendGapFill: {\n this.sessionLogger.warning(`gap recovery abandoned (storm protection): ${action.reason}`)\n break\n }\n }\n\n // Accept the current message — don't block waiting for gap fill.\n // The gap will be filled by the resend response, but this message is valid.\n ret = true\n state.lastPeerMsgSeqNum = seqNo\n this.coordinator.onMessageReceived(seqNo, false)\n } else {\n ret = true\n state.lastPeerMsgSeqNum = seqNo\n this.coordinator.onMessageReceived(seqNo, false)\n }\n\n // Reset timeout recovery on successful message receipt\n if (ret) {\n this.coordinator.resetTimeoutRecovery()\n }\n return ret\n }\n }\n }\n\n protected checkForwardMsg (msgType: string, view: MsgView): void {\n const okToForward = this.validStateApplicationMsg()\n if (okToForward) {\n this.sessionLogger.info(`ascii forwarding msgType = '${msgType}' to application`)\n this.setState(SessionState.ActiveNormalSession)\n this.onApplicationMsg(msgType, view)\n } else {\n this.terminate(new Error(`msgType ${msgType} received in state ${this.stateString()}`))\n }\n }\n\n private sendReject (msgType: string, seqNo: number, msg: string, reason: number): void {\n const factory = this.config.factory\n const reject = factory?.reject(msgType, seqNo, msg, reason)\n if (reject) {\n this.sessionLogger.warning(`rejecting with ${JSON.stringify(reject)}`)\n this.send(MsgType.Reject, reject)\n }\n }\n\n protected sendResendRequest (lastSeq: number, receivedSeq: number): void {\n const resend = this.config.factory?.resendRequest(lastSeq + 1, 0)\n if (resend) {\n this.sessionLogger.warning(`received seq ${receivedSeq}, but last known seq is ${lastSeq}. Sending resend request for all messages > ${lastSeq}`)\n this.send(MsgType.ResendRequest, resend)\n }\n }\n\n private checkIntegrity (msgType: string, view: MsgView): boolean {\n const state = this.sessionState\n const seqNum = view.getTyped(MsgTag.MsgSeqNum) as number\n\n const received: number = parseInt(view.getString(MsgTag.CheckSum) ?? '', 10)\n const computed = view.checksum()\n if (received !== computed) {\n const msg: string = `msgType ${msgType} checksum failed. received = ${received} computed = ${computed}`\n this.sendReject(msgType, seqNum, msg, SessionRejectReason.ValueIsIncorrect)\n return false\n }\n\n if (view.segment.type === SegmentType.Unknown) {\n const msg: string = `msgType ${msgType} unknown`\n this.sendReject(msgType, seqNum, msg, SessionRejectReason.InvalidMsgType)\n return false\n }\n\n const invalid = view.invalid()\n if (invalid.length > 0) {\n const msg: string = `msgType ${msgType} invalid tag${invalid.length > 1 ? 's' : ''} ${invalid.join(', ')}`\n this.sendReject(msgType, seqNum, msg, SessionRejectReason.InvalidTagNumber)\n return false\n }\n\n const undefinedMsg: string | null = view.undefinedForMsg()\n if (undefinedMsg) {\n const msg: string = `msgType ${msgType} ${undefinedMsg}`\n this.sendReject(msgType, seqNum, msg, SessionRejectReason.TagNotDefinedForThisMessageType)\n return false\n }\n\n const missingRequired = view.missing()\n if (missingRequired.length > 0) {\n const msg: string = `msgType ${msgType} missing required tag${missingRequired.length > 1 ? 's' : ''} ${missingRequired.join(', ')}`\n this.sendReject(msgType, seqNum, msg, SessionRejectReason.RequiredTagMissing)\n return false\n }\n\n switch (state.state) {\n case SessionState.InitiationLogonReceived:\n case SessionState.InitiationLogonResponse: {\n const targetCompId = view.getString(MsgTag.TargetCompID)\n if (targetCompId !== state.compId) {\n const msg: string = `msgType ${msgType} unexpected TargetCompID ${targetCompId} expecting ${state.compId})`\n this.sendReject(msgType, seqNum, msg, SessionRejectReason.CompIDProblem)\n return false\n }\n\n const peerCompId = view.getString(MsgTag.SenderCompID)\n if (peerCompId !== state.peerCompId) {\n const msg: string = `msgType ${msgType} unexpected SenderCompID ${peerCompId} expecting ${state.compId}`\n this.sendReject(msgType, seqNum, msg, SessionRejectReason.CompIDProblem)\n return false\n }\n }\n break\n\n default: {\n break\n }\n }\n\n return true\n }\n\n /**\n * Override to resend stored messages following a sequence reset.\n * @protected\n */\n protected onResendRequest (view: MsgView): void {\n // if no records are in store then send a gap fill for entire sequence\n this.setState(SessionState.HandleResendRequest)\n const [beginSeqNo, requestedEndSeqNo] = view.getTypedTags([MsgTag.BeginSeqNo, MsgTag.EndSeqNo])\n const endSeqNo = requestedEndSeqNo === 0\n ? this.sessionState.lastSentSeqNum()\n : requestedEndSeqNo\n\n this.sessionLogger.info(`onResendRequest getResendRequest beginSeqNo = ${beginSeqNo}, endSeqNo = ${endSeqNo}`)\n this.resender.getResendRequest(beginSeqNo as number, endSeqNo as number).then((records: IFixMsgStoreRecord[]) => {\n const validRecords = records.filter(rec => rec.obj !== null)\n this.sessionLogger.info(`sending ${validRecords.length}`)\n validRecords.forEach(rec => {\n if (rec.obj) {\n this.send(rec.msgType, rec.obj)\n }\n })\n this.setState(SessionState.ActiveNormalSession)\n }).catch((e: Error) => {\n this.sessionLogger.error(e)\n })\n }\n\n protected override onPrepareForReconnect (): void {\n this.coordinator.prepareForReconnect()\n this.sessionLogger.info('coordinator reset transient state for reconnect')\n }\n\n protected override txOnEncoded (msgType: string, data: string, hdr: ILooseObject): void {\n super.txOnEncoded(msgType, data, hdr)\n // Store the encoded message in the session store for recovery/resend\n const seqNum = hdr?.MsgSeqNum as number | undefined\n if (seqNum != null) {\n const record = new FixMsgStoreRecord(msgType, new Date(), seqNum, undefined, data)\n this.sessionStore.put(record).catch((e: Error) => {\n // Never block sends on store errors\n this.sessionLogger.warning(`failed to store message seq=${seqNum}: ${e.message}`)\n })\n }\n }\n\n private static readonly MaxLogonRetries = 100\n private static readonly MaxTimeoutRecoveryAttempts = 0\n\n private static createStoreFactory (storeConfig?: { type: string, directory?: string }): IFixSessionStoreFactory {\n if (!storeConfig) return new MemorySessionStoreFactory()\n switch (storeConfig.type?.toLowerCase()) {\n case 'file':\n return new FileSessionStoreFactory(storeConfig.directory ?? 'store')\n default:\n return new MemorySessionStoreFactory()\n }\n }\n\n private handleLogonRejected (text: string | null): void {\n if (!this.coordinator.onLogonRejectedForSequence(AsciiSession.MaxLogonRetries)) {\n this.sessionLogger.warning(`max logon retries (${AsciiSession.MaxLogonRetries}) exceeded, giving up. Text='${text}'`)\n this.setState(SessionState.PeerLogonRejected)\n this.stop()\n return\n }\n\n // The encoder's msgSeqNum is already incremented after each message is sent,\n // so we just need to retry the logon. The next logon will use the next sequence number.\n this.sessionLogger.info(`LOGON_SEQ_RETRY: attempt=${this.coordinator.logonRetryCount}/${AsciiSession.MaxLogonRetries}, reason='${text}'`)\n this.sendLogon()\n }\n\n okForLogon (): boolean {\n const state = this.sessionState.state\n if (this.acceptor) {\n return state === SessionState.WaitingForALogon\n }\n return state === SessionState.InitiationLogonSent\n }\n\n protected onSessionMsg (msgType: string, view: MsgView): void {\n const logger = this.sessionLogger\n\n switch (msgType) {\n case MsgType.Logon: {\n // only valid to receive a logon when in LogonSent or WaitingALogon\n // else will drop connection immediately.\n if (this.okForLogon()) {\n this.peerLogon(view)\n } else {\n this.terminate(new Error(`state ${this.stateString()} is illegal for Logon`))\n }\n break\n }\n\n case MsgType.Logout: {\n this.peerLogout(view)\n break\n }\n\n case MsgType.TestRequest: {\n const req: string | null = view.getString(MsgTag.TestReqID)\n if (req) {\n this.sendHeartbeat(req)\n }\n break\n }\n\n case MsgType.Heartbeat: {\n this.sessionState.lastTestRequestAt = null\n this.setState(SessionState.ActiveNormalSession)\n break\n }\n\n case MsgType.ResendRequest: {\n logger.info(`peer sends '${msgType}' resend request.`)\n this.onResendRequest(view)\n break\n }\n\n case MsgType.SequenceReset: {\n const newSeqNo: number = view.getTyped(MsgTag.NewSeqNo) as number\n const gapFillSeq: number = view.getTyped(MsgTag.MsgSeqNum) as number\n logger.info(`peer sends '${msgType}' sequence reset. newSeqNo = ${newSeqNo}`)\n // expect newSeqNo to be the next message's sequence number.\n this.sessionState.lastPeerMsgSeqNum = newSeqNo - 1\n // Notify coordinator to update expected target and clear pending resend requests\n this.coordinator.onGapFillReceived(gapFillSeq, newSeqNo)\n break\n }\n\n case MsgType.Reject: {\n const refMsgType = view.getString(MsgTag.RefMsgType)\n const text = view.getString(MsgTag.Text)\n const reason = view.getTyped(MsgTag.SessionRejectReason) as number | undefined\n logger.info(`peer rejects RefMsgType='${refMsgType}', reason=${reason}, text='${text}'`)\n\n // Check if this is a logon rejection due to sequence mismatch while we're waiting for logon response.\n // Only retry for ValueIsIncorrect (sequence too low) — structural rejections (RequiredTagMissing etc.)\n // indicate a config problem that retrying won't fix.\n if (refMsgType === MsgType.Logon &&\n this.sessionState.state === SessionState.InitiationLogonSent &&\n reason === SessionRejectReason.ValueIsIncorrect) {\n this.handleLogonRejected(text)\n }\n break\n }\n }\n }\n\n protected onMsg (msgType: string, view: MsgView): void {\n if (!this.checkSeqNo(msgType, view)) {\n this.sessionLogger.info(`message '${msgType}' failed checkSeqNo.`)\n return\n }\n\n if (this.checkMsgIntegrity && !this.checkIntegrity(msgType, view)) {\n this.sessionLogger.info(`message '${msgType}' failed checkIntegrity.`)\n switch (msgType) {\n case MsgType.Logon: {\n this.setState(SessionState.PeerLogonRejected)\n this.startTimer()\n break\n }\n }\n return\n }\n\n switch (msgType) {\n case MsgType.Logon:\n case MsgType.Logout:\n case MsgType.TestRequest:\n case MsgType.Reject:\n case MsgType.SequenceReset:\n case MsgType.Heartbeat:\n case MsgType.ResendRequest: {\n this.onSessionMsg(msgType, view)\n break\n }\n\n default: {\n this.checkForwardMsg(msgType, view)\n break\n }\n }\n }\n\n private startTimer (interval: number = 200): void {\n const logger = this.sessionLogger\n logger.info(`start heartbeat timer. interval = ${interval}`)\n this.timer = setInterval(() => {\n this.tick()\n }, interval)\n }\n\n private peerLogon (view: MsgView): void {\n const logger = this.sessionLogger\n const [heartBtInt, peerCompId, userName, password] = view.getTypedTags([MsgTag.HeartBtInt, MsgTag.SenderCompID, MsgTag.Username, MsgTag.Password])\n const resetSeqNumFlag = view.getTyped(MsgTag.ResetSeqNumFlag) as boolean | undefined\n logger.info(`peerLogon Username = ${userName}, heartBtInt = ${heartBtInt}, peerCompId = ${peerCompId}, resetSeqNumFlag = ${resetSeqNumFlag}`)\n\n // Handle ResetSeqNumFlag from peer's logon\n if (resetSeqNumFlag === true) {\n const peerSeqNum = (view.getTyped(MsgTag.MsgSeqNum) as number) ?? 1\n const weAlsoReset = this.config.description.ResetSeqNumFlag\n logger.info(`peer sent ResetSeqNumFlag=Y with seqNum=${peerSeqNum}, weAlsoReset=${weAlsoReset}`)\n\n const transmitter = this.transport?.transmitter as AsciiMsgTransmitter | undefined\n const savedEncoderSeqNum = weAlsoReset && transmitter ? transmitter.msgSeqNum : null\n\n // Fire-and-forget the async coordinator call (store updates resolve on next microtask)\n // but compute the expected values synchronously since we know the reset outcome\n this.coordinator.handlePeerReset(peerSeqNum, weAlsoReset)\n if (transmitter) {\n transmitter.msgSeqNum = savedEncoderSeqNum ?? 1\n }\n this.sessionState.lastPeerMsgSeqNum = peerSeqNum\n\n // Recreate resender with empty store\n if (this.store) {\n this.store.clear()\n this.resender = new FixMsgAsciiStoreResend(this.store, this.config)\n }\n logger.info(`reset complete: encoderSeqNum=${transmitter?.msgSeqNum}, lastPeerMsgSeqNum=${peerSeqNum}`)\n }\n\n const state = this.sessionState\n state.peerHeartBeatSecs = view.getTyped(MsgTag.HeartBtInt) as number\n state.peerCompId = view.getTyped(MsgTag.SenderCompID) as string\n const res = this.onLogon(view, userName as string, password as string)\n // currently not using this.\n logger.info(`peerLogon onLogon returns ${res}`)\n if (this.acceptor) {\n this.setState(SessionState.InitiationLogonResponse)\n logger.info('acceptor responds to logon request')\n\n // If WE (acceptor) are sending ResetSeqNumFlag=Y but peer didn't request it,\n // reset our sequences before sending our logon response.\n // This handles the broker-reset pattern where client sends N, we respond with Y.\n const weReset = this.config.description.ResetSeqNumFlag\n if (weReset && resetSeqNumFlag !== true) {\n logger.info('acceptor sending ResetSeqNumFlag=Y (peer sent N), resetting sequences')\n // Fire-and-forget async coordinator call, set values synchronously\n this.coordinator.resetAsAcceptor()\n const transmitter = this.transport?.transmitter as AsciiMsgTransmitter | undefined\n if (transmitter) {\n transmitter.msgSeqNum = 1\n }\n this.sessionState.lastPeerMsgSeqNum = 0\n if (this.store) {\n this.store.clear()\n this.resender = new FixMsgAsciiStoreResend(this.store, this.config)\n }\n }\n\n this.sendLogon() // if res send response else reject, terminate\n } else { // as an initiator the acceptor has responded\n logger.info('initiator receives logon response')\n this.setState(SessionState.InitiationLogonReceived)\n }\n // Reset logon retry counter on successful logon\n this.coordinator.resetLogonRetryCount()\n\n if (this.heartbeat) {\n this.startTimer()\n }\n logger.info('system ready, inform app')\n this.onReady(view)\n }\n\n private sendTestRequest (): void {\n const factory = this.config.factory\n this.setState(SessionState.AwaitingProcessingResponseToTestRequest)\n const tr = factory?.testRequest()\n if (tr) {\n this.send(MsgType.TestRequest, tr)\n }\n }\n\n private sendHeartbeat (testReqId: string): void {\n const factory = this.config.factory\n const hb = factory?.heartbeat(testReqId)\n if (hb) {\n this.send(MsgType.Heartbeat, hb)\n }\n }\n\n private tick (): void {\n if (!this.transport) return\n const sessionState = this.sessionState\n const action: TickAction = sessionState.calcAction(new Date())\n const application: IMsgApplication | null = this.transport.config.description.application ?? null\n const logger = this.sessionLogger\n // Clean up timed-out resend requests\n this.coordinator.tick()\n\n switch (action) {\n case TickAction.Nothing: {\n // all is well\n break\n }\n\n case TickAction.TestRequest: {\n logger.debug(`send test req. state = ${sessionState.toString()}`)\n this.sendTestRequest()\n break\n }\n\n case TickAction.Heartbeat: {\n logger.debug(`send heartbeat. state = ${sessionState.toString()}`)\n this.sendHeartbeat(sessionState.now.toUTCString())\n break\n }\n\n case TickAction.TerminateOnError: {\n if (this.coordinator.incrementTimeoutRecovery(AsciiSession.MaxTimeoutRecoveryAttempts)) {\n // Try to recover — reset timeout state to give session a fresh window.\n // This helps survive sleep/wake scenarios where TCP connection may still be alive.\n logger.info(`timeout recovery attempt ${this.coordinator.timeoutRecoveryAttempts}, resetting timeout state`)\n sessionState.lastTestRequestAt = null\n sessionState.lastReceivedAt = new Date()\n this.setState(SessionState.ActiveNormalSession)\n } else {\n logger.info(sessionState.toString())\n this.terminate(new Error(`${application?.name}: peer not responding`))\n }\n break\n }\n\n case TickAction.Stop: {\n logger.info(sessionState.toString())\n logger.info('stopping')\n this.stop()\n break\n }\n\n default:\n throw new Error('unexpected action')\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ascii-session.js","sourceRoot":"","sources":["../../../src/transport/ascii/ascii-session.ts"],"names":[],"mappings":";;;AACA,uCAAkE;AAElE,wDAAmD;AACnD,uCAKoB;AACpB,gCAAqC;AACrC,gDAA2C;AAE3C,oEAA+D;AAC/D,0FAAoF;AACpF,oDAAsD;AACtD,8EAAoE;AAIpE,MAAsB,YAAa,SAAQ,wBAAU;IAQnD,YAAuC,MAAoB;;QACzD,KAAK,CAAC,MAAM,CAAC,CAAA;QADwB,WAAM,GAAN,MAAM,CAAc;QAPpD,cAAS,GAAY,IAAI,CAAA;QACtB,UAAK,GAAwB,IAAI,CAAA;QAQzC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,GAAG,eAAO,CAAC,MAAM,CAAA;QAChE,IAAI,CAAC,gBAAgB,GAAG,eAAO,CAAC,KAAK,CAAA;QACrC,IAAI,CAAC,KAAK,GAAG,IAAI,yBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QACrF,IAAI,CAAC,QA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ACN,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC,CAAA;oBACpC,IAAI,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,IAAI,uBAAuB,CAAC,CAAC,CAAA;gBACxE,CAAC;gBACD,MAAK;YACP,CAAC;YAED,KAAK,wBAAU,CAAC,IAAI,CAAC,CAAC,CAAC;gBACrB,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC,CAAA;gBACpC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;gBACvB,IAAI,CAAC,IAAI,EAAE,CAAA;gBACX,MAAK;YACP,CAAC;YAED;gBACE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;QACxC,CAAC;IACH,CAAC;;AAzjBH,oCA0jBC;AAvSyB,4BAAe,GAAG,GAAG,AAAN,CAAM;AACrB,uCAA0B,GAAG,CAAC,AAAJ,CAAI","sourcesContent":["import { MsgView } from '../../buffer'\nimport { MsgTag, MsgType, SessionRejectReason } from '../../types'\nimport { IJsFixConfig } from '../../config'\nimport { FixSession } from '../session/fix-session'\nimport {\n FixMsgAsciiStoreResend, FixMsgMemoryStore, FixMsgStoreRecord,\n IFixMsgStore, IFixMsgStoreRecord,\n IFixSessionStore, IFixSessionStoreFactory,\n MemorySessionStoreFactory, FileSessionStoreFactory, SessionId\n} from '../../store'\nimport { SessionState } from '../tcp'\nimport { TickAction } from '../tick-action'\nimport { IMsgApplication } from '../msg-application'\nimport { SegmentType } from '../../buffer/segment/segment-type'\nimport { SessionSequenceCoordinator } from '../session/session-sequence-coordinator'\nimport { DefaultFixClock } from '../session/fix-clock'\nimport { ResendActionType } from '../session/resend-request-manager'\nimport { AsciiMsgTransmitter } from './ascii-msg-transmitter'\nimport { ILooseObject } from '../../collections/collection'\n\nexport abstract class AsciiSession extends FixSession {\n public heartbeat: boolean = true\n protected store: IFixMsgStore | null = null\n protected resender: FixMsgAsciiStoreResend\n protected readonly coordinator: SessionSequenceCoordinator\n protected readonly sessionStore: IFixSessionStore\n protected readonly sessionId: SessionId\n\n protected constructor (public readonly config: IJsFixConfig) {\n super(config)\n this.requestLogoutType = this.respondLogoutType = MsgType.Logout\n this.requestLogonType = MsgType.Logon\n this.store = new FixMsgMemoryStore(this.config.description.SenderCompId, this.config)\n this.resender = new FixMsgAsciiStoreResend(this.store, this.config)\n\n // Create session store from factory.\n // Priority: programmatic config > JSON store config > default in-memory\n const storeFactory = config.sessionStoreFactory ?? AsciiSession.createStoreFactory(config.description.store)\n this.sessionId = new SessionId(\n config.description.BeginString,\n config.description.SenderCompId,\n config.description.TargetCompID\n )\n this.sessionStore = storeFactory.create(this.sessionId)\n\n const clock = new DefaultFixClock()\n this.coordinator = new SessionSequenceCoordinator(this.sessionStore, clock)\n const lastReceivedSeqNum = config.description.LastReceivedSeqNum ?? 0\n this.coordinator.initializeFromConfig(undefined, lastReceivedSeqNum + 1)\n }\n\n private checkSeqNo (msgType: string, view: MsgView): boolean {\n switch (msgType) {\n case MsgType.SequenceReset: {\n return true\n }\n\n case MsgType.Logon: {\n // If peer sends ResetSeqNumFlag=Y, accept any sequence number.\n // PeerLogon handles the full sequence reset.\n if (view.getTyped(MsgTag.ResetSeqNumFlag) === true) {\n this.sessionLogger.info('logon with ResetSeqNumFlag=Y, accepting regardless of sequence')\n const seqNo = view.getTyped(MsgTag.MsgSeqNum) as number\n this.sessionState.lastPeerMsgSeqNum = seqNo\n this.coordinator.onMessageReceived(seqNo, false)\n return true\n }\n }\n // falls through\n\n default: {\n const state = this.sessionState\n const lastSeq: number = state.lastPeerMsgSeqNum\n const seqNo: number = view.getTyped(MsgTag.MsgSeqNum) as number\n let ret: boolean = false\n const seqDelta: number = seqNo - lastSeq\n if (seqDelta <= 0) {\n // Check if this is a PossDupFlag=Y message (resend replay) before rejecting.\n // PossDupFlag messages have old sequence numbers and bypass normal checks.\n const possDupFlag = view.getTyped(MsgTag.PossDupFlag) as boolean | undefined\n if (possDupFlag === true) {\n this.sessionLogger.debug(`message '${msgType}' has PossDupFlag=Y, bypassing sequence check`)\n this.coordinator.onMessageReceived(seqNo, true)\n return true\n }\n // Check if this is a delayed message that fills a pending gap range.\n const pendingRequests = this.coordinator.pendingResendRequests\n const inPendingGapRange = pendingRequests.some(p => seqNo >= p.begin && seqNo <= p.end)\n if (inPendingGapRange) {\n this.sessionLogger.info(`accepting delayed message seq ${seqNo} (in pending gap range)`)\n this.coordinator.onMessageReceived(seqNo, false)\n return true\n }\n // serious problem ... drop immediately\n this.sessionLogger.warning(`terminate as seqDelta (${seqDelta}) < 0 lastSeq = ${lastSeq} seqNo = ${seqNo}`)\n this.stop()\n } else if (seqDelta > 1) {\n // resend request required as have missed messages.\n const expectedSeq = lastSeq + 1\n\n // We process a Logon beforehand to confirm the connection even we out of sync\n if (msgType === MsgType.Logon) {\n this.peerLogon(view)\n }\n // If the out of sync message is a resend request itself, then we handle it first in order\n // to avoid triggering an endless loop of both sides sending resend requests in response to resend requests.\n if (msgType === MsgType.ResendRequest) {\n this.onResendRequest(view)\n }\n\n // Use coordinator to determine what action to take for the gap\n const action = this.coordinator.onGapDetected(expectedSeq, seqNo)\n this.sessionLogger.info(`gap action: ${action}`)\n\n switch (action.type) {\n case ResendActionType.SendResendRequest: {\n if (action.begin != null && action.end != null) {\n this.sendResendRequest(lastSeq, seqNo)\n this.coordinator.recordResendRequestSent(action.begin, action.end)\n }\n break\n }\n case ResendActionType.Wait: {\n this.sessionLogger.info(`waiting for existing resend request: ${action.reason}`)\n break\n }\n case ResendActionType.SendGapFill: {\n this.sessionLogger.warning(`gap recovery abandoned (storm protection): ${action.reason}`)\n break\n }\n }\n\n // Accept the current message — don't block waiting for gap fill.\n // The gap will be filled by the resend response, but this message is valid.\n ret = true\n state.lastPeerMsgSeqNum = seqNo\n this.coordinator.onMessageReceived(seqNo, false)\n } else {\n ret = true\n state.lastPeerMsgSeqNum = seqNo\n this.coordinator.onMessageReceived(seqNo, false)\n }\n\n // Reset timeout recovery on successful message receipt\n if (ret) {\n this.coordinator.resetTimeoutRecovery()\n }\n return ret\n }\n }\n }\n\n protected checkForwardMsg (msgType: string, view: MsgView): void {\n const okToForward = this.validStateApplicationMsg()\n if (okToForward) {\n this.sessionLogger.info(`ascii forwarding msgType = '${msgType}' to application`)\n this.setState(SessionState.ActiveNormalSession)\n this.onApplicationMsg(msgType, view)\n } else {\n this.terminate(new Error(`msgType ${msgType} received in state ${this.stateString()}`))\n }\n }\n\n private sendReject (msgType: string, seqNo: number, msg: string, reason: number): void {\n const factory = this.config.factory\n const reject = factory?.reject(msgType, seqNo, msg, reason)\n if (reject) {\n this.sessionLogger.warning(`rejecting with ${JSON.stringify(reject)}`)\n this.send(MsgType.Reject, reject)\n }\n }\n\n protected sendResendRequest (lastSeq: number, receivedSeq: number): void {\n const resend = this.config.factory?.resendRequest(lastSeq + 1, 0)\n if (resend) {\n this.sessionLogger.warning(`received seq ${receivedSeq}, but last known seq is ${lastSeq}. Sending resend request for all messages > ${lastSeq}`)\n this.send(MsgType.ResendRequest, resend)\n }\n }\n\n private checkIntegrity (msgType: string, view: MsgView): boolean {\n const state = this.sessionState\n const seqNum = view.getTyped(MsgTag.MsgSeqNum) as number\n\n const received: number = parseInt(view.getString(MsgTag.CheckSum) ?? '', 10)\n const computed = view.checksum()\n if (received !== computed) {\n const msg: string = `msgType ${msgType} checksum failed. received = ${received} computed = ${computed}`\n this.sendReject(msgType, seqNum, msg, SessionRejectReason.ValueIsIncorrect)\n return false\n }\n\n if (view.segment.type === SegmentType.Unknown) {\n const msg: string = `msgType ${msgType} unknown`\n this.sendReject(msgType, seqNum, msg, SessionRejectReason.InvalidMsgType)\n return false\n }\n\n const invalid = view.invalid()\n if (invalid.length > 0) {\n const msg: string = `msgType ${msgType} invalid tag${invalid.length > 1 ? 's' : ''} ${invalid.join(', ')}`\n this.sendReject(msgType, seqNum, msg, SessionRejectReason.InvalidTagNumber)\n return false\n }\n\n const undefinedMsg: string | null = view.undefinedForMsg()\n if (undefinedMsg) {\n const msg: string = `msgType ${msgType} ${undefinedMsg}`\n this.sendReject(msgType, seqNum, msg, SessionRejectReason.TagNotDefinedForThisMessageType)\n return false\n }\n\n const missingRequired = view.missing()\n if (missingRequired.length > 0) {\n const msg: string = `msgType ${msgType} missing required tag${missingRequired.length > 1 ? 's' : ''} ${missingRequired.join(', ')}`\n this.sendReject(msgType, seqNum, msg, SessionRejectReason.RequiredTagMissing)\n return false\n }\n\n switch (state.state) {\n case SessionState.InitiationLogonReceived:\n case SessionState.InitiationLogonResponse: {\n const targetCompId = view.getString(MsgTag.TargetCompID)\n if (targetCompId !== state.compId) {\n const msg: string = `msgType ${msgType} unexpected TargetCompID ${targetCompId} expecting ${state.compId})`\n this.sendReject(msgType, seqNum, msg, SessionRejectReason.CompIDProblem)\n return false\n }\n\n const peerCompId = view.getString(MsgTag.SenderCompID)\n if (peerCompId !== state.peerCompId) {\n const msg: string = `msgType ${msgType} unexpected SenderCompID ${peerCompId} expecting ${state.compId}`\n this.sendReject(msgType, seqNum, msg, SessionRejectReason.CompIDProblem)\n return false\n }\n }\n break\n\n default: {\n break\n }\n }\n\n return true\n }\n\n /**\n * Override to resend stored messages following a sequence reset.\n * @protected\n */\n protected onResendRequest (view: MsgView): void {\n // if no records are in store then send a gap fill for entire sequence\n this.setState(SessionState.HandleResendRequest)\n const [beginSeqNo, requestedEndSeqNo] = view.getTypedTags([MsgTag.BeginSeqNo, MsgTag.EndSeqNo])\n const endSeqNo = requestedEndSeqNo === 0\n ? this.sessionState.lastSentSeqNum()\n : requestedEndSeqNo\n\n this.sessionLogger.info(`onResendRequest getResendRequest beginSeqNo = ${beginSeqNo}, endSeqNo = ${endSeqNo}`)\n this.resender.getResendRequest(beginSeqNo as number, endSeqNo as number).then((records: IFixMsgStoreRecord[]) => {\n const validRecords = records.filter(rec => rec.obj !== null)\n this.sessionLogger.info(`sending ${validRecords.length}`)\n validRecords.forEach(rec => {\n if (rec.obj) {\n this.send(rec.msgType, rec.obj)\n }\n })\n this.setState(SessionState.ActiveNormalSession)\n }).catch((e: Error) => {\n this.sessionLogger.error(e)\n })\n }\n\n protected override onPrepareForReconnect (): void {\n this.coordinator.prepareForReconnect()\n this.sessionLogger.info('coordinator reset transient state for reconnect')\n }\n\n protected override txOnEncoded (msgType: string, data: string, hdr: ILooseObject): void {\n super.txOnEncoded(msgType, data, hdr)\n // Store the encoded message in the session store for recovery/resend\n const seqNum = hdr?.MsgSeqNum as number | undefined\n if (seqNum != null) {\n const record = new FixMsgStoreRecord(msgType, new Date(), seqNum, undefined, data)\n this.sessionStore.put(record).catch((e: Error) => {\n // Never block sends on store errors\n this.sessionLogger.warning(`failed to store message seq=${seqNum}: ${e.message}`)\n })\n // Update store's sender sequence number (next outgoing seq = seqNum + 1)\n this.sessionStore.setSenderSeqNum(seqNum + 1).catch((e: Error) => {\n this.sessionLogger.warning(`failed to update sender seq: ${e.message}`)\n })\n }\n }\n\n private static readonly MaxLogonRetries = 100\n private static readonly MaxTimeoutRecoveryAttempts = 0\n\n private static createStoreFactory (storeConfig?: { type: string, directory?: string }): IFixSessionStoreFactory {\n if (!storeConfig) return new MemorySessionStoreFactory()\n switch (storeConfig.type?.toLowerCase()) {\n case 'file':\n return new FileSessionStoreFactory(storeConfig.directory ?? 'store')\n default:\n return new MemorySessionStoreFactory()\n }\n }\n\n private handleLogonRejected (text: string | null): void {\n if (!this.coordinator.onLogonRejectedForSequence(AsciiSession.MaxLogonRetries)) {\n this.sessionLogger.warning(`max logon retries (${AsciiSession.MaxLogonRetries}) exceeded, giving up. Text='${text}'`)\n this.setState(SessionState.PeerLogonRejected)\n this.stop()\n return\n }\n\n // The encoder's msgSeqNum is already incremented after each message is sent,\n // so we just need to retry the logon. The next logon will use the next sequence number.\n this.sessionLogger.info(`LOGON_SEQ_RETRY: attempt=${this.coordinator.logonRetryCount}/${AsciiSession.MaxLogonRetries}, reason='${text}'`)\n this.sendLogon()\n }\n\n okForLogon (): boolean {\n const state = this.sessionState.state\n if (this.acceptor) {\n return state === SessionState.WaitingForALogon\n }\n return state === SessionState.InitiationLogonSent\n }\n\n protected onSessionMsg (msgType: string, view: MsgView): void {\n const logger = this.sessionLogger\n\n switch (msgType) {\n case MsgType.Logon: {\n // only valid to receive a logon when in LogonSent or WaitingALogon\n // else will drop connection immediately.\n if (this.okForLogon()) {\n this.peerLogon(view)\n } else {\n this.terminate(new Error(`state ${this.stateString()} is illegal for Logon`))\n }\n break\n }\n\n case MsgType.Logout: {\n this.peerLogout(view)\n break\n }\n\n case MsgType.TestRequest: {\n const req: string | null = view.getString(MsgTag.TestReqID)\n if (req) {\n this.sendHeartbeat(req)\n }\n break\n }\n\n case MsgType.Heartbeat: {\n this.sessionState.lastTestRequestAt = null\n this.setState(SessionState.ActiveNormalSession)\n break\n }\n\n case MsgType.ResendRequest: {\n logger.info(`peer sends '${msgType}' resend request.`)\n this.onResendRequest(view)\n break\n }\n\n case MsgType.SequenceReset: {\n const newSeqNo: number = view.getTyped(MsgTag.NewSeqNo) as number\n const gapFillSeq: number = view.getTyped(MsgTag.MsgSeqNum) as number\n logger.info(`peer sends '${msgType}' sequence reset. newSeqNo = ${newSeqNo}`)\n // expect newSeqNo to be the next message's sequence number.\n this.sessionState.lastPeerMsgSeqNum = newSeqNo - 1\n // Notify coordinator to update expected target and clear pending resend requests\n this.coordinator.onGapFillReceived(gapFillSeq, newSeqNo)\n break\n }\n\n case MsgType.Reject: {\n const refMsgType = view.getString(MsgTag.RefMsgType)\n const text = view.getString(MsgTag.Text)\n const reason = view.getTyped(MsgTag.SessionRejectReason) as number | undefined\n logger.info(`peer rejects RefMsgType='${refMsgType}', reason=${reason}, text='${text}'`)\n\n // Check if this is a logon rejection due to sequence mismatch while we're waiting for logon response.\n // Only retry for ValueIsIncorrect (sequence too low) — structural rejections (RequiredTagMissing etc.)\n // indicate a config problem that retrying won't fix.\n if (refMsgType === MsgType.Logon &&\n this.sessionState.state === SessionState.InitiationLogonSent &&\n reason === SessionRejectReason.ValueIsIncorrect) {\n this.handleLogonRejected(text)\n }\n break\n }\n }\n }\n\n protected onMsg (msgType: string, view: MsgView): void {\n if (!this.checkSeqNo(msgType, view)) {\n this.sessionLogger.info(`message '${msgType}' failed checkSeqNo.`)\n return\n }\n\n if (this.checkMsgIntegrity && !this.checkIntegrity(msgType, view)) {\n this.sessionLogger.info(`message '${msgType}' failed checkIntegrity.`)\n switch (msgType) {\n case MsgType.Logon: {\n this.setState(SessionState.PeerLogonRejected)\n this.startTimer()\n break\n }\n }\n return\n }\n\n switch (msgType) {\n case MsgType.Logon:\n case MsgType.Logout:\n case MsgType.TestRequest:\n case MsgType.Reject:\n case MsgType.SequenceReset:\n case MsgType.Heartbeat:\n case MsgType.ResendRequest: {\n this.onSessionMsg(msgType, view)\n break\n }\n\n default: {\n this.checkForwardMsg(msgType, view)\n break\n }\n }\n }\n\n private startTimer (interval: number = 200): void {\n const logger = this.sessionLogger\n logger.info(`start heartbeat timer. interval = ${interval}`)\n this.timer = setInterval(() => {\n this.tick()\n }, interval)\n }\n\n private peerLogon (view: MsgView): void {\n const logger = this.sessionLogger\n const [heartBtInt, peerCompId, userName, password] = view.getTypedTags([MsgTag.HeartBtInt, MsgTag.SenderCompID, MsgTag.Username, MsgTag.Password])\n const resetSeqNumFlag = view.getTyped(MsgTag.ResetSeqNumFlag) as boolean | undefined\n logger.info(`peerLogon Username = ${userName}, heartBtInt = ${heartBtInt}, peerCompId = ${peerCompId}, resetSeqNumFlag = ${resetSeqNumFlag}`)\n\n // Handle ResetSeqNumFlag from peer's logon\n if (resetSeqNumFlag === true) {\n const peerSeqNum = (view.getTyped(MsgTag.MsgSeqNum) as number) ?? 1\n const weAlsoReset = this.config.description.ResetSeqNumFlag\n logger.info(`peer sent ResetSeqNumFlag=Y with seqNum=${peerSeqNum}, weAlsoReset=${weAlsoReset}`)\n\n const transmitter = this.transport?.transmitter as AsciiMsgTransmitter | undefined\n const savedEncoderSeqNum = weAlsoReset && transmitter ? transmitter.msgSeqNum : null\n\n // Fire-and-forget the async coordinator call (store updates resolve on next microtask)\n // but compute the expected values synchronously since we know the reset outcome\n this.coordinator.handlePeerReset(peerSeqNum, weAlsoReset)\n if (transmitter) {\n transmitter.msgSeqNum = savedEncoderSeqNum ?? 1\n }\n this.sessionState.lastPeerMsgSeqNum = peerSeqNum\n\n // Recreate resender with empty store\n if (this.store) {\n this.store.clear()\n this.resender = new FixMsgAsciiStoreResend(this.store, this.config)\n }\n logger.info(`reset complete: encoderSeqNum=${transmitter?.msgSeqNum}, lastPeerMsgSeqNum=${peerSeqNum}`)\n }\n\n const state = this.sessionState\n state.peerHeartBeatSecs = view.getTyped(MsgTag.HeartBtInt) as number\n state.peerCompId = view.getTyped(MsgTag.SenderCompID) as string\n const res = this.onLogon(view, userName as string, password as string)\n // currently not using this.\n logger.info(`peerLogon onLogon returns ${res}`)\n if (this.acceptor) {\n this.setState(SessionState.InitiationLogonResponse)\n logger.info('acceptor responds to logon request')\n\n // If WE (acceptor) are sending ResetSeqNumFlag=Y but peer didn't request it,\n // reset our sequences before sending our logon response.\n // This handles the broker-reset pattern where client sends N, we respond with Y.\n const weReset = this.config.description.ResetSeqNumFlag\n if (weReset && resetSeqNumFlag !== true) {\n logger.info('acceptor sending ResetSeqNumFlag=Y (peer sent N), resetting sequences')\n // Fire-and-forget async coordinator call, set values synchronously\n this.coordinator.resetAsAcceptor()\n const transmitter = this.transport?.transmitter as AsciiMsgTransmitter | undefined\n if (transmitter) {\n transmitter.msgSeqNum = 1\n }\n this.sessionState.lastPeerMsgSeqNum = 0\n if (this.store) {\n this.store.clear()\n this.resender = new FixMsgAsciiStoreResend(this.store, this.config)\n }\n }\n\n this.sendLogon() // if res send response else reject, terminate\n } else { // as an initiator the acceptor has responded\n logger.info('initiator receives logon response')\n this.setState(SessionState.InitiationLogonReceived)\n }\n // Reset logon retry counter on successful logon\n this.coordinator.resetLogonRetryCount()\n\n if (this.heartbeat) {\n this.startTimer()\n }\n logger.info('system ready, inform app')\n this.onReady(view)\n }\n\n private sendTestRequest (): void {\n const factory = this.config.factory\n this.setState(SessionState.AwaitingProcessingResponseToTestRequest)\n const tr = factory?.testRequest()\n if (tr) {\n this.send(MsgType.TestRequest, tr)\n }\n }\n\n private sendHeartbeat (testReqId: string): void {\n const factory = this.config.factory\n const hb = factory?.heartbeat(testReqId)\n if (hb) {\n this.send(MsgType.Heartbeat, hb)\n }\n }\n\n private tick (): void {\n if (!this.transport) return\n const sessionState = this.sessionState\n const action: TickAction = sessionState.calcAction(new Date())\n const application: IMsgApplication | null = this.transport.config.description.application ?? null\n const logger = this.sessionLogger\n // Clean up timed-out resend requests\n this.coordinator.tick()\n\n switch (action) {\n case TickAction.Nothing: {\n // all is well\n break\n }\n\n case TickAction.TestRequest: {\n logger.debug(`send test req. state = ${sessionState.toString()}`)\n this.sendTestRequest()\n break\n }\n\n case TickAction.Heartbeat: {\n logger.debug(`send heartbeat. state = ${sessionState.toString()}`)\n this.sendHeartbeat(sessionState.now.toUTCString())\n break\n }\n\n case TickAction.TerminateOnError: {\n if (this.coordinator.incrementTimeoutRecovery(AsciiSession.MaxTimeoutRecoveryAttempts)) {\n // Try to recover — reset timeout state to give session a fresh window.\n // This helps survive sleep/wake scenarios where TCP connection may still be alive.\n logger.info(`timeout recovery attempt ${this.coordinator.timeoutRecoveryAttempts}, resetting timeout state`)\n sessionState.lastTestRequestAt = null\n sessionState.lastReceivedAt = new Date()\n this.setState(SessionState.ActiveNormalSession)\n } else {\n logger.info(sessionState.toString())\n this.terminate(new Error(`${application?.name}: peer not responding`))\n }\n break\n }\n\n case TickAction.Stop: {\n logger.info(sessionState.toString())\n logger.info('stopping')\n this.stop()\n break\n }\n\n default:\n throw new Error('unexpected action')\n }\n }\n}\n"]}
|
|
@@ -74,7 +74,7 @@ class DefinitionFactory {
|
|
|
74
74
|
parser = new parser_1.RepositoryXmlParser(path, getLogger);
|
|
75
75
|
}
|
|
76
76
|
else {
|
|
77
|
-
parser = new parser_1.
|
|
77
|
+
parser = new parser_1.QuickFixGraphFileParser(() => new transport_1.FileDuplex(path), getLogger);
|
|
78
78
|
}
|
|
79
79
|
return parser;
|
|
80
80
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition-factory.js","sourceRoot":"","sources":["../../src/util/definition-factory.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,sCAA2D;AAC3D,2CAA4B;AAC5B,uCAAwB;AACxB,
|
|
1
|
+
{"version":3,"file":"definition-factory.js","sourceRoot":"","sources":["../../src/util/definition-factory.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,sCAA2D;AAC3D,2CAA4B;AAC5B,uCAAwB;AACxB,iDAAiG;AAEjG,4CAAyC;AAEzC,MAAM,IAAI,GAAW,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;AAEnD,MAAa,iBAAiB;IAC5B,WAAW,CAAE,CAAS;QACpB,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC,CAAA;QACnE,OAAO,UAAU,CAAC,CAAC,CAAC,CAAA;IACtB,CAAC;IAEK,cAAc;6DAAE,IAAY,EAAE,YAA4B,wBAAe;YAC7E,MAAM,EAAE,GAAoB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;YAClD,IAAI,EAAE,EAAE,CAAC;gBACP,IAAI,GAAG,EAAE,CAAC,IAAI,CAAA;YAChB,CAAC;YACD,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACtB,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;YAC9C,OAAO,MAAM,CAAC,KAAK,EAAE,CAAA;QACvB,CAAC;KAAA;IAED,SAAS,CAAE,IAAY,EAAE,SAAyB;QAChD,IAAI,MAAiB,CAAA;QACrB,IAAI,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/D,MAAM,GAAG,IAAI,qBAAY,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;QAC5C,CAAC;aAAM,IAAI,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;YAC5C,MAAM,GAAG,IAAI,4BAAmB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;QACnD,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,IAAI,gCAAuB,CAAC,GAAG,EAAE,CAAC,IAAI,sBAAU,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,CAAA;QAC7E,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;IAED,IAAI,CAAE,CAAS;QACb,IAAI,CAAC,GAAW,CAAC,CAAA;QACjB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;YACxB,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;QACxB,CAAC;QACD,OAAO,CAAC,CAAA;IACV,CAAC;CACF;AAnCD,8CAmCC","sourcesContent":["import { FixParser } from '../dictionary'\nimport { FixDefinitions } from '../dictionary/definition'\nimport { GetJsFixLogger, makeEmptyLogger } from '../config'\nimport * as path from 'path'\nimport * as fs from 'fs'\nimport { FixXsdParser, QuickFixGraphFileParser, RepositoryXmlParser } from '../dictionary/parser'\nimport { IDictionaryPath } from './dictionary-path'\nimport { FileDuplex } from '../transport'\n\nconst root: string = path.join(__dirname, '../../')\n\nexport class DefinitionFactory {\n getDictPath (p: string): IDictionaryPath {\n const dictionary = require(path.join(root, 'data/dictionary.json'))\n return dictionary[p]\n }\n\n async getDefinitions (path: string, getLogger: GetJsFixLogger = makeEmptyLogger): Promise<FixDefinitions> {\n const dp: IDictionaryPath = this.getDictPath(path)\n if (dp) {\n path = dp.dict\n }\n path = this.norm(path)\n const parser = this.getParser(path, getLogger)\n return parser.parse()\n }\n\n getParser (path: string, getLogger: GetJsFixLogger): FixParser {\n let parser: FixParser\n if (fs.lstatSync(path).isDirectory() && path.includes('fixml')) {\n parser = new FixXsdParser(path, getLogger)\n } else if (fs.lstatSync(path).isDirectory()) {\n parser = new RepositoryXmlParser(path, getLogger)\n } else {\n parser = new QuickFixGraphFileParser(() => new FileDuplex(path), getLogger)\n }\n return parser\n }\n\n norm (p: string): string {\n let f: string = p\n if (!path.isAbsolute(p)) {\n f = path.join(root, f)\n }\n return f\n }\n}\n"]}
|