yggio 0.0.14 → 0.0.15
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/benchmarks/fix.js +24 -28
- package/binding.d.ts +147 -69
- package/binding.js +126 -74
- package/index.d.ts +1067 -571
- package/index.js +15 -12
- package/package.json +5 -5
- package/records.js +30 -0
package/binding.js
CHANGED
|
@@ -4992,6 +4992,18 @@ for (const Clause of [NativeTerm, NativeFilter, NativeSelector]) {
|
|
|
4992
4992
|
})
|
|
4993
4993
|
}
|
|
4994
4994
|
|
|
4995
|
+
// A plan binds its own parameters, in every section and every plan it holds
|
|
4996
|
+
// (`Plan::with_parameters`): no schema, the record alone.
|
|
4997
|
+
{
|
|
4998
|
+
const nativeBind = takePrivate(NativePlan, '_bindNative')
|
|
4999
|
+
Object.defineProperty(NativePlan.prototype, 'bind', {
|
|
5000
|
+
configurable: true,
|
|
5001
|
+
value(parameters) {
|
|
5002
|
+
return nativeBind.call(this, suppliedParameters(parameters))
|
|
5003
|
+
},
|
|
5004
|
+
})
|
|
5005
|
+
}
|
|
5006
|
+
|
|
4995
5007
|
// One Arrow surface per applier: `applyArrowReader` keeps a native reader
|
|
4996
5008
|
// lazy, `applyArrowBatch` and `applyArrowTable` keep the Apache Arrow JS
|
|
4997
5009
|
// holder they were given, and `applyArrow` infers which of the three it has.
|
|
@@ -5639,15 +5651,16 @@ for (const name of [
|
|
|
5639
5651
|
// dictionary, the message it types and the process default are one name
|
|
5640
5652
|
// rather than four top-level classes.
|
|
5641
5653
|
//
|
|
5642
|
-
// A message value is whatever `Scalar.from` reads, and
|
|
5643
|
-
// in this loader, so the public
|
|
5644
|
-
// the
|
|
5645
|
-
// a factory, never by `new`: the
|
|
5654
|
+
// A message value is whatever `Scalar.from` reads, and a line whatever
|
|
5655
|
+
// `toBytes` reads; those conversions live in this loader, so the public
|
|
5656
|
+
// factories are the one widening gate and hand the native class the value it
|
|
5657
|
+
// already understands. A message is built by a factory, never by `new`: the
|
|
5658
|
+
// core reads a line, a record or a row into one.
|
|
5646
5659
|
const NativeMarketMessage = binding.MarketMessage
|
|
5647
5660
|
const asScalar = (value) => (value instanceof Scalar ? value : Scalar.from(value))
|
|
5648
5661
|
function MarketMessage() {
|
|
5649
5662
|
throw new TypeError(
|
|
5650
|
-
'MarketMessage has no constructor: build one with MarketMessage.fromFixRecord or MarketMessage.fromRow',
|
|
5663
|
+
'MarketMessage has no constructor: build one with MarketMessage.fromLine, MarketMessage.fromFixRecord or MarketMessage.fromRow',
|
|
5651
5664
|
)
|
|
5652
5665
|
}
|
|
5653
5666
|
MarketMessage.prototype = NativeMarketMessage.prototype
|
|
@@ -5658,11 +5671,29 @@ Object.defineProperty(MarketMessage.prototype, 'constructor', {
|
|
|
5658
5671
|
})
|
|
5659
5672
|
// A record, a row read back and a value written cross the one gate: whatever
|
|
5660
5673
|
// `Scalar.from` reads, and the core alone types it.
|
|
5661
|
-
MarketMessage.fromFixRecord = function fromFixRecord(field, value,
|
|
5662
|
-
return NativeMarketMessage.fromFixRecord(field, asScalar(value),
|
|
5674
|
+
MarketMessage.fromFixRecord = function fromFixRecord(field, value, options) {
|
|
5675
|
+
return NativeMarketMessage.fromFixRecord(field, asScalar(value), options)
|
|
5676
|
+
}
|
|
5677
|
+
MarketMessage.fromRow = function fromRow(schema, row, options) {
|
|
5678
|
+
return NativeMarketMessage.fromRow(schema, asScalar(row), options)
|
|
5663
5679
|
}
|
|
5664
|
-
|
|
5665
|
-
|
|
5680
|
+
for (const name of ['fromLine', 'fromFixMessage', 'fromUllinkLine', 'fromFixmlMessage']) {
|
|
5681
|
+
const native = NativeMarketMessage[name]
|
|
5682
|
+
MarketMessage[name] = {
|
|
5683
|
+
[name](body, options) {
|
|
5684
|
+
return native.call(NativeMarketMessage, toBytes(body), options)
|
|
5685
|
+
},
|
|
5686
|
+
}[name]
|
|
5687
|
+
}
|
|
5688
|
+
// A native factory builds through the class it is called on, so each is
|
|
5689
|
+
// called on the native class, never on this constructor that refuses `new`.
|
|
5690
|
+
for (const name of ['fromTextLine', 'fromPairs']) {
|
|
5691
|
+
const native = NativeMarketMessage[name]
|
|
5692
|
+
MarketMessage[name] = {
|
|
5693
|
+
[name](value, options) {
|
|
5694
|
+
return native.call(NativeMarketMessage, value, options)
|
|
5695
|
+
},
|
|
5696
|
+
}[name]
|
|
5666
5697
|
}
|
|
5667
5698
|
MarketMessage.field = NativeMarketMessage.field
|
|
5668
5699
|
const nativeMarketMessageSet = NativeMarketMessage.prototype.set
|
|
@@ -5671,30 +5702,42 @@ NativeMarketMessage.prototype.set = function set(key, value) {
|
|
|
5671
5702
|
}
|
|
5672
5703
|
|
|
5673
5704
|
// A line crosses as the `TextLine` a text read answered - there is nothing to
|
|
5674
|
-
// widen, because a line is a decoded row and not a value -
|
|
5675
|
-
//
|
|
5676
|
-
//
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
}
|
|
5685
|
-
const
|
|
5686
|
-
|
|
5687
|
-
|
|
5705
|
+
// widen, because a line is a decoded row and not a value - a batch source as
|
|
5706
|
+
// whatever `BatchReader.from` accepts: a reader, an Arrow JS table or batch,
|
|
5707
|
+
// IPC bytes - and a root as any `FieldLike`. That widening lives here, beside
|
|
5708
|
+
// the conversions it uses.
|
|
5709
|
+
const NativeMarketMessages = binding.MarketMessages
|
|
5710
|
+
const fieldOrAbsent = (field) => (field === undefined || field === null ? field : intoField(field))
|
|
5711
|
+
{
|
|
5712
|
+
const nativeFromArrowReader = NativeMarketMessages.prototype.fromArrowReader
|
|
5713
|
+
NativeMarketMessages.prototype.fromArrowReader = function fromArrowReader(source, field) {
|
|
5714
|
+
return nativeFromArrowReader.call(this, BatchReader.from(source), fieldOrAbsent(field))
|
|
5715
|
+
}
|
|
5716
|
+
const nativeFromTextArrowReader = NativeMarketMessages.prototype.fromTextArrowReader
|
|
5717
|
+
NativeMarketMessages.prototype.fromTextArrowReader = function fromTextArrowReader(source) {
|
|
5718
|
+
return nativeFromTextArrowReader.call(this, BatchReader.from(source))
|
|
5719
|
+
}
|
|
5720
|
+
for (const name of ['intoArrowReader', 'intoSerie']) {
|
|
5721
|
+
const native = NativeMarketMessages.prototype[name]
|
|
5722
|
+
NativeMarketMessages.prototype[name] = {
|
|
5723
|
+
[name](field) {
|
|
5724
|
+
return native.call(this, fieldOrAbsent(field))
|
|
5725
|
+
},
|
|
5726
|
+
}[name]
|
|
5727
|
+
}
|
|
5728
|
+
const nativeMessageSearch = binding.Underlyings.prototype.messageSearch
|
|
5729
|
+
binding.Underlyings.prototype.messageSearch = function messageSearch(text, field, options) {
|
|
5730
|
+
return nativeMessageSearch.call(this, text, intoField(field), options)
|
|
5731
|
+
}
|
|
5688
5732
|
}
|
|
5689
5733
|
|
|
5690
|
-
// A
|
|
5691
|
-
// protocol runs here, and the native
|
|
5692
|
-
//
|
|
5693
|
-
//
|
|
5694
|
-
//
|
|
5695
|
-
//
|
|
5696
|
-
//
|
|
5697
|
-
// travels through the native stage as that stage's own failure.
|
|
5734
|
+
// A source over an iterable pulls one item at a time: the iterable's own
|
|
5735
|
+
// protocol runs here, and the native stream asks for the next item only when
|
|
5736
|
+
// it is read that far, so nothing is collected on the way across. `read`
|
|
5737
|
+
// turns one item into the value the native source takes. What the iterable
|
|
5738
|
+
// or the reading throws ends the pull: it travels through the native stream
|
|
5739
|
+
// as the item after the last one - what a stage or a sink downstream reports
|
|
5740
|
+
// - and is kept in `failed`, as itself, for `next` to throw in its place.
|
|
5698
5741
|
const FAILED = Symbol('yggio.fix.failed')
|
|
5699
5742
|
function pullOf(iterable, read, what, failed) {
|
|
5700
5743
|
if (iterable == null || typeof iterable[Symbol.iterator] !== 'function') {
|
|
@@ -5702,14 +5745,13 @@ function pullOf(iterable, read, what, failed) {
|
|
|
5702
5745
|
}
|
|
5703
5746
|
const iterator = iterable[Symbol.iterator]()
|
|
5704
5747
|
return () => {
|
|
5705
|
-
if (failed
|
|
5748
|
+
if (failed.error !== undefined) return null
|
|
5706
5749
|
try {
|
|
5707
5750
|
const step = iterator.next()
|
|
5708
5751
|
return step.done ? null : read(step.value)
|
|
5709
5752
|
} catch (error) {
|
|
5710
|
-
if (failed === undefined) throw error
|
|
5711
5753
|
failed.error = error
|
|
5712
|
-
|
|
5754
|
+
throw error
|
|
5713
5755
|
}
|
|
5714
5756
|
}
|
|
5715
5757
|
}
|
|
@@ -5726,15 +5768,15 @@ function asLine(value) {
|
|
|
5726
5768
|
return value
|
|
5727
5769
|
}
|
|
5728
5770
|
{
|
|
5729
|
-
const
|
|
5730
|
-
[
|
|
5731
|
-
[
|
|
5732
|
-
[
|
|
5771
|
+
const sources = [
|
|
5772
|
+
['fromLines', '_fromLinesNative', toBytes, 'lines'],
|
|
5773
|
+
['fromTextLines', '_fromTextLinesNative', asLine, 'lines'],
|
|
5774
|
+
['fromItems', '_fromItemsNative', asMessage, 'messages'],
|
|
5733
5775
|
]
|
|
5734
|
-
for (const [
|
|
5735
|
-
const native =
|
|
5736
|
-
delete
|
|
5737
|
-
|
|
5776
|
+
for (const [name, hidden, read, what] of sources) {
|
|
5777
|
+
const native = NativeMarketMessages.prototype[hidden]
|
|
5778
|
+
delete NativeMarketMessages.prototype[hidden]
|
|
5779
|
+
NativeMarketMessages.prototype[name] = {
|
|
5738
5780
|
[name](iterable) {
|
|
5739
5781
|
const failed = {}
|
|
5740
5782
|
const stream = native.call(this, pullOf(iterable, read, what, failed))
|
|
@@ -5743,38 +5785,44 @@ function asLine(value) {
|
|
|
5743
5785
|
},
|
|
5744
5786
|
}[name]
|
|
5745
5787
|
}
|
|
5746
|
-
//
|
|
5747
|
-
//
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
delete binding.FixCodec.prototype._formatMessagesNative
|
|
5758
|
-
binding.FixCodec.prototype.formatMessages = function formatMessages(messages, field) {
|
|
5759
|
-
return nativeFormat.call(this, intoField(field), pullOf(messages, asMessage, 'messages'))
|
|
5788
|
+
// A stage reads the stream it takes, so the failure kept for that stream
|
|
5789
|
+
// is the one its own stream throws.
|
|
5790
|
+
for (const name of ['intoLifecycle', 'intoLineage']) {
|
|
5791
|
+
const native = NativeMarketMessages.prototype[name]
|
|
5792
|
+
NativeMarketMessages.prototype[name] = {
|
|
5793
|
+
[name]() {
|
|
5794
|
+
const stream = native.call(this)
|
|
5795
|
+
stream[FAILED] = this[FAILED]
|
|
5796
|
+
return stream
|
|
5797
|
+
},
|
|
5798
|
+
}[name]
|
|
5760
5799
|
}
|
|
5761
5800
|
}
|
|
5762
5801
|
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
const
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5802
|
+
// A stream over an iterable ends where the iterable failed: the native stream
|
|
5803
|
+
// throws a copy of the failure in place of its end, and the failure kept for
|
|
5804
|
+
// it is thrown instead, once, as itself.
|
|
5805
|
+
function keptFailure(stream) {
|
|
5806
|
+
const failed = stream[FAILED]
|
|
5807
|
+
if (failed === undefined || failed.error === undefined) return undefined
|
|
5808
|
+
const { error } = failed
|
|
5809
|
+
failed.error = undefined
|
|
5810
|
+
return error
|
|
5811
|
+
}
|
|
5812
|
+
const nativeMarketMessagesNext = NativeMarketMessages.prototype.next
|
|
5813
|
+
NativeMarketMessages.prototype.next = function next() {
|
|
5814
|
+
let value
|
|
5815
|
+
try {
|
|
5816
|
+
value = nativeMarketMessagesNext.call(this)
|
|
5817
|
+
} catch (error) {
|
|
5818
|
+
throw keptFailure(this) ?? error
|
|
5774
5819
|
}
|
|
5820
|
+
if (value !== null) return { value, done: false }
|
|
5821
|
+
const failed = keptFailure(this)
|
|
5822
|
+
if (failed !== undefined) throw failed
|
|
5775
5823
|
return { value: undefined, done: true }
|
|
5776
5824
|
}
|
|
5777
|
-
Object.defineProperty(
|
|
5825
|
+
Object.defineProperty(NativeMarketMessages.prototype, Symbol.iterator, {
|
|
5778
5826
|
configurable: true,
|
|
5779
5827
|
value: function messages() { return this },
|
|
5780
5828
|
})
|
|
@@ -5810,9 +5858,9 @@ const fix = Object.freeze({
|
|
|
5810
5858
|
ULBRIDGE_ROWHEADER: ulbridgeRowheader,
|
|
5811
5859
|
FixRegistry: binding.FixRegistry,
|
|
5812
5860
|
MarketMessage,
|
|
5813
|
-
|
|
5861
|
+
MarketMessagesOptions: binding.MarketMessagesOptions,
|
|
5862
|
+
MarketMessages: NativeMarketMessages,
|
|
5814
5863
|
MsgType: binding.MsgType,
|
|
5815
|
-
FixMessages: binding.FixMessages,
|
|
5816
5864
|
Underlyings: binding.Underlyings,
|
|
5817
5865
|
crateFields: binding.fixCrateFields,
|
|
5818
5866
|
underlyingField: binding.fixUnderlyingField,
|
|
@@ -5822,6 +5870,8 @@ const fix = Object.freeze({
|
|
|
5822
5870
|
fxRateField: binding.fixFxRateField,
|
|
5823
5871
|
pluginField: binding.fixPluginField,
|
|
5824
5872
|
pluginSide: binding.fixPluginSide,
|
|
5873
|
+
reports: binding.fixReports,
|
|
5874
|
+
rules: binding.fixRules,
|
|
5825
5875
|
})
|
|
5826
5876
|
|
|
5827
5877
|
// The FIX values are reached through the namespace and nowhere else, so a
|
|
@@ -5829,17 +5879,17 @@ const fix = Object.freeze({
|
|
|
5829
5879
|
for (const name of [
|
|
5830
5880
|
'FixFieldIterator',
|
|
5831
5881
|
'MarketMessage',
|
|
5832
|
-
'
|
|
5882
|
+
'MarketMessagesOptions',
|
|
5883
|
+
'MarketMessages',
|
|
5833
5884
|
'FixRegistry',
|
|
5834
5885
|
'MsgType',
|
|
5835
|
-
'FixMessages',
|
|
5836
5886
|
'Underlyings',
|
|
5837
5887
|
'JsFixFieldIterator',
|
|
5838
5888
|
'JsMarketMessage',
|
|
5839
|
-
'
|
|
5889
|
+
'JsMarketMessagesOptions',
|
|
5890
|
+
'JsMarketMessages',
|
|
5840
5891
|
'JsFixRegistry',
|
|
5841
5892
|
'JsMsgType',
|
|
5842
|
-
'JsFixMessages',
|
|
5843
5893
|
'JsUnderlyings',
|
|
5844
5894
|
'fixCrateFields',
|
|
5845
5895
|
'fixUnderlyingField',
|
|
@@ -5849,6 +5899,8 @@ for (const name of [
|
|
|
5849
5899
|
'fixFxRateField',
|
|
5850
5900
|
'fixPluginField',
|
|
5851
5901
|
'fixPluginSide',
|
|
5902
|
+
'fixReports',
|
|
5903
|
+
'fixRules',
|
|
5852
5904
|
]) {
|
|
5853
5905
|
delete binding[name]
|
|
5854
5906
|
}
|