@xbbg/core 1.4.1 → 1.4.2
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/dist/index.d.ts +49 -1
- package/dist/index.js +137 -15
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -74,6 +74,26 @@ interface StringPair {
|
|
|
74
74
|
key: string;
|
|
75
75
|
value: string;
|
|
76
76
|
}
|
|
77
|
+
type SeatType = 'BPS' | 'NONBPS' | 'INVALID';
|
|
78
|
+
interface EntitlementReport {
|
|
79
|
+
entitled: boolean;
|
|
80
|
+
failedEids: number[];
|
|
81
|
+
}
|
|
82
|
+
interface BloombergMetadataError {
|
|
83
|
+
category?: string;
|
|
84
|
+
code?: string | number;
|
|
85
|
+
subcategory?: string;
|
|
86
|
+
message?: string;
|
|
87
|
+
}
|
|
88
|
+
interface BloombergFieldException extends BloombergMetadataError {
|
|
89
|
+
field?: string;
|
|
90
|
+
}
|
|
91
|
+
interface ResultMetadata {
|
|
92
|
+
metadata: Record<string, string>;
|
|
93
|
+
eidData?: Record<string, number[]>;
|
|
94
|
+
securityErrors?: Record<string, BloombergMetadataError>;
|
|
95
|
+
fieldExceptions?: Record<string, BloombergFieldException[]>;
|
|
96
|
+
}
|
|
77
97
|
interface ServerAddress {
|
|
78
98
|
host: string;
|
|
79
99
|
port: number;
|
|
@@ -185,6 +205,7 @@ interface RequestInput {
|
|
|
185
205
|
options?: readonly StringPair[];
|
|
186
206
|
fieldTypes?: readonly StringPair[];
|
|
187
207
|
includeSecurityErrors?: boolean;
|
|
208
|
+
returnEids?: boolean;
|
|
188
209
|
validateFields?: boolean;
|
|
189
210
|
searchSpec?: string;
|
|
190
211
|
fieldIds?: readonly string[];
|
|
@@ -237,6 +258,7 @@ interface BdpOptions {
|
|
|
237
258
|
format?: string;
|
|
238
259
|
backend?: BackendKind;
|
|
239
260
|
includeSecurityErrors?: boolean;
|
|
261
|
+
returnEids?: boolean;
|
|
240
262
|
validateFields?: boolean;
|
|
241
263
|
}
|
|
242
264
|
interface BdhOptions {
|
|
@@ -246,6 +268,7 @@ interface BdhOptions {
|
|
|
246
268
|
kwargs?: OverridesMap;
|
|
247
269
|
format?: string;
|
|
248
270
|
backend?: BackendKind;
|
|
271
|
+
returnEids?: boolean;
|
|
249
272
|
validateFields?: boolean;
|
|
250
273
|
}
|
|
251
274
|
interface BdibOptions {
|
|
@@ -508,6 +531,7 @@ interface NativeArrowZeroCopyBatch {
|
|
|
508
531
|
readonly kind: 'zeroCopy';
|
|
509
532
|
readonly numRows: number;
|
|
510
533
|
readonly columns: NativeArrowColumn[];
|
|
534
|
+
readonly metadata: Record<string, string>;
|
|
511
535
|
}
|
|
512
536
|
type NativeUpdateValue = null | boolean | number | string;
|
|
513
537
|
interface NativeSubscriptionUpdate {
|
|
@@ -641,6 +665,30 @@ declare class Engine {
|
|
|
641
665
|
* session timeout) — prefer this factory in servers.
|
|
642
666
|
*/
|
|
643
667
|
static connect(config?: EngineConfig): Promise<Engine>;
|
|
668
|
+
/**
|
|
669
|
+
* Return the Bloomberg identity seat type: "BPS", "NONBPS", or "INVALID".
|
|
670
|
+
*
|
|
671
|
+
* Identity operations authorize lazily using the engine auth config when
|
|
672
|
+
* configured, otherwise the Desktop terminal OS-logon user. The first call
|
|
673
|
+
* may block for a few seconds and transient failures are retryable.
|
|
674
|
+
*/
|
|
675
|
+
seatType(): Promise<SeatType>;
|
|
676
|
+
/**
|
|
677
|
+
* Check whether the authorized identity is entitled to all supplied EIDs.
|
|
678
|
+
*
|
|
679
|
+
* Identity operations authorize lazily using the engine auth config when
|
|
680
|
+
* configured, otherwise the Desktop terminal OS-logon user. The first call
|
|
681
|
+
* may block for a few seconds and transient failures are retryable.
|
|
682
|
+
*/
|
|
683
|
+
checkEntitlements(service: string, eids: readonly number[]): Promise<EntitlementReport>;
|
|
684
|
+
/**
|
|
685
|
+
* Return whether the authorized identity may use the Bloomberg service.
|
|
686
|
+
*
|
|
687
|
+
* Identity operations authorize lazily using the engine auth config when
|
|
688
|
+
* configured, otherwise the Desktop terminal OS-logon user. The first call
|
|
689
|
+
* may block for a few seconds and transient failures are retryable.
|
|
690
|
+
*/
|
|
691
|
+
identityIsAuthorized(service: string): Promise<boolean>;
|
|
644
692
|
request(params: RequestInput): Promise<unknown>;
|
|
645
693
|
requestRaw(params: RequestInput): Promise<Buffer>;
|
|
646
694
|
bdp(tickers: readonly string[], fields: readonly string[], options?: BdpOptions): Promise<unknown>;
|
|
@@ -792,4 +840,4 @@ declare function version(): string;
|
|
|
792
840
|
declare const setLogLevel: (level: string) => void;
|
|
793
841
|
declare const getLogLevel: () => string;
|
|
794
842
|
|
|
795
|
-
export { type ActiveCdxOptions, ArrowSubscription, type AuthConfig, Backend, type BackendKind, type BdhOptions, type BdibOptions, type BdpOptions, type BdtickOptions, type BeqsOptions, type BfldsOptions, type BlkpOptions, BlpError, BlpInternalError, BlpLimitError, BlpRequestError, BlpSessionError, BlpTimeoutError, BlpValidationError, type BqlOptions, type BqrOptions, type BsrchOptions, type BtaOptions, CDX_INFO_FIELDS, CDX_PRICING_FIELDS, CDX_RISK_FIELDS, type CdxOptions, type CdxTickerInfo, type CorporateBondsOptions, type DateLike, type DateTimeLike, type DividendOptions, type DividendYieldOptions, Engine, type EngineConfig, type EtfHoldingsOptions, type ExchangeInfoResult, type ExchangeOverrideInput, FieldHandle, type FieldInfo, Format, type FormatKind, type FuturesCandidate, type FuturesCurveOptions, type FuturesResolveOptions, type FxPairInfo, type IndexMembersOptions, type MarketRule, type OverrideEntry, type OverrideNestedSource, type OverrideObject, type OverrideSource, OverrideSpec, type OverrideSpecLike, type OverrideValue, type OverridesInput, type OverridesMap, type PreferredsOptions, type PrimitiveValue, type RecipeBackendOptions, type RequestInput, type RequestOptions, type SecurityOverrideSpec, type ServerAddress, type SessionWindowsInfo, type Socks5Config, type StreamOptions, type StringPair, Subscription, type SubscriptionStats, Tick, type TickValue, type TickerParts, type TimeRange, type TlsConfig, type TurnoverOptions, type VolFieldSpec, type VolSurfaceOptions, type VolSurfacePreset, type YasOptions, abdh, abdib, abdp, abds, abdtick, asubscribe, bdh, bdib, bdp, bds, bdtick, blp, configure, connect, ext, formatDate, formatDateTime, getLogLevel, ovr, setLogLevel, subscribe, version, wrapError };
|
|
843
|
+
export { type ActiveCdxOptions, ArrowSubscription, type AuthConfig, Backend, type BackendKind, type BdhOptions, type BdibOptions, type BdpOptions, type BdtickOptions, type BeqsOptions, type BfldsOptions, type BlkpOptions, type BloombergFieldException, type BloombergMetadataError, BlpError, BlpInternalError, BlpLimitError, BlpRequestError, BlpSessionError, BlpTimeoutError, BlpValidationError, type BqlOptions, type BqrOptions, type BsrchOptions, type BtaOptions, CDX_INFO_FIELDS, CDX_PRICING_FIELDS, CDX_RISK_FIELDS, type CdxOptions, type CdxTickerInfo, type CorporateBondsOptions, type DateLike, type DateTimeLike, type DividendOptions, type DividendYieldOptions, Engine, type EngineConfig, type EntitlementReport, type EtfHoldingsOptions, type ExchangeInfoResult, type ExchangeOverrideInput, FieldHandle, type FieldInfo, Format, type FormatKind, type FuturesCandidate, type FuturesCurveOptions, type FuturesResolveOptions, type FxPairInfo, type IndexMembersOptions, type MarketRule, type OverrideEntry, type OverrideNestedSource, type OverrideObject, type OverrideSource, OverrideSpec, type OverrideSpecLike, type OverrideValue, type OverridesInput, type OverridesMap, type PreferredsOptions, type PrimitiveValue, type RecipeBackendOptions, type RequestInput, type RequestOptions, type ResultMetadata, type SeatType, type SecurityOverrideSpec, type ServerAddress, type SessionWindowsInfo, type Socks5Config, type StreamOptions, type StringPair, Subscription, type SubscriptionStats, Tick, type TickValue, type TickerParts, type TimeRange, type TlsConfig, type TurnoverOptions, type VolFieldSpec, type VolSurfaceOptions, type VolSurfacePreset, type YasOptions, abdh, abdib, abdp, abds, abdtick, asubscribe, bdh, bdib, bdp, bds, bdtick, blp, configure, connect, ext, formatDate, formatDateTime, getLogLevel, ovr, setLogLevel, subscribe, version, wrapError };
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,7 @@ function tableFromNativeArrowBatch(batch) {
|
|
|
22
22
|
return new apacheArrow.Field(column.name, type, column.nullable);
|
|
23
23
|
});
|
|
24
24
|
const children = batch.columns.map((column) => dataFromColumn(column, retainedBuffers));
|
|
25
|
-
const schema = new apacheArrow.Schema(fields);
|
|
25
|
+
const schema = new apacheArrow.Schema(fields, new Map(Object.entries(batch.metadata)));
|
|
26
26
|
const structData = apacheArrow.makeData({
|
|
27
27
|
children,
|
|
28
28
|
length: batch.numRows,
|
|
@@ -1078,7 +1078,83 @@ var TA_DEFAULTS = Object.freeze({
|
|
|
1078
1078
|
});
|
|
1079
1079
|
var MKTDATA_SERVICE = "//blp/mktdata";
|
|
1080
1080
|
function toArrowTableFromNative(batch) {
|
|
1081
|
-
return tableFromNativeArrowBatch(batch);
|
|
1081
|
+
return attachResultMetadata(tableFromNativeArrowBatch(batch), batch.metadata);
|
|
1082
|
+
}
|
|
1083
|
+
var METADATA_KEY_EID_DATA = "xbbg.eid_data";
|
|
1084
|
+
var METADATA_KEY_SECURITY_ERRORS = "xbbg.security_errors";
|
|
1085
|
+
var METADATA_KEY_FIELD_EXCEPTIONS = "xbbg.field_exceptions";
|
|
1086
|
+
function metadataRecordFromMap(metadata) {
|
|
1087
|
+
return Object.fromEntries(metadata.entries());
|
|
1088
|
+
}
|
|
1089
|
+
function parseJsonMetadata(metadata, key, guard) {
|
|
1090
|
+
const raw = metadata[key];
|
|
1091
|
+
if (raw === void 0) {
|
|
1092
|
+
return void 0;
|
|
1093
|
+
}
|
|
1094
|
+
try {
|
|
1095
|
+
const parsed = JSON.parse(raw);
|
|
1096
|
+
return guard(parsed) ? parsed : void 0;
|
|
1097
|
+
} catch {
|
|
1098
|
+
return void 0;
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
function isNumberArrayRecord(value) {
|
|
1102
|
+
if (!isPlainObject(value)) {
|
|
1103
|
+
return false;
|
|
1104
|
+
}
|
|
1105
|
+
return Object.values(value).every(
|
|
1106
|
+
(entry) => Array.isArray(entry) && entry.every((eid) => typeof eid === "number")
|
|
1107
|
+
);
|
|
1108
|
+
}
|
|
1109
|
+
function isMetadataError(value) {
|
|
1110
|
+
if (!isPlainObject(value)) {
|
|
1111
|
+
return false;
|
|
1112
|
+
}
|
|
1113
|
+
const { category, code, message, subcategory } = value;
|
|
1114
|
+
return (category === void 0 || typeof category === "string") && (code === void 0 || typeof code === "string" || typeof code === "number") && (message === void 0 || typeof message === "string") && (subcategory === void 0 || typeof subcategory === "string");
|
|
1115
|
+
}
|
|
1116
|
+
function isMetadataErrorRecord(value) {
|
|
1117
|
+
if (!isPlainObject(value)) {
|
|
1118
|
+
return false;
|
|
1119
|
+
}
|
|
1120
|
+
return Object.values(value).every(isMetadataError);
|
|
1121
|
+
}
|
|
1122
|
+
function isFieldException(value) {
|
|
1123
|
+
if (!isMetadataError(value)) {
|
|
1124
|
+
return false;
|
|
1125
|
+
}
|
|
1126
|
+
if (!("field" in value)) {
|
|
1127
|
+
return true;
|
|
1128
|
+
}
|
|
1129
|
+
return typeof value.field === "string";
|
|
1130
|
+
}
|
|
1131
|
+
function isFieldExceptionRecord(value) {
|
|
1132
|
+
if (!isPlainObject(value)) {
|
|
1133
|
+
return false;
|
|
1134
|
+
}
|
|
1135
|
+
return Object.values(value).every(
|
|
1136
|
+
(entry) => Array.isArray(entry) && entry.every(isFieldException)
|
|
1137
|
+
);
|
|
1138
|
+
}
|
|
1139
|
+
function attachResultMetadata(result, metadata) {
|
|
1140
|
+
const eidData = parseJsonMetadata(metadata, METADATA_KEY_EID_DATA, isNumberArrayRecord);
|
|
1141
|
+
const securityErrors = parseJsonMetadata(
|
|
1142
|
+
metadata,
|
|
1143
|
+
METADATA_KEY_SECURITY_ERRORS,
|
|
1144
|
+
isMetadataErrorRecord
|
|
1145
|
+
);
|
|
1146
|
+
const fieldExceptions = parseJsonMetadata(
|
|
1147
|
+
metadata,
|
|
1148
|
+
METADATA_KEY_FIELD_EXCEPTIONS,
|
|
1149
|
+
isFieldExceptionRecord
|
|
1150
|
+
);
|
|
1151
|
+
Object.defineProperties(result, {
|
|
1152
|
+
eidData: { enumerable: true, value: eidData },
|
|
1153
|
+
fieldExceptions: { enumerable: true, value: fieldExceptions },
|
|
1154
|
+
metadata: { enumerable: true, value: { ...metadata } },
|
|
1155
|
+
securityErrors: { enumerable: true, value: securityErrors }
|
|
1156
|
+
});
|
|
1157
|
+
return result;
|
|
1082
1158
|
}
|
|
1083
1159
|
function isPlainObject(value) {
|
|
1084
1160
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -1086,6 +1162,12 @@ function isPlainObject(value) {
|
|
|
1086
1162
|
function toRequestString(value) {
|
|
1087
1163
|
return String(value);
|
|
1088
1164
|
}
|
|
1165
|
+
function getLegacySecurityOverrides(params) {
|
|
1166
|
+
if ("securityOverrides" in params) {
|
|
1167
|
+
return params.securityOverrides;
|
|
1168
|
+
}
|
|
1169
|
+
return void 0;
|
|
1170
|
+
}
|
|
1089
1171
|
function mapObjectToPairs(obj) {
|
|
1090
1172
|
if (obj === void 0) {
|
|
1091
1173
|
return void 0;
|
|
@@ -1556,13 +1638,15 @@ function normalizeBackend(backend) {
|
|
|
1556
1638
|
}
|
|
1557
1639
|
function ipcToBackend(buffer, backend) {
|
|
1558
1640
|
const selected = normalizeBackend(backend);
|
|
1641
|
+
const table = apacheArrow.tableFromIPC(buffer);
|
|
1642
|
+
const metadata = metadataRecordFromMap(table.schema.metadata);
|
|
1559
1643
|
if (selected === Backend.JSON) {
|
|
1560
|
-
return [...
|
|
1644
|
+
return attachResultMetadata([...table], metadata);
|
|
1561
1645
|
}
|
|
1562
1646
|
if (selected === Backend.POLARS) {
|
|
1563
1647
|
return loadPolars().readIPC(buffer);
|
|
1564
1648
|
}
|
|
1565
|
-
return
|
|
1649
|
+
return attachResultMetadata(table, metadata);
|
|
1566
1650
|
}
|
|
1567
1651
|
var configuredEngineConfig;
|
|
1568
1652
|
var configuredEnginePromise;
|
|
@@ -1798,14 +1882,52 @@ var Engine = class _Engine {
|
|
|
1798
1882
|
throw wrapError(error);
|
|
1799
1883
|
}
|
|
1800
1884
|
}
|
|
1885
|
+
/**
|
|
1886
|
+
* Return the Bloomberg identity seat type: "BPS", "NONBPS", or "INVALID".
|
|
1887
|
+
*
|
|
1888
|
+
* Identity operations authorize lazily using the engine auth config when
|
|
1889
|
+
* configured, otherwise the Desktop terminal OS-logon user. The first call
|
|
1890
|
+
* may block for a few seconds and transient failures are retryable.
|
|
1891
|
+
*/
|
|
1892
|
+
async seatType() {
|
|
1893
|
+
try {
|
|
1894
|
+
return await this.inner.seatType();
|
|
1895
|
+
} catch (error) {
|
|
1896
|
+
throw wrapError(error);
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
/**
|
|
1900
|
+
* Check whether the authorized identity is entitled to all supplied EIDs.
|
|
1901
|
+
*
|
|
1902
|
+
* Identity operations authorize lazily using the engine auth config when
|
|
1903
|
+
* configured, otherwise the Desktop terminal OS-logon user. The first call
|
|
1904
|
+
* may block for a few seconds and transient failures are retryable.
|
|
1905
|
+
*/
|
|
1906
|
+
async checkEntitlements(service, eids) {
|
|
1907
|
+
try {
|
|
1908
|
+
return await this.inner.checkEntitlements(service, eids);
|
|
1909
|
+
} catch (error) {
|
|
1910
|
+
throw wrapError(error);
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
/**
|
|
1914
|
+
* Return whether the authorized identity may use the Bloomberg service.
|
|
1915
|
+
*
|
|
1916
|
+
* Identity operations authorize lazily using the engine auth config when
|
|
1917
|
+
* configured, otherwise the Desktop terminal OS-logon user. The first call
|
|
1918
|
+
* may block for a few seconds and transient failures are retryable.
|
|
1919
|
+
*/
|
|
1920
|
+
async identityIsAuthorized(service) {
|
|
1921
|
+
try {
|
|
1922
|
+
return await this.inner.identityIsAuthorized(service);
|
|
1923
|
+
} catch (error) {
|
|
1924
|
+
throw wrapError(error);
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1801
1927
|
async request(params) {
|
|
1802
1928
|
const backend = normalizeBackend(params.backend);
|
|
1803
|
-
const {
|
|
1804
|
-
|
|
1805
|
-
overrides,
|
|
1806
|
-
securityOverrides: legacySecurityOverrides,
|
|
1807
|
-
...rest
|
|
1808
|
-
} = params;
|
|
1929
|
+
const { backend: _discarded, overrides, ...rest } = params;
|
|
1930
|
+
const legacySecurityOverrides = getLegacySecurityOverrides(params);
|
|
1809
1931
|
if (legacySecurityOverrides !== void 0) {
|
|
1810
1932
|
throw new TypeError(
|
|
1811
1933
|
'Use overrides: ovr({ "<SECURITY>": { ... } }) for per-security overrides'
|
|
@@ -1820,11 +1942,8 @@ var Engine = class _Engine {
|
|
|
1820
1942
|
}
|
|
1821
1943
|
}
|
|
1822
1944
|
async requestRaw(params) {
|
|
1823
|
-
const {
|
|
1824
|
-
|
|
1825
|
-
securityOverrides: legacySecurityOverrides,
|
|
1826
|
-
...rest
|
|
1827
|
-
} = params;
|
|
1945
|
+
const { overrides, ...rest } = params;
|
|
1946
|
+
const legacySecurityOverrides = getLegacySecurityOverrides(params);
|
|
1828
1947
|
if (legacySecurityOverrides !== void 0) {
|
|
1829
1948
|
throw new TypeError(
|
|
1830
1949
|
'Use overrides: ovr({ "<SECURITY>": { ... } }) for per-security overrides'
|
|
@@ -1843,6 +1962,7 @@ var Engine = class _Engine {
|
|
|
1843
1962
|
fields,
|
|
1844
1963
|
format: options.format,
|
|
1845
1964
|
includeSecurityErrors: Boolean(options.includeSecurityErrors),
|
|
1965
|
+
returnEids: options.returnEids,
|
|
1846
1966
|
kwargs: mapObjectToPairs(options.kwargs),
|
|
1847
1967
|
operation: "ReferenceDataRequest",
|
|
1848
1968
|
overrides: options.overrides,
|
|
@@ -1857,6 +1977,7 @@ var Engine = class _Engine {
|
|
|
1857
1977
|
extractor: "bulk",
|
|
1858
1978
|
fields,
|
|
1859
1979
|
format: options.format,
|
|
1980
|
+
returnEids: options.returnEids,
|
|
1860
1981
|
kwargs: mapObjectToPairs(options.kwargs),
|
|
1861
1982
|
operation: "ReferenceDataRequest",
|
|
1862
1983
|
overrides: options.overrides,
|
|
@@ -1872,6 +1993,7 @@ var Engine = class _Engine {
|
|
|
1872
1993
|
extractor: "histdata",
|
|
1873
1994
|
fields,
|
|
1874
1995
|
format: options.format,
|
|
1996
|
+
returnEids: options.returnEids,
|
|
1875
1997
|
kwargs: mapObjectToPairs(options.kwargs),
|
|
1876
1998
|
operation: "HistoricalDataRequest",
|
|
1877
1999
|
overrides: options.overrides,
|