@xbbg/core 1.2.1 → 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,90 +176,137 @@ 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) {
300
276
  const buffer = requireBuffer(column, "data");
277
+ assertBufferByteLength(column, "data", buffer, column.length, ctor.BYTES_PER_ELEMENT);
301
278
  retainedBuffers.push(buffer);
302
279
  return new ctor(buffer.buffer, buffer.byteOffset, column.length);
303
280
  }
304
281
  function requiredOffsets(column, retainedBuffers) {
305
282
  const buffer = requireBuffer(column, "offsets");
283
+ assertBufferByteLength(
284
+ column,
285
+ "offsets",
286
+ buffer,
287
+ column.length + 1,
288
+ Int32Array.BYTES_PER_ELEMENT
289
+ );
306
290
  retainedBuffers.push(buffer);
307
291
  return new Int32Array(buffer.buffer, buffer.byteOffset, column.length + 1);
308
292
  }
309
293
  function requiredLargeOffsets(column, retainedBuffers) {
310
294
  const buffer = requireBuffer(column, "offsets");
295
+ assertBufferByteLength(
296
+ column,
297
+ "offsets",
298
+ buffer,
299
+ column.length + 1,
300
+ BigInt64Array.BYTES_PER_ELEMENT
301
+ );
311
302
  retainedBuffers.push(buffer);
312
303
  return new BigInt64Array(buffer.buffer, buffer.byteOffset, column.length + 1);
313
304
  }
314
305
  function requiredUint8View(column, retainedBuffers, byteLength) {
315
306
  const buffer = requireBuffer(column, "data");
307
+ if (byteLength !== void 0) {
308
+ assertBufferByteLength(column, "data", buffer, byteLength, 1);
309
+ }
316
310
  retainedBuffers.push(buffer);
317
311
  return new Uint8Array(buffer.buffer, buffer.byteOffset, byteLength ?? buffer.byteLength);
318
312
  }
@@ -323,6 +317,19 @@ function optionalUint8View(buffer, retainedBuffers) {
323
317
  retainedBuffers.push(buffer);
324
318
  return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
325
319
  }
320
+ function assertBufferByteLength(column, property, buffer, elements, bytesPerElement) {
321
+ if (!Number.isSafeInteger(elements) || elements < 0) {
322
+ throw new Error(
323
+ `native Arrow column ${column.name} has invalid ${property} element count: ${elements}`
324
+ );
325
+ }
326
+ const requiredBytes = elements * bytesPerElement;
327
+ if (!Number.isSafeInteger(requiredBytes) || buffer.byteLength < requiredBytes) {
328
+ throw new Error(
329
+ `native Arrow column ${column.name} ${property} buffer is too small: expected at least ${requiredBytes} bytes, got ${buffer.byteLength}`
330
+ );
331
+ }
332
+ }
326
333
  function requireBuffer(column, property) {
327
334
  const buffer = column[property];
328
335
  if (buffer === void 0) {
@@ -332,9 +339,9 @@ function requireBuffer(column, property) {
332
339
  }
333
340
 
334
341
  // src/dates.ts
335
- var ISO_DATE_RE = /^\d{4}[-/]\d{2}[-/]\d{2}$/;
336
- var BBG_DATE_RE = /^\d{8}$/;
337
- 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;
338
345
  function hasToJSDate(value) {
339
346
  return typeof value === "object" && value !== null && "toJSDate" in value && typeof value.toJSDate === "function";
340
347
  }
@@ -377,9 +384,7 @@ function dateLikeToJSDate(value) {
377
384
  }
378
385
  return dt;
379
386
  }
380
- throw new TypeError(
381
- `Cannot convert ${typeof value} value ${String(value)} to a Date.`
382
- );
387
+ throw new TypeError(`Cannot convert ${typeof value} value ${String(value)} to a Date.`);
383
388
  }
384
389
  function formatDate(value) {
385
390
  if (value === void 0 || value === null) {
@@ -395,7 +400,7 @@ function formatDate(value) {
395
400
  }
396
401
  rejectAmbiguousString(text);
397
402
  if (ISO_DATE_RE.test(text)) {
398
- return text.replace(/[-/]/g, "");
403
+ return text.replaceAll(/[-/]/gu, "");
399
404
  }
400
405
  }
401
406
  const date = dateLikeToJSDate(value);
@@ -423,6 +428,87 @@ function formatDateTime(value) {
423
428
  return date.toISOString();
424
429
  }
425
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
+
426
512
  // src/native/platform-map.ts
427
513
  var platformPackages = Object.freeze({
428
514
  "darwin-arm64": "@xbbg/core-darwin-arm64",
@@ -454,7 +540,7 @@ function validateNativePackage(packageName, resolved) {
454
540
  throw new Error(`Invalid native package ${packageName}: missing binaryPath`);
455
541
  }
456
542
  if (typeof resolved.binaryPath !== "string") {
457
- 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`);
458
544
  }
459
545
  return resolved;
460
546
  }
@@ -481,11 +567,11 @@ function resolveInstalledPackage(packageName, requirePackage, existsFile) {
481
567
  );
482
568
  }
483
569
  return resolved;
484
- } catch (err) {
485
- if (isOptionalPackageMissing(err, packageName)) {
570
+ } catch (error) {
571
+ if (isOptionalPackageMissing(error, packageName)) {
486
572
  return null;
487
573
  }
488
- throw err;
574
+ throw error;
489
575
  }
490
576
  }
491
577
  function resolveLocalPackage(repoRoot, packageName, requirePackage, existsFile) {
@@ -504,33 +590,65 @@ function resolveLocalPackage(repoRoot, packageName, requirePackage, existsFile)
504
590
  function resolveNativeAddonCore(options) {
505
591
  const { key, packageName, repoRoot, requirePackage, exists: existsFile } = options;
506
592
  if (packageName === null) {
507
- return { key, packageName: null, binaryPath: null };
593
+ return { binaryPath: null, key, packageName: null };
508
594
  }
509
595
  const installed = resolveInstalledPackage(packageName, requirePackage, existsFile);
510
596
  if (installed !== null) {
511
- return { key, packageName, binaryPath: installed.binaryPath };
597
+ return { binaryPath: installed.binaryPath, key, packageName };
512
598
  }
513
599
  const local = resolveLocalPackage(repoRoot, packageName, requirePackage, existsFile);
514
600
  if (local !== null) {
515
- return { key, packageName, binaryPath: local.binaryPath };
601
+ return { binaryPath: local.binaryPath, key, packageName };
516
602
  }
517
- return { key, packageName, binaryPath: null };
603
+ return { binaryPath: null, key, packageName };
518
604
  }
519
605
  function resolveNativeAddon(repoRoot) {
520
606
  const key = platformKey();
521
607
  const packageName = platformPackages[key] ?? null;
522
608
  return resolveNativeAddonCore({
609
+ exists,
523
610
  key,
524
611
  packageName,
525
612
  repoRoot,
526
- requirePackage: (id) => nodeRequire(id),
527
- exists
613
+ requirePackage: (id) => nodeRequire(id)
528
614
  });
529
615
  }
530
616
 
531
617
  // src/index.ts
532
618
  var nodeRequire2 = module$1.createRequire(__filename);
533
- 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"));
534
652
  function containsBlpapiRuntime(dir) {
535
653
  if (dir.length === 0 || !fs2__default.default.existsSync(dir)) {
536
654
  return false;
@@ -560,8 +678,12 @@ function compareSdkRoots(left, right) {
560
678
  }
561
679
  }
562
680
  }
563
- if (leftParts !== null) return -1;
564
- if (rightParts !== null) return 1;
681
+ if (leftParts !== null) {
682
+ return -1;
683
+ }
684
+ if (rightParts !== null) {
685
+ return 1;
686
+ }
565
687
  return right.localeCompare(left);
566
688
  }
567
689
  function pushSdkRuntimeCandidates(candidates, sdkRoot) {
@@ -632,12 +754,12 @@ function loadNative() {
632
754
  ];
633
755
  for (const candidate of candidates) {
634
756
  if (fs2__default.default.existsSync(candidate)) {
635
- return nodeRequire2(candidate);
757
+ return requireNativeAddon(candidate);
636
758
  }
637
759
  }
638
760
  const { key, packageName, binaryPath } = resolveNativeAddon(root);
639
761
  if (binaryPath !== null) {
640
- return nodeRequire2(binaryPath);
762
+ return requireNativeAddon(binaryPath);
641
763
  }
642
764
  if (packageName === null) {
643
765
  throw new Error(
@@ -691,72 +813,67 @@ var CDX_RISK_FIELDS = Object.freeze([
691
813
  "CDS_RECOVERY_RT"
692
814
  ]);
693
815
  var TA_STUDIES = Object.freeze({
694
- smavg: "smavgStudyAttributes",
695
- sma: "smavgStudyAttributes",
696
- 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",
697
826
  ema: "emavgStudyAttributes",
698
- wmavg: "wmavgStudyAttributes",
699
- wma: "wmavgStudyAttributes",
700
- vmavg: "vmavgStudyAttributes",
701
- vma: "vmavgStudyAttributes",
702
- tmavg: "tmavgStudyAttributes",
703
- tma: "tmavgStudyAttributes",
827
+ emavg: "emavgStudyAttributes",
828
+ etd: "etdStudyAttributes",
829
+ fear_greed: "fgStudyAttributes",
830
+ fg: "fgStudyAttributes",
831
+ goc: "gocStudyAttributes",
832
+ hurst: "hurstStudyAttributes",
833
+ ichimoku: "gocStudyAttributes",
704
834
  ipmavg: "ipmavgStudyAttributes",
705
- rsi: "rsiStudyAttributes",
835
+ keltner: "kltnStudyAttributes",
836
+ kltn: "kltnStudyAttributes",
706
837
  macd: "macdStudyAttributes",
838
+ mae: "maeStudyAttributes",
707
839
  mao: "maoStudyAttributes",
708
- momentum: "momentumStudyAttributes",
840
+ maxmin: "maxminStudyAttributes",
709
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",
710
850
  roc: "rocStudyAttributes",
711
- boll: "bollStudyAttributes",
712
- bb: "bollStudyAttributes",
713
- kltn: "kltnStudyAttributes",
714
- keltner: "kltnStudyAttributes",
715
- mae: "maeStudyAttributes",
716
- te: "teStudyAttributes",
717
- al: "alStudyAttributes",
718
- dmi: "dmiStudyAttributes",
719
- adx: "dmiStudyAttributes",
720
- tas: "tasStudyAttributes",
851
+ rsi: "rsiStudyAttributes",
852
+ rv: "rvStudyAttributes",
853
+ sar: "ptpsStudyAttributes",
854
+ sma: "smavgStudyAttributes",
855
+ smavg: "smavgStudyAttributes",
721
856
  stoch: "tasStudyAttributes",
857
+ tas: "tasStudyAttributes",
858
+ te: "teStudyAttributes",
859
+ tma: "tmavgStudyAttributes",
860
+ tmavg: "tmavgStudyAttributes",
722
861
  trender: "trenderStudyAttributes",
723
- ptps: "ptpsStudyAttributes",
724
- parabolic: "ptpsStudyAttributes",
725
- sar: "ptpsStudyAttributes",
726
- chko: "chkoStudyAttributes",
727
- ado: "adoStudyAttributes",
728
- vat: "vatStudyAttributes",
729
862
  tvat: "tvatStudyAttributes",
730
- atr: "atrStudyAttributes",
731
- hurst: "hurstStudyAttributes",
732
- fg: "fgStudyAttributes",
733
- fear_greed: "fgStudyAttributes",
734
- goc: "gocStudyAttributes",
735
- ichimoku: "gocStudyAttributes",
736
- cmci: "cmciStudyAttributes",
737
- wlpr: "wlprStudyAttributes",
863
+ vat: "vatStudyAttributes",
864
+ vma: "vmavgStudyAttributes",
865
+ vmavg: "vmavgStudyAttributes",
738
866
  williams: "wlprStudyAttributes",
739
- maxmin: "maxminStudyAttributes",
740
- rex: "rexStudyAttributes",
741
- etd: "etdStudyAttributes",
742
- pd: "pdStudyAttributes",
743
- rv: "rvStudyAttributes",
744
- pivot: "pivotStudyAttributes",
745
- or: "orStudyAttributes",
746
- pcr: "pcrStudyAttributes",
747
- bs: "bsStudyAttributes"
867
+ wlpr: "wlprStudyAttributes",
868
+ wma: "wmavgStudyAttributes",
869
+ wmavg: "wmavgStudyAttributes"
748
870
  });
749
871
  var TA_DEFAULTS = Object.freeze({
750
- smavgStudyAttributes: Object.freeze({ period: 20, priceSourceClose: "PX_LAST" }),
751
- emavgStudyAttributes: Object.freeze({ period: 20, priceSourceClose: "PX_LAST" }),
752
- wmavgStudyAttributes: Object.freeze({ period: 20, priceSourceClose: "PX_LAST" }),
753
- vmavgStudyAttributes: Object.freeze({ period: 20, priceSourceClose: "PX_LAST" }),
754
- tmavgStudyAttributes: Object.freeze({ period: 20, priceSourceClose: "PX_LAST" }),
755
- rsiStudyAttributes: Object.freeze({ period: 14, priceSourceClose: "PX_LAST" }),
756
- macdStudyAttributes: Object.freeze({
757
- maPeriod1: 12,
758
- maPeriod2: 26,
759
- sigPeriod: 9,
872
+ atrStudyAttributes: Object.freeze({
873
+ maType: "Simple",
874
+ period: 14,
875
+ priceSourceHigh: "PX_HIGH",
876
+ priceSourceLow: "PX_LOW",
760
877
  priceSourceClose: "PX_LAST"
761
878
  }),
762
879
  bollStudyAttributes: Object.freeze({
@@ -771,13 +888,15 @@ var TA_DEFAULTS = Object.freeze({
771
888
  priceSourceLow: "PX_LOW",
772
889
  priceSourceClose: "PX_LAST"
773
890
  }),
774
- atrStudyAttributes: Object.freeze({
775
- maType: "Simple",
776
- period: 14,
777
- priceSourceHigh: "PX_HIGH",
778
- 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,
779
896
  priceSourceClose: "PX_LAST"
780
897
  }),
898
+ rsiStudyAttributes: Object.freeze({ period: 14, priceSourceClose: "PX_LAST" }),
899
+ smavgStudyAttributes: Object.freeze({ period: 20, priceSourceClose: "PX_LAST" }),
781
900
  tasStudyAttributes: Object.freeze({
782
901
  periodK: 14,
783
902
  periodD: 3,
@@ -786,7 +905,10 @@ var TA_DEFAULTS = Object.freeze({
786
905
  priceSourceHigh: "PX_HIGH",
787
906
  priceSourceLow: "PX_LOW",
788
907
  priceSourceClose: "PX_LAST"
789
- })
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" })
790
912
  });
791
913
  var MKTDATA_SERVICE = "//blp/mktdata";
792
914
  function toArrowTableFromNative(batch) {
@@ -843,6 +965,39 @@ function toStringArray(value) {
843
965
  }
844
966
  return [toRequestString(value)];
845
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
+ }
846
1001
  function subscriptionOptionKey(option) {
847
1002
  return normalizeSubscriptionOption(option).split("=")[0]?.trim().toLowerCase() ?? "";
848
1003
  }
@@ -855,7 +1010,7 @@ function normalizeSubscriptionOption(option) {
855
1010
  }
856
1011
  function buildStreamSubscriptionOptions(service, options) {
857
1012
  const rawOptions = options.options;
858
- const conflate = options.conflate;
1013
+ const { conflate } = options;
859
1014
  if (rawOptions === void 0 && conflate !== true) {
860
1015
  return void 0;
861
1016
  }
@@ -896,9 +1051,7 @@ function normalizeConfigureArgs(configOrHost, port) {
896
1051
  if (isPlainObject(configOrHost)) {
897
1052
  return { ...configOrHost };
898
1053
  }
899
- throw new TypeError(
900
- "configure expects either a config object or host/port arguments"
901
- );
1054
+ throw new TypeError("configure expects either a config object or host/port arguments");
902
1055
  }
903
1056
  function normalizeRecoveryOptions(options = {}) {
904
1057
  const normalized = { ...options };
@@ -907,7 +1060,7 @@ function normalizeRecoveryOptions(options = {}) {
907
1060
  delete normalized.recovery_rate;
908
1061
  if (recoveryRate !== void 0) {
909
1062
  normalized.overrides = {
910
- ...normalized.overrides ?? {},
1063
+ ...normalized.overrides,
911
1064
  CDS_RR: toRequestString(recoveryRate)
912
1065
  };
913
1066
  }
@@ -920,15 +1073,15 @@ function fullDayRange(dt) {
920
1073
  }
921
1074
  const day = `${formatted.slice(0, 4)}-${formatted.slice(4, 6)}-${formatted.slice(6, 8)}`;
922
1075
  return {
923
- start: `${day}T00:00:00`,
924
- end: `${day}T23:59:59`
1076
+ end: `${day}T23:59:59`,
1077
+ start: `${day}T00:00:00`
925
1078
  };
926
1079
  }
927
1080
  function normalizeDate(value) {
928
1081
  return formatDate(value);
929
1082
  }
930
1083
  function getStudyAttrName(study) {
931
- const normalized = study.toLowerCase().replace(/-/g, "_").replace(/ /g, "_");
1084
+ const normalized = study.toLowerCase().replaceAll(/-/gu, "_").replaceAll(/ /gu, "_");
932
1085
  const mapped = TA_STUDIES[normalized];
933
1086
  if (mapped !== void 0) {
934
1087
  return mapped;
@@ -942,14 +1095,16 @@ function buildTaRequest(ticker, study, options = {}) {
942
1095
  const rawStudy = typeof study === "string" ? { studyType: study } : { ...study };
943
1096
  const studyType = rawStudy.studyType ?? rawStudy.study ?? (typeof study === "string" ? study : "");
944
1097
  const attrName = getStudyAttrName(toRequestString(studyType));
945
- const kwargs = { ...options.kwargs ?? {} };
1098
+ const kwargs = { ...options.kwargs };
946
1099
  const startDate = normalizeDate(
947
1100
  stringOrUndef(kwargs.startDate) ?? stringOrUndef(kwargs.start_date) ?? options.startDate ?? options.start_date
948
1101
  );
949
1102
  const endDate = normalizeDate(
950
1103
  stringOrUndef(kwargs.endDate) ?? stringOrUndef(kwargs.end_date) ?? options.endDate ?? options.end_date
951
1104
  );
952
- 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();
953
1108
  const interval = kwargs.interval ?? rawStudy.interval ?? options.interval;
954
1109
  delete kwargs.startDate;
955
1110
  delete kwargs.start_date;
@@ -965,8 +1120,8 @@ function buildTaRequest(ticker, study, options = {}) {
965
1120
  }
966
1121
  delete rawStudy.length;
967
1122
  const params = {
968
- ...TA_DEFAULTS[attrName] ?? {},
969
- ...options.studyParams ?? {},
1123
+ ...TA_DEFAULTS[attrName],
1124
+ ...options.studyParams,
970
1125
  ...rawStudy
971
1126
  };
972
1127
  if (params.length !== void 0 && params.period === void 0) {
@@ -1022,7 +1177,7 @@ function cachePolarsLoadError(err) {
1022
1177
  const error = new Error(
1023
1178
  "nodejs-polars is required for Polars backend. Install: npm install nodejs-polars"
1024
1179
  );
1025
- Object.defineProperty(error, "cause", { value: err, configurable: true });
1180
+ Object.defineProperty(error, "cause", { configurable: true, value: err });
1026
1181
  polarsLoadError = error;
1027
1182
  return error;
1028
1183
  }
@@ -1034,10 +1189,10 @@ function loadPolars() {
1034
1189
  throw polarsLoadError;
1035
1190
  }
1036
1191
  try {
1037
- polarsModule = nodeRequire2("nodejs-polars");
1192
+ polarsModule = requirePolarsModule();
1038
1193
  return polarsModule;
1039
- } catch (err) {
1040
- throw cachePolarsLoadError(err);
1194
+ } catch (error) {
1195
+ throw cachePolarsLoadError(error);
1041
1196
  }
1042
1197
  }
1043
1198
  function normalizeBackend(backend) {
@@ -1054,7 +1209,7 @@ function normalizeBackend(backend) {
1054
1209
  function ipcToBackend(buffer, backend) {
1055
1210
  const selected = normalizeBackend(backend);
1056
1211
  if (selected === Backend.JSON) {
1057
- return Array.from(apacheArrow.tableFromIPC(buffer));
1212
+ return [...apacheArrow.tableFromIPC(buffer)];
1058
1213
  }
1059
1214
  if (selected === Backend.POLARS) {
1060
1215
  return loadPolars().readIPC(buffer);
@@ -1067,10 +1222,13 @@ function clearConfiguredEngine() {
1067
1222
  const existing = configuredEnginePromise;
1068
1223
  configuredEnginePromise = void 0;
1069
1224
  if (existing !== void 0) {
1070
- existing.then((engine) => {
1071
- engine.signalShutdown();
1072
- }).catch(() => {
1073
- });
1225
+ void (async () => {
1226
+ try {
1227
+ const engine = await existing;
1228
+ engine.signalShutdown();
1229
+ } catch {
1230
+ }
1231
+ })();
1074
1232
  }
1075
1233
  }
1076
1234
  async function getConfiguredEngine() {
@@ -1092,28 +1250,32 @@ var FieldHandle = class {
1092
1250
  name;
1093
1251
  };
1094
1252
  var Tick = class {
1095
- constructor(_update) {
1096
- this._update = _update;
1097
- 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]));
1098
1256
  }
1099
- _update;
1100
- _positions;
1257
+ update;
1258
+ positions;
1101
1259
  get topic() {
1102
- return this._update.topic;
1260
+ return this.update.topic;
1103
1261
  }
1104
1262
  get timestampUs() {
1105
- return this._update.timestampUs;
1263
+ return this.update.timestampUs;
1106
1264
  }
1107
1265
  get layoutVersion() {
1108
- return this._update.layoutVersion;
1266
+ return this.update.layoutVersion;
1109
1267
  }
1110
1268
  get(field) {
1111
1269
  const name = typeof field === "string" ? field : field.name;
1112
- const index = this._positions.get(name);
1113
- if (index === void 0) return null;
1114
- const value = this._update.values[index] ?? null;
1115
- const kind = this._update.valueKinds[index] ?? "unknown";
1116
- 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
+ }
1117
1279
  if (kind === "i64" || kind === "time64_us" || kind === "timestamp_us") {
1118
1280
  try {
1119
1281
  return BigInt(String(value));
@@ -1128,13 +1290,17 @@ var Tick = class {
1128
1290
  }
1129
1291
  f64(field) {
1130
1292
  const value = this.get(field);
1131
- if (value === null) return null;
1293
+ if (value === null) {
1294
+ return null;
1295
+ }
1132
1296
  const parsed = Number(value);
1133
1297
  return Number.isFinite(parsed) ? parsed : null;
1134
1298
  }
1135
1299
  i64(field) {
1136
1300
  const value = this.get(field);
1137
- if (value === null) return null;
1301
+ if (value === null) {
1302
+ return null;
1303
+ }
1138
1304
  try {
1139
1305
  return BigInt(String(value));
1140
1306
  } catch {
@@ -1146,35 +1312,35 @@ var Tick = class {
1146
1312
  return value === null ? null : String(value);
1147
1313
  }
1148
1314
  toObject() {
1149
- const out = { topic: this.topic, timestampUs: this.timestampUs };
1150
- for (const field of this._update.fields) {
1315
+ const out = { timestampUs: this.timestampUs, topic: this.topic };
1316
+ for (const field of this.update.fields) {
1151
1317
  out[field] = this.get(field);
1152
1318
  }
1153
1319
  return out;
1154
1320
  }
1155
1321
  };
1156
1322
  var ArrowSubscription = class {
1157
- constructor(_inner) {
1158
- this._inner = _inner;
1323
+ constructor(inner) {
1324
+ this.inner = inner;
1159
1325
  }
1160
- _inner;
1326
+ inner;
1161
1327
  async next() {
1162
1328
  try {
1163
- const batch = await this._inner.nextArrow();
1329
+ const batch = await this.inner.nextArrow();
1164
1330
  if (batch === null) {
1165
1331
  return { done: true, value: void 0 };
1166
1332
  }
1167
1333
  return { done: false, value: toArrowTableFromNative(batch) };
1168
- } catch (err) {
1169
- throw wrapError(err);
1334
+ } catch (error) {
1335
+ throw wrapError(error);
1170
1336
  }
1171
1337
  }
1172
1338
  async unsubscribe(drain = false) {
1173
1339
  try {
1174
- const drained = await this._inner.unsubscribeArrow(drain);
1340
+ const drained = await this.inner.unsubscribeArrow(drain);
1175
1341
  return drained?.map(toArrowTableFromNative) ?? [];
1176
- } catch (err) {
1177
- throw wrapError(err);
1342
+ } catch (error) {
1343
+ throw wrapError(error);
1178
1344
  }
1179
1345
  }
1180
1346
  [Symbol.asyncIterator]() {
@@ -1182,63 +1348,63 @@ var ArrowSubscription = class {
1182
1348
  }
1183
1349
  };
1184
1350
  var Subscription = class {
1185
- _inner;
1351
+ inner;
1186
1352
  constructor(inner) {
1187
- this._inner = inner;
1353
+ this.inner = inner;
1188
1354
  }
1189
1355
  async next() {
1190
1356
  try {
1191
- const update = await this._inner.nextUpdate();
1357
+ const update = await this.inner.nextUpdate();
1192
1358
  if (update === null) {
1193
1359
  return { done: true, value: void 0 };
1194
1360
  }
1195
1361
  return { done: false, value: new Tick(update) };
1196
- } catch (err) {
1197
- throw wrapError(err);
1362
+ } catch (error) {
1363
+ throw wrapError(error);
1198
1364
  }
1199
1365
  }
1200
1366
  async add(tickers) {
1201
1367
  try {
1202
- await this._inner.add(tickers);
1203
- } catch (err) {
1204
- throw wrapError(err);
1368
+ await this.inner.add(tickers);
1369
+ } catch (error) {
1370
+ throw wrapError(error);
1205
1371
  }
1206
1372
  }
1207
1373
  async remove(tickers) {
1208
1374
  try {
1209
- await this._inner.remove(tickers);
1210
- } catch (err) {
1211
- throw wrapError(err);
1375
+ await this.inner.remove(tickers);
1376
+ } catch (error) {
1377
+ throw wrapError(error);
1212
1378
  }
1213
1379
  }
1214
1380
  async unsubscribe(drain = false) {
1215
1381
  try {
1216
- const drained = await this._inner.unsubscribe(drain);
1382
+ const drained = await this.inner.unsubscribe(drain);
1217
1383
  if (drained === null) {
1218
1384
  return [];
1219
1385
  }
1220
1386
  return drained.map((update) => new Tick(update));
1221
- } catch (err) {
1222
- throw wrapError(err);
1387
+ } catch (error) {
1388
+ throw wrapError(error);
1223
1389
  }
1224
1390
  }
1225
1391
  field(name) {
1226
1392
  return new FieldHandle(name);
1227
1393
  }
1228
1394
  arrow() {
1229
- return new ArrowSubscription(this._inner);
1395
+ return new ArrowSubscription(this.inner);
1230
1396
  }
1231
1397
  get tickers() {
1232
- return this._inner.tickers;
1398
+ return this.inner.tickers;
1233
1399
  }
1234
1400
  get fields() {
1235
- return this._inner.fields;
1401
+ return this.inner.fields;
1236
1402
  }
1237
1403
  get isActive() {
1238
- return this._inner.isActive;
1404
+ return this.inner.isActive;
1239
1405
  }
1240
1406
  get stats() {
1241
- return this._inner.stats;
1407
+ return this.inner.stats;
1242
1408
  }
1243
1409
  [Symbol.asyncIterator]() {
1244
1410
  return this;
@@ -1246,20 +1412,24 @@ var Subscription = class {
1246
1412
  };
1247
1413
  var Engine = class _Engine {
1248
1414
  // Set via constructor or via `withConfig` (which instantiates via Object.create).
1249
- _inner;
1415
+ inner;
1250
1416
  constructor(host = "localhost", port = 8194) {
1251
1417
  try {
1252
- this._inner = new native.JsEngine(host, port);
1253
- } catch (err) {
1254
- throw wrapError(err);
1418
+ this.inner = new native.JsEngine(host, port);
1419
+ } catch (error) {
1420
+ throw wrapError(error);
1255
1421
  }
1256
1422
  }
1257
1423
  static withConfig(config = {}) {
1258
- 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;
1259
1429
  try {
1260
- engine._inner = native.JsEngine.withConfig(config);
1261
- } catch (err) {
1262
- throw wrapError(err);
1430
+ engine.inner = native.JsEngine.withConfig(config);
1431
+ } catch (error) {
1432
+ throw wrapError(error);
1263
1433
  }
1264
1434
  return engine;
1265
1435
  }
@@ -1267,104 +1437,104 @@ var Engine = class _Engine {
1267
1437
  const backend = normalizeBackend(params.backend);
1268
1438
  const { backend: _discarded, ...nativeParams } = params;
1269
1439
  try {
1270
- const buffer = await this._inner.request(nativeParams);
1440
+ const buffer = await this.inner.request(nativeParams);
1271
1441
  return ipcToBackend(buffer, backend);
1272
- } catch (err) {
1273
- throw wrapError(err);
1442
+ } catch (error) {
1443
+ throw wrapError(error);
1274
1444
  }
1275
1445
  }
1276
1446
  async requestRaw(params) {
1277
1447
  try {
1278
- return await this._inner.request(params);
1279
- } catch (err) {
1280
- throw wrapError(err);
1448
+ return await this.inner.request(params);
1449
+ } catch (error) {
1450
+ throw wrapError(error);
1281
1451
  }
1282
1452
  }
1283
1453
  async bdp(tickers, fields, options = {}) {
1284
1454
  return await this.request({
1285
- service: "//blp/refdata",
1286
- operation: "ReferenceDataRequest",
1287
- securities: tickers,
1455
+ backend: options.backend,
1456
+ extractor: "refdata",
1288
1457
  fields,
1289
- overrides: mapObjectToPairs(options.overrides),
1290
- kwargs: mapObjectToPairs(options.kwargs),
1291
1458
  format: options.format,
1292
- backend: options.backend,
1293
1459
  includeSecurityErrors: Boolean(options.includeSecurityErrors),
1294
- validateFields: options.validateFields,
1295
- 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
1296
1466
  });
1297
1467
  }
1298
1468
  async bds(tickers, fields, options = {}) {
1299
1469
  return await this.request({
1300
- service: "//blp/refdata",
1301
- operation: "ReferenceDataRequest",
1302
- securities: tickers,
1470
+ backend: options.backend,
1471
+ extractor: "bulk",
1303
1472
  fields,
1304
- overrides: mapObjectToPairs(options.overrides),
1305
- kwargs: mapObjectToPairs(options.kwargs),
1306
1473
  format: options.format,
1307
- backend: options.backend,
1308
- validateFields: options.validateFields,
1309
- 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
1310
1480
  });
1311
1481
  }
1312
1482
  async bdh(tickers, fields, options = {}) {
1313
1483
  return await this.request({
1314
- 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),
1315
1490
  operation: "HistoricalDataRequest",
1491
+ overrides: mapObjectToPairs(options.overrides),
1316
1492
  securities: tickers,
1317
- fields,
1493
+ service: "//blp/refdata",
1318
1494
  startDate: formatDate(options.start),
1319
- endDate: formatDate(options.end),
1320
- overrides: mapObjectToPairs(options.overrides),
1321
- kwargs: mapObjectToPairs(options.kwargs),
1322
- format: options.format,
1323
- backend: options.backend,
1324
- validateFields: options.validateFields,
1325
- extractor: "histdata"
1495
+ validateFields: options.validateFields
1326
1496
  });
1327
1497
  }
1328
1498
  async bdib(ticker, options = {}) {
1329
1499
  return await this.request({
1330
- service: "//blp/refdata",
1331
- operation: "IntradayBarRequest",
1332
- security: ticker,
1500
+ backend: options.backend,
1501
+ endDatetime: formatDateTime(options.end),
1333
1502
  eventType: options.eventType ?? "TRADE",
1503
+ extractor: "intraday_bar",
1334
1504
  interval: options.interval ?? 1,
1335
- startDatetime: formatDateTime(options.start),
1336
- endDatetime: formatDateTime(options.end),
1337
- requestTz: options.requestTz,
1338
- outputTz: options.outputTz,
1339
1505
  kwargs: mapObjectToPairs(options.kwargs),
1340
- backend: options.backend,
1341
- 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)
1342
1512
  });
1343
1513
  }
1344
1514
  async bdtick(ticker, options = {}) {
1345
1515
  return await this.request({
1346
- service: "//blp/refdata",
1347
- operation: "IntradayTickRequest",
1348
- security: ticker,
1349
- eventTypes: options.eventTypes ?? ["TRADE"],
1350
- startDatetime: formatDateTime(options.start),
1516
+ backend: options.backend,
1351
1517
  endDatetime: formatDateTime(options.end),
1352
- requestTz: options.requestTz,
1353
- outputTz: options.outputTz,
1518
+ eventTypes: options.eventTypes ?? ["TRADE"],
1519
+ extractor: "intraday_tick",
1354
1520
  kwargs: buildBdtickKwargs(options),
1355
- backend: options.backend,
1356
- 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)
1357
1527
  });
1358
1528
  }
1359
1529
  async bql(query, options = {}) {
1360
1530
  return await this.request({
1361
- service: "//blp/bqlsvc",
1362
- operation: "sendQuery",
1363
- elements: [{ key: "expression", value: toRequestString(query) }],
1364
1531
  backend: options.backend,
1365
- kwargs: mapObjectToPairs(options.kwargs),
1532
+ elements: [{ key: "expression", value: toRequestString(query) }],
1533
+ extractor: "bql",
1366
1534
  format: options.format,
1367
- extractor: "bql"
1535
+ kwargs: mapObjectToPairs(options.kwargs),
1536
+ operation: "sendQuery",
1537
+ service: "//blp/bqlsvc"
1368
1538
  });
1369
1539
  }
1370
1540
  async beqs(screen, options = {}) {
@@ -1379,108 +1549,108 @@ var Engine = class _Engine {
1379
1549
  elements.push({ key: "asOfDate", value: asofFormatted });
1380
1550
  }
1381
1551
  }
1382
- const overrides = { ...options.overrides ?? {} };
1552
+ const overrides = { ...options.overrides };
1383
1553
  return await this.request({
1384
- service: "//blp/refdata",
1385
- operation: "BeqsRequest",
1386
- elements,
1387
1554
  backend: options.backend,
1555
+ elements,
1556
+ extractor: "generic",
1557
+ format: options.format,
1388
1558
  kwargs: mapObjectToPairs(options.kwargs),
1559
+ operation: "BeqsRequest",
1389
1560
  overrides: mapObjectToPairs(overrides),
1390
- format: options.format,
1391
- extractor: "generic"
1561
+ service: "//blp/refdata"
1392
1562
  });
1393
1563
  }
1394
1564
  async bsrch(searchSpec, options = {}) {
1395
1565
  const elements = {
1396
1566
  Domain: toRequestString(searchSpec),
1397
- ...options.overrides ?? {},
1398
- ...options.kwargs ?? {}
1567
+ ...options.overrides,
1568
+ ...options.kwargs
1399
1569
  };
1400
1570
  return await this.request({
1401
- service: "//blp/exrsvc",
1402
- operation: "ExcelGetGridRequest",
1403
1571
  backend: options.backend,
1404
1572
  elements: mapObjectToPairs(elements),
1573
+ extractor: "bsrch",
1405
1574
  format: options.format,
1406
- extractor: "bsrch"
1575
+ operation: "ExcelGetGridRequest",
1576
+ service: "//blp/exrsvc"
1407
1577
  });
1408
1578
  }
1409
1579
  async bta(ticker, study, options = {}) {
1410
1580
  return await this.request({
1411
- service: "//blp/tasvc",
1412
- operation: "studyRequest",
1413
- elements: buildTaRequest(ticker, study, options),
1414
1581
  backend: options.backend,
1582
+ elements: buildTaRequest(ticker, study, options),
1583
+ extractor: "generic",
1415
1584
  format: options.format,
1416
- extractor: "generic"
1585
+ operation: "studyRequest",
1586
+ service: "//blp/tasvc"
1417
1587
  });
1418
1588
  }
1419
1589
  async bflds(options = {}) {
1420
1590
  if (options.searchSpec !== void 0) {
1421
1591
  return await this.request({
1422
- service: "//blp/apiflds",
1423
- operation: "FieldSearchRequest",
1424
- searchSpec: toRequestString(options.searchSpec),
1425
1592
  backend: options.backend,
1593
+ format: options.format,
1426
1594
  kwargs: mapObjectToPairs(options.kwargs),
1427
- format: options.format
1595
+ operation: "FieldSearchRequest",
1596
+ searchSpec: toRequestString(options.searchSpec),
1597
+ service: "//blp/apiflds"
1428
1598
  });
1429
1599
  }
1430
- const fields = Array.isArray(options.fields) ? options.fields : typeof options.fields === "string" ? [options.fields] : [];
1600
+ const fields = toStringArray(options.fields);
1431
1601
  return await this.request({
1432
- service: "//blp/apiflds",
1433
- operation: "FieldInfoRequest",
1434
- fieldIds: fields,
1435
1602
  backend: options.backend,
1603
+ fieldIds: fields,
1604
+ format: options.format,
1436
1605
  kwargs: mapObjectToPairs(options.kwargs),
1437
- format: options.format
1606
+ operation: "FieldInfoRequest",
1607
+ service: "//blp/apiflds"
1438
1608
  });
1439
1609
  }
1440
1610
  async blkp(query, options = {}) {
1441
1611
  return await this.request({
1442
- service: "//blp/instruments",
1443
- operation: "instrumentListRequest",
1444
- elements: [{ key: "query", value: toRequestString(query) }],
1445
1612
  backend: options.backend,
1613
+ elements: [{ key: "query", value: toRequestString(query) }],
1614
+ format: options.format,
1446
1615
  kwargs: mapObjectToPairs(options.kwargs),
1447
- format: options.format
1616
+ operation: "instrumentListRequest",
1617
+ service: "//blp/instruments"
1448
1618
  });
1449
1619
  }
1450
1620
  async bport(portfolio, fields, options = {}) {
1451
1621
  return await this.request({
1452
- service: "//blp/refdata",
1453
- operation: "PortfolioDataRequest",
1454
- security: toRequestString(portfolio),
1455
- fields: Array.isArray(fields) ? fields : [toRequestString(fields)],
1456
1622
  backend: options.backend,
1457
- overrides: mapObjectToPairs(options.overrides),
1623
+ fields: Array.isArray(fields) ? fields : [toRequestString(fields)],
1624
+ format: options.format,
1458
1625
  kwargs: mapObjectToPairs(options.kwargs),
1459
- format: options.format
1626
+ operation: "PortfolioDataRequest",
1627
+ overrides: mapObjectToPairs(options.overrides),
1628
+ security: toRequestString(portfolio),
1629
+ service: "//blp/refdata"
1460
1630
  });
1461
1631
  }
1462
1632
  async bcurves(ticker, options = {}) {
1463
1633
  return await this.request({
1464
- service: "//blp/instruments",
1465
- operation: "curveListRequest",
1466
- elements: [{ key: "query", value: toRequestString(ticker) }],
1467
1634
  backend: options.backend,
1635
+ elements: [{ key: "query", value: toRequestString(ticker) }],
1636
+ format: options.format,
1468
1637
  kwargs: mapObjectToPairs(options.kwargs),
1469
- format: options.format
1638
+ operation: "curveListRequest",
1639
+ service: "//blp/instruments"
1470
1640
  });
1471
1641
  }
1472
1642
  async bgovts(ticker, options = {}) {
1473
1643
  return await this.request({
1474
- service: "//blp/instruments",
1475
- operation: "govtListRequest",
1476
- elements: [{ key: "query", value: toRequestString(ticker) }],
1477
1644
  backend: options.backend,
1645
+ elements: [{ key: "query", value: toRequestString(ticker) }],
1646
+ format: options.format,
1478
1647
  kwargs: mapObjectToPairs(options.kwargs),
1479
- format: options.format
1648
+ operation: "govtListRequest",
1649
+ service: "//blp/instruments"
1480
1650
  });
1481
1651
  }
1482
1652
  async resolveFieldTypes(fields, overrides, defaultType = "string") {
1483
- const items = await this._inner.resolveFieldTypes(
1653
+ const items = await this.inner.resolveFieldTypes(
1484
1654
  fields,
1485
1655
  mapObjectToPairs(overrides),
1486
1656
  defaultType
@@ -1488,55 +1658,55 @@ var Engine = class _Engine {
1488
1658
  return Object.fromEntries(items.map((item) => [item.key, item.value]));
1489
1659
  }
1490
1660
  getFieldInfo(field) {
1491
- return this._inner.getFieldInfo(field);
1661
+ return this.inner.getFieldInfo(field);
1492
1662
  }
1493
1663
  clearFieldCache() {
1494
- this._inner.clearFieldCache();
1664
+ this.inner.clearFieldCache();
1495
1665
  }
1496
1666
  saveFieldCache() {
1497
- this._inner.saveFieldCache();
1667
+ this.inner.saveFieldCache();
1498
1668
  }
1499
1669
  async validateFields(fields) {
1500
- return await this._inner.validateFields(fields);
1670
+ return await this.inner.validateFields(fields);
1501
1671
  }
1502
1672
  isFieldValidationEnabled() {
1503
- return this._inner.isFieldValidationEnabled();
1673
+ return this.inner.isFieldValidationEnabled();
1504
1674
  }
1505
1675
  async getSchema(service) {
1506
- const json = await this._inner.getSchema(service);
1676
+ const json = await this.inner.getSchema(service);
1507
1677
  return JSON.parse(json);
1508
1678
  }
1509
1679
  async getOperation(service, operation) {
1510
- const json = await this._inner.getOperation(service, operation);
1680
+ const json = await this.inner.getOperation(service, operation);
1511
1681
  return JSON.parse(json);
1512
1682
  }
1513
1683
  async listOperations(service) {
1514
- return await this._inner.listOperations(service);
1684
+ return await this.inner.listOperations(service);
1515
1685
  }
1516
1686
  getCachedSchema(service) {
1517
- const json = this._inner.getCachedSchema(service);
1687
+ const json = this.inner.getCachedSchema(service);
1518
1688
  return json === null ? null : JSON.parse(json);
1519
1689
  }
1520
1690
  invalidateSchema(service) {
1521
- this._inner.invalidateSchema(service);
1691
+ this.inner.invalidateSchema(service);
1522
1692
  }
1523
1693
  clearSchemaCache() {
1524
- this._inner.clearSchemaCache();
1694
+ this.inner.clearSchemaCache();
1525
1695
  }
1526
1696
  listCachedSchemas() {
1527
- return this._inner.listCachedSchemas();
1697
+ return this.inner.listCachedSchemas();
1528
1698
  }
1529
1699
  async getEnumValues(service, operation, element) {
1530
- return await this._inner.getEnumValues(service, operation, element);
1700
+ return await this.inner.getEnumValues(service, operation, element);
1531
1701
  }
1532
1702
  async listValidElements(service, operation) {
1533
- return await this._inner.listValidElements(service, operation);
1703
+ return await this.inner.listValidElements(service, operation);
1534
1704
  }
1535
1705
  async subscribe(tickers, fields, options = {}) {
1536
1706
  try {
1537
1707
  const subscriptionOptions = buildStreamSubscriptionOptions(MKTDATA_SERVICE, options);
1538
1708
  const useOptions = subscriptionOptions !== void 0 || options.flushThreshold !== void 0 || options.overflowPolicy !== void 0 || options.streamCapacity !== void 0;
1539
- const stream = useOptions ? await this._inner.subscribeWithOptions(
1709
+ const stream = useOptions ? await this.inner.subscribeWithOptions(
1540
1710
  MKTDATA_SERVICE,
1541
1711
  tickers,
1542
1712
  fields,
@@ -1545,15 +1715,15 @@ var Engine = class _Engine {
1545
1715
  options.overflowPolicy,
1546
1716
  options.streamCapacity,
1547
1717
  options.allFields
1548
- ) : await this._inner.subscribe(tickers, fields, options.allFields);
1718
+ ) : await this.inner.subscribe(tickers, fields, options.allFields);
1549
1719
  return new Subscription(stream);
1550
- } catch (err) {
1551
- throw wrapError(err);
1720
+ } catch (error) {
1721
+ throw wrapError(error);
1552
1722
  }
1553
1723
  }
1554
1724
  async subscribeWithOptions(service, tickers, fields, options, flushThreshold, overflowPolicy, streamCapacity, allFields) {
1555
1725
  try {
1556
- const stream = await this._inner.subscribeWithOptions(
1726
+ const stream = await this.inner.subscribeWithOptions(
1557
1727
  service,
1558
1728
  tickers,
1559
1729
  fields,
@@ -1564,15 +1734,15 @@ var Engine = class _Engine {
1564
1734
  allFields
1565
1735
  );
1566
1736
  return new Subscription(stream);
1567
- } catch (err) {
1568
- throw wrapError(err);
1737
+ } catch (error) {
1738
+ throw wrapError(error);
1569
1739
  }
1570
1740
  }
1571
1741
  signalShutdown() {
1572
- this._inner.signalShutdown();
1742
+ this.inner.signalShutdown();
1573
1743
  }
1574
1744
  isAvailable() {
1575
- return this._inner.isAvailable();
1745
+ return this.inner.isAvailable();
1576
1746
  }
1577
1747
  async stream(tickers, fields, options = {}) {
1578
1748
  return await this.subscribeWithOptions(
@@ -1635,19 +1805,19 @@ var Engine = class _Engine {
1635
1805
  );
1636
1806
  }
1637
1807
  async bops(service) {
1638
- return await this._inner.listOperations(service);
1808
+ return await this.inner.listOperations(service);
1639
1809
  }
1640
1810
  async bschema(service, operation) {
1641
1811
  if (operation !== void 0) {
1642
- const json2 = await this._inner.getOperation(service, operation);
1812
+ const json2 = await this.inner.getOperation(service, operation);
1643
1813
  return JSON.parse(json2);
1644
1814
  }
1645
- const json = await this._inner.getSchema(service);
1815
+ const json = await this.inner.getSchema(service);
1646
1816
  return JSON.parse(json);
1647
1817
  }
1648
1818
  async fieldInfo(fields, options = {}) {
1649
1819
  return await this.bflds({
1650
- fields: Array.isArray(fields) ? fields : [toRequestString(fields)],
1820
+ fields: toStringArray(fields),
1651
1821
  ...options
1652
1822
  });
1653
1823
  }
@@ -1658,7 +1828,7 @@ var Engine = class _Engine {
1658
1828
  async bqr(ticker, options = {}) {
1659
1829
  const backend = normalizeBackend(options.backend);
1660
1830
  try {
1661
- const buffer = await this._inner.recipeBqr(
1831
+ const buffer = await this.inner.recipeBqr(
1662
1832
  toRequestString(ticker),
1663
1833
  formatDateTime(options.startDatetime),
1664
1834
  formatDateTime(options.endDatetime),
@@ -1666,14 +1836,14 @@ var Engine = class _Engine {
1666
1836
  options.includeBrokerCodes !== false
1667
1837
  );
1668
1838
  return ipcToBackend(buffer, backend);
1669
- } catch (err) {
1670
- throw wrapError(err);
1839
+ } catch (error) {
1840
+ throw wrapError(error);
1671
1841
  }
1672
1842
  }
1673
1843
  async yas(tickers, fields, options = {}) {
1674
1844
  const backend = normalizeBackend(options.backend);
1675
1845
  try {
1676
- const buffer = await this._inner.recipeYas(
1846
+ const buffer = await this.inner.recipeYas(
1677
1847
  toStringArray(tickers),
1678
1848
  toStringArray(fields),
1679
1849
  formatDate(options.settleDt),
@@ -1684,105 +1854,135 @@ var Engine = class _Engine {
1684
1854
  options.benchmark ?? void 0
1685
1855
  );
1686
1856
  return ipcToBackend(buffer, backend);
1687
- } catch (err) {
1688
- throw wrapError(err);
1857
+ } catch (error) {
1858
+ throw wrapError(error);
1689
1859
  }
1690
1860
  }
1691
1861
  async preferreds(equityTicker, options = {}) {
1692
1862
  const backend = normalizeBackend(options.backend);
1693
1863
  try {
1694
- const buffer = await this._inner.recipePreferreds(
1864
+ const buffer = await this.inner.recipePreferreds(
1695
1865
  toRequestString(equityTicker),
1696
1866
  options.fields !== void 0 ? toStringArray(options.fields) : null
1697
1867
  );
1698
1868
  return ipcToBackend(buffer, backend);
1699
- } catch (err) {
1700
- throw wrapError(err);
1869
+ } catch (error) {
1870
+ throw wrapError(error);
1701
1871
  }
1702
1872
  }
1703
1873
  async corporateBonds(ticker, options = {}) {
1704
1874
  const backend = normalizeBackend(options.backend);
1705
1875
  try {
1706
- const buffer = await this._inner.recipeCorporateBonds(
1876
+ const buffer = await this.inner.recipeCorporateBonds(
1707
1877
  toRequestString(ticker),
1708
1878
  options.ccy ?? void 0,
1709
1879
  options.fields !== void 0 ? toStringArray(options.fields) : null,
1710
1880
  options.activeOnly !== false
1711
1881
  );
1712
1882
  return ipcToBackend(buffer, backend);
1713
- } catch (err) {
1714
- throw wrapError(err);
1883
+ } catch (error) {
1884
+ throw wrapError(error);
1715
1885
  }
1716
1886
  }
1717
1887
  async futTicker(genTicker, dt, options = {}) {
1718
1888
  const backend = normalizeBackend(options.backend);
1719
1889
  try {
1720
- const buffer = await this._inner.recipeFutTicker(
1890
+ const buffer = await this.inner.recipeFutTicker(
1721
1891
  toRequestString(genTicker),
1722
1892
  formatDate(dt) ?? "",
1723
1893
  options.freq ?? void 0
1724
1894
  );
1725
1895
  return ipcToBackend(buffer, backend);
1726
- } catch (err) {
1727
- throw wrapError(err);
1896
+ } catch (error) {
1897
+ throw wrapError(error);
1728
1898
  }
1729
1899
  }
1730
1900
  async activeFutures(genTicker, dt, options = {}) {
1731
1901
  const backend = normalizeBackend(options.backend);
1732
1902
  try {
1733
- const buffer = await this._inner.recipeActiveFutures(
1903
+ const buffer = await this.inner.recipeActiveFutures(
1734
1904
  toRequestString(genTicker),
1735
1905
  formatDate(dt) ?? "",
1736
1906
  options.freq ?? void 0
1737
1907
  );
1738
1908
  return ipcToBackend(buffer, backend);
1739
- } catch (err) {
1740
- 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);
1741
1926
  }
1742
1927
  }
1743
1928
  async cdxTicker(genTicker, dt, options = {}) {
1744
1929
  const backend = normalizeBackend(options.backend);
1745
1930
  try {
1746
- const buffer = await this._inner.recipeCdxTicker(
1931
+ const buffer = await this.inner.recipeCdxTicker(
1747
1932
  toRequestString(genTicker),
1748
1933
  formatDate(dt) ?? ""
1749
1934
  );
1750
1935
  return ipcToBackend(buffer, backend);
1751
- } catch (err) {
1752
- throw wrapError(err);
1936
+ } catch (error) {
1937
+ throw wrapError(error);
1753
1938
  }
1754
1939
  }
1755
1940
  async activeCdx(genTicker, dt, options = {}) {
1756
1941
  const backend = normalizeBackend(options.backend);
1757
1942
  try {
1758
- const buffer = await this._inner.recipeActiveCdx(
1943
+ const buffer = await this.inner.recipeActiveCdx(
1759
1944
  toRequestString(genTicker),
1760
1945
  formatDate(dt) ?? "",
1761
1946
  options.lookbackDays ?? void 0
1762
1947
  );
1763
1948
  return ipcToBackend(buffer, backend);
1764
- } catch (err) {
1765
- throw wrapError(err);
1949
+ } catch (error) {
1950
+ throw wrapError(error);
1766
1951
  }
1767
1952
  }
1768
1953
  async dividend(tickers, startDate, endDate, options = {}) {
1769
1954
  const backend = normalizeBackend(options.backend);
1770
1955
  try {
1771
- const buffer = await this._inner.recipeDividend(
1956
+ const buffer = await this.inner.recipeDividend(
1772
1957
  toStringArray(tickers),
1773
1958
  formatDate(startDate) ?? "",
1774
1959
  formatDate(endDate) ?? "",
1775
1960
  options.dvdType ?? void 0
1776
1961
  );
1777
1962
  return ipcToBackend(buffer, backend);
1778
- } catch (err) {
1779
- 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);
1780
1980
  }
1781
1981
  }
1782
1982
  async turnover(tickers, startDate, endDate, options = {}) {
1783
1983
  const backend = normalizeBackend(options.backend);
1784
1984
  try {
1785
- const buffer = await this._inner.recipeTurnover(
1985
+ const buffer = await this.inner.recipeTurnover(
1786
1986
  toStringArray(tickers),
1787
1987
  formatDate(startDate) ?? "",
1788
1988
  formatDate(endDate) ?? "",
@@ -1790,41 +1990,89 @@ var Engine = class _Engine {
1790
1990
  options.factor ?? void 0
1791
1991
  );
1792
1992
  return ipcToBackend(buffer, backend);
1793
- } catch (err) {
1794
- throw wrapError(err);
1993
+ } catch (error) {
1994
+ throw wrapError(error);
1795
1995
  }
1796
1996
  }
1797
1997
  async etfHoldings(etfTicker, options = {}) {
1798
1998
  const backend = normalizeBackend(options.backend);
1799
1999
  try {
1800
- const buffer = await this._inner.recipeEtfHoldings(
2000
+ const buffer = await this.inner.recipeEtfHoldings(
1801
2001
  toRequestString(etfTicker),
1802
2002
  options.fields !== void 0 ? toStringArray(options.fields) : null
1803
2003
  );
1804
2004
  return ipcToBackend(buffer, backend);
1805
- } catch (err) {
1806
- 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);
1807
2057
  }
1808
2058
  }
1809
2059
  async currencyConversion(ticker, targetCcy, startDate, endDate, options = {}) {
1810
2060
  const backend = normalizeBackend(options.backend);
1811
2061
  try {
1812
- const buffer = await this._inner.recipeCurrencyConversion(
2062
+ const buffer = await this.inner.recipeCurrencyConversion(
1813
2063
  toRequestString(ticker),
1814
2064
  toRequestString(targetCcy),
1815
2065
  formatDate(startDate) ?? "",
1816
2066
  formatDate(endDate) ?? ""
1817
2067
  );
1818
2068
  return ipcToBackend(buffer, backend);
1819
- } catch (err) {
1820
- throw wrapError(err);
2069
+ } catch (error) {
2070
+ throw wrapError(error);
1821
2071
  }
1822
2072
  }
1823
2073
  };
1824
2074
  async function connect(config) {
1825
- return await Promise.resolve(
1826
- config === void 0 ? new Engine() : Engine.withConfig(config)
1827
- );
2075
+ return await Promise.resolve(config === void 0 ? new Engine() : Engine.withConfig(config));
1828
2076
  }
1829
2077
  function configure(configOrHost, port) {
1830
2078
  configuredEngineConfig = normalizeConfigureArgs(configOrHost, port);
@@ -1840,17 +2088,16 @@ async function bdp(tickers, fields, options = {}) {
1840
2088
  }
1841
2089
  async function abdh(tickers, fields, start, end, options = {}) {
1842
2090
  const engine = await getConfiguredEngine();
1843
- if (isPlainObject(start) && !(start instanceof Date) && !hasToJSDate(start) && end === void 0) {
1844
- return await engine.bdh(
1845
- toStringArray(tickers),
1846
- toStringArray(fields),
1847
- start
1848
- );
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);
1849
2096
  }
1850
2097
  return await engine.bdh(toStringArray(tickers), toStringArray(fields), {
1851
2098
  ...options,
1852
- start,
1853
- end
2099
+ end,
2100
+ start
1854
2101
  });
1855
2102
  }
1856
2103
  async function bdh(tickers, fields, options = {}) {
@@ -1858,25 +2105,20 @@ async function bdh(tickers, fields, options = {}) {
1858
2105
  }
1859
2106
  async function abds(tickers, fields, overrides, options = {}) {
1860
2107
  const engine = await getConfiguredEngine();
1861
- const normalizedOptions = isPlainObject(overrides) ? { ...options, overrides: { ...options.overrides ?? {}, ...overrides } } : options;
1862
- return await engine.bds(
1863
- toStringArray(tickers),
1864
- toStringArray(fields),
1865
- normalizedOptions
1866
- );
2108
+ const normalizedOptions = isPlainObject(overrides) ? { ...options, overrides: { ...options.overrides, ...overrides } } : options;
2109
+ return await engine.bds(toStringArray(tickers), toStringArray(fields), normalizedOptions);
1867
2110
  }
1868
2111
  async function bds(tickers, fields, options = {}) {
1869
2112
  return await abds(tickers, fields, void 0, options);
1870
2113
  }
1871
2114
  async function abdib(ticker, dt, interval = 1, options = {}) {
1872
2115
  const engine = await getConfiguredEngine();
1873
- const dtIsOptions = isPlainObject(dt) && !(dt instanceof Date) && !hasToJSDate(dt);
1874
- if (dtIsOptions && interval === 1 && Object.keys(options).length === 0) {
2116
+ if (isBdibOptionsInput(dt) && interval === 1 && Object.keys(options).length === 0) {
1875
2117
  return await engine.bdib(toRequestString(ticker), dt);
1876
2118
  }
1877
- 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 };
1878
2120
  if (normalizedOptions.start === void 0 && normalizedOptions.end === void 0) {
1879
- if (dt === void 0) {
2121
+ if (dt === void 0 || isBdibOptionsInput(dt)) {
1880
2122
  throw new TypeError("abdib requires dt or explicit start/end options");
1881
2123
  }
1882
2124
  const range = fullDayRange(dt);
@@ -1893,7 +2135,7 @@ async function abdtick(ticker, start, end, options = {}) {
1893
2135
  throw new TypeError("abdtick requires both start and end datetimes");
1894
2136
  }
1895
2137
  const engine = await getConfiguredEngine();
1896
- return await engine.bdtick(toRequestString(ticker), { ...options, start, end });
2138
+ return await engine.bdtick(toRequestString(ticker), { ...options, end, start });
1897
2139
  }
1898
2140
  async function bdtick(ticker, options = {}) {
1899
2141
  const engine = await getConfiguredEngine();
@@ -1927,76 +2169,76 @@ async function acdxRisk(ticker, options = {}) {
1927
2169
  );
1928
2170
  }
1929
2171
  var blp = Object.freeze({
1930
- bdp,
1931
- bdh,
1932
- bds,
1933
- bdib,
1934
- bdtick,
1935
- subscribe,
1936
- abdp,
1937
2172
  abdh,
1938
- abds,
1939
2173
  abdib,
2174
+ abdp,
2175
+ abds,
1940
2176
  abdtick,
1941
- asubscribe
2177
+ asubscribe,
2178
+ bdh,
2179
+ bdib,
2180
+ bdp,
2181
+ bds,
2182
+ bdtick,
2183
+ subscribe
1942
2184
  });
1943
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,
1944
2194
  cdx: Object.freeze({
1945
2195
  acdx_info: acdxInfo,
1946
2196
  acdx_pricing: acdxPricing,
1947
2197
  acdx_risk: acdxRisk
1948
2198
  }),
1949
- parseDate: native.extParseDate,
1950
- fmtDate: native.extFmtDate,
1951
- pivotToWide: native.extPivotToWide,
1952
- isLongFormat: native.extIsLongFormat,
1953
- parseTicker: native.extParseTicker,
1954
- isSpecificContract: native.extIsSpecificContract,
1955
- buildFuturesTicker: native.extBuildFuturesTicker,
1956
- normalizeTickers: native.extNormalizeTickers,
1957
- filterEquityTickers: native.extFilterEquityTickers,
1958
- generateFuturesCandidates: native.extGenerateFuturesCandidates,
1959
- validateGenericTicker: native.extValidateGenericTicker,
2199
+ cdxGenToSpecific: native.extCdxGenToSpecific,
2200
+ clearExchangeOverride: native.extClearExchangeOverride,
1960
2201
  contractIndex: native.extContractIndex,
2202
+ currenciesNeedingConversion: native.extCurrenciesNeedingConversion,
2203
+ defaultBqrDatetimes: native.extDefaultBqrDatetimes,
2204
+ defaultTurnoverDates: native.extDefaultTurnoverDates,
2205
+ deriveSessions: native.extDeriveSessions,
1961
2206
  filterCandidatesByCycle: native.extFilterCandidatesByCycle,
2207
+ filterEquityTickers: native.extFilterEquityTickers,
1962
2208
  filterValidContracts: native.extFilterValidContracts,
1963
- parseCdxTicker: native.extParseCdxTicker,
1964
- previousCdxSeries: native.extPreviousCdxSeries,
1965
- cdxGenToSpecific: native.extCdxGenToSpecific,
1966
- buildFxPair: native.extBuildFxPair,
1967
- sameCurrency: native.extSameCurrency,
1968
- currenciesNeedingConversion: native.extCurrenciesNeedingConversion,
1969
- renameDividendColumns: native.extRenameDividendColumns,
1970
- renameEtfColumns: native.extRenameEtfColumns,
1971
- getMonthCode: native.extGetMonthCode,
1972
- getMonthName: native.extGetMonthName,
1973
- getFuturesMonths: native.extGetFuturesMonths,
2209
+ fmtDate: native.extFmtDate,
2210
+ generateFuturesCandidates: native.extGenerateFuturesCandidates,
2211
+ getDvdCols: native.extGetDvdCols,
1974
2212
  getDvdType: native.extGetDvdType,
1975
2213
  getDvdTypes: native.extGetDvdTypes,
1976
- getDvdCols: native.extGetDvdCols,
1977
2214
  getEtfCols: native.extGetEtfCols,
1978
- buildYasOverrides: native.extBuildYasOverrides,
1979
- buildEarningHeaderRename: native.extBuildEarningHeaderRename,
1980
- calculateLevelPercentages: native.extCalculateLevelPercentages,
1981
- buildPreferredsQuery: native.extBuildPreferredsQuery,
1982
- buildCorporateBondsQuery: native.extBuildCorporateBondsQuery,
1983
- buildEtfHoldingsQuery: native.extBuildEtfHoldingsQuery,
1984
- defaultTurnoverDates: native.extDefaultTurnoverDates,
1985
- defaultBqrDatetimes: native.extDefaultBqrDatetimes,
1986
- deriveSessions: native.extDeriveSessions,
2215
+ getExchangeOverride: native.extGetExchangeOverride,
2216
+ getFuturesMonths: native.extGetFuturesMonths,
1987
2217
  getMarketRule: native.extGetMarketRule,
2218
+ getMonthCode: native.extGetMonthCode,
2219
+ getMonthName: native.extGetMonthName,
1988
2220
  inferTimezone: native.extInferTimezone,
1989
- setExchangeOverride: native.extSetExchangeOverride,
1990
- getExchangeOverride: native.extGetExchangeOverride,
1991
- clearExchangeOverride: native.extClearExchangeOverride,
2221
+ isLongFormat: native.extIsLongFormat,
2222
+ isSpecificContract: native.extIsSpecificContract,
1992
2223
  listExchangeOverrides: native.extListExchangeOverrides,
1993
- 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
1994
2236
  });
1995
2237
  function version() {
1996
2238
  return packageJson.version;
1997
2239
  }
1998
- var setLogLevel = native.setLogLevel;
1999
- var getLogLevel = native.getLogLevel;
2240
+ var { setLogLevel } = native;
2241
+ var { getLogLevel } = native;
2000
2242
 
2001
2243
  exports.ArrowSubscription = ArrowSubscription;
2002
2244
  exports.Backend = Backend;