@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.
Files changed (104) hide show
  1. package/CMakeLists.txt +135 -0
  2. package/LICENSE +21 -0
  3. package/README.md +638 -2
  4. package/THIRD_PARTY_LICENSES +48 -0
  5. package/cpp/acceptor_wrap.cpp +468 -0
  6. package/cpp/acceptor_wrap.h +116 -0
  7. package/cpp/addon.cpp +87 -0
  8. package/cpp/application_bridge.cpp +466 -0
  9. package/cpp/application_bridge.h +204 -0
  10. package/cpp/data_dictionary_wrap.cpp +165 -0
  11. package/cpp/data_dictionary_wrap.h +59 -0
  12. package/cpp/engine_common.cpp +5 -0
  13. package/cpp/engine_common.h +127 -0
  14. package/cpp/engine_workers.h +167 -0
  15. package/cpp/errors.h +142 -0
  16. package/cpp/field_map_ops.h +492 -0
  17. package/cpp/group_wrap.cpp +221 -0
  18. package/cpp/group_wrap.h +76 -0
  19. package/cpp/initiator_wrap.cpp +492 -0
  20. package/cpp/initiator_wrap.h +104 -0
  21. package/cpp/message_wrap.cpp +288 -0
  22. package/cpp/message_wrap.h +95 -0
  23. package/cpp/session_id_wrap.cpp +91 -0
  24. package/cpp/session_id_wrap.h +46 -0
  25. package/cpp/session_op_gate.h +201 -0
  26. package/cpp/session_settings_wrap.cpp +98 -0
  27. package/cpp/session_settings_wrap.h +40 -0
  28. package/cpp/session_static.cpp +220 -0
  29. package/cpp/session_wrap.cpp +438 -0
  30. package/cpp/session_wrap.h +144 -0
  31. package/dist/cjs/acceptor.d.ts +29 -0
  32. package/dist/cjs/acceptor.js +38 -0
  33. package/dist/cjs/application.d.ts +115 -0
  34. package/dist/cjs/application.js +62 -0
  35. package/dist/cjs/data-dictionary.d.ts +67 -0
  36. package/dist/cjs/data-dictionary.js +105 -0
  37. package/dist/cjs/engine.d.ts +152 -0
  38. package/dist/cjs/engine.js +183 -0
  39. package/dist/cjs/enums.d.ts +56 -0
  40. package/dist/cjs/enums.js +44 -0
  41. package/dist/cjs/field-value.d.ts +12 -0
  42. package/dist/cjs/field-value.js +40 -0
  43. package/dist/cjs/generated/fields.d.ts +6122 -0
  44. package/dist/cjs/generated/fields.js +6127 -0
  45. package/dist/cjs/generated/values.d.ts +8548 -0
  46. package/dist/cjs/generated/values.js +8580 -0
  47. package/dist/cjs/group.d.ts +126 -0
  48. package/dist/cjs/group.js +185 -0
  49. package/dist/cjs/index.d.ts +68 -0
  50. package/dist/cjs/index.js +73 -0
  51. package/dist/cjs/initiator.d.ts +29 -0
  52. package/dist/cjs/initiator.js +38 -0
  53. package/dist/cjs/load-native.cjs +5 -0
  54. package/dist/cjs/message.d.ts +238 -0
  55. package/dist/cjs/message.js +299 -0
  56. package/dist/cjs/native.d.ts +325 -0
  57. package/dist/cjs/native.js +22 -0
  58. package/dist/cjs/package.json +1 -0
  59. package/dist/cjs/session-id.d.ts +51 -0
  60. package/dist/cjs/session-id.js +87 -0
  61. package/dist/cjs/session-settings.d.ts +46 -0
  62. package/dist/cjs/session-settings.js +75 -0
  63. package/dist/cjs/session.d.ts +213 -0
  64. package/dist/cjs/session.js +337 -0
  65. package/dist/esm/acceptor.d.ts +29 -0
  66. package/dist/esm/acceptor.js +34 -0
  67. package/dist/esm/application.d.ts +115 -0
  68. package/dist/esm/application.js +57 -0
  69. package/dist/esm/data-dictionary.d.ts +67 -0
  70. package/dist/esm/data-dictionary.js +101 -0
  71. package/dist/esm/engine.d.ts +152 -0
  72. package/dist/esm/engine.js +179 -0
  73. package/dist/esm/enums.d.ts +56 -0
  74. package/dist/esm/enums.js +35 -0
  75. package/dist/esm/field-value.d.ts +12 -0
  76. package/dist/esm/field-value.js +37 -0
  77. package/dist/esm/generated/fields.d.ts +6122 -0
  78. package/dist/esm/generated/fields.js +6124 -0
  79. package/dist/esm/generated/values.d.ts +8548 -0
  80. package/dist/esm/generated/values.js +8564 -0
  81. package/dist/esm/group.d.ts +126 -0
  82. package/dist/esm/group.js +181 -0
  83. package/dist/esm/index.d.ts +68 -0
  84. package/dist/esm/index.js +43 -0
  85. package/dist/esm/initiator.d.ts +29 -0
  86. package/dist/esm/initiator.js +34 -0
  87. package/dist/esm/load-native.cjs +5 -0
  88. package/dist/esm/message.d.ts +238 -0
  89. package/dist/esm/message.js +293 -0
  90. package/dist/esm/native.d.ts +325 -0
  91. package/dist/esm/native.js +16 -0
  92. package/dist/esm/session-id.d.ts +51 -0
  93. package/dist/esm/session-id.js +82 -0
  94. package/dist/esm/session-settings.d.ts +46 -0
  95. package/dist/esm/session-settings.js +71 -0
  96. package/dist/esm/session.d.ts +213 -0
  97. package/dist/esm/session.js +329 -0
  98. package/package.json +95 -4
  99. package/prebuilds/darwin-arm64/node.napi.node +0 -0
  100. package/prebuilds/darwin-x64/node.napi.node +0 -0
  101. package/prebuilds/linux-x64/node.napi.glibc.node +0 -0
  102. package/prebuilds/linux-x64/node.napi.musl.node +0 -0
  103. package/prebuilds/win32-x64/node.napi.node +0 -0
  104. 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,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.enums = exports.TimeInForce = exports.OrdType = exports.Side = exports.MsgType = exports.VALUES = exports.FIELD = void 0;
4
+ /**
5
+ * FIX constants.
6
+ *
7
+ * - {@link FIELD} — field-name → tag-number (e.g. `FIELD.MsgType === 35`).
8
+ * Generated from QuickFIX's `FixFieldNumbers.h` (see `src/generated/fields.ts`),
9
+ * so it carries every `FIX::FIELD::*` name the bundled engine knows.
10
+ * - value groups such as {@link MsgType} and {@link Side} (e.g.
11
+ * `MsgType.Logon === 'A'`, `Side.Buy === '1'`) — one per field, generated from
12
+ * QuickFIX's `FixValues.h` (see `src/generated/values.ts`), so every
13
+ * `FIX::<Field>_<VALUE>` constant is here. {@link VALUES} holds all of them
14
+ * keyed by field name, and each group is also importable from
15
+ * `@homaiohq/napi-quickfix/values` without loading the native addon.
16
+ *
17
+ * Everything carries literal types and is frozen, so a misspelt name is a
18
+ * compile error and consumers cannot mutate the shared constant tables.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import { FIELD, MsgType, enums } from '@homaiohq/napi-quickfix';
23
+ * msg.setField(FIELD.MsgType, MsgType.Logon);
24
+ * const side = enums.Side.Buy;
25
+ * ```
26
+ */
27
+ const fields_js_1 = require("./generated/fields.js");
28
+ const values_js_1 = require("./generated/values.js");
29
+ var fields_js_2 = require("./generated/fields.js");
30
+ Object.defineProperty(exports, "FIELD", { enumerable: true, get: function () { return fields_js_2.FIELD; } });
31
+ var values_js_2 = require("./generated/values.js");
32
+ Object.defineProperty(exports, "VALUES", { enumerable: true, get: function () { return values_js_2.VALUES; } });
33
+ Object.defineProperty(exports, "MsgType", { enumerable: true, get: function () { return values_js_2.MsgType; } });
34
+ Object.defineProperty(exports, "Side", { enumerable: true, get: function () { return values_js_2.Side; } });
35
+ Object.defineProperty(exports, "OrdType", { enumerable: true, get: function () { return values_js_2.OrdType; } });
36
+ Object.defineProperty(exports, "TimeInForce", { enumerable: true, get: function () { return values_js_2.TimeInForce; } });
37
+ /**
38
+ * The complete tree of FIX constants (frozen), e.g. `enums.FIELD.MsgType`,
39
+ * `enums.MsgType.Logon`, `enums.Side.Buy`.
40
+ *
41
+ * `enums.FIELD` is the same table as {@link FIELD}; every other member is the
42
+ * same object as the corresponding {@link VALUES} group.
43
+ */
44
+ exports.enums = Object.freeze({ ...values_js_1.VALUES, FIELD: fields_js_1.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,40 @@
1
+ "use strict";
2
+ /**
3
+ * Wire formatting of the `string | number` field values `Message` and `Group`
4
+ * accept.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.formatFieldValue = formatFieldValue;
8
+ /**
9
+ * A field value as FIX text. Strings pass through. A number keeps its shortest
10
+ * round-trip digits but is written without exponent notation, which FIX numeric
11
+ * fields do not allow (`1e-7` → `'0.0000001'`, `1e21` →
12
+ * `'1000000000000000000000'`, where `String` gives `'1e-7'` and `'1e+21'`).
13
+ * @throws `RangeError` for `NaN` and `±Infinity`, which have no FIX form.
14
+ */
15
+ function formatFieldValue(value) {
16
+ if (typeof value !== 'number') {
17
+ return String(value);
18
+ }
19
+ if (!Number.isFinite(value)) {
20
+ throw new RangeError(`field value must be a finite number, got ${value}`);
21
+ }
22
+ const text = String(value);
23
+ const e = text.indexOf('e');
24
+ if (e === -1) {
25
+ return text;
26
+ }
27
+ // `[-]d[.ddd]e±n`: move the decimal point of the mantissa n places.
28
+ const sign = value < 0 ? '-' : '';
29
+ const mantissa = text.slice(sign.length, e);
30
+ const point = mantissa.indexOf('.');
31
+ const digits = mantissa.replace('.', '');
32
+ const at = (point === -1 ? mantissa.length : point) + Number(text.slice(e + 1));
33
+ if (at <= 0) {
34
+ return `${sign}0.${'0'.repeat(-at)}${digits}`;
35
+ }
36
+ if (at >= digits.length) {
37
+ return `${sign}${digits}${'0'.repeat(at - digits.length)}`;
38
+ }
39
+ return `${sign}${digits.slice(0, at)}.${digits.slice(at)}`;
40
+ }