@xbbg/core 1.2.2 → 1.2.3

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.js CHANGED
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
+ var apacheArrow = require('apache-arrow');
3
4
  var fs2 = require('fs');
4
- var path2 = require('path');
5
5
  var module$1 = require('module');
6
- var apacheArrow = require('apache-arrow');
6
+ var path2 = require('path');
7
7
 
8
8
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
9
 
@@ -11,88 +11,10 @@ var fs2__default = /*#__PURE__*/_interopDefault(fs2);
11
11
  var path2__default = /*#__PURE__*/_interopDefault(path2);
12
12
 
13
13
  // src/index.ts
14
-
15
- // src/errors.ts
16
- var BlpError = class extends Error {
17
- constructor(message) {
18
- super(message);
19
- this.name = new.target.name;
20
- }
21
- };
22
- var BlpSessionError = class extends BlpError {
23
- };
24
- var BlpRequestError = class extends BlpError {
25
- service;
26
- operation;
27
- request_id;
28
- code;
29
- constructor(message, options = {}) {
30
- super(message);
31
- this.service = options.service;
32
- this.operation = options.operation;
33
- this.request_id = options.request_id;
34
- this.code = options.code;
35
- }
36
- };
37
- var BlpValidationError = class extends BlpError {
38
- element;
39
- suggestion;
40
- constructor(message, options = {}) {
41
- super(message);
42
- this.element = options.element;
43
- this.suggestion = options.suggestion;
44
- }
45
- };
46
- var BlpTimeoutError = class extends BlpError {
47
- };
48
- var BlpInternalError = class extends BlpError {
49
- };
50
- function wrapError(napiError) {
51
- if (napiError instanceof BlpError) {
52
- return napiError;
53
- }
54
- const msg = napiError instanceof Error ? napiError.message : typeof napiError === "string" ? napiError : "";
55
- if (msg.includes("Session start failed") || msg.includes("session start failed") || msg.includes("Failed to start session") || msg.includes("Failed to open service") || msg.includes("failed to spawn worker") || msg.includes("connect event failed")) {
56
- return new BlpSessionError(msg);
57
- }
58
- if (msg.includes("Request failed") || msg.includes("Subscription failed")) {
59
- const options = parseRequestOptions(msg);
60
- return new BlpRequestError(msg, options);
61
- }
62
- if (msg.includes("Invalid argument") || msg.includes("Configuration error") || msg.includes("Operation not found") || msg.includes("Schema element not found") || msg.includes("Schema type mismatch") || msg.includes("Unsupported schema") || msg.includes("invalid extractor") || msg.includes("(did you mean")) {
63
- const options = parseValidationOptions(msg);
64
- return new BlpValidationError(msg, options);
65
- }
66
- if (msg.includes("Request timed out")) {
67
- return new BlpTimeoutError(msg);
68
- }
69
- if (msg.includes("Internal error") || msg.includes("Channel closed") || msg.includes("Stream buffer full") || msg.includes("Request was cancelled")) {
70
- return new BlpInternalError(msg);
71
- }
72
- return new BlpError(msg);
73
- }
74
- function parseRequestOptions(msg) {
75
- const options = {};
76
- const serviceOpMatch = /on ([^:]+)::([^ (]+)/.exec(msg);
77
- if (serviceOpMatch !== null) {
78
- options.service = serviceOpMatch[1];
79
- options.operation = serviceOpMatch[2];
80
- }
81
- const requestIdMatch = /\[request_id=([^\]]+)\]/.exec(msg);
82
- if (requestIdMatch !== null) {
83
- options.request_id = requestIdMatch[1];
84
- }
85
- return options;
86
- }
87
- function parseValidationOptions(msg) {
88
- const options = {};
89
- const suggestionMatch = /\(did you mean '([^']+)'\?\)/.exec(msg);
90
- if (suggestionMatch !== null) {
91
- options.suggestion = suggestionMatch[1];
92
- }
93
- return options;
94
- }
95
14
  var NATIVE_ARROW_BUFFERS = /* @__PURE__ */ Symbol("@xbbg/nativeArrowBuffers");
15
+ function unsupportedNativeArrowType(type) {
16
+ throw new Error(`Unsupported native Arrow column type: ${String(type)}`);
17
+ }
96
18
  function tableFromNativeArrowBatch(batch) {
97
19
  const retainedBuffers = [];
98
20
  const fields = batch.columns.map((column) => {
@@ -102,21 +24,21 @@ function tableFromNativeArrowBatch(batch) {
102
24
  const children = batch.columns.map((column) => dataFromColumn(column, retainedBuffers));
103
25
  const schema = new apacheArrow.Schema(fields);
104
26
  const structData = apacheArrow.makeData({
105
- type: new apacheArrow.Struct(fields),
27
+ children,
106
28
  length: batch.numRows,
107
- children
29
+ type: new apacheArrow.Struct(fields)
108
30
  });
109
31
  const table = new apacheArrow.Table(schema, new apacheArrow.RecordBatch(schema, structData));
110
32
  Object.defineProperty(table, NATIVE_ARROW_BUFFERS, {
111
- value: retainedBuffers,
112
- enumerable: false
33
+ enumerable: false,
34
+ value: retainedBuffers
113
35
  });
114
36
  return table;
115
37
  }
116
38
  function dataFromColumn(column, retainedBuffers) {
117
39
  const nullBitmap = optionalUint8View(column.nullBitmap, retainedBuffers);
118
40
  switch (column.type) {
119
- case "bool":
41
+ case "bool": {
120
42
  return apacheArrow.makeData({
121
43
  type: new apacheArrow.Bool(),
122
44
  length: column.length,
@@ -124,7 +46,8 @@ function dataFromColumn(column, retainedBuffers) {
124
46
  nullBitmap,
125
47
  data: requiredUint8View(column, retainedBuffers, Math.ceil(column.length / 8))
126
48
  });
127
- case "binary":
49
+ }
50
+ case "binary": {
128
51
  return apacheArrow.makeData({
129
52
  type: new apacheArrow.Binary(),
130
53
  length: column.length,
@@ -133,23 +56,32 @@ function dataFromColumn(column, retainedBuffers) {
133
56
  valueOffsets: requiredOffsets(column, retainedBuffers),
134
57
  data: requiredUint8View(column, retainedBuffers)
135
58
  });
136
- case "date32":
59
+ }
60
+ case "date32": {
137
61
  return scalarData(column, retainedBuffers, nullBitmap, new apacheArrow.DateDay(), Int32Array);
138
- case "date64":
62
+ }
63
+ case "date64": {
139
64
  return scalarData(column, retainedBuffers, nullBitmap, new apacheArrow.DateMillisecond(), BigInt64Array);
140
- case "float32":
65
+ }
66
+ case "float32": {
141
67
  return scalarData(column, retainedBuffers, nullBitmap, new apacheArrow.Float32(), Float32Array);
142
- case "float64":
68
+ }
69
+ case "float64": {
143
70
  return scalarData(column, retainedBuffers, nullBitmap, new apacheArrow.Float64(), Float64Array);
144
- case "int8":
71
+ }
72
+ case "int8": {
145
73
  return scalarData(column, retainedBuffers, nullBitmap, new apacheArrow.Int8(), Int8Array);
146
- case "int16":
74
+ }
75
+ case "int16": {
147
76
  return scalarData(column, retainedBuffers, nullBitmap, new apacheArrow.Int16(), Int16Array);
148
- case "int32":
77
+ }
78
+ case "int32": {
149
79
  return scalarData(column, retainedBuffers, nullBitmap, new apacheArrow.Int32(), Int32Array);
150
- case "int64":
80
+ }
81
+ case "int64": {
151
82
  return scalarData(column, retainedBuffers, nullBitmap, new apacheArrow.Int64(), BigInt64Array);
152
- case "large_binary":
83
+ }
84
+ case "large_binary": {
153
85
  return apacheArrow.makeData({
154
86
  type: new apacheArrow.LargeBinary(),
155
87
  length: column.length,
@@ -158,7 +90,8 @@ function dataFromColumn(column, retainedBuffers) {
158
90
  valueOffsets: requiredLargeOffsets(column, retainedBuffers),
159
91
  data: requiredUint8View(column, retainedBuffers)
160
92
  });
161
- case "large_utf8":
93
+ }
94
+ case "large_utf8": {
162
95
  return apacheArrow.makeData({
163
96
  type: new apacheArrow.LargeUtf8(),
164
97
  length: column.length,
@@ -167,20 +100,26 @@ function dataFromColumn(column, retainedBuffers) {
167
100
  valueOffsets: requiredLargeOffsets(column, retainedBuffers),
168
101
  data: requiredUint8View(column, retainedBuffers)
169
102
  });
170
- case "null":
103
+ }
104
+ case "null": {
171
105
  return apacheArrow.makeData({
172
106
  type: new apacheArrow.Null(),
173
107
  length: column.length
174
108
  });
175
- case "time32_ms":
109
+ }
110
+ case "time32_ms": {
176
111
  return scalarData(column, retainedBuffers, nullBitmap, new apacheArrow.TimeMillisecond(), Int32Array);
177
- case "time32_s":
112
+ }
113
+ case "time32_s": {
178
114
  return scalarData(column, retainedBuffers, nullBitmap, new apacheArrow.TimeSecond(), Int32Array);
179
- case "time64_us":
115
+ }
116
+ case "time64_us": {
180
117
  return scalarData(column, retainedBuffers, nullBitmap, new apacheArrow.TimeMicrosecond(), BigInt64Array);
181
- case "time64_ns":
118
+ }
119
+ case "time64_ns": {
182
120
  return scalarData(column, retainedBuffers, nullBitmap, new apacheArrow.TimeNanosecond(), BigInt64Array);
183
- case "timestamp_ms":
121
+ }
122
+ case "timestamp_ms": {
184
123
  return scalarData(
185
124
  column,
186
125
  retainedBuffers,
@@ -188,7 +127,8 @@ function dataFromColumn(column, retainedBuffers) {
188
127
  new apacheArrow.TimestampMillisecond(column.timezone),
189
128
  BigInt64Array
190
129
  );
191
- case "timestamp_ns":
130
+ }
131
+ case "timestamp_ns": {
192
132
  return scalarData(
193
133
  column,
194
134
  retainedBuffers,
@@ -196,7 +136,8 @@ function dataFromColumn(column, retainedBuffers) {
196
136
  new apacheArrow.TimestampNanosecond(column.timezone),
197
137
  BigInt64Array
198
138
  );
199
- case "timestamp_s":
139
+ }
140
+ case "timestamp_s": {
200
141
  return scalarData(
201
142
  column,
202
143
  retainedBuffers,
@@ -204,7 +145,8 @@ function dataFromColumn(column, retainedBuffers) {
204
145
  new apacheArrow.TimestampSecond(column.timezone),
205
146
  BigInt64Array
206
147
  );
207
- case "timestamp_us":
148
+ }
149
+ case "timestamp_us": {
208
150
  return scalarData(
209
151
  column,
210
152
  retainedBuffers,
@@ -212,15 +154,20 @@ function dataFromColumn(column, retainedBuffers) {
212
154
  new apacheArrow.TimestampMicrosecond(column.timezone),
213
155
  BigInt64Array
214
156
  );
215
- case "uint8":
157
+ }
158
+ case "uint8": {
216
159
  return scalarData(column, retainedBuffers, nullBitmap, new apacheArrow.Uint8(), Uint8Array);
217
- case "uint16":
160
+ }
161
+ case "uint16": {
218
162
  return scalarData(column, retainedBuffers, nullBitmap, new apacheArrow.Uint16(), Uint16Array);
219
- case "uint32":
163
+ }
164
+ case "uint32": {
220
165
  return scalarData(column, retainedBuffers, nullBitmap, new apacheArrow.Uint32(), Uint32Array);
221
- case "uint64":
166
+ }
167
+ case "uint64": {
222
168
  return scalarData(column, retainedBuffers, nullBitmap, new apacheArrow.Uint64(), BigUint64Array);
223
- case "utf8":
169
+ }
170
+ case "utf8": {
224
171
  return apacheArrow.makeData({
225
172
  type: new apacheArrow.Utf8(),
226
173
  length: column.length,
@@ -229,71 +176,100 @@ function dataFromColumn(column, retainedBuffers) {
229
176
  valueOffsets: requiredOffsets(column, retainedBuffers),
230
177
  data: requiredUint8View(column, retainedBuffers)
231
178
  });
179
+ }
232
180
  }
181
+ return unsupportedNativeArrowType(column.type);
233
182
  }
234
183
  function arrowType(column) {
235
184
  switch (column.type) {
236
- case "bool":
185
+ case "bool": {
237
186
  return new apacheArrow.Bool();
238
- case "binary":
187
+ }
188
+ case "binary": {
239
189
  return new apacheArrow.Binary();
240
- case "date32":
190
+ }
191
+ case "date32": {
241
192
  return new apacheArrow.DateDay();
242
- case "date64":
193
+ }
194
+ case "date64": {
243
195
  return new apacheArrow.DateMillisecond();
244
- case "float32":
196
+ }
197
+ case "float32": {
245
198
  return new apacheArrow.Float32();
246
- case "float64":
199
+ }
200
+ case "float64": {
247
201
  return new apacheArrow.Float64();
248
- case "int8":
202
+ }
203
+ case "int8": {
249
204
  return new apacheArrow.Int8();
250
- case "int16":
205
+ }
206
+ case "int16": {
251
207
  return new apacheArrow.Int16();
252
- case "int32":
208
+ }
209
+ case "int32": {
253
210
  return new apacheArrow.Int32();
254
- case "int64":
211
+ }
212
+ case "int64": {
255
213
  return new apacheArrow.Int64();
256
- case "large_binary":
214
+ }
215
+ case "large_binary": {
257
216
  return new apacheArrow.LargeBinary();
258
- case "large_utf8":
217
+ }
218
+ case "large_utf8": {
259
219
  return new apacheArrow.LargeUtf8();
260
- case "null":
220
+ }
221
+ case "null": {
261
222
  return new apacheArrow.Null();
262
- case "time32_ms":
223
+ }
224
+ case "time32_ms": {
263
225
  return new apacheArrow.TimeMillisecond();
264
- case "time32_s":
226
+ }
227
+ case "time32_s": {
265
228
  return new apacheArrow.TimeSecond();
266
- case "time64_us":
229
+ }
230
+ case "time64_us": {
267
231
  return new apacheArrow.TimeMicrosecond();
268
- case "time64_ns":
232
+ }
233
+ case "time64_ns": {
269
234
  return new apacheArrow.TimeNanosecond();
270
- case "timestamp_ms":
235
+ }
236
+ case "timestamp_ms": {
271
237
  return new apacheArrow.TimestampMillisecond(column.timezone);
272
- case "timestamp_ns":
238
+ }
239
+ case "timestamp_ns": {
273
240
  return new apacheArrow.TimestampNanosecond(column.timezone);
274
- case "timestamp_s":
241
+ }
242
+ case "timestamp_s": {
275
243
  return new apacheArrow.TimestampSecond(column.timezone);
276
- case "timestamp_us":
244
+ }
245
+ case "timestamp_us": {
277
246
  return new apacheArrow.TimestampMicrosecond(column.timezone);
278
- case "uint8":
247
+ }
248
+ case "uint8": {
279
249
  return new apacheArrow.Uint8();
280
- case "uint16":
250
+ }
251
+ case "uint16": {
281
252
  return new apacheArrow.Uint16();
282
- case "uint32":
253
+ }
254
+ case "uint32": {
283
255
  return new apacheArrow.Uint32();
284
- case "uint64":
256
+ }
257
+ case "uint64": {
285
258
  return new apacheArrow.Uint64();
286
- case "utf8":
259
+ }
260
+ case "utf8": {
287
261
  return new apacheArrow.Utf8();
262
+ }
288
263
  }
264
+ return unsupportedNativeArrowType(column.type);
289
265
  }
290
266
  function scalarData(column, retainedBuffers, nullBitmap, type, ctor) {
291
267
  return apacheArrow.makeData({
292
- type,
268
+ data: requiredTypedView(column, ctor, retainedBuffers),
293
269
  length: column.length,
294
- nullCount: column.nullCount,
295
270
  nullBitmap,
296
- data: requiredTypedView(column, ctor, retainedBuffers)
271
+ nullCount: column.nullCount,
272
+ type
297
273
  });
298
274
  }
299
275
  function requiredTypedView(column, ctor, retainedBuffers) {
@@ -304,13 +280,25 @@ function requiredTypedView(column, ctor, retainedBuffers) {
304
280
  }
305
281
  function requiredOffsets(column, retainedBuffers) {
306
282
  const buffer = requireBuffer(column, "offsets");
307
- assertBufferByteLength(column, "offsets", buffer, column.length + 1, Int32Array.BYTES_PER_ELEMENT);
283
+ assertBufferByteLength(
284
+ column,
285
+ "offsets",
286
+ buffer,
287
+ column.length + 1,
288
+ Int32Array.BYTES_PER_ELEMENT
289
+ );
308
290
  retainedBuffers.push(buffer);
309
291
  return new Int32Array(buffer.buffer, buffer.byteOffset, column.length + 1);
310
292
  }
311
293
  function requiredLargeOffsets(column, retainedBuffers) {
312
294
  const buffer = requireBuffer(column, "offsets");
313
- assertBufferByteLength(column, "offsets", buffer, column.length + 1, BigInt64Array.BYTES_PER_ELEMENT);
295
+ assertBufferByteLength(
296
+ column,
297
+ "offsets",
298
+ buffer,
299
+ column.length + 1,
300
+ BigInt64Array.BYTES_PER_ELEMENT
301
+ );
314
302
  retainedBuffers.push(buffer);
315
303
  return new BigInt64Array(buffer.buffer, buffer.byteOffset, column.length + 1);
316
304
  }
@@ -331,7 +319,9 @@ function optionalUint8View(buffer, retainedBuffers) {
331
319
  }
332
320
  function assertBufferByteLength(column, property, buffer, elements, bytesPerElement) {
333
321
  if (!Number.isSafeInteger(elements) || elements < 0) {
334
- throw new Error(`native Arrow column ${column.name} has invalid ${property} element count: ${elements}`);
322
+ throw new Error(
323
+ `native Arrow column ${column.name} has invalid ${property} element count: ${elements}`
324
+ );
335
325
  }
336
326
  const requiredBytes = elements * bytesPerElement;
337
327
  if (!Number.isSafeInteger(requiredBytes) || buffer.byteLength < requiredBytes) {
@@ -349,9 +339,9 @@ function requireBuffer(column, property) {
349
339
  }
350
340
 
351
341
  // src/dates.ts
352
- var ISO_DATE_RE = /^\d{4}[-/]\d{2}[-/]\d{2}$/;
353
- var BBG_DATE_RE = /^\d{8}$/;
354
- var AMBIGUOUS_DATE_RE = /^\d{1,2}[-/]\d{1,2}[-/]\d{2,4}([T \D]|$)/;
342
+ var ISO_DATE_RE = /^\d{4}[-/]\d{2}[-/]\d{2}$/u;
343
+ var BBG_DATE_RE = /^\d{8}$/u;
344
+ var AMBIGUOUS_DATE_RE = /^\d{1,2}[-/]\d{1,2}[-/]\d{2,4}([T \D]|$)/u;
355
345
  function hasToJSDate(value) {
356
346
  return typeof value === "object" && value !== null && "toJSDate" in value && typeof value.toJSDate === "function";
357
347
  }
@@ -394,9 +384,7 @@ function dateLikeToJSDate(value) {
394
384
  }
395
385
  return dt;
396
386
  }
397
- throw new TypeError(
398
- `Cannot convert ${typeof value} value ${String(value)} to a Date.`
399
- );
387
+ throw new TypeError(`Cannot convert ${typeof value} value ${String(value)} to a Date.`);
400
388
  }
401
389
  function formatDate(value) {
402
390
  if (value === void 0 || value === null) {
@@ -412,7 +400,7 @@ function formatDate(value) {
412
400
  }
413
401
  rejectAmbiguousString(text);
414
402
  if (ISO_DATE_RE.test(text)) {
415
- return text.replace(/[-/]/g, "");
403
+ return text.replaceAll(/[-/]/gu, "");
416
404
  }
417
405
  }
418
406
  const date = dateLikeToJSDate(value);
@@ -440,6 +428,87 @@ function formatDateTime(value) {
440
428
  return date.toISOString();
441
429
  }
442
430
 
431
+ // src/errors.ts
432
+ var BlpError = class extends Error {
433
+ constructor(message) {
434
+ super(message);
435
+ this.name = new.target.name;
436
+ }
437
+ };
438
+ var BlpSessionError = class extends BlpError {
439
+ };
440
+ var BlpRequestError = class extends BlpError {
441
+ service;
442
+ operation;
443
+ request_id;
444
+ code;
445
+ constructor(message, options = {}) {
446
+ super(message);
447
+ this.service = options.service;
448
+ this.operation = options.operation;
449
+ this.request_id = options.request_id;
450
+ this.code = options.code;
451
+ }
452
+ };
453
+ var BlpValidationError = class extends BlpError {
454
+ element;
455
+ suggestion;
456
+ constructor(message, options = {}) {
457
+ super(message);
458
+ this.element = options.element;
459
+ this.suggestion = options.suggestion;
460
+ }
461
+ };
462
+ var BlpTimeoutError = class extends BlpError {
463
+ };
464
+ var BlpInternalError = class extends BlpError {
465
+ };
466
+ function wrapError(napiError) {
467
+ if (napiError instanceof BlpError) {
468
+ return napiError;
469
+ }
470
+ const msg = napiError instanceof Error ? napiError.message : typeof napiError === "string" ? napiError : "";
471
+ if (msg.includes("Session start failed") || msg.includes("session start failed") || msg.includes("Failed to start session") || msg.includes("Failed to open service") || msg.includes("failed to spawn worker") || msg.includes("connect event failed")) {
472
+ return new BlpSessionError(msg);
473
+ }
474
+ if (msg.includes("Request failed") || msg.includes("Subscription failed")) {
475
+ const options = parseRequestOptions(msg);
476
+ return new BlpRequestError(msg, options);
477
+ }
478
+ if (msg.includes("Invalid argument") || msg.includes("Configuration error") || msg.includes("Operation not found") || msg.includes("Schema element not found") || msg.includes("Schema type mismatch") || msg.includes("Unsupported schema") || msg.includes("invalid extractor") || msg.includes("(did you mean")) {
479
+ const options = parseValidationOptions(msg);
480
+ return new BlpValidationError(msg, options);
481
+ }
482
+ if (msg.includes("Request timed out")) {
483
+ return new BlpTimeoutError(msg);
484
+ }
485
+ if (msg.includes("Internal error") || msg.includes("Channel closed") || msg.includes("Stream buffer full") || msg.includes("Request was cancelled")) {
486
+ return new BlpInternalError(msg);
487
+ }
488
+ return new BlpError(msg);
489
+ }
490
+ function parseRequestOptions(msg) {
491
+ const options = {};
492
+ const serviceOpMatch = /on ([^:]+)::([^ (]+)/u.exec(msg);
493
+ if (serviceOpMatch !== null) {
494
+ options.service = serviceOpMatch[1];
495
+ options.operation = serviceOpMatch[2];
496
+ }
497
+ const requestIdMatch = /\[request_id=([^\]]+)\]/u.exec(msg);
498
+ if (requestIdMatch !== null) {
499
+ options.request_id = requestIdMatch[1];
500
+ }
501
+ return options;
502
+ }
503
+ function parseValidationOptions(msg) {
504
+ const options = {};
505
+ const suggestionMatch = /\(did you mean '([^']+)'\?\)/u.exec(msg);
506
+ if (suggestionMatch !== null) {
507
+ options.suggestion = suggestionMatch[1];
508
+ }
509
+ return options;
510
+ }
511
+
443
512
  // src/native/platform-map.ts
444
513
  var platformPackages = Object.freeze({
445
514
  "darwin-arm64": "@xbbg/core-darwin-arm64",
@@ -471,7 +540,7 @@ function validateNativePackage(packageName, resolved) {
471
540
  throw new Error(`Invalid native package ${packageName}: missing binaryPath`);
472
541
  }
473
542
  if (typeof resolved.binaryPath !== "string") {
474
- throw new Error(`Invalid native package ${packageName}: binaryPath must be a string`);
543
+ throw new TypeError(`Invalid native package ${packageName}: binaryPath must be a string`);
475
544
  }
476
545
  return resolved;
477
546
  }
@@ -498,11 +567,11 @@ function resolveInstalledPackage(packageName, requirePackage, existsFile) {
498
567
  );
499
568
  }
500
569
  return resolved;
501
- } catch (err) {
502
- if (isOptionalPackageMissing(err, packageName)) {
570
+ } catch (error) {
571
+ if (isOptionalPackageMissing(error, packageName)) {
503
572
  return null;
504
573
  }
505
- throw err;
574
+ throw error;
506
575
  }
507
576
  }
508
577
  function resolveLocalPackage(repoRoot, packageName, requirePackage, existsFile) {
@@ -521,33 +590,65 @@ function resolveLocalPackage(repoRoot, packageName, requirePackage, existsFile)
521
590
  function resolveNativeAddonCore(options) {
522
591
  const { key, packageName, repoRoot, requirePackage, exists: existsFile } = options;
523
592
  if (packageName === null) {
524
- return { key, packageName: null, binaryPath: null };
593
+ return { binaryPath: null, key, packageName: null };
525
594
  }
526
595
  const installed = resolveInstalledPackage(packageName, requirePackage, existsFile);
527
596
  if (installed !== null) {
528
- return { key, packageName, binaryPath: installed.binaryPath };
597
+ return { binaryPath: installed.binaryPath, key, packageName };
529
598
  }
530
599
  const local = resolveLocalPackage(repoRoot, packageName, requirePackage, existsFile);
531
600
  if (local !== null) {
532
- return { key, packageName, binaryPath: local.binaryPath };
601
+ return { binaryPath: local.binaryPath, key, packageName };
533
602
  }
534
- return { key, packageName, binaryPath: null };
603
+ return { binaryPath: null, key, packageName };
535
604
  }
536
605
  function resolveNativeAddon(repoRoot) {
537
606
  const key = platformKey();
538
607
  const packageName = platformPackages[key] ?? null;
539
608
  return resolveNativeAddonCore({
609
+ exists,
540
610
  key,
541
611
  packageName,
542
612
  repoRoot,
543
- requirePackage: (id) => nodeRequire(id),
544
- exists
613
+ requirePackage: (id) => nodeRequire(id)
545
614
  });
546
615
  }
547
616
 
548
617
  // src/index.ts
549
618
  var nodeRequire2 = module$1.createRequire(__filename);
550
- var packageJson = nodeRequire2("../package.json");
619
+ function parsePackageJsonShape(value) {
620
+ if (isPlainObject(value) && typeof value.version === "string") {
621
+ return { version: value.version };
622
+ }
623
+ throw new TypeError("@xbbg/core package.json is missing a string version field");
624
+ }
625
+ function isNativeAddon(value) {
626
+ return isPlainObject(value) && typeof value.JsEngine === "function" && typeof value.getLogLevel === "function" && typeof value.setLogLevel === "function";
627
+ }
628
+ function requireNativeAddon(modulePath) {
629
+ const loaded = nodeRequire2(modulePath);
630
+ if (isNativeAddon(loaded)) {
631
+ return loaded;
632
+ }
633
+ throw new TypeError(`Native addon ${modulePath} does not expose the expected @xbbg/core surface`);
634
+ }
635
+ function isPolarsModule(value) {
636
+ return isPlainObject(value) && typeof value.readIPC === "function";
637
+ }
638
+ function requirePolarsModule() {
639
+ const loaded = nodeRequire2("nodejs-polars");
640
+ if (isPolarsModule(loaded)) {
641
+ return loaded;
642
+ }
643
+ throw new TypeError("nodejs-polars did not expose readIPC(buffer)");
644
+ }
645
+ function isBdhOptionsInput(value) {
646
+ return isPlainObject(value) && !(value instanceof Date) && !hasToJSDate(value);
647
+ }
648
+ function isBdibOptionsInput(value) {
649
+ return isPlainObject(value) && !(value instanceof Date) && !hasToJSDate(value);
650
+ }
651
+ var packageJson = parsePackageJsonShape(nodeRequire2("../package.json"));
551
652
  function containsBlpapiRuntime(dir) {
552
653
  if (dir.length === 0 || !fs2__default.default.existsSync(dir)) {
553
654
  return false;
@@ -577,8 +678,12 @@ function compareSdkRoots(left, right) {
577
678
  }
578
679
  }
579
680
  }
580
- if (leftParts !== null) return -1;
581
- if (rightParts !== null) return 1;
681
+ if (leftParts !== null) {
682
+ return -1;
683
+ }
684
+ if (rightParts !== null) {
685
+ return 1;
686
+ }
582
687
  return right.localeCompare(left);
583
688
  }
584
689
  function pushSdkRuntimeCandidates(candidates, sdkRoot) {
@@ -649,12 +754,12 @@ function loadNative() {
649
754
  ];
650
755
  for (const candidate of candidates) {
651
756
  if (fs2__default.default.existsSync(candidate)) {
652
- return nodeRequire2(candidate);
757
+ return requireNativeAddon(candidate);
653
758
  }
654
759
  }
655
760
  const { key, packageName, binaryPath } = resolveNativeAddon(root);
656
761
  if (binaryPath !== null) {
657
- return nodeRequire2(binaryPath);
762
+ return requireNativeAddon(binaryPath);
658
763
  }
659
764
  if (packageName === null) {
660
765
  throw new Error(
@@ -708,72 +813,67 @@ var CDX_RISK_FIELDS = Object.freeze([
708
813
  "CDS_RECOVERY_RT"
709
814
  ]);
710
815
  var TA_STUDIES = Object.freeze({
711
- smavg: "smavgStudyAttributes",
712
- sma: "smavgStudyAttributes",
713
- emavg: "emavgStudyAttributes",
816
+ ado: "adoStudyAttributes",
817
+ adx: "dmiStudyAttributes",
818
+ al: "alStudyAttributes",
819
+ atr: "atrStudyAttributes",
820
+ bb: "bollStudyAttributes",
821
+ boll: "bollStudyAttributes",
822
+ bs: "bsStudyAttributes",
823
+ chko: "chkoStudyAttributes",
824
+ cmci: "cmciStudyAttributes",
825
+ dmi: "dmiStudyAttributes",
714
826
  ema: "emavgStudyAttributes",
715
- wmavg: "wmavgStudyAttributes",
716
- wma: "wmavgStudyAttributes",
717
- vmavg: "vmavgStudyAttributes",
718
- vma: "vmavgStudyAttributes",
719
- tmavg: "tmavgStudyAttributes",
720
- tma: "tmavgStudyAttributes",
827
+ emavg: "emavgStudyAttributes",
828
+ etd: "etdStudyAttributes",
829
+ fear_greed: "fgStudyAttributes",
830
+ fg: "fgStudyAttributes",
831
+ goc: "gocStudyAttributes",
832
+ hurst: "hurstStudyAttributes",
833
+ ichimoku: "gocStudyAttributes",
721
834
  ipmavg: "ipmavgStudyAttributes",
722
- rsi: "rsiStudyAttributes",
835
+ keltner: "kltnStudyAttributes",
836
+ kltn: "kltnStudyAttributes",
723
837
  macd: "macdStudyAttributes",
838
+ mae: "maeStudyAttributes",
724
839
  mao: "maoStudyAttributes",
725
- momentum: "momentumStudyAttributes",
840
+ maxmin: "maxminStudyAttributes",
726
841
  mom: "momentumStudyAttributes",
842
+ momentum: "momentumStudyAttributes",
843
+ or: "orStudyAttributes",
844
+ parabolic: "ptpsStudyAttributes",
845
+ pcr: "pcrStudyAttributes",
846
+ pd: "pdStudyAttributes",
847
+ pivot: "pivotStudyAttributes",
848
+ ptps: "ptpsStudyAttributes",
849
+ rex: "rexStudyAttributes",
727
850
  roc: "rocStudyAttributes",
728
- boll: "bollStudyAttributes",
729
- bb: "bollStudyAttributes",
730
- kltn: "kltnStudyAttributes",
731
- keltner: "kltnStudyAttributes",
732
- mae: "maeStudyAttributes",
733
- te: "teStudyAttributes",
734
- al: "alStudyAttributes",
735
- dmi: "dmiStudyAttributes",
736
- adx: "dmiStudyAttributes",
737
- tas: "tasStudyAttributes",
851
+ rsi: "rsiStudyAttributes",
852
+ rv: "rvStudyAttributes",
853
+ sar: "ptpsStudyAttributes",
854
+ sma: "smavgStudyAttributes",
855
+ smavg: "smavgStudyAttributes",
738
856
  stoch: "tasStudyAttributes",
857
+ tas: "tasStudyAttributes",
858
+ te: "teStudyAttributes",
859
+ tma: "tmavgStudyAttributes",
860
+ tmavg: "tmavgStudyAttributes",
739
861
  trender: "trenderStudyAttributes",
740
- ptps: "ptpsStudyAttributes",
741
- parabolic: "ptpsStudyAttributes",
742
- sar: "ptpsStudyAttributes",
743
- chko: "chkoStudyAttributes",
744
- ado: "adoStudyAttributes",
745
- vat: "vatStudyAttributes",
746
862
  tvat: "tvatStudyAttributes",
747
- atr: "atrStudyAttributes",
748
- hurst: "hurstStudyAttributes",
749
- fg: "fgStudyAttributes",
750
- fear_greed: "fgStudyAttributes",
751
- goc: "gocStudyAttributes",
752
- ichimoku: "gocStudyAttributes",
753
- cmci: "cmciStudyAttributes",
754
- wlpr: "wlprStudyAttributes",
863
+ vat: "vatStudyAttributes",
864
+ vma: "vmavgStudyAttributes",
865
+ vmavg: "vmavgStudyAttributes",
755
866
  williams: "wlprStudyAttributes",
756
- maxmin: "maxminStudyAttributes",
757
- rex: "rexStudyAttributes",
758
- etd: "etdStudyAttributes",
759
- pd: "pdStudyAttributes",
760
- rv: "rvStudyAttributes",
761
- pivot: "pivotStudyAttributes",
762
- or: "orStudyAttributes",
763
- pcr: "pcrStudyAttributes",
764
- bs: "bsStudyAttributes"
867
+ wlpr: "wlprStudyAttributes",
868
+ wma: "wmavgStudyAttributes",
869
+ wmavg: "wmavgStudyAttributes"
765
870
  });
766
871
  var TA_DEFAULTS = Object.freeze({
767
- smavgStudyAttributes: Object.freeze({ period: 20, priceSourceClose: "PX_LAST" }),
768
- emavgStudyAttributes: Object.freeze({ period: 20, priceSourceClose: "PX_LAST" }),
769
- wmavgStudyAttributes: Object.freeze({ period: 20, priceSourceClose: "PX_LAST" }),
770
- vmavgStudyAttributes: Object.freeze({ period: 20, priceSourceClose: "PX_LAST" }),
771
- tmavgStudyAttributes: Object.freeze({ period: 20, priceSourceClose: "PX_LAST" }),
772
- rsiStudyAttributes: Object.freeze({ period: 14, priceSourceClose: "PX_LAST" }),
773
- macdStudyAttributes: Object.freeze({
774
- maPeriod1: 12,
775
- maPeriod2: 26,
776
- sigPeriod: 9,
872
+ atrStudyAttributes: Object.freeze({
873
+ maType: "Simple",
874
+ period: 14,
875
+ priceSourceHigh: "PX_HIGH",
876
+ priceSourceLow: "PX_LOW",
777
877
  priceSourceClose: "PX_LAST"
778
878
  }),
779
879
  bollStudyAttributes: Object.freeze({
@@ -788,13 +888,15 @@ var TA_DEFAULTS = Object.freeze({
788
888
  priceSourceLow: "PX_LOW",
789
889
  priceSourceClose: "PX_LAST"
790
890
  }),
791
- atrStudyAttributes: Object.freeze({
792
- maType: "Simple",
793
- period: 14,
794
- priceSourceHigh: "PX_HIGH",
795
- priceSourceLow: "PX_LOW",
891
+ emavgStudyAttributes: Object.freeze({ period: 20, priceSourceClose: "PX_LAST" }),
892
+ macdStudyAttributes: Object.freeze({
893
+ maPeriod1: 12,
894
+ maPeriod2: 26,
895
+ sigPeriod: 9,
796
896
  priceSourceClose: "PX_LAST"
797
897
  }),
898
+ rsiStudyAttributes: Object.freeze({ period: 14, priceSourceClose: "PX_LAST" }),
899
+ smavgStudyAttributes: Object.freeze({ period: 20, priceSourceClose: "PX_LAST" }),
798
900
  tasStudyAttributes: Object.freeze({
799
901
  periodK: 14,
800
902
  periodD: 3,
@@ -803,7 +905,10 @@ var TA_DEFAULTS = Object.freeze({
803
905
  priceSourceHigh: "PX_HIGH",
804
906
  priceSourceLow: "PX_LOW",
805
907
  priceSourceClose: "PX_LAST"
806
- })
908
+ }),
909
+ tmavgStudyAttributes: Object.freeze({ period: 20, priceSourceClose: "PX_LAST" }),
910
+ vmavgStudyAttributes: Object.freeze({ period: 20, priceSourceClose: "PX_LAST" }),
911
+ wmavgStudyAttributes: Object.freeze({ period: 20, priceSourceClose: "PX_LAST" })
807
912
  });
808
913
  var MKTDATA_SERVICE = "//blp/mktdata";
809
914
  function toArrowTableFromNative(batch) {
@@ -860,6 +965,39 @@ function toStringArray(value) {
860
965
  }
861
966
  return [toRequestString(value)];
862
967
  }
968
+ function encodeVolFieldSpec(field, spec) {
969
+ if (spec === void 0) {
970
+ return field;
971
+ }
972
+ return [
973
+ field,
974
+ spec.metric ?? "",
975
+ spec.tenor ?? "",
976
+ spec.pointType ?? "",
977
+ spec.point === void 0 ? "" : String(spec.point)
978
+ ].join("|");
979
+ }
980
+ function isVolFieldSpecMap(fields) {
981
+ return fields !== void 0 && !Array.isArray(fields);
982
+ }
983
+ function normalizeVolFieldSpecs(fields) {
984
+ if (fields === void 0) {
985
+ return null;
986
+ }
987
+ if (!isVolFieldSpecMap(fields)) {
988
+ return fields.map((field) => toRequestString(field));
989
+ }
990
+ return Object.entries(fields).map(([field, spec]) => encodeVolFieldSpec(field, spec));
991
+ }
992
+ function isVolSurfacePresetArray(preset) {
993
+ return Array.isArray(preset);
994
+ }
995
+ function normalizeVolPresets(preset) {
996
+ if (preset === void 0 || preset === null) {
997
+ return null;
998
+ }
999
+ return isVolSurfacePresetArray(preset) ? [...preset] : [preset];
1000
+ }
863
1001
  function subscriptionOptionKey(option) {
864
1002
  return normalizeSubscriptionOption(option).split("=")[0]?.trim().toLowerCase() ?? "";
865
1003
  }
@@ -872,7 +1010,7 @@ function normalizeSubscriptionOption(option) {
872
1010
  }
873
1011
  function buildStreamSubscriptionOptions(service, options) {
874
1012
  const rawOptions = options.options;
875
- const conflate = options.conflate;
1013
+ const { conflate } = options;
876
1014
  if (rawOptions === void 0 && conflate !== true) {
877
1015
  return void 0;
878
1016
  }
@@ -913,9 +1051,7 @@ function normalizeConfigureArgs(configOrHost, port) {
913
1051
  if (isPlainObject(configOrHost)) {
914
1052
  return { ...configOrHost };
915
1053
  }
916
- throw new TypeError(
917
- "configure expects either a config object or host/port arguments"
918
- );
1054
+ throw new TypeError("configure expects either a config object or host/port arguments");
919
1055
  }
920
1056
  function normalizeRecoveryOptions(options = {}) {
921
1057
  const normalized = { ...options };
@@ -924,7 +1060,7 @@ function normalizeRecoveryOptions(options = {}) {
924
1060
  delete normalized.recovery_rate;
925
1061
  if (recoveryRate !== void 0) {
926
1062
  normalized.overrides = {
927
- ...normalized.overrides ?? {},
1063
+ ...normalized.overrides,
928
1064
  CDS_RR: toRequestString(recoveryRate)
929
1065
  };
930
1066
  }
@@ -937,15 +1073,15 @@ function fullDayRange(dt) {
937
1073
  }
938
1074
  const day = `${formatted.slice(0, 4)}-${formatted.slice(4, 6)}-${formatted.slice(6, 8)}`;
939
1075
  return {
940
- start: `${day}T00:00:00`,
941
- end: `${day}T23:59:59`
1076
+ end: `${day}T23:59:59`,
1077
+ start: `${day}T00:00:00`
942
1078
  };
943
1079
  }
944
1080
  function normalizeDate(value) {
945
1081
  return formatDate(value);
946
1082
  }
947
1083
  function getStudyAttrName(study) {
948
- const normalized = study.toLowerCase().replace(/-/g, "_").replace(/ /g, "_");
1084
+ const normalized = study.toLowerCase().replaceAll(/-/gu, "_").replaceAll(/ /gu, "_");
949
1085
  const mapped = TA_STUDIES[normalized];
950
1086
  if (mapped !== void 0) {
951
1087
  return mapped;
@@ -959,14 +1095,16 @@ function buildTaRequest(ticker, study, options = {}) {
959
1095
  const rawStudy = typeof study === "string" ? { studyType: study } : { ...study };
960
1096
  const studyType = rawStudy.studyType ?? rawStudy.study ?? (typeof study === "string" ? study : "");
961
1097
  const attrName = getStudyAttrName(toRequestString(studyType));
962
- const kwargs = { ...options.kwargs ?? {} };
1098
+ const kwargs = { ...options.kwargs };
963
1099
  const startDate = normalizeDate(
964
1100
  stringOrUndef(kwargs.startDate) ?? stringOrUndef(kwargs.start_date) ?? options.startDate ?? options.start_date
965
1101
  );
966
1102
  const endDate = normalizeDate(
967
1103
  stringOrUndef(kwargs.endDate) ?? stringOrUndef(kwargs.end_date) ?? options.endDate ?? options.end_date
968
1104
  );
969
- const periodicity = toRequestString(stringOrUndef(kwargs.periodicitySelection) ?? stringOrUndef(kwargs.periodicity) ?? rawStudy.calcInterval ?? options.periodicity ?? "DAILY").toUpperCase();
1105
+ const periodicity = toRequestString(
1106
+ stringOrUndef(kwargs.periodicitySelection) ?? stringOrUndef(kwargs.periodicity) ?? rawStudy.calcInterval ?? options.periodicity ?? "DAILY"
1107
+ ).toUpperCase();
970
1108
  const interval = kwargs.interval ?? rawStudy.interval ?? options.interval;
971
1109
  delete kwargs.startDate;
972
1110
  delete kwargs.start_date;
@@ -982,8 +1120,8 @@ function buildTaRequest(ticker, study, options = {}) {
982
1120
  }
983
1121
  delete rawStudy.length;
984
1122
  const params = {
985
- ...TA_DEFAULTS[attrName] ?? {},
986
- ...options.studyParams ?? {},
1123
+ ...TA_DEFAULTS[attrName],
1124
+ ...options.studyParams,
987
1125
  ...rawStudy
988
1126
  };
989
1127
  if (params.length !== void 0 && params.period === void 0) {
@@ -1039,7 +1177,7 @@ function cachePolarsLoadError(err) {
1039
1177
  const error = new Error(
1040
1178
  "nodejs-polars is required for Polars backend. Install: npm install nodejs-polars"
1041
1179
  );
1042
- Object.defineProperty(error, "cause", { value: err, configurable: true });
1180
+ Object.defineProperty(error, "cause", { configurable: true, value: err });
1043
1181
  polarsLoadError = error;
1044
1182
  return error;
1045
1183
  }
@@ -1051,10 +1189,10 @@ function loadPolars() {
1051
1189
  throw polarsLoadError;
1052
1190
  }
1053
1191
  try {
1054
- polarsModule = nodeRequire2("nodejs-polars");
1192
+ polarsModule = requirePolarsModule();
1055
1193
  return polarsModule;
1056
- } catch (err) {
1057
- throw cachePolarsLoadError(err);
1194
+ } catch (error) {
1195
+ throw cachePolarsLoadError(error);
1058
1196
  }
1059
1197
  }
1060
1198
  function normalizeBackend(backend) {
@@ -1071,7 +1209,7 @@ function normalizeBackend(backend) {
1071
1209
  function ipcToBackend(buffer, backend) {
1072
1210
  const selected = normalizeBackend(backend);
1073
1211
  if (selected === Backend.JSON) {
1074
- return Array.from(apacheArrow.tableFromIPC(buffer));
1212
+ return [...apacheArrow.tableFromIPC(buffer)];
1075
1213
  }
1076
1214
  if (selected === Backend.POLARS) {
1077
1215
  return loadPolars().readIPC(buffer);
@@ -1084,10 +1222,13 @@ function clearConfiguredEngine() {
1084
1222
  const existing = configuredEnginePromise;
1085
1223
  configuredEnginePromise = void 0;
1086
1224
  if (existing !== void 0) {
1087
- existing.then((engine) => {
1088
- engine.signalShutdown();
1089
- }).catch(() => {
1090
- });
1225
+ void (async () => {
1226
+ try {
1227
+ const engine = await existing;
1228
+ engine.signalShutdown();
1229
+ } catch {
1230
+ }
1231
+ })();
1091
1232
  }
1092
1233
  }
1093
1234
  async function getConfiguredEngine() {
@@ -1109,28 +1250,32 @@ var FieldHandle = class {
1109
1250
  name;
1110
1251
  };
1111
1252
  var Tick = class {
1112
- constructor(_update) {
1113
- this._update = _update;
1114
- this._positions = new Map(_update.fields.map((field, index) => [field, index]));
1253
+ constructor(update) {
1254
+ this.update = update;
1255
+ this.positions = new Map(update.fields.map((field, index) => [field, index]));
1115
1256
  }
1116
- _update;
1117
- _positions;
1257
+ update;
1258
+ positions;
1118
1259
  get topic() {
1119
- return this._update.topic;
1260
+ return this.update.topic;
1120
1261
  }
1121
1262
  get timestampUs() {
1122
- return this._update.timestampUs;
1263
+ return this.update.timestampUs;
1123
1264
  }
1124
1265
  get layoutVersion() {
1125
- return this._update.layoutVersion;
1266
+ return this.update.layoutVersion;
1126
1267
  }
1127
1268
  get(field) {
1128
1269
  const name = typeof field === "string" ? field : field.name;
1129
- const index = this._positions.get(name);
1130
- if (index === void 0) return null;
1131
- const value = this._update.values[index] ?? null;
1132
- const kind = this._update.valueKinds[index] ?? "unknown";
1133
- if (value === null) return null;
1270
+ const index = this.positions.get(name);
1271
+ if (index === void 0) {
1272
+ return null;
1273
+ }
1274
+ const value = this.update.values[index] ?? null;
1275
+ const kind = this.update.valueKinds[index] ?? "unknown";
1276
+ if (value === null) {
1277
+ return null;
1278
+ }
1134
1279
  if (kind === "i64" || kind === "time64_us" || kind === "timestamp_us") {
1135
1280
  try {
1136
1281
  return BigInt(String(value));
@@ -1145,13 +1290,17 @@ var Tick = class {
1145
1290
  }
1146
1291
  f64(field) {
1147
1292
  const value = this.get(field);
1148
- if (value === null) return null;
1293
+ if (value === null) {
1294
+ return null;
1295
+ }
1149
1296
  const parsed = Number(value);
1150
1297
  return Number.isFinite(parsed) ? parsed : null;
1151
1298
  }
1152
1299
  i64(field) {
1153
1300
  const value = this.get(field);
1154
- if (value === null) return null;
1301
+ if (value === null) {
1302
+ return null;
1303
+ }
1155
1304
  try {
1156
1305
  return BigInt(String(value));
1157
1306
  } catch {
@@ -1163,35 +1312,35 @@ var Tick = class {
1163
1312
  return value === null ? null : String(value);
1164
1313
  }
1165
1314
  toObject() {
1166
- const out = { topic: this.topic, timestampUs: this.timestampUs };
1167
- for (const field of this._update.fields) {
1315
+ const out = { timestampUs: this.timestampUs, topic: this.topic };
1316
+ for (const field of this.update.fields) {
1168
1317
  out[field] = this.get(field);
1169
1318
  }
1170
1319
  return out;
1171
1320
  }
1172
1321
  };
1173
1322
  var ArrowSubscription = class {
1174
- constructor(_inner) {
1175
- this._inner = _inner;
1323
+ constructor(inner) {
1324
+ this.inner = inner;
1176
1325
  }
1177
- _inner;
1326
+ inner;
1178
1327
  async next() {
1179
1328
  try {
1180
- const batch = await this._inner.nextArrow();
1329
+ const batch = await this.inner.nextArrow();
1181
1330
  if (batch === null) {
1182
1331
  return { done: true, value: void 0 };
1183
1332
  }
1184
1333
  return { done: false, value: toArrowTableFromNative(batch) };
1185
- } catch (err) {
1186
- throw wrapError(err);
1334
+ } catch (error) {
1335
+ throw wrapError(error);
1187
1336
  }
1188
1337
  }
1189
1338
  async unsubscribe(drain = false) {
1190
1339
  try {
1191
- const drained = await this._inner.unsubscribeArrow(drain);
1340
+ const drained = await this.inner.unsubscribeArrow(drain);
1192
1341
  return drained?.map(toArrowTableFromNative) ?? [];
1193
- } catch (err) {
1194
- throw wrapError(err);
1342
+ } catch (error) {
1343
+ throw wrapError(error);
1195
1344
  }
1196
1345
  }
1197
1346
  [Symbol.asyncIterator]() {
@@ -1199,63 +1348,63 @@ var ArrowSubscription = class {
1199
1348
  }
1200
1349
  };
1201
1350
  var Subscription = class {
1202
- _inner;
1351
+ inner;
1203
1352
  constructor(inner) {
1204
- this._inner = inner;
1353
+ this.inner = inner;
1205
1354
  }
1206
1355
  async next() {
1207
1356
  try {
1208
- const update = await this._inner.nextUpdate();
1357
+ const update = await this.inner.nextUpdate();
1209
1358
  if (update === null) {
1210
1359
  return { done: true, value: void 0 };
1211
1360
  }
1212
1361
  return { done: false, value: new Tick(update) };
1213
- } catch (err) {
1214
- throw wrapError(err);
1362
+ } catch (error) {
1363
+ throw wrapError(error);
1215
1364
  }
1216
1365
  }
1217
1366
  async add(tickers) {
1218
1367
  try {
1219
- await this._inner.add(tickers);
1220
- } catch (err) {
1221
- throw wrapError(err);
1368
+ await this.inner.add(tickers);
1369
+ } catch (error) {
1370
+ throw wrapError(error);
1222
1371
  }
1223
1372
  }
1224
1373
  async remove(tickers) {
1225
1374
  try {
1226
- await this._inner.remove(tickers);
1227
- } catch (err) {
1228
- throw wrapError(err);
1375
+ await this.inner.remove(tickers);
1376
+ } catch (error) {
1377
+ throw wrapError(error);
1229
1378
  }
1230
1379
  }
1231
1380
  async unsubscribe(drain = false) {
1232
1381
  try {
1233
- const drained = await this._inner.unsubscribe(drain);
1382
+ const drained = await this.inner.unsubscribe(drain);
1234
1383
  if (drained === null) {
1235
1384
  return [];
1236
1385
  }
1237
1386
  return drained.map((update) => new Tick(update));
1238
- } catch (err) {
1239
- throw wrapError(err);
1387
+ } catch (error) {
1388
+ throw wrapError(error);
1240
1389
  }
1241
1390
  }
1242
1391
  field(name) {
1243
1392
  return new FieldHandle(name);
1244
1393
  }
1245
1394
  arrow() {
1246
- return new ArrowSubscription(this._inner);
1395
+ return new ArrowSubscription(this.inner);
1247
1396
  }
1248
1397
  get tickers() {
1249
- return this._inner.tickers;
1398
+ return this.inner.tickers;
1250
1399
  }
1251
1400
  get fields() {
1252
- return this._inner.fields;
1401
+ return this.inner.fields;
1253
1402
  }
1254
1403
  get isActive() {
1255
- return this._inner.isActive;
1404
+ return this.inner.isActive;
1256
1405
  }
1257
1406
  get stats() {
1258
- return this._inner.stats;
1407
+ return this.inner.stats;
1259
1408
  }
1260
1409
  [Symbol.asyncIterator]() {
1261
1410
  return this;
@@ -1263,20 +1412,24 @@ var Subscription = class {
1263
1412
  };
1264
1413
  var Engine = class _Engine {
1265
1414
  // Set via constructor or via `withConfig` (which instantiates via Object.create).
1266
- _inner;
1415
+ inner;
1267
1416
  constructor(host = "localhost", port = 8194) {
1268
1417
  try {
1269
- this._inner = new native.JsEngine(host, port);
1270
- } catch (err) {
1271
- throw wrapError(err);
1418
+ this.inner = new native.JsEngine(host, port);
1419
+ } catch (error) {
1420
+ throw wrapError(error);
1272
1421
  }
1273
1422
  }
1274
1423
  static withConfig(config = {}) {
1275
- const engine = Object.create(_Engine.prototype);
1424
+ const maybeEngine = Object.create(_Engine.prototype);
1425
+ if (!(maybeEngine instanceof _Engine)) {
1426
+ throw new TypeError("Failed to allocate Engine instance");
1427
+ }
1428
+ const engine = maybeEngine;
1276
1429
  try {
1277
- engine._inner = native.JsEngine.withConfig(config);
1278
- } catch (err) {
1279
- throw wrapError(err);
1430
+ engine.inner = native.JsEngine.withConfig(config);
1431
+ } catch (error) {
1432
+ throw wrapError(error);
1280
1433
  }
1281
1434
  return engine;
1282
1435
  }
@@ -1284,104 +1437,104 @@ var Engine = class _Engine {
1284
1437
  const backend = normalizeBackend(params.backend);
1285
1438
  const { backend: _discarded, ...nativeParams } = params;
1286
1439
  try {
1287
- const buffer = await this._inner.request(nativeParams);
1440
+ const buffer = await this.inner.request(nativeParams);
1288
1441
  return ipcToBackend(buffer, backend);
1289
- } catch (err) {
1290
- throw wrapError(err);
1442
+ } catch (error) {
1443
+ throw wrapError(error);
1291
1444
  }
1292
1445
  }
1293
1446
  async requestRaw(params) {
1294
1447
  try {
1295
- return await this._inner.request(params);
1296
- } catch (err) {
1297
- throw wrapError(err);
1448
+ return await this.inner.request(params);
1449
+ } catch (error) {
1450
+ throw wrapError(error);
1298
1451
  }
1299
1452
  }
1300
1453
  async bdp(tickers, fields, options = {}) {
1301
1454
  return await this.request({
1302
- service: "//blp/refdata",
1303
- operation: "ReferenceDataRequest",
1304
- securities: tickers,
1455
+ backend: options.backend,
1456
+ extractor: "refdata",
1305
1457
  fields,
1306
- overrides: mapObjectToPairs(options.overrides),
1307
- kwargs: mapObjectToPairs(options.kwargs),
1308
1458
  format: options.format,
1309
- backend: options.backend,
1310
1459
  includeSecurityErrors: Boolean(options.includeSecurityErrors),
1311
- validateFields: options.validateFields,
1312
- extractor: "refdata"
1460
+ kwargs: mapObjectToPairs(options.kwargs),
1461
+ operation: "ReferenceDataRequest",
1462
+ overrides: mapObjectToPairs(options.overrides),
1463
+ securities: tickers,
1464
+ service: "//blp/refdata",
1465
+ validateFields: options.validateFields
1313
1466
  });
1314
1467
  }
1315
1468
  async bds(tickers, fields, options = {}) {
1316
1469
  return await this.request({
1317
- service: "//blp/refdata",
1318
- operation: "ReferenceDataRequest",
1319
- securities: tickers,
1470
+ backend: options.backend,
1471
+ extractor: "bulk",
1320
1472
  fields,
1321
- overrides: mapObjectToPairs(options.overrides),
1322
- kwargs: mapObjectToPairs(options.kwargs),
1323
1473
  format: options.format,
1324
- backend: options.backend,
1325
- validateFields: options.validateFields,
1326
- extractor: "bulk"
1474
+ kwargs: mapObjectToPairs(options.kwargs),
1475
+ operation: "ReferenceDataRequest",
1476
+ overrides: mapObjectToPairs(options.overrides),
1477
+ securities: tickers,
1478
+ service: "//blp/refdata",
1479
+ validateFields: options.validateFields
1327
1480
  });
1328
1481
  }
1329
1482
  async bdh(tickers, fields, options = {}) {
1330
1483
  return await this.request({
1331
- service: "//blp/refdata",
1484
+ backend: options.backend,
1485
+ endDate: formatDate(options.end),
1486
+ extractor: "histdata",
1487
+ fields,
1488
+ format: options.format,
1489
+ kwargs: mapObjectToPairs(options.kwargs),
1332
1490
  operation: "HistoricalDataRequest",
1491
+ overrides: mapObjectToPairs(options.overrides),
1333
1492
  securities: tickers,
1334
- fields,
1493
+ service: "//blp/refdata",
1335
1494
  startDate: formatDate(options.start),
1336
- endDate: formatDate(options.end),
1337
- overrides: mapObjectToPairs(options.overrides),
1338
- kwargs: mapObjectToPairs(options.kwargs),
1339
- format: options.format,
1340
- backend: options.backend,
1341
- validateFields: options.validateFields,
1342
- extractor: "histdata"
1495
+ validateFields: options.validateFields
1343
1496
  });
1344
1497
  }
1345
1498
  async bdib(ticker, options = {}) {
1346
1499
  return await this.request({
1347
- service: "//blp/refdata",
1348
- operation: "IntradayBarRequest",
1349
- security: ticker,
1500
+ backend: options.backend,
1501
+ endDatetime: formatDateTime(options.end),
1350
1502
  eventType: options.eventType ?? "TRADE",
1503
+ extractor: "intraday_bar",
1351
1504
  interval: options.interval ?? 1,
1352
- startDatetime: formatDateTime(options.start),
1353
- endDatetime: formatDateTime(options.end),
1354
- requestTz: options.requestTz,
1355
- outputTz: options.outputTz,
1356
1505
  kwargs: mapObjectToPairs(options.kwargs),
1357
- backend: options.backend,
1358
- extractor: "intraday_bar"
1506
+ operation: "IntradayBarRequest",
1507
+ outputTz: options.outputTz,
1508
+ requestTz: options.requestTz,
1509
+ security: ticker,
1510
+ service: "//blp/refdata",
1511
+ startDatetime: formatDateTime(options.start)
1359
1512
  });
1360
1513
  }
1361
1514
  async bdtick(ticker, options = {}) {
1362
1515
  return await this.request({
1363
- service: "//blp/refdata",
1364
- operation: "IntradayTickRequest",
1365
- security: ticker,
1366
- eventTypes: options.eventTypes ?? ["TRADE"],
1367
- startDatetime: formatDateTime(options.start),
1516
+ backend: options.backend,
1368
1517
  endDatetime: formatDateTime(options.end),
1369
- requestTz: options.requestTz,
1370
- outputTz: options.outputTz,
1518
+ eventTypes: options.eventTypes ?? ["TRADE"],
1519
+ extractor: "intraday_tick",
1371
1520
  kwargs: buildBdtickKwargs(options),
1372
- backend: options.backend,
1373
- extractor: "intraday_tick"
1521
+ operation: "IntradayTickRequest",
1522
+ outputTz: options.outputTz,
1523
+ requestTz: options.requestTz,
1524
+ security: ticker,
1525
+ service: "//blp/refdata",
1526
+ startDatetime: formatDateTime(options.start)
1374
1527
  });
1375
1528
  }
1376
1529
  async bql(query, options = {}) {
1377
1530
  return await this.request({
1378
- service: "//blp/bqlsvc",
1379
- operation: "sendQuery",
1380
- elements: [{ key: "expression", value: toRequestString(query) }],
1381
1531
  backend: options.backend,
1382
- kwargs: mapObjectToPairs(options.kwargs),
1532
+ elements: [{ key: "expression", value: toRequestString(query) }],
1533
+ extractor: "bql",
1383
1534
  format: options.format,
1384
- extractor: "bql"
1535
+ kwargs: mapObjectToPairs(options.kwargs),
1536
+ operation: "sendQuery",
1537
+ service: "//blp/bqlsvc"
1385
1538
  });
1386
1539
  }
1387
1540
  async beqs(screen, options = {}) {
@@ -1396,108 +1549,108 @@ var Engine = class _Engine {
1396
1549
  elements.push({ key: "asOfDate", value: asofFormatted });
1397
1550
  }
1398
1551
  }
1399
- const overrides = { ...options.overrides ?? {} };
1552
+ const overrides = { ...options.overrides };
1400
1553
  return await this.request({
1401
- service: "//blp/refdata",
1402
- operation: "BeqsRequest",
1403
- elements,
1404
1554
  backend: options.backend,
1555
+ elements,
1556
+ extractor: "generic",
1557
+ format: options.format,
1405
1558
  kwargs: mapObjectToPairs(options.kwargs),
1559
+ operation: "BeqsRequest",
1406
1560
  overrides: mapObjectToPairs(overrides),
1407
- format: options.format,
1408
- extractor: "generic"
1561
+ service: "//blp/refdata"
1409
1562
  });
1410
1563
  }
1411
1564
  async bsrch(searchSpec, options = {}) {
1412
1565
  const elements = {
1413
1566
  Domain: toRequestString(searchSpec),
1414
- ...options.overrides ?? {},
1415
- ...options.kwargs ?? {}
1567
+ ...options.overrides,
1568
+ ...options.kwargs
1416
1569
  };
1417
1570
  return await this.request({
1418
- service: "//blp/exrsvc",
1419
- operation: "ExcelGetGridRequest",
1420
1571
  backend: options.backend,
1421
1572
  elements: mapObjectToPairs(elements),
1573
+ extractor: "bsrch",
1422
1574
  format: options.format,
1423
- extractor: "bsrch"
1575
+ operation: "ExcelGetGridRequest",
1576
+ service: "//blp/exrsvc"
1424
1577
  });
1425
1578
  }
1426
1579
  async bta(ticker, study, options = {}) {
1427
1580
  return await this.request({
1428
- service: "//blp/tasvc",
1429
- operation: "studyRequest",
1430
- elements: buildTaRequest(ticker, study, options),
1431
1581
  backend: options.backend,
1582
+ elements: buildTaRequest(ticker, study, options),
1583
+ extractor: "generic",
1432
1584
  format: options.format,
1433
- extractor: "generic"
1585
+ operation: "studyRequest",
1586
+ service: "//blp/tasvc"
1434
1587
  });
1435
1588
  }
1436
1589
  async bflds(options = {}) {
1437
1590
  if (options.searchSpec !== void 0) {
1438
1591
  return await this.request({
1439
- service: "//blp/apiflds",
1440
- operation: "FieldSearchRequest",
1441
- searchSpec: toRequestString(options.searchSpec),
1442
1592
  backend: options.backend,
1593
+ format: options.format,
1443
1594
  kwargs: mapObjectToPairs(options.kwargs),
1444
- format: options.format
1595
+ operation: "FieldSearchRequest",
1596
+ searchSpec: toRequestString(options.searchSpec),
1597
+ service: "//blp/apiflds"
1445
1598
  });
1446
1599
  }
1447
- const fields = Array.isArray(options.fields) ? options.fields : typeof options.fields === "string" ? [options.fields] : [];
1600
+ const fields = toStringArray(options.fields);
1448
1601
  return await this.request({
1449
- service: "//blp/apiflds",
1450
- operation: "FieldInfoRequest",
1451
- fieldIds: fields,
1452
1602
  backend: options.backend,
1603
+ fieldIds: fields,
1604
+ format: options.format,
1453
1605
  kwargs: mapObjectToPairs(options.kwargs),
1454
- format: options.format
1606
+ operation: "FieldInfoRequest",
1607
+ service: "//blp/apiflds"
1455
1608
  });
1456
1609
  }
1457
1610
  async blkp(query, options = {}) {
1458
1611
  return await this.request({
1459
- service: "//blp/instruments",
1460
- operation: "instrumentListRequest",
1461
- elements: [{ key: "query", value: toRequestString(query) }],
1462
1612
  backend: options.backend,
1613
+ elements: [{ key: "query", value: toRequestString(query) }],
1614
+ format: options.format,
1463
1615
  kwargs: mapObjectToPairs(options.kwargs),
1464
- format: options.format
1616
+ operation: "instrumentListRequest",
1617
+ service: "//blp/instruments"
1465
1618
  });
1466
1619
  }
1467
1620
  async bport(portfolio, fields, options = {}) {
1468
1621
  return await this.request({
1469
- service: "//blp/refdata",
1470
- operation: "PortfolioDataRequest",
1471
- security: toRequestString(portfolio),
1472
- fields: Array.isArray(fields) ? fields : [toRequestString(fields)],
1473
1622
  backend: options.backend,
1474
- overrides: mapObjectToPairs(options.overrides),
1623
+ fields: Array.isArray(fields) ? fields : [toRequestString(fields)],
1624
+ format: options.format,
1475
1625
  kwargs: mapObjectToPairs(options.kwargs),
1476
- format: options.format
1626
+ operation: "PortfolioDataRequest",
1627
+ overrides: mapObjectToPairs(options.overrides),
1628
+ security: toRequestString(portfolio),
1629
+ service: "//blp/refdata"
1477
1630
  });
1478
1631
  }
1479
1632
  async bcurves(ticker, options = {}) {
1480
1633
  return await this.request({
1481
- service: "//blp/instruments",
1482
- operation: "curveListRequest",
1483
- elements: [{ key: "query", value: toRequestString(ticker) }],
1484
1634
  backend: options.backend,
1635
+ elements: [{ key: "query", value: toRequestString(ticker) }],
1636
+ format: options.format,
1485
1637
  kwargs: mapObjectToPairs(options.kwargs),
1486
- format: options.format
1638
+ operation: "curveListRequest",
1639
+ service: "//blp/instruments"
1487
1640
  });
1488
1641
  }
1489
1642
  async bgovts(ticker, options = {}) {
1490
1643
  return await this.request({
1491
- service: "//blp/instruments",
1492
- operation: "govtListRequest",
1493
- elements: [{ key: "query", value: toRequestString(ticker) }],
1494
1644
  backend: options.backend,
1645
+ elements: [{ key: "query", value: toRequestString(ticker) }],
1646
+ format: options.format,
1495
1647
  kwargs: mapObjectToPairs(options.kwargs),
1496
- format: options.format
1648
+ operation: "govtListRequest",
1649
+ service: "//blp/instruments"
1497
1650
  });
1498
1651
  }
1499
1652
  async resolveFieldTypes(fields, overrides, defaultType = "string") {
1500
- const items = await this._inner.resolveFieldTypes(
1653
+ const items = await this.inner.resolveFieldTypes(
1501
1654
  fields,
1502
1655
  mapObjectToPairs(overrides),
1503
1656
  defaultType
@@ -1505,55 +1658,55 @@ var Engine = class _Engine {
1505
1658
  return Object.fromEntries(items.map((item) => [item.key, item.value]));
1506
1659
  }
1507
1660
  getFieldInfo(field) {
1508
- return this._inner.getFieldInfo(field);
1661
+ return this.inner.getFieldInfo(field);
1509
1662
  }
1510
1663
  clearFieldCache() {
1511
- this._inner.clearFieldCache();
1664
+ this.inner.clearFieldCache();
1512
1665
  }
1513
1666
  saveFieldCache() {
1514
- this._inner.saveFieldCache();
1667
+ this.inner.saveFieldCache();
1515
1668
  }
1516
1669
  async validateFields(fields) {
1517
- return await this._inner.validateFields(fields);
1670
+ return await this.inner.validateFields(fields);
1518
1671
  }
1519
1672
  isFieldValidationEnabled() {
1520
- return this._inner.isFieldValidationEnabled();
1673
+ return this.inner.isFieldValidationEnabled();
1521
1674
  }
1522
1675
  async getSchema(service) {
1523
- const json = await this._inner.getSchema(service);
1676
+ const json = await this.inner.getSchema(service);
1524
1677
  return JSON.parse(json);
1525
1678
  }
1526
1679
  async getOperation(service, operation) {
1527
- const json = await this._inner.getOperation(service, operation);
1680
+ const json = await this.inner.getOperation(service, operation);
1528
1681
  return JSON.parse(json);
1529
1682
  }
1530
1683
  async listOperations(service) {
1531
- return await this._inner.listOperations(service);
1684
+ return await this.inner.listOperations(service);
1532
1685
  }
1533
1686
  getCachedSchema(service) {
1534
- const json = this._inner.getCachedSchema(service);
1687
+ const json = this.inner.getCachedSchema(service);
1535
1688
  return json === null ? null : JSON.parse(json);
1536
1689
  }
1537
1690
  invalidateSchema(service) {
1538
- this._inner.invalidateSchema(service);
1691
+ this.inner.invalidateSchema(service);
1539
1692
  }
1540
1693
  clearSchemaCache() {
1541
- this._inner.clearSchemaCache();
1694
+ this.inner.clearSchemaCache();
1542
1695
  }
1543
1696
  listCachedSchemas() {
1544
- return this._inner.listCachedSchemas();
1697
+ return this.inner.listCachedSchemas();
1545
1698
  }
1546
1699
  async getEnumValues(service, operation, element) {
1547
- return await this._inner.getEnumValues(service, operation, element);
1700
+ return await this.inner.getEnumValues(service, operation, element);
1548
1701
  }
1549
1702
  async listValidElements(service, operation) {
1550
- return await this._inner.listValidElements(service, operation);
1703
+ return await this.inner.listValidElements(service, operation);
1551
1704
  }
1552
1705
  async subscribe(tickers, fields, options = {}) {
1553
1706
  try {
1554
1707
  const subscriptionOptions = buildStreamSubscriptionOptions(MKTDATA_SERVICE, options);
1555
1708
  const useOptions = subscriptionOptions !== void 0 || options.flushThreshold !== void 0 || options.overflowPolicy !== void 0 || options.streamCapacity !== void 0;
1556
- const stream = useOptions ? await this._inner.subscribeWithOptions(
1709
+ const stream = useOptions ? await this.inner.subscribeWithOptions(
1557
1710
  MKTDATA_SERVICE,
1558
1711
  tickers,
1559
1712
  fields,
@@ -1562,15 +1715,15 @@ var Engine = class _Engine {
1562
1715
  options.overflowPolicy,
1563
1716
  options.streamCapacity,
1564
1717
  options.allFields
1565
- ) : await this._inner.subscribe(tickers, fields, options.allFields);
1718
+ ) : await this.inner.subscribe(tickers, fields, options.allFields);
1566
1719
  return new Subscription(stream);
1567
- } catch (err) {
1568
- throw wrapError(err);
1720
+ } catch (error) {
1721
+ throw wrapError(error);
1569
1722
  }
1570
1723
  }
1571
1724
  async subscribeWithOptions(service, tickers, fields, options, flushThreshold, overflowPolicy, streamCapacity, allFields) {
1572
1725
  try {
1573
- const stream = await this._inner.subscribeWithOptions(
1726
+ const stream = await this.inner.subscribeWithOptions(
1574
1727
  service,
1575
1728
  tickers,
1576
1729
  fields,
@@ -1581,15 +1734,15 @@ var Engine = class _Engine {
1581
1734
  allFields
1582
1735
  );
1583
1736
  return new Subscription(stream);
1584
- } catch (err) {
1585
- throw wrapError(err);
1737
+ } catch (error) {
1738
+ throw wrapError(error);
1586
1739
  }
1587
1740
  }
1588
1741
  signalShutdown() {
1589
- this._inner.signalShutdown();
1742
+ this.inner.signalShutdown();
1590
1743
  }
1591
1744
  isAvailable() {
1592
- return this._inner.isAvailable();
1745
+ return this.inner.isAvailable();
1593
1746
  }
1594
1747
  async stream(tickers, fields, options = {}) {
1595
1748
  return await this.subscribeWithOptions(
@@ -1652,19 +1805,19 @@ var Engine = class _Engine {
1652
1805
  );
1653
1806
  }
1654
1807
  async bops(service) {
1655
- return await this._inner.listOperations(service);
1808
+ return await this.inner.listOperations(service);
1656
1809
  }
1657
1810
  async bschema(service, operation) {
1658
1811
  if (operation !== void 0) {
1659
- const json2 = await this._inner.getOperation(service, operation);
1812
+ const json2 = await this.inner.getOperation(service, operation);
1660
1813
  return JSON.parse(json2);
1661
1814
  }
1662
- const json = await this._inner.getSchema(service);
1815
+ const json = await this.inner.getSchema(service);
1663
1816
  return JSON.parse(json);
1664
1817
  }
1665
1818
  async fieldInfo(fields, options = {}) {
1666
1819
  return await this.bflds({
1667
- fields: Array.isArray(fields) ? fields : [toRequestString(fields)],
1820
+ fields: toStringArray(fields),
1668
1821
  ...options
1669
1822
  });
1670
1823
  }
@@ -1675,7 +1828,7 @@ var Engine = class _Engine {
1675
1828
  async bqr(ticker, options = {}) {
1676
1829
  const backend = normalizeBackend(options.backend);
1677
1830
  try {
1678
- const buffer = await this._inner.recipeBqr(
1831
+ const buffer = await this.inner.recipeBqr(
1679
1832
  toRequestString(ticker),
1680
1833
  formatDateTime(options.startDatetime),
1681
1834
  formatDateTime(options.endDatetime),
@@ -1683,14 +1836,14 @@ var Engine = class _Engine {
1683
1836
  options.includeBrokerCodes !== false
1684
1837
  );
1685
1838
  return ipcToBackend(buffer, backend);
1686
- } catch (err) {
1687
- throw wrapError(err);
1839
+ } catch (error) {
1840
+ throw wrapError(error);
1688
1841
  }
1689
1842
  }
1690
1843
  async yas(tickers, fields, options = {}) {
1691
1844
  const backend = normalizeBackend(options.backend);
1692
1845
  try {
1693
- const buffer = await this._inner.recipeYas(
1846
+ const buffer = await this.inner.recipeYas(
1694
1847
  toStringArray(tickers),
1695
1848
  toStringArray(fields),
1696
1849
  formatDate(options.settleDt),
@@ -1701,105 +1854,135 @@ var Engine = class _Engine {
1701
1854
  options.benchmark ?? void 0
1702
1855
  );
1703
1856
  return ipcToBackend(buffer, backend);
1704
- } catch (err) {
1705
- throw wrapError(err);
1857
+ } catch (error) {
1858
+ throw wrapError(error);
1706
1859
  }
1707
1860
  }
1708
1861
  async preferreds(equityTicker, options = {}) {
1709
1862
  const backend = normalizeBackend(options.backend);
1710
1863
  try {
1711
- const buffer = await this._inner.recipePreferreds(
1864
+ const buffer = await this.inner.recipePreferreds(
1712
1865
  toRequestString(equityTicker),
1713
1866
  options.fields !== void 0 ? toStringArray(options.fields) : null
1714
1867
  );
1715
1868
  return ipcToBackend(buffer, backend);
1716
- } catch (err) {
1717
- throw wrapError(err);
1869
+ } catch (error) {
1870
+ throw wrapError(error);
1718
1871
  }
1719
1872
  }
1720
1873
  async corporateBonds(ticker, options = {}) {
1721
1874
  const backend = normalizeBackend(options.backend);
1722
1875
  try {
1723
- const buffer = await this._inner.recipeCorporateBonds(
1876
+ const buffer = await this.inner.recipeCorporateBonds(
1724
1877
  toRequestString(ticker),
1725
1878
  options.ccy ?? void 0,
1726
1879
  options.fields !== void 0 ? toStringArray(options.fields) : null,
1727
1880
  options.activeOnly !== false
1728
1881
  );
1729
1882
  return ipcToBackend(buffer, backend);
1730
- } catch (err) {
1731
- throw wrapError(err);
1883
+ } catch (error) {
1884
+ throw wrapError(error);
1732
1885
  }
1733
1886
  }
1734
1887
  async futTicker(genTicker, dt, options = {}) {
1735
1888
  const backend = normalizeBackend(options.backend);
1736
1889
  try {
1737
- const buffer = await this._inner.recipeFutTicker(
1890
+ const buffer = await this.inner.recipeFutTicker(
1738
1891
  toRequestString(genTicker),
1739
1892
  formatDate(dt) ?? "",
1740
1893
  options.freq ?? void 0
1741
1894
  );
1742
1895
  return ipcToBackend(buffer, backend);
1743
- } catch (err) {
1744
- throw wrapError(err);
1896
+ } catch (error) {
1897
+ throw wrapError(error);
1745
1898
  }
1746
1899
  }
1747
1900
  async activeFutures(genTicker, dt, options = {}) {
1748
1901
  const backend = normalizeBackend(options.backend);
1749
1902
  try {
1750
- const buffer = await this._inner.recipeActiveFutures(
1903
+ const buffer = await this.inner.recipeActiveFutures(
1751
1904
  toRequestString(genTicker),
1752
1905
  formatDate(dt) ?? "",
1753
1906
  options.freq ?? void 0
1754
1907
  );
1755
1908
  return ipcToBackend(buffer, backend);
1756
- } catch (err) {
1757
- throw wrapError(err);
1909
+ } catch (error) {
1910
+ throw wrapError(error);
1911
+ }
1912
+ }
1913
+ async futuresCurve(genTicker, options = {}) {
1914
+ const backend = normalizeBackend(options.backend);
1915
+ try {
1916
+ const buffer = await this.inner.recipeFuturesCurve(
1917
+ toRequestString(genTicker),
1918
+ options.asof === void 0 ? void 0 : formatDate(options.asof) ?? "",
1919
+ options.chainField ?? void 0,
1920
+ options.fields !== void 0 ? toStringArray(options.fields) : null,
1921
+ options.maxContracts ?? void 0
1922
+ );
1923
+ return ipcToBackend(buffer, backend);
1924
+ } catch (error) {
1925
+ throw wrapError(error);
1758
1926
  }
1759
1927
  }
1760
1928
  async cdxTicker(genTicker, dt, options = {}) {
1761
1929
  const backend = normalizeBackend(options.backend);
1762
1930
  try {
1763
- const buffer = await this._inner.recipeCdxTicker(
1931
+ const buffer = await this.inner.recipeCdxTicker(
1764
1932
  toRequestString(genTicker),
1765
1933
  formatDate(dt) ?? ""
1766
1934
  );
1767
1935
  return ipcToBackend(buffer, backend);
1768
- } catch (err) {
1769
- throw wrapError(err);
1936
+ } catch (error) {
1937
+ throw wrapError(error);
1770
1938
  }
1771
1939
  }
1772
1940
  async activeCdx(genTicker, dt, options = {}) {
1773
1941
  const backend = normalizeBackend(options.backend);
1774
1942
  try {
1775
- const buffer = await this._inner.recipeActiveCdx(
1943
+ const buffer = await this.inner.recipeActiveCdx(
1776
1944
  toRequestString(genTicker),
1777
1945
  formatDate(dt) ?? "",
1778
1946
  options.lookbackDays ?? void 0
1779
1947
  );
1780
1948
  return ipcToBackend(buffer, backend);
1781
- } catch (err) {
1782
- throw wrapError(err);
1949
+ } catch (error) {
1950
+ throw wrapError(error);
1783
1951
  }
1784
1952
  }
1785
1953
  async dividend(tickers, startDate, endDate, options = {}) {
1786
1954
  const backend = normalizeBackend(options.backend);
1787
1955
  try {
1788
- const buffer = await this._inner.recipeDividend(
1956
+ const buffer = await this.inner.recipeDividend(
1789
1957
  toStringArray(tickers),
1790
1958
  formatDate(startDate) ?? "",
1791
1959
  formatDate(endDate) ?? "",
1792
1960
  options.dvdType ?? void 0
1793
1961
  );
1794
1962
  return ipcToBackend(buffer, backend);
1795
- } catch (err) {
1796
- throw wrapError(err);
1963
+ } catch (error) {
1964
+ throw wrapError(error);
1965
+ }
1966
+ }
1967
+ async dividendYield(tickers, startDate, endDate, options = {}) {
1968
+ const backend = normalizeBackend(options.backend);
1969
+ try {
1970
+ const buffer = await this.inner.recipeDividendYield(
1971
+ toStringArray(tickers),
1972
+ formatDate(startDate) ?? "",
1973
+ formatDate(endDate) ?? "",
1974
+ options.dividendTypes !== void 0 ? toStringArray(options.dividendTypes) : null,
1975
+ options.windowDays ?? void 0
1976
+ );
1977
+ return ipcToBackend(buffer, backend);
1978
+ } catch (error) {
1979
+ throw wrapError(error);
1797
1980
  }
1798
1981
  }
1799
1982
  async turnover(tickers, startDate, endDate, options = {}) {
1800
1983
  const backend = normalizeBackend(options.backend);
1801
1984
  try {
1802
- const buffer = await this._inner.recipeTurnover(
1985
+ const buffer = await this.inner.recipeTurnover(
1803
1986
  toStringArray(tickers),
1804
1987
  formatDate(startDate) ?? "",
1805
1988
  formatDate(endDate) ?? "",
@@ -1807,41 +1990,89 @@ var Engine = class _Engine {
1807
1990
  options.factor ?? void 0
1808
1991
  );
1809
1992
  return ipcToBackend(buffer, backend);
1810
- } catch (err) {
1811
- throw wrapError(err);
1993
+ } catch (error) {
1994
+ throw wrapError(error);
1812
1995
  }
1813
1996
  }
1814
1997
  async etfHoldings(etfTicker, options = {}) {
1815
1998
  const backend = normalizeBackend(options.backend);
1816
1999
  try {
1817
- const buffer = await this._inner.recipeEtfHoldings(
2000
+ const buffer = await this.inner.recipeEtfHoldings(
1818
2001
  toRequestString(etfTicker),
1819
2002
  options.fields !== void 0 ? toStringArray(options.fields) : null
1820
2003
  );
1821
2004
  return ipcToBackend(buffer, backend);
1822
- } catch (err) {
1823
- throw wrapError(err);
2005
+ } catch (error) {
2006
+ throw wrapError(error);
2007
+ }
2008
+ }
2009
+ async volSurface(tickers, startDate, endDate, options = {}) {
2010
+ const backend = normalizeBackend(options.backend);
2011
+ try {
2012
+ const buffer = await this.inner.recipeVolSurface(
2013
+ toStringArray(tickers),
2014
+ formatDate(startDate) ?? "",
2015
+ formatDate(endDate) ?? "",
2016
+ normalizeVolPresets(options.preset ?? "MONEYNESS_30D"),
2017
+ normalizeVolFieldSpecs(options.fields),
2018
+ options.asDecimal ?? true,
2019
+ options.includeDerived ?? false,
2020
+ options.riskFreeRate ?? void 0,
2021
+ options.dividendYieldField ?? void 0
2022
+ );
2023
+ return ipcToBackend(buffer, backend);
2024
+ } catch (error) {
2025
+ throw wrapError(error);
2026
+ }
2027
+ }
2028
+ async indexMembers(index, options = {}) {
2029
+ const backend = normalizeBackend(options.backend);
2030
+ try {
2031
+ const buffer = await this.inner.recipeIndexMembers(
2032
+ toRequestString(index),
2033
+ options.field ?? void 0,
2034
+ options.asof === void 0 ? void 0 : formatDate(options.asof) ?? ""
2035
+ );
2036
+ return ipcToBackend(buffer, backend);
2037
+ } catch (error) {
2038
+ throw wrapError(error);
2039
+ }
2040
+ }
2041
+ async resolveIsins(isins, options = {}) {
2042
+ const backend = normalizeBackend(options.backend);
2043
+ try {
2044
+ const buffer = await this.inner.recipeResolveIsins(toStringArray(isins));
2045
+ return ipcToBackend(buffer, backend);
2046
+ } catch (error) {
2047
+ throw wrapError(error);
2048
+ }
2049
+ }
2050
+ async issuerIsins(bondIsins, options = {}) {
2051
+ const backend = normalizeBackend(options.backend);
2052
+ try {
2053
+ const buffer = await this.inner.recipeIssuerIsins(toStringArray(bondIsins));
2054
+ return ipcToBackend(buffer, backend);
2055
+ } catch (error) {
2056
+ throw wrapError(error);
1824
2057
  }
1825
2058
  }
1826
2059
  async currencyConversion(ticker, targetCcy, startDate, endDate, options = {}) {
1827
2060
  const backend = normalizeBackend(options.backend);
1828
2061
  try {
1829
- const buffer = await this._inner.recipeCurrencyConversion(
2062
+ const buffer = await this.inner.recipeCurrencyConversion(
1830
2063
  toRequestString(ticker),
1831
2064
  toRequestString(targetCcy),
1832
2065
  formatDate(startDate) ?? "",
1833
2066
  formatDate(endDate) ?? ""
1834
2067
  );
1835
2068
  return ipcToBackend(buffer, backend);
1836
- } catch (err) {
1837
- throw wrapError(err);
2069
+ } catch (error) {
2070
+ throw wrapError(error);
1838
2071
  }
1839
2072
  }
1840
2073
  };
1841
2074
  async function connect(config) {
1842
- return await Promise.resolve(
1843
- config === void 0 ? new Engine() : Engine.withConfig(config)
1844
- );
2075
+ return await Promise.resolve(config === void 0 ? new Engine() : Engine.withConfig(config));
1845
2076
  }
1846
2077
  function configure(configOrHost, port) {
1847
2078
  configuredEngineConfig = normalizeConfigureArgs(configOrHost, port);
@@ -1857,17 +2088,16 @@ async function bdp(tickers, fields, options = {}) {
1857
2088
  }
1858
2089
  async function abdh(tickers, fields, start, end, options = {}) {
1859
2090
  const engine = await getConfiguredEngine();
1860
- if (isPlainObject(start) && !(start instanceof Date) && !hasToJSDate(start) && end === void 0) {
1861
- return await engine.bdh(
1862
- toStringArray(tickers),
1863
- toStringArray(fields),
1864
- start
1865
- );
2091
+ if (isBdhOptionsInput(start)) {
2092
+ if (end !== void 0) {
2093
+ throw new TypeError("abdh options object cannot be combined with a positional end date");
2094
+ }
2095
+ return await engine.bdh(toStringArray(tickers), toStringArray(fields), start);
1866
2096
  }
1867
2097
  return await engine.bdh(toStringArray(tickers), toStringArray(fields), {
1868
2098
  ...options,
1869
- start,
1870
- end
2099
+ end,
2100
+ start
1871
2101
  });
1872
2102
  }
1873
2103
  async function bdh(tickers, fields, options = {}) {
@@ -1875,25 +2105,20 @@ async function bdh(tickers, fields, options = {}) {
1875
2105
  }
1876
2106
  async function abds(tickers, fields, overrides, options = {}) {
1877
2107
  const engine = await getConfiguredEngine();
1878
- const normalizedOptions = isPlainObject(overrides) ? { ...options, overrides: { ...options.overrides ?? {}, ...overrides } } : options;
1879
- return await engine.bds(
1880
- toStringArray(tickers),
1881
- toStringArray(fields),
1882
- normalizedOptions
1883
- );
2108
+ const normalizedOptions = isPlainObject(overrides) ? { ...options, overrides: { ...options.overrides, ...overrides } } : options;
2109
+ return await engine.bds(toStringArray(tickers), toStringArray(fields), normalizedOptions);
1884
2110
  }
1885
2111
  async function bds(tickers, fields, options = {}) {
1886
2112
  return await abds(tickers, fields, void 0, options);
1887
2113
  }
1888
2114
  async function abdib(ticker, dt, interval = 1, options = {}) {
1889
2115
  const engine = await getConfiguredEngine();
1890
- const dtIsOptions = isPlainObject(dt) && !(dt instanceof Date) && !hasToJSDate(dt);
1891
- if (dtIsOptions && interval === 1 && Object.keys(options).length === 0) {
2116
+ if (isBdibOptionsInput(dt) && interval === 1 && Object.keys(options).length === 0) {
1892
2117
  return await engine.bdib(toRequestString(ticker), dt);
1893
2118
  }
1894
- const normalizedOptions = isPlainObject(interval) ? { ...interval } : { ...options, interval: typeof interval === "number" ? interval : 1 };
2119
+ const normalizedOptions = isBdibOptionsInput(interval) ? { ...interval } : { ...options, interval: typeof interval === "number" ? interval : 1 };
1895
2120
  if (normalizedOptions.start === void 0 && normalizedOptions.end === void 0) {
1896
- if (dt === void 0) {
2121
+ if (dt === void 0 || isBdibOptionsInput(dt)) {
1897
2122
  throw new TypeError("abdib requires dt or explicit start/end options");
1898
2123
  }
1899
2124
  const range = fullDayRange(dt);
@@ -1910,7 +2135,7 @@ async function abdtick(ticker, start, end, options = {}) {
1910
2135
  throw new TypeError("abdtick requires both start and end datetimes");
1911
2136
  }
1912
2137
  const engine = await getConfiguredEngine();
1913
- return await engine.bdtick(toRequestString(ticker), { ...options, start, end });
2138
+ return await engine.bdtick(toRequestString(ticker), { ...options, end, start });
1914
2139
  }
1915
2140
  async function bdtick(ticker, options = {}) {
1916
2141
  const engine = await getConfiguredEngine();
@@ -1944,76 +2169,76 @@ async function acdxRisk(ticker, options = {}) {
1944
2169
  );
1945
2170
  }
1946
2171
  var blp = Object.freeze({
1947
- bdp,
1948
- bdh,
1949
- bds,
1950
- bdib,
1951
- bdtick,
1952
- subscribe,
1953
- abdp,
1954
2172
  abdh,
1955
- abds,
1956
2173
  abdib,
2174
+ abdp,
2175
+ abds,
1957
2176
  abdtick,
1958
- asubscribe
2177
+ asubscribe,
2178
+ bdh,
2179
+ bdib,
2180
+ bdp,
2181
+ bds,
2182
+ bdtick,
2183
+ subscribe
1959
2184
  });
1960
2185
  var ext = Object.freeze({
2186
+ buildCorporateBondsQuery: native.extBuildCorporateBondsQuery,
2187
+ buildEarningHeaderRename: native.extBuildEarningHeaderRename,
2188
+ buildEtfHoldingsQuery: native.extBuildEtfHoldingsQuery,
2189
+ buildFuturesTicker: native.extBuildFuturesTicker,
2190
+ buildFxPair: native.extBuildFxPair,
2191
+ buildPreferredsQuery: native.extBuildPreferredsQuery,
2192
+ buildYasOverrides: native.extBuildYasOverrides,
2193
+ calculateLevelPercentages: native.extCalculateLevelPercentages,
1961
2194
  cdx: Object.freeze({
1962
2195
  acdx_info: acdxInfo,
1963
2196
  acdx_pricing: acdxPricing,
1964
2197
  acdx_risk: acdxRisk
1965
2198
  }),
1966
- parseDate: native.extParseDate,
1967
- fmtDate: native.extFmtDate,
1968
- pivotToWide: native.extPivotToWide,
1969
- isLongFormat: native.extIsLongFormat,
1970
- parseTicker: native.extParseTicker,
1971
- isSpecificContract: native.extIsSpecificContract,
1972
- buildFuturesTicker: native.extBuildFuturesTicker,
1973
- normalizeTickers: native.extNormalizeTickers,
1974
- filterEquityTickers: native.extFilterEquityTickers,
1975
- generateFuturesCandidates: native.extGenerateFuturesCandidates,
1976
- validateGenericTicker: native.extValidateGenericTicker,
2199
+ cdxGenToSpecific: native.extCdxGenToSpecific,
2200
+ clearExchangeOverride: native.extClearExchangeOverride,
1977
2201
  contractIndex: native.extContractIndex,
2202
+ currenciesNeedingConversion: native.extCurrenciesNeedingConversion,
2203
+ defaultBqrDatetimes: native.extDefaultBqrDatetimes,
2204
+ defaultTurnoverDates: native.extDefaultTurnoverDates,
2205
+ deriveSessions: native.extDeriveSessions,
1978
2206
  filterCandidatesByCycle: native.extFilterCandidatesByCycle,
2207
+ filterEquityTickers: native.extFilterEquityTickers,
1979
2208
  filterValidContracts: native.extFilterValidContracts,
1980
- parseCdxTicker: native.extParseCdxTicker,
1981
- previousCdxSeries: native.extPreviousCdxSeries,
1982
- cdxGenToSpecific: native.extCdxGenToSpecific,
1983
- buildFxPair: native.extBuildFxPair,
1984
- sameCurrency: native.extSameCurrency,
1985
- currenciesNeedingConversion: native.extCurrenciesNeedingConversion,
1986
- renameDividendColumns: native.extRenameDividendColumns,
1987
- renameEtfColumns: native.extRenameEtfColumns,
1988
- getMonthCode: native.extGetMonthCode,
1989
- getMonthName: native.extGetMonthName,
1990
- getFuturesMonths: native.extGetFuturesMonths,
2209
+ fmtDate: native.extFmtDate,
2210
+ generateFuturesCandidates: native.extGenerateFuturesCandidates,
2211
+ getDvdCols: native.extGetDvdCols,
1991
2212
  getDvdType: native.extGetDvdType,
1992
2213
  getDvdTypes: native.extGetDvdTypes,
1993
- getDvdCols: native.extGetDvdCols,
1994
2214
  getEtfCols: native.extGetEtfCols,
1995
- buildYasOverrides: native.extBuildYasOverrides,
1996
- buildEarningHeaderRename: native.extBuildEarningHeaderRename,
1997
- calculateLevelPercentages: native.extCalculateLevelPercentages,
1998
- buildPreferredsQuery: native.extBuildPreferredsQuery,
1999
- buildCorporateBondsQuery: native.extBuildCorporateBondsQuery,
2000
- buildEtfHoldingsQuery: native.extBuildEtfHoldingsQuery,
2001
- defaultTurnoverDates: native.extDefaultTurnoverDates,
2002
- defaultBqrDatetimes: native.extDefaultBqrDatetimes,
2003
- deriveSessions: native.extDeriveSessions,
2215
+ getExchangeOverride: native.extGetExchangeOverride,
2216
+ getFuturesMonths: native.extGetFuturesMonths,
2004
2217
  getMarketRule: native.extGetMarketRule,
2218
+ getMonthCode: native.extGetMonthCode,
2219
+ getMonthName: native.extGetMonthName,
2005
2220
  inferTimezone: native.extInferTimezone,
2006
- setExchangeOverride: native.extSetExchangeOverride,
2007
- getExchangeOverride: native.extGetExchangeOverride,
2008
- clearExchangeOverride: native.extClearExchangeOverride,
2221
+ isLongFormat: native.extIsLongFormat,
2222
+ isSpecificContract: native.extIsSpecificContract,
2009
2223
  listExchangeOverrides: native.extListExchangeOverrides,
2010
- sessionTimesToUtc: native.extSessionTimesToUtc
2224
+ normalizeTickers: native.extNormalizeTickers,
2225
+ parseCdxTicker: native.extParseCdxTicker,
2226
+ parseDate: native.extParseDate,
2227
+ parseTicker: native.extParseTicker,
2228
+ pivotToWide: native.extPivotToWide,
2229
+ previousCdxSeries: native.extPreviousCdxSeries,
2230
+ renameDividendColumns: native.extRenameDividendColumns,
2231
+ renameEtfColumns: native.extRenameEtfColumns,
2232
+ sameCurrency: native.extSameCurrency,
2233
+ sessionTimesToUtc: native.extSessionTimesToUtc,
2234
+ setExchangeOverride: native.extSetExchangeOverride,
2235
+ validateGenericTicker: native.extValidateGenericTicker
2011
2236
  });
2012
2237
  function version() {
2013
2238
  return packageJson.version;
2014
2239
  }
2015
- var setLogLevel = native.setLogLevel;
2016
- var getLogLevel = native.getLogLevel;
2240
+ var { setLogLevel } = native;
2241
+ var { getLogLevel } = native;
2017
2242
 
2018
2243
  exports.ArrowSubscription = ArrowSubscription;
2019
2244
  exports.Backend = Backend;