yggio 0.0.6 → 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 +27 -31
- package/benchmarks/types.js +3 -3
- package/binding.d.ts +177 -80
- package/binding.js +131 -79
- package/index.d.ts +2074 -510
- package/index.js +35 -8
- package/package.json +8 -4
- package/records.js +30 -0
package/binding.js
CHANGED
|
@@ -1435,11 +1435,6 @@ Object.defineProperties(Scalar.prototype, {
|
|
|
1435
1435
|
return Reflect.apply(nativeScalarRemove, this, [Scalar.from(key)])
|
|
1436
1436
|
},
|
|
1437
1437
|
},
|
|
1438
|
-
toJSON: {
|
|
1439
|
-
value() {
|
|
1440
|
-
return JSON.parse(this.intoJson())
|
|
1441
|
-
},
|
|
1442
|
-
},
|
|
1443
1438
|
})
|
|
1444
1439
|
|
|
1445
1440
|
// A serie is the native value; the conversions it needs from JavaScript -
|
|
@@ -4997,6 +4992,18 @@ for (const Clause of [NativeTerm, NativeFilter, NativeSelector]) {
|
|
|
4997
4992
|
})
|
|
4998
4993
|
}
|
|
4999
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
|
+
|
|
5000
5007
|
// One Arrow surface per applier: `applyArrowReader` keeps a native reader
|
|
5001
5008
|
// lazy, `applyArrowBatch` and `applyArrowTable` keep the Apache Arrow JS
|
|
5002
5009
|
// holder they were given, and `applyArrow` infers which of the three it has.
|
|
@@ -5644,15 +5651,16 @@ for (const name of [
|
|
|
5644
5651
|
// dictionary, the message it types and the process default are one name
|
|
5645
5652
|
// rather than four top-level classes.
|
|
5646
5653
|
//
|
|
5647
|
-
// A message value is whatever `Scalar.from` reads, and
|
|
5648
|
-
// in this loader, so the public
|
|
5649
|
-
// the
|
|
5650
|
-
// 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.
|
|
5651
5659
|
const NativeMarketMessage = binding.MarketMessage
|
|
5652
5660
|
const asScalar = (value) => (value instanceof Scalar ? value : Scalar.from(value))
|
|
5653
5661
|
function MarketMessage() {
|
|
5654
5662
|
throw new TypeError(
|
|
5655
|
-
'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',
|
|
5656
5664
|
)
|
|
5657
5665
|
}
|
|
5658
5666
|
MarketMessage.prototype = NativeMarketMessage.prototype
|
|
@@ -5663,11 +5671,29 @@ Object.defineProperty(MarketMessage.prototype, 'constructor', {
|
|
|
5663
5671
|
})
|
|
5664
5672
|
// A record, a row read back and a value written cross the one gate: whatever
|
|
5665
5673
|
// `Scalar.from` reads, and the core alone types it.
|
|
5666
|
-
MarketMessage.fromFixRecord = function fromFixRecord(field, value,
|
|
5667
|
-
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)
|
|
5679
|
+
}
|
|
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]
|
|
5668
5687
|
}
|
|
5669
|
-
|
|
5670
|
-
|
|
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]
|
|
5671
5697
|
}
|
|
5672
5698
|
MarketMessage.field = NativeMarketMessage.field
|
|
5673
5699
|
const nativeMarketMessageSet = NativeMarketMessage.prototype.set
|
|
@@ -5676,30 +5702,42 @@ NativeMarketMessage.prototype.set = function set(key, value) {
|
|
|
5676
5702
|
}
|
|
5677
5703
|
|
|
5678
5704
|
// A line crosses as the `TextLine` a text read answered - there is nothing to
|
|
5679
|
-
// widen, because a line is a decoded row and not a value -
|
|
5680
|
-
//
|
|
5681
|
-
//
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
|
|
5689
|
-
}
|
|
5690
|
-
const
|
|
5691
|
-
|
|
5692
|
-
|
|
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
|
+
}
|
|
5693
5732
|
}
|
|
5694
5733
|
|
|
5695
|
-
// A
|
|
5696
|
-
// protocol runs here, and the native
|
|
5697
|
-
//
|
|
5698
|
-
//
|
|
5699
|
-
//
|
|
5700
|
-
//
|
|
5701
|
-
//
|
|
5702
|
-
// 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.
|
|
5703
5741
|
const FAILED = Symbol('yggio.fix.failed')
|
|
5704
5742
|
function pullOf(iterable, read, what, failed) {
|
|
5705
5743
|
if (iterable == null || typeof iterable[Symbol.iterator] !== 'function') {
|
|
@@ -5707,14 +5745,13 @@ function pullOf(iterable, read, what, failed) {
|
|
|
5707
5745
|
}
|
|
5708
5746
|
const iterator = iterable[Symbol.iterator]()
|
|
5709
5747
|
return () => {
|
|
5710
|
-
if (failed
|
|
5748
|
+
if (failed.error !== undefined) return null
|
|
5711
5749
|
try {
|
|
5712
5750
|
const step = iterator.next()
|
|
5713
5751
|
return step.done ? null : read(step.value)
|
|
5714
5752
|
} catch (error) {
|
|
5715
|
-
if (failed === undefined) throw error
|
|
5716
5753
|
failed.error = error
|
|
5717
|
-
|
|
5754
|
+
throw error
|
|
5718
5755
|
}
|
|
5719
5756
|
}
|
|
5720
5757
|
}
|
|
@@ -5731,15 +5768,15 @@ function asLine(value) {
|
|
|
5731
5768
|
return value
|
|
5732
5769
|
}
|
|
5733
5770
|
{
|
|
5734
|
-
const
|
|
5735
|
-
[
|
|
5736
|
-
[
|
|
5737
|
-
[
|
|
5771
|
+
const sources = [
|
|
5772
|
+
['fromLines', '_fromLinesNative', toBytes, 'lines'],
|
|
5773
|
+
['fromTextLines', '_fromTextLinesNative', asLine, 'lines'],
|
|
5774
|
+
['fromItems', '_fromItemsNative', asMessage, 'messages'],
|
|
5738
5775
|
]
|
|
5739
|
-
for (const [
|
|
5740
|
-
const native =
|
|
5741
|
-
delete
|
|
5742
|
-
|
|
5776
|
+
for (const [name, hidden, read, what] of sources) {
|
|
5777
|
+
const native = NativeMarketMessages.prototype[hidden]
|
|
5778
|
+
delete NativeMarketMessages.prototype[hidden]
|
|
5779
|
+
NativeMarketMessages.prototype[name] = {
|
|
5743
5780
|
[name](iterable) {
|
|
5744
5781
|
const failed = {}
|
|
5745
5782
|
const stream = native.call(this, pullOf(iterable, read, what, failed))
|
|
@@ -5748,38 +5785,44 @@ function asLine(value) {
|
|
|
5748
5785
|
},
|
|
5749
5786
|
}[name]
|
|
5750
5787
|
}
|
|
5751
|
-
//
|
|
5752
|
-
//
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
delete binding.FixCodec.prototype._formatMessagesNative
|
|
5763
|
-
binding.FixCodec.prototype.formatMessages = function formatMessages(messages, field) {
|
|
5764
|
-
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]
|
|
5765
5799
|
}
|
|
5766
5800
|
}
|
|
5767
5801
|
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
const
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
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
|
|
5779
5819
|
}
|
|
5820
|
+
if (value !== null) return { value, done: false }
|
|
5821
|
+
const failed = keptFailure(this)
|
|
5822
|
+
if (failed !== undefined) throw failed
|
|
5780
5823
|
return { value: undefined, done: true }
|
|
5781
5824
|
}
|
|
5782
|
-
Object.defineProperty(
|
|
5825
|
+
Object.defineProperty(NativeMarketMessages.prototype, Symbol.iterator, {
|
|
5783
5826
|
configurable: true,
|
|
5784
5827
|
value: function messages() { return this },
|
|
5785
5828
|
})
|
|
@@ -5815,16 +5858,20 @@ const fix = Object.freeze({
|
|
|
5815
5858
|
ULBRIDGE_ROWHEADER: ulbridgeRowheader,
|
|
5816
5859
|
FixRegistry: binding.FixRegistry,
|
|
5817
5860
|
MarketMessage,
|
|
5818
|
-
|
|
5861
|
+
MarketMessagesOptions: binding.MarketMessagesOptions,
|
|
5862
|
+
MarketMessages: NativeMarketMessages,
|
|
5819
5863
|
MsgType: binding.MsgType,
|
|
5820
|
-
|
|
5864
|
+
Underlyings: binding.Underlyings,
|
|
5821
5865
|
crateFields: binding.fixCrateFields,
|
|
5822
5866
|
underlyingField: binding.fixUnderlyingField,
|
|
5867
|
+
registryField: binding.fixRegistryField,
|
|
5823
5868
|
micEntryField: binding.fixMicEntryField,
|
|
5824
5869
|
legalEntityField: binding.fixLegalEntityField,
|
|
5825
5870
|
fxRateField: binding.fixFxRateField,
|
|
5826
5871
|
pluginField: binding.fixPluginField,
|
|
5827
5872
|
pluginSide: binding.fixPluginSide,
|
|
5873
|
+
reports: binding.fixReports,
|
|
5874
|
+
rules: binding.fixRules,
|
|
5828
5875
|
})
|
|
5829
5876
|
|
|
5830
5877
|
// The FIX values are reached through the namespace and nowhere else, so a
|
|
@@ -5832,23 +5879,28 @@ const fix = Object.freeze({
|
|
|
5832
5879
|
for (const name of [
|
|
5833
5880
|
'FixFieldIterator',
|
|
5834
5881
|
'MarketMessage',
|
|
5835
|
-
'
|
|
5882
|
+
'MarketMessagesOptions',
|
|
5883
|
+
'MarketMessages',
|
|
5836
5884
|
'FixRegistry',
|
|
5837
5885
|
'MsgType',
|
|
5838
|
-
'
|
|
5886
|
+
'Underlyings',
|
|
5839
5887
|
'JsFixFieldIterator',
|
|
5840
5888
|
'JsMarketMessage',
|
|
5841
|
-
'
|
|
5889
|
+
'JsMarketMessagesOptions',
|
|
5890
|
+
'JsMarketMessages',
|
|
5842
5891
|
'JsFixRegistry',
|
|
5843
5892
|
'JsMsgType',
|
|
5844
|
-
'
|
|
5893
|
+
'JsUnderlyings',
|
|
5845
5894
|
'fixCrateFields',
|
|
5846
5895
|
'fixUnderlyingField',
|
|
5896
|
+
'fixRegistryField',
|
|
5847
5897
|
'fixMicEntryField',
|
|
5848
5898
|
'fixLegalEntityField',
|
|
5849
5899
|
'fixFxRateField',
|
|
5850
5900
|
'fixPluginField',
|
|
5851
5901
|
'fixPluginSide',
|
|
5902
|
+
'fixReports',
|
|
5903
|
+
'fixRules',
|
|
5852
5904
|
]) {
|
|
5853
5905
|
delete binding[name]
|
|
5854
5906
|
}
|