@homaiohq/napi-quickfix 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CMakeLists.txt +135 -0
- package/LICENSE +21 -0
- package/README.md +638 -2
- package/THIRD_PARTY_LICENSES +48 -0
- package/cpp/acceptor_wrap.cpp +468 -0
- package/cpp/acceptor_wrap.h +116 -0
- package/cpp/addon.cpp +87 -0
- package/cpp/application_bridge.cpp +466 -0
- package/cpp/application_bridge.h +204 -0
- package/cpp/data_dictionary_wrap.cpp +165 -0
- package/cpp/data_dictionary_wrap.h +59 -0
- package/cpp/engine_common.cpp +5 -0
- package/cpp/engine_common.h +127 -0
- package/cpp/engine_workers.h +167 -0
- package/cpp/errors.h +142 -0
- package/cpp/field_map_ops.h +492 -0
- package/cpp/group_wrap.cpp +221 -0
- package/cpp/group_wrap.h +76 -0
- package/cpp/initiator_wrap.cpp +492 -0
- package/cpp/initiator_wrap.h +104 -0
- package/cpp/message_wrap.cpp +288 -0
- package/cpp/message_wrap.h +95 -0
- package/cpp/session_id_wrap.cpp +91 -0
- package/cpp/session_id_wrap.h +46 -0
- package/cpp/session_op_gate.h +201 -0
- package/cpp/session_settings_wrap.cpp +98 -0
- package/cpp/session_settings_wrap.h +40 -0
- package/cpp/session_static.cpp +220 -0
- package/cpp/session_wrap.cpp +438 -0
- package/cpp/session_wrap.h +144 -0
- package/dist/cjs/acceptor.d.ts +29 -0
- package/dist/cjs/acceptor.js +38 -0
- package/dist/cjs/application.d.ts +115 -0
- package/dist/cjs/application.js +62 -0
- package/dist/cjs/data-dictionary.d.ts +67 -0
- package/dist/cjs/data-dictionary.js +105 -0
- package/dist/cjs/engine.d.ts +152 -0
- package/dist/cjs/engine.js +183 -0
- package/dist/cjs/enums.d.ts +56 -0
- package/dist/cjs/enums.js +44 -0
- package/dist/cjs/field-value.d.ts +12 -0
- package/dist/cjs/field-value.js +40 -0
- package/dist/cjs/generated/fields.d.ts +6122 -0
- package/dist/cjs/generated/fields.js +6127 -0
- package/dist/cjs/generated/values.d.ts +8548 -0
- package/dist/cjs/generated/values.js +8580 -0
- package/dist/cjs/group.d.ts +126 -0
- package/dist/cjs/group.js +185 -0
- package/dist/cjs/index.d.ts +68 -0
- package/dist/cjs/index.js +73 -0
- package/dist/cjs/initiator.d.ts +29 -0
- package/dist/cjs/initiator.js +38 -0
- package/dist/cjs/load-native.cjs +5 -0
- package/dist/cjs/message.d.ts +238 -0
- package/dist/cjs/message.js +299 -0
- package/dist/cjs/native.d.ts +325 -0
- package/dist/cjs/native.js +22 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/session-id.d.ts +51 -0
- package/dist/cjs/session-id.js +87 -0
- package/dist/cjs/session-settings.d.ts +46 -0
- package/dist/cjs/session-settings.js +75 -0
- package/dist/cjs/session.d.ts +213 -0
- package/dist/cjs/session.js +337 -0
- package/dist/esm/acceptor.d.ts +29 -0
- package/dist/esm/acceptor.js +34 -0
- package/dist/esm/application.d.ts +115 -0
- package/dist/esm/application.js +57 -0
- package/dist/esm/data-dictionary.d.ts +67 -0
- package/dist/esm/data-dictionary.js +101 -0
- package/dist/esm/engine.d.ts +152 -0
- package/dist/esm/engine.js +179 -0
- package/dist/esm/enums.d.ts +56 -0
- package/dist/esm/enums.js +35 -0
- package/dist/esm/field-value.d.ts +12 -0
- package/dist/esm/field-value.js +37 -0
- package/dist/esm/generated/fields.d.ts +6122 -0
- package/dist/esm/generated/fields.js +6124 -0
- package/dist/esm/generated/values.d.ts +8548 -0
- package/dist/esm/generated/values.js +8564 -0
- package/dist/esm/group.d.ts +126 -0
- package/dist/esm/group.js +181 -0
- package/dist/esm/index.d.ts +68 -0
- package/dist/esm/index.js +43 -0
- package/dist/esm/initiator.d.ts +29 -0
- package/dist/esm/initiator.js +34 -0
- package/dist/esm/load-native.cjs +5 -0
- package/dist/esm/message.d.ts +238 -0
- package/dist/esm/message.js +293 -0
- package/dist/esm/native.d.ts +325 -0
- package/dist/esm/native.js +16 -0
- package/dist/esm/session-id.d.ts +51 -0
- package/dist/esm/session-id.js +82 -0
- package/dist/esm/session-settings.d.ts +46 -0
- package/dist/esm/session-settings.js +71 -0
- package/dist/esm/session.d.ts +213 -0
- package/dist/esm/session.js +329 -0
- package/package.json +95 -4
- package/prebuilds/darwin-arm64/node.napi.node +0 -0
- package/prebuilds/darwin-x64/node.napi.node +0 -0
- package/prebuilds/linux-x64/node.napi.glibc.node +0 -0
- package/prebuilds/linux-x64/node.napi.musl.node +0 -0
- package/prebuilds/win32-x64/node.napi.node +0 -0
- package/src/load-native.cjs +5 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ergonomic wrapper around the native `FIX::Group`: one entry of a repeating
|
|
3
|
+
* group.
|
|
4
|
+
*/
|
|
5
|
+
import { type NativeGroup } from './native.js';
|
|
6
|
+
/**
|
|
7
|
+
* One entry of a FIX repeating group.
|
|
8
|
+
*
|
|
9
|
+
* A group is identified by its **count tag** (`field`, e.g. `453 NoPartyIDs`)
|
|
10
|
+
* and its **delimiter** (`delim`, the first tag of every entry, e.g.
|
|
11
|
+
* `448 PartyID`). Build an entry, fill its fields, then
|
|
12
|
+
* {@link Message.addGroup} it; QuickFIX maintains the count field for you.
|
|
13
|
+
*
|
|
14
|
+
* Field values are accepted as `string | number` on input (numbers are written
|
|
15
|
+
* without exponent notation) and always returned as `string`, exactly as on
|
|
16
|
+
* {@link Message}. Groups nest: an entry can carry its own repeating groups
|
|
17
|
+
* through the same `addGroup` / `getGroup` API.
|
|
18
|
+
*
|
|
19
|
+
* Entries read back with `getGroup` are **snapshot copies**: mutating one does
|
|
20
|
+
* not change the message it came from. Write it back with
|
|
21
|
+
* {@link Message.replaceGroup}.
|
|
22
|
+
*
|
|
23
|
+
* Group indices are **1-based**, as in QuickFIX.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { Group, Message, FIELD } from '@homaiohq/napi-quickfix';
|
|
28
|
+
*
|
|
29
|
+
* const party = new Group(FIELD.NoPartyIDs, FIELD.PartyID)
|
|
30
|
+
* .setField(FIELD.PartyID, 'TRADER-1')
|
|
31
|
+
* .setField(FIELD.PartyIDSource, 'D')
|
|
32
|
+
* .setField(FIELD.PartyRole, 11);
|
|
33
|
+
* order.addGroup(party);
|
|
34
|
+
*
|
|
35
|
+
* order.groupCount(FIELD.NoPartyIDs); // 1
|
|
36
|
+
* order.getGroup(1, FIELD.NoPartyIDs).getField(FIELD.PartyID); // 'TRADER-1'
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare class Group {
|
|
40
|
+
#private;
|
|
41
|
+
/**
|
|
42
|
+
* Create an empty group entry.
|
|
43
|
+
*
|
|
44
|
+
* @param field The group's count tag (e.g. `FIELD.NoPartyIDs`), or an
|
|
45
|
+
* existing native handle to adopt (internal).
|
|
46
|
+
* @param delim The delimiter: the first tag of every entry (e.g.
|
|
47
|
+
* `FIELD.PartyID`).
|
|
48
|
+
* @param order Optional complete field order of an entry, delimiter first
|
|
49
|
+
* (e.g. `[448, 447, 452]`). Fields not listed sort after the listed ones by
|
|
50
|
+
* tag number. Without it, fields sort delimiter-first then by tag number,
|
|
51
|
+
* which already matches the standard dictionaries for most groups.
|
|
52
|
+
*/
|
|
53
|
+
constructor(field: number | NativeGroup, delim?: number, order?: readonly number[]);
|
|
54
|
+
/** @internal Wrap an existing native group handle. */
|
|
55
|
+
static fromNative(handle: NativeGroup): Group;
|
|
56
|
+
/** @internal The native handle backing this group. */
|
|
57
|
+
get nativeHandle(): NativeGroup;
|
|
58
|
+
/** The group's count tag (e.g. `453` for `NoPartyIDs`). */
|
|
59
|
+
get field(): number;
|
|
60
|
+
/** The delimiter: the first tag of every entry (e.g. `448` for `PartyID`). */
|
|
61
|
+
get delim(): number;
|
|
62
|
+
/**
|
|
63
|
+
* Read a field by tag.
|
|
64
|
+
* @throws A `QuickFixError` (`fixErrorName: 'FieldNotFound'`) if absent.
|
|
65
|
+
*/
|
|
66
|
+
getField(tag: number): string;
|
|
67
|
+
/** Set a field. Returns `this` for chaining. */
|
|
68
|
+
setField(tag: number, value: string | number): this;
|
|
69
|
+
/** Whether a field is present. */
|
|
70
|
+
isSetField(tag: number): boolean;
|
|
71
|
+
/** Remove a field (no-op if absent). Returns `this` for chaining. */
|
|
72
|
+
removeField(tag: number): this;
|
|
73
|
+
/** Read a field by tag, or `undefined` if absent. */
|
|
74
|
+
getFieldIfSet(tag: number): string | undefined;
|
|
75
|
+
/** The number of fields, including every field of every nested group entry. */
|
|
76
|
+
totalFields(): number;
|
|
77
|
+
/** Whether the entry has no fields of its own. */
|
|
78
|
+
isEmpty(): boolean;
|
|
79
|
+
/** Remove every field and nested group. Returns `this` for chaining. */
|
|
80
|
+
clear(): this;
|
|
81
|
+
/** The entry's own fields, in wire order, as `[tag, value]` pairs. */
|
|
82
|
+
fields(): [number, string][];
|
|
83
|
+
/** Iterates the entry's own fields as `[tag, value]` pairs (see {@link Group.fields}). */
|
|
84
|
+
[Symbol.iterator](): IterableIterator<[number, string]>;
|
|
85
|
+
/**
|
|
86
|
+
* Append a nested group entry under its own count tag (a copy is stored; the
|
|
87
|
+
* count field is updated). Returns `this` for chaining.
|
|
88
|
+
* @throws `TypeError` when `group.delim` differs from the delimiter of the
|
|
89
|
+
* entries already stored under `group.field`.
|
|
90
|
+
*/
|
|
91
|
+
addGroup(group: Group): this;
|
|
92
|
+
/**
|
|
93
|
+
* A snapshot copy of the `index`-th entry (1-based) of the nested group `tag`.
|
|
94
|
+
* Mutations do not affect this entry; write them back with
|
|
95
|
+
* {@link Group.replaceGroup}.
|
|
96
|
+
* @throws A `QuickFixError` (`fixErrorName: 'FieldNotFound'`) when the tag
|
|
97
|
+
* has no entries or `index` is out of range.
|
|
98
|
+
*/
|
|
99
|
+
getGroup(index: number, tag: number): Group;
|
|
100
|
+
/**
|
|
101
|
+
* Overwrite the `index`-th entry (1-based) under `group.field` with a copy of
|
|
102
|
+
* `group`. Returns `this` for chaining.
|
|
103
|
+
* @throws A `QuickFixError` (`fixErrorName: 'FieldNotFound'`) when that
|
|
104
|
+
* entry does not exist.
|
|
105
|
+
* @throws `TypeError` when `group.delim` differs from the stored entry's
|
|
106
|
+
* delimiter.
|
|
107
|
+
*/
|
|
108
|
+
replaceGroup(index: number, group: Group): this;
|
|
109
|
+
/**
|
|
110
|
+
* Remove every entry of the nested group `tag` (and its count field), or
|
|
111
|
+
* only the `index`-th entry (1-based). Returns `this`.
|
|
112
|
+
*
|
|
113
|
+
* Removing every entry of a tag that has none is a no-op.
|
|
114
|
+
* @throws A `QuickFixError` (`fixErrorName: 'FieldNotFound'`) when the
|
|
115
|
+
* `index`-th entry does not exist.
|
|
116
|
+
*/
|
|
117
|
+
removeGroup(tag: number): this;
|
|
118
|
+
removeGroup(index: number, tag: number): this;
|
|
119
|
+
/** Whether the nested group `tag` has any entry, or has an `index`-th entry (1-based). */
|
|
120
|
+
hasGroup(tag: number): boolean;
|
|
121
|
+
hasGroup(index: number, tag: number): boolean;
|
|
122
|
+
/** The number of entries of the nested group `tag` (0 if none). */
|
|
123
|
+
groupCount(tag: number): number;
|
|
124
|
+
/** The entry's fields (and nested groups) as a SOH-delimited string, in wire order. */
|
|
125
|
+
toString(): string;
|
|
126
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ergonomic wrapper around the native `FIX::Group`: one entry of a repeating
|
|
3
|
+
* group.
|
|
4
|
+
*/
|
|
5
|
+
import { native } from './native.js';
|
|
6
|
+
import { formatFieldValue } from './field-value.js';
|
|
7
|
+
/**
|
|
8
|
+
* One entry of a FIX repeating group.
|
|
9
|
+
*
|
|
10
|
+
* A group is identified by its **count tag** (`field`, e.g. `453 NoPartyIDs`)
|
|
11
|
+
* and its **delimiter** (`delim`, the first tag of every entry, e.g.
|
|
12
|
+
* `448 PartyID`). Build an entry, fill its fields, then
|
|
13
|
+
* {@link Message.addGroup} it; QuickFIX maintains the count field for you.
|
|
14
|
+
*
|
|
15
|
+
* Field values are accepted as `string | number` on input (numbers are written
|
|
16
|
+
* without exponent notation) and always returned as `string`, exactly as on
|
|
17
|
+
* {@link Message}. Groups nest: an entry can carry its own repeating groups
|
|
18
|
+
* through the same `addGroup` / `getGroup` API.
|
|
19
|
+
*
|
|
20
|
+
* Entries read back with `getGroup` are **snapshot copies**: mutating one does
|
|
21
|
+
* not change the message it came from. Write it back with
|
|
22
|
+
* {@link Message.replaceGroup}.
|
|
23
|
+
*
|
|
24
|
+
* Group indices are **1-based**, as in QuickFIX.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* import { Group, Message, FIELD } from '@homaiohq/napi-quickfix';
|
|
29
|
+
*
|
|
30
|
+
* const party = new Group(FIELD.NoPartyIDs, FIELD.PartyID)
|
|
31
|
+
* .setField(FIELD.PartyID, 'TRADER-1')
|
|
32
|
+
* .setField(FIELD.PartyIDSource, 'D')
|
|
33
|
+
* .setField(FIELD.PartyRole, 11);
|
|
34
|
+
* order.addGroup(party);
|
|
35
|
+
*
|
|
36
|
+
* order.groupCount(FIELD.NoPartyIDs); // 1
|
|
37
|
+
* order.getGroup(1, FIELD.NoPartyIDs).getField(FIELD.PartyID); // 'TRADER-1'
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export class Group {
|
|
41
|
+
/** @internal Underlying native handle. */
|
|
42
|
+
#native;
|
|
43
|
+
/**
|
|
44
|
+
* Create an empty group entry.
|
|
45
|
+
*
|
|
46
|
+
* @param field The group's count tag (e.g. `FIELD.NoPartyIDs`), or an
|
|
47
|
+
* existing native handle to adopt (internal).
|
|
48
|
+
* @param delim The delimiter: the first tag of every entry (e.g.
|
|
49
|
+
* `FIELD.PartyID`).
|
|
50
|
+
* @param order Optional complete field order of an entry, delimiter first
|
|
51
|
+
* (e.g. `[448, 447, 452]`). Fields not listed sort after the listed ones by
|
|
52
|
+
* tag number. Without it, fields sort delimiter-first then by tag number,
|
|
53
|
+
* which already matches the standard dictionaries for most groups.
|
|
54
|
+
*/
|
|
55
|
+
constructor(field, delim, order) {
|
|
56
|
+
if (typeof field !== 'number') {
|
|
57
|
+
// Adopt an existing native handle (getGroup path).
|
|
58
|
+
this.#native = field;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
if (typeof delim !== 'number') {
|
|
62
|
+
throw new TypeError('new Group(field: number, delim: number, order?: number[])');
|
|
63
|
+
}
|
|
64
|
+
this.#native = new native.GroupWrap(field, delim, order);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** @internal Wrap an existing native group handle. */
|
|
68
|
+
static fromNative(handle) {
|
|
69
|
+
return new Group(handle);
|
|
70
|
+
}
|
|
71
|
+
/** @internal The native handle backing this group. */
|
|
72
|
+
get nativeHandle() {
|
|
73
|
+
return this.#native;
|
|
74
|
+
}
|
|
75
|
+
/** The group's count tag (e.g. `453` for `NoPartyIDs`). */
|
|
76
|
+
get field() {
|
|
77
|
+
return this.#native.field();
|
|
78
|
+
}
|
|
79
|
+
/** The delimiter: the first tag of every entry (e.g. `448` for `PartyID`). */
|
|
80
|
+
get delim() {
|
|
81
|
+
return this.#native.delim();
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Read a field by tag.
|
|
85
|
+
* @throws A `QuickFixError` (`fixErrorName: 'FieldNotFound'`) if absent.
|
|
86
|
+
*/
|
|
87
|
+
getField(tag) {
|
|
88
|
+
return this.#native.getField(tag);
|
|
89
|
+
}
|
|
90
|
+
/** Set a field. Returns `this` for chaining. */
|
|
91
|
+
setField(tag, value) {
|
|
92
|
+
this.#native.setField(tag, formatFieldValue(value));
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
/** Whether a field is present. */
|
|
96
|
+
isSetField(tag) {
|
|
97
|
+
return this.#native.isSetField(tag);
|
|
98
|
+
}
|
|
99
|
+
/** Remove a field (no-op if absent). Returns `this` for chaining. */
|
|
100
|
+
removeField(tag) {
|
|
101
|
+
this.#native.removeField(tag);
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
/** Read a field by tag, or `undefined` if absent. */
|
|
105
|
+
getFieldIfSet(tag) {
|
|
106
|
+
return this.#native.getFieldIfSet(tag);
|
|
107
|
+
}
|
|
108
|
+
/** The number of fields, including every field of every nested group entry. */
|
|
109
|
+
totalFields() {
|
|
110
|
+
return this.#native.totalFields();
|
|
111
|
+
}
|
|
112
|
+
/** Whether the entry has no fields of its own. */
|
|
113
|
+
isEmpty() {
|
|
114
|
+
return this.#native.isEmpty();
|
|
115
|
+
}
|
|
116
|
+
/** Remove every field and nested group. Returns `this` for chaining. */
|
|
117
|
+
clear() {
|
|
118
|
+
this.#native.clear();
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
/** The entry's own fields, in wire order, as `[tag, value]` pairs. */
|
|
122
|
+
fields() {
|
|
123
|
+
return this.#native.fields();
|
|
124
|
+
}
|
|
125
|
+
/** Iterates the entry's own fields as `[tag, value]` pairs (see {@link Group.fields}). */
|
|
126
|
+
[Symbol.iterator]() {
|
|
127
|
+
return this.fields()[Symbol.iterator]();
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Append a nested group entry under its own count tag (a copy is stored; the
|
|
131
|
+
* count field is updated). Returns `this` for chaining.
|
|
132
|
+
* @throws `TypeError` when `group.delim` differs from the delimiter of the
|
|
133
|
+
* entries already stored under `group.field`.
|
|
134
|
+
*/
|
|
135
|
+
addGroup(group) {
|
|
136
|
+
this.#native.addGroup(group.nativeHandle);
|
|
137
|
+
return this;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* A snapshot copy of the `index`-th entry (1-based) of the nested group `tag`.
|
|
141
|
+
* Mutations do not affect this entry; write them back with
|
|
142
|
+
* {@link Group.replaceGroup}.
|
|
143
|
+
* @throws A `QuickFixError` (`fixErrorName: 'FieldNotFound'`) when the tag
|
|
144
|
+
* has no entries or `index` is out of range.
|
|
145
|
+
*/
|
|
146
|
+
getGroup(index, tag) {
|
|
147
|
+
return Group.fromNative(this.#native.getGroup(index, tag));
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Overwrite the `index`-th entry (1-based) under `group.field` with a copy of
|
|
151
|
+
* `group`. Returns `this` for chaining.
|
|
152
|
+
* @throws A `QuickFixError` (`fixErrorName: 'FieldNotFound'`) when that
|
|
153
|
+
* entry does not exist.
|
|
154
|
+
* @throws `TypeError` when `group.delim` differs from the stored entry's
|
|
155
|
+
* delimiter.
|
|
156
|
+
*/
|
|
157
|
+
replaceGroup(index, group) {
|
|
158
|
+
this.#native.replaceGroup(index, group.nativeHandle);
|
|
159
|
+
return this;
|
|
160
|
+
}
|
|
161
|
+
removeGroup(a, b) {
|
|
162
|
+
if (b === undefined) {
|
|
163
|
+
this.#native.removeGroup(a);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
this.#native.removeGroup(a, b);
|
|
167
|
+
}
|
|
168
|
+
return this;
|
|
169
|
+
}
|
|
170
|
+
hasGroup(a, b) {
|
|
171
|
+
return b === undefined ? this.#native.hasGroup(a) : this.#native.hasGroup(a, b);
|
|
172
|
+
}
|
|
173
|
+
/** The number of entries of the nested group `tag` (0 if none). */
|
|
174
|
+
groupCount(tag) {
|
|
175
|
+
return this.#native.groupCount(tag);
|
|
176
|
+
}
|
|
177
|
+
/** The entry's fields (and nested groups) as a SOH-delimited string, in wire order. */
|
|
178
|
+
toString() {
|
|
179
|
+
return this.#native.toString();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Message } from './message.js';
|
|
2
|
+
import { type SessionID } from './session-id.js';
|
|
3
|
+
export { Message, createMessage, parseMessage } from './message.js';
|
|
4
|
+
export type { MessageParseOptions, MessageJSON } from './message.js';
|
|
5
|
+
export { Group } from './group.js';
|
|
6
|
+
export { SessionID } from './session-id.js';
|
|
7
|
+
export { SessionSettings } from './session-settings.js';
|
|
8
|
+
export { DataDictionary } from './data-dictionary.js';
|
|
9
|
+
export { Initiator } from './initiator.js';
|
|
10
|
+
export { Acceptor } from './acceptor.js';
|
|
11
|
+
export { Engine } from './engine.js';
|
|
12
|
+
export type { EngineOptions, EngineEvents } from './engine.js';
|
|
13
|
+
export { Session, lookupSession, doesSessionExist, getSessions, numSessions } from './session.js';
|
|
14
|
+
export { FixReject, fixReject } from './application.js';
|
|
15
|
+
export type { ApplicationHandlers, FixRejectKind } from './application.js';
|
|
16
|
+
export type { QuickFixError } from './native.js';
|
|
17
|
+
export { enums, FIELD, VALUES, MsgType, Side, OrdType, TimeInForce } from './enums.js';
|
|
18
|
+
export type { Enums, EnumGroup, FieldName, ValueGroups, ValueGroupName } from './enums.js';
|
|
19
|
+
/**
|
|
20
|
+
* Send a message to the target session identified by `sessionID`.
|
|
21
|
+
*
|
|
22
|
+
* Wraps `FIX::Session::sendToTarget`. The session must exist and be logged on
|
|
23
|
+
* for delivery; otherwise the engine queues or drops per its configuration.
|
|
24
|
+
*
|
|
25
|
+
* Runs off the main thread and resolves once the engine has accepted (or
|
|
26
|
+
* rejected) the message, so the event loop stays free for callbacks. On a
|
|
27
|
+
* missing session the returned Promise rejects with a
|
|
28
|
+
* {@link QuickFixError} (`fixErrorName: 'SessionNotFound'`). The send is
|
|
29
|
+
* bound to the engine that owns the session when it is called: if that
|
|
30
|
+
* engine is stopped before the send reaches its session, the Promise rejects
|
|
31
|
+
* with `SessionNotFound` rather than running through an engine created later
|
|
32
|
+
* with the same id.
|
|
33
|
+
*
|
|
34
|
+
* @param message The message to send.
|
|
35
|
+
* @param sessionID The destination session.
|
|
36
|
+
* @returns A Promise resolving to `true` if the message was accepted for sending.
|
|
37
|
+
* @throws {TypeError} synchronously if `sessionID` is neither a {@link SessionID}
|
|
38
|
+
* nor a qualifier string (it is not routed by the header instead).
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* import { sendToTarget, createMessage, SessionID, FIELD, MsgType } from '@homaiohq/napi-quickfix';
|
|
43
|
+
* const order = createMessage({ [FIELD.MsgType]: MsgType.NewOrderSingle });
|
|
44
|
+
* await sendToTarget(order, new SessionID('FIX.4.4', 'CLIENT', 'BROKER'));
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function sendToTarget(message: Message, sessionID: SessionID): Promise<boolean>;
|
|
48
|
+
/**
|
|
49
|
+
* Send a message to the session identified by the message's **own header**
|
|
50
|
+
* (`BeginString`, `SenderCompID`, `TargetCompID`) plus an optional session
|
|
51
|
+
* qualifier.
|
|
52
|
+
*
|
|
53
|
+
* Wraps the `FIX::Session::sendToTarget(message, qualifier)` overload. Same
|
|
54
|
+
* threading and error behaviour as the SessionID form; a message whose header
|
|
55
|
+
* does not identify an existing session rejects with
|
|
56
|
+
* `fixErrorName: 'SessionNotFound'`.
|
|
57
|
+
*
|
|
58
|
+
* @param message The message to send; its header must carry tags 8, 49 and 56.
|
|
59
|
+
* @param qualifier Optional session qualifier (`SessionQualifier` in the settings).
|
|
60
|
+
*/
|
|
61
|
+
export declare function sendToTarget(message: Message, qualifier?: string): Promise<boolean>;
|
|
62
|
+
/** The QuickFIX engine / addon version string. */
|
|
63
|
+
export declare const version: () => string;
|
|
64
|
+
/**
|
|
65
|
+
* Parse the MsgType (tag 35) out of a raw FIX wire string. Low-level helper;
|
|
66
|
+
* prefer {@link Message.parse} + {@link Message.getMsgType} for general use.
|
|
67
|
+
*/
|
|
68
|
+
export declare const quickfixParseMsgType: (raw: string) => string;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@homaiohq/napi-quickfix` — a modern Node-API binding for the QuickFIX C++
|
|
3
|
+
* FIX-protocol engine.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
import { native } from './native.js';
|
|
8
|
+
import { toNativeSessionID } from './session-id.js';
|
|
9
|
+
// --- Pure layer -----------------------------------------------------------
|
|
10
|
+
export { Message, createMessage, parseMessage } from './message.js';
|
|
11
|
+
export { Group } from './group.js';
|
|
12
|
+
export { SessionID } from './session-id.js';
|
|
13
|
+
export { SessionSettings } from './session-settings.js';
|
|
14
|
+
export { DataDictionary } from './data-dictionary.js';
|
|
15
|
+
// --- Session engine -------------------------------------------------------
|
|
16
|
+
export { Initiator } from './initiator.js';
|
|
17
|
+
export { Acceptor } from './acceptor.js';
|
|
18
|
+
export { Engine } from './engine.js';
|
|
19
|
+
export { Session, lookupSession, doesSessionExist, getSessions, numSessions } from './session.js';
|
|
20
|
+
export { FixReject, fixReject } from './application.js';
|
|
21
|
+
// --- Enums / constants ----------------------------------------------------
|
|
22
|
+
// Every other value group (ExecType, OrdStatus, SecurityType, ...) is reachable
|
|
23
|
+
// as `enums.<Field>` / `VALUES.<Field>`, or by name from the
|
|
24
|
+
// `@homaiohq/napi-quickfix/values` subpath, which keeps this namespace small.
|
|
25
|
+
export { enums, FIELD, VALUES, MsgType, Side, OrdType, TimeInForce } from './enums.js';
|
|
26
|
+
export function sendToTarget(message, sessionIDOrQualifier) {
|
|
27
|
+
// Dispatch on the primitive, not `instanceof SessionID`: this package ships
|
|
28
|
+
// ESM and CJS builds, and a SessionID created by the other build is a
|
|
29
|
+
// different class with the same shape (see toNativeSessionID). Anything
|
|
30
|
+
// else is a TypeError here rather than an `undefined` target the native
|
|
31
|
+
// layer would read as "route by the message header".
|
|
32
|
+
const target = typeof sessionIDOrQualifier === 'string' || sessionIDOrQualifier === undefined
|
|
33
|
+
? sessionIDOrQualifier
|
|
34
|
+
: toNativeSessionID(sessionIDOrQualifier, 'sessionID');
|
|
35
|
+
return native.sendToTarget(message.nativeHandle, target);
|
|
36
|
+
}
|
|
37
|
+
/** The QuickFIX engine / addon version string. */
|
|
38
|
+
export const version = () => native.version();
|
|
39
|
+
/**
|
|
40
|
+
* Parse the MsgType (tag 35) out of a raw FIX wire string. Low-level helper;
|
|
41
|
+
* prefer {@link Message.parse} + {@link Message.getMsgType} for general use.
|
|
42
|
+
*/
|
|
43
|
+
export const quickfixParseMsgType = (raw) => native.quickfixParseMsgType(raw);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Engine, type EngineOptions } from './engine.js';
|
|
2
|
+
export type { EngineOptions } from './engine.js';
|
|
3
|
+
/**
|
|
4
|
+
* A FIX session initiator (wraps `FIX::SocketInitiator`). Initiators establish
|
|
5
|
+
* outbound connections to acceptors as configured in {@link EngineOptions.settings}.
|
|
6
|
+
*
|
|
7
|
+
* Extends {@link Engine} (an {@link import('node:events').EventEmitter}), so you
|
|
8
|
+
* can observe lifecycle/message events in addition to supplying `handlers`.
|
|
9
|
+
* Remember: only `handlers` may mutate outbound messages or reject inbound ones;
|
|
10
|
+
* events are observe-only.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const initiator = new Initiator({
|
|
15
|
+
* settings: SessionSettings.fromString(cfg),
|
|
16
|
+
* handlers: { onLogon: (id) => console.log('up', id.toString()) },
|
|
17
|
+
* store: 'memory',
|
|
18
|
+
* log: 'none',
|
|
19
|
+
* });
|
|
20
|
+
* initiator.on('fromApp', (msg) => console.log('recv', msg.getMsgType()));
|
|
21
|
+
* await initiator.start();
|
|
22
|
+
* // ... later
|
|
23
|
+
* await initiator.stop();
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class Initiator extends Engine {
|
|
27
|
+
/** @param options Engine options. */
|
|
28
|
+
constructor(options: EngineOptions);
|
|
29
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FIX session initiator (client side — connects out to acceptors).
|
|
3
|
+
*/
|
|
4
|
+
import { native } from './native.js';
|
|
5
|
+
import { Engine } from './engine.js';
|
|
6
|
+
/**
|
|
7
|
+
* A FIX session initiator (wraps `FIX::SocketInitiator`). Initiators establish
|
|
8
|
+
* outbound connections to acceptors as configured in {@link EngineOptions.settings}.
|
|
9
|
+
*
|
|
10
|
+
* Extends {@link Engine} (an {@link import('node:events').EventEmitter}), so you
|
|
11
|
+
* can observe lifecycle/message events in addition to supplying `handlers`.
|
|
12
|
+
* Remember: only `handlers` may mutate outbound messages or reject inbound ones;
|
|
13
|
+
* events are observe-only.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const initiator = new Initiator({
|
|
18
|
+
* settings: SessionSettings.fromString(cfg),
|
|
19
|
+
* handlers: { onLogon: (id) => console.log('up', id.toString()) },
|
|
20
|
+
* store: 'memory',
|
|
21
|
+
* log: 'none',
|
|
22
|
+
* });
|
|
23
|
+
* initiator.on('fromApp', (msg) => console.log('recv', msg.getMsgType()));
|
|
24
|
+
* await initiator.start();
|
|
25
|
+
* // ... later
|
|
26
|
+
* await initiator.stop();
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export class Initiator extends Engine {
|
|
30
|
+
/** @param options Engine options. */
|
|
31
|
+
constructor(options) {
|
|
32
|
+
super(native.InitiatorWrap, options);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Authored (NOT compiled by tsc). Copied verbatim into dist/esm and dist/cjs by
|
|
2
|
+
// build:ts:copy. From either of those directories, two levels up is the package
|
|
3
|
+
// root, where prebuilds/ lives (and build/Release/*.node in local dev).
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
module.exports = require('node-gyp-build')(path.join(__dirname, '..', '..'));
|