@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,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FIX constants.
|
|
3
|
+
*
|
|
4
|
+
* - {@link FIELD} — field-name → tag-number (e.g. `FIELD.MsgType === 35`).
|
|
5
|
+
* Generated from QuickFIX's `FixFieldNumbers.h` (see `src/generated/fields.ts`),
|
|
6
|
+
* so it carries every `FIX::FIELD::*` name the bundled engine knows.
|
|
7
|
+
* - value groups such as {@link MsgType} and {@link Side} (e.g.
|
|
8
|
+
* `MsgType.Logon === 'A'`, `Side.Buy === '1'`) — one per field, generated from
|
|
9
|
+
* QuickFIX's `FixValues.h` (see `src/generated/values.ts`), so every
|
|
10
|
+
* `FIX::<Field>_<VALUE>` constant is here. {@link VALUES} holds all of them
|
|
11
|
+
* keyed by field name, and each group is also importable from
|
|
12
|
+
* `@homaiohq/napi-quickfix/values` without loading the native addon.
|
|
13
|
+
*
|
|
14
|
+
* Everything carries literal types and is frozen, so a misspelt name is a
|
|
15
|
+
* compile error and consumers cannot mutate the shared constant tables.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { FIELD, MsgType, enums } from '@homaiohq/napi-quickfix';
|
|
20
|
+
* msg.setField(FIELD.MsgType, MsgType.Logon);
|
|
21
|
+
* const side = enums.Side.Buy;
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
import { FIELD } from './generated/fields.js';
|
|
25
|
+
import { type ValueGroups } from './generated/values.js';
|
|
26
|
+
export { FIELD, type FieldName } from './generated/fields.js';
|
|
27
|
+
export { VALUES, MsgType, Side, OrdType, TimeInForce, type ValueGroups, type ValueGroupName, } from './generated/values.js';
|
|
28
|
+
/**
|
|
29
|
+
* A single group of FIX constants widened to a string-indexed map (name → value).
|
|
30
|
+
*
|
|
31
|
+
* Every value group and {@link FIELD} is assignable to it, so use it where a group
|
|
32
|
+
* is looked up by a `string` key the compiler cannot narrow (a name read from
|
|
33
|
+
* configuration, say) instead of the literally-typed group itself:
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* const group: EnumGroup = enums[name as ValueGroupName];
|
|
38
|
+
* const code = group[valueName];
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export type EnumGroup = Readonly<Record<string, number | string>>;
|
|
42
|
+
/**
|
|
43
|
+
* The full, frozen tree of FIX constants: every value group of {@link ValueGroups}
|
|
44
|
+
* plus the {@link FIELD} tag table.
|
|
45
|
+
*/
|
|
46
|
+
export type Enums = ValueGroups & {
|
|
47
|
+
readonly FIELD: typeof FIELD;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* The complete tree of FIX constants (frozen), e.g. `enums.FIELD.MsgType`,
|
|
51
|
+
* `enums.MsgType.Logon`, `enums.Side.Buy`.
|
|
52
|
+
*
|
|
53
|
+
* `enums.FIELD` is the same table as {@link FIELD}; every other member is the
|
|
54
|
+
* same object as the corresponding {@link VALUES} group.
|
|
55
|
+
*/
|
|
56
|
+
export declare const enums: Enums;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FIX constants.
|
|
3
|
+
*
|
|
4
|
+
* - {@link FIELD} — field-name → tag-number (e.g. `FIELD.MsgType === 35`).
|
|
5
|
+
* Generated from QuickFIX's `FixFieldNumbers.h` (see `src/generated/fields.ts`),
|
|
6
|
+
* so it carries every `FIX::FIELD::*` name the bundled engine knows.
|
|
7
|
+
* - value groups such as {@link MsgType} and {@link Side} (e.g.
|
|
8
|
+
* `MsgType.Logon === 'A'`, `Side.Buy === '1'`) — one per field, generated from
|
|
9
|
+
* QuickFIX's `FixValues.h` (see `src/generated/values.ts`), so every
|
|
10
|
+
* `FIX::<Field>_<VALUE>` constant is here. {@link VALUES} holds all of them
|
|
11
|
+
* keyed by field name, and each group is also importable from
|
|
12
|
+
* `@homaiohq/napi-quickfix/values` without loading the native addon.
|
|
13
|
+
*
|
|
14
|
+
* Everything carries literal types and is frozen, so a misspelt name is a
|
|
15
|
+
* compile error and consumers cannot mutate the shared constant tables.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { FIELD, MsgType, enums } from '@homaiohq/napi-quickfix';
|
|
20
|
+
* msg.setField(FIELD.MsgType, MsgType.Logon);
|
|
21
|
+
* const side = enums.Side.Buy;
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
import { FIELD } from './generated/fields.js';
|
|
25
|
+
import { VALUES } from './generated/values.js';
|
|
26
|
+
export { FIELD } from './generated/fields.js';
|
|
27
|
+
export { VALUES, MsgType, Side, OrdType, TimeInForce, } from './generated/values.js';
|
|
28
|
+
/**
|
|
29
|
+
* The complete tree of FIX constants (frozen), e.g. `enums.FIELD.MsgType`,
|
|
30
|
+
* `enums.MsgType.Logon`, `enums.Side.Buy`.
|
|
31
|
+
*
|
|
32
|
+
* `enums.FIELD` is the same table as {@link FIELD}; every other member is the
|
|
33
|
+
* same object as the corresponding {@link VALUES} group.
|
|
34
|
+
*/
|
|
35
|
+
export const enums = /* @__PURE__ */ Object.freeze({ ...VALUES, FIELD });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire formatting of the `string | number` field values `Message` and `Group`
|
|
3
|
+
* accept.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* A field value as FIX text. Strings pass through. A number keeps its shortest
|
|
7
|
+
* round-trip digits but is written without exponent notation, which FIX numeric
|
|
8
|
+
* fields do not allow (`1e-7` → `'0.0000001'`, `1e21` →
|
|
9
|
+
* `'1000000000000000000000'`, where `String` gives `'1e-7'` and `'1e+21'`).
|
|
10
|
+
* @throws `RangeError` for `NaN` and `±Infinity`, which have no FIX form.
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatFieldValue(value: string | number): string;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire formatting of the `string | number` field values `Message` and `Group`
|
|
3
|
+
* accept.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* A field value as FIX text. Strings pass through. A number keeps its shortest
|
|
7
|
+
* round-trip digits but is written without exponent notation, which FIX numeric
|
|
8
|
+
* fields do not allow (`1e-7` → `'0.0000001'`, `1e21` →
|
|
9
|
+
* `'1000000000000000000000'`, where `String` gives `'1e-7'` and `'1e+21'`).
|
|
10
|
+
* @throws `RangeError` for `NaN` and `±Infinity`, which have no FIX form.
|
|
11
|
+
*/
|
|
12
|
+
export function formatFieldValue(value) {
|
|
13
|
+
if (typeof value !== 'number') {
|
|
14
|
+
return String(value);
|
|
15
|
+
}
|
|
16
|
+
if (!Number.isFinite(value)) {
|
|
17
|
+
throw new RangeError(`field value must be a finite number, got ${value}`);
|
|
18
|
+
}
|
|
19
|
+
const text = String(value);
|
|
20
|
+
const e = text.indexOf('e');
|
|
21
|
+
if (e === -1) {
|
|
22
|
+
return text;
|
|
23
|
+
}
|
|
24
|
+
// `[-]d[.ddd]e±n`: move the decimal point of the mantissa n places.
|
|
25
|
+
const sign = value < 0 ? '-' : '';
|
|
26
|
+
const mantissa = text.slice(sign.length, e);
|
|
27
|
+
const point = mantissa.indexOf('.');
|
|
28
|
+
const digits = mantissa.replace('.', '');
|
|
29
|
+
const at = (point === -1 ? mantissa.length : point) + Number(text.slice(e + 1));
|
|
30
|
+
if (at <= 0) {
|
|
31
|
+
return `${sign}0.${'0'.repeat(-at)}${digits}`;
|
|
32
|
+
}
|
|
33
|
+
if (at >= digits.length) {
|
|
34
|
+
return `${sign}${digits}${'0'.repeat(at - digits.length)}`;
|
|
35
|
+
}
|
|
36
|
+
return `${sign}${digits.slice(0, at)}.${digits.slice(at)}`;
|
|
37
|
+
}
|