@forzalabs/remora 2.0.3 → 2.1.0

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/index.js CHANGED
@@ -1190,8 +1190,8 @@ var require_levels = __commonJS({
1190
1190
  var require_align = __commonJS({
1191
1191
  "../../node_modules/logform/align.js"(exports2, module2) {
1192
1192
  "use strict";
1193
- var format3 = require_format();
1194
- module2.exports = format3((info) => {
1193
+ var format4 = require_format();
1194
+ module2.exports = format4((info) => {
1195
1195
  info.message = ` ${info.message}`;
1196
1196
  return info;
1197
1197
  });
@@ -1202,9 +1202,9 @@ var require_align = __commonJS({
1202
1202
  var require_errors = __commonJS({
1203
1203
  "../../node_modules/logform/errors.js"(exports2, module2) {
1204
1204
  "use strict";
1205
- var format3 = require_format();
1205
+ var format4 = require_format();
1206
1206
  var { LEVEL, MESSAGE } = require_triple_beam();
1207
- module2.exports = format3((einfo, { stack, cause }) => {
1207
+ module2.exports = format4((einfo, { stack, cause }) => {
1208
1208
  if (einfo instanceof Error) {
1209
1209
  const info = Object.assign({}, einfo, {
1210
1210
  level: einfo.level,
@@ -1340,7 +1340,7 @@ var require_cli2 = __commonJS({
1340
1340
  var require_combine = __commonJS({
1341
1341
  "../../node_modules/logform/combine.js"(exports2, module2) {
1342
1342
  "use strict";
1343
- var format3 = require_format();
1343
+ var format4 = require_format();
1344
1344
  function cascade(formats) {
1345
1345
  if (!formats.every(isValidFormat)) {
1346
1346
  return;
@@ -1367,7 +1367,7 @@ var require_combine = __commonJS({
1367
1367
  return true;
1368
1368
  }
1369
1369
  module2.exports = (...formats) => {
1370
- const combinedFormat = format3(cascade(formats));
1370
+ const combinedFormat = format4(cascade(formats));
1371
1371
  const instance = combinedFormat();
1372
1372
  instance.Format = combinedFormat.Format;
1373
1373
  return instance;
@@ -1976,7 +1976,7 @@ ${originalIndentation}`;
1976
1976
  var require_json = __commonJS({
1977
1977
  "../../node_modules/logform/json.js"(exports2, module2) {
1978
1978
  "use strict";
1979
- var format3 = require_format();
1979
+ var format4 = require_format();
1980
1980
  var { MESSAGE } = require_triple_beam();
1981
1981
  var stringify = require_safe_stable_stringify();
1982
1982
  function replacer(key, value) {
@@ -1984,7 +1984,7 @@ var require_json = __commonJS({
1984
1984
  return value.toString();
1985
1985
  return value;
1986
1986
  }
1987
- module2.exports = format3((info, opts) => {
1987
+ module2.exports = format4((info, opts) => {
1988
1988
  const jsonStringify = stringify.configure(opts);
1989
1989
  info[MESSAGE] = jsonStringify(info, opts.replacer || replacer, opts.space);
1990
1990
  return info;
@@ -1996,8 +1996,8 @@ var require_json = __commonJS({
1996
1996
  var require_label = __commonJS({
1997
1997
  "../../node_modules/logform/label.js"(exports2, module2) {
1998
1998
  "use strict";
1999
- var format3 = require_format();
2000
- module2.exports = format3((info, opts) => {
1999
+ var format4 = require_format();
2000
+ module2.exports = format4((info, opts) => {
2001
2001
  if (opts.message) {
2002
2002
  info.message = `[${opts.label}] ${info.message}`;
2003
2003
  return info;
@@ -2012,10 +2012,10 @@ var require_label = __commonJS({
2012
2012
  var require_logstash = __commonJS({
2013
2013
  "../../node_modules/logform/logstash.js"(exports2, module2) {
2014
2014
  "use strict";
2015
- var format3 = require_format();
2015
+ var format4 = require_format();
2016
2016
  var { MESSAGE } = require_triple_beam();
2017
2017
  var jsonStringify = require_safe_stable_stringify();
2018
- module2.exports = format3((info) => {
2018
+ module2.exports = format4((info) => {
2019
2019
  const logstash = {};
2020
2020
  if (info.message) {
2021
2021
  logstash["@message"] = info.message;
@@ -2036,7 +2036,7 @@ var require_logstash = __commonJS({
2036
2036
  var require_metadata = __commonJS({
2037
2037
  "../../node_modules/logform/metadata.js"(exports2, module2) {
2038
2038
  "use strict";
2039
- var format3 = require_format();
2039
+ var format4 = require_format();
2040
2040
  function fillExcept(info, fillExceptKeys, metadataKey) {
2041
2041
  const savedKeys = fillExceptKeys.reduce((acc, key) => {
2042
2042
  acc[key] = info[key];
@@ -2061,7 +2061,7 @@ var require_metadata = __commonJS({
2061
2061
  }, {});
2062
2062
  return info;
2063
2063
  }
2064
- module2.exports = format3((info, opts = {}) => {
2064
+ module2.exports = format4((info, opts = {}) => {
2065
2065
  let metadataKey = "metadata";
2066
2066
  if (opts.key) {
2067
2067
  metadataKey = opts.key;
@@ -2205,9 +2205,9 @@ var require_ms = __commonJS({
2205
2205
  var require_ms2 = __commonJS({
2206
2206
  "../../node_modules/logform/ms.js"(exports2, module2) {
2207
2207
  "use strict";
2208
- var format3 = require_format();
2208
+ var format4 = require_format();
2209
2209
  var ms2 = require_ms();
2210
- module2.exports = format3((info) => {
2210
+ module2.exports = format4((info) => {
2211
2211
  const curr = +/* @__PURE__ */ new Date();
2212
2212
  exports2.diff = curr - (exports2.prevTime || curr);
2213
2213
  exports2.prevTime = curr;
@@ -2222,9 +2222,9 @@ var require_pretty_print = __commonJS({
2222
2222
  "../../node_modules/logform/pretty-print.js"(exports2, module2) {
2223
2223
  "use strict";
2224
2224
  var inspect = require("util").inspect;
2225
- var format3 = require_format();
2225
+ var format4 = require_format();
2226
2226
  var { LEVEL, MESSAGE, SPLAT } = require_triple_beam();
2227
- module2.exports = format3((info, opts = {}) => {
2227
+ module2.exports = format4((info, opts = {}) => {
2228
2228
  const stripped = Object.assign({}, info);
2229
2229
  delete stripped[LEVEL];
2230
2230
  delete stripped[MESSAGE];
@@ -2258,10 +2258,10 @@ var require_printf = __commonJS({
2258
2258
  var require_simple = __commonJS({
2259
2259
  "../../node_modules/logform/simple.js"(exports2, module2) {
2260
2260
  "use strict";
2261
- var format3 = require_format();
2261
+ var format4 = require_format();
2262
2262
  var { MESSAGE } = require_triple_beam();
2263
2263
  var jsonStringify = require_safe_stable_stringify();
2264
- module2.exports = format3((info) => {
2264
+ module2.exports = format4((info) => {
2265
2265
  const stringifiedRest = jsonStringify(Object.assign({}, info, {
2266
2266
  level: void 0,
2267
2267
  message: void 0,
@@ -2383,14 +2383,14 @@ function assign(origObj) {
2383
2383
  }
2384
2384
  return origObj;
2385
2385
  }
2386
- function parse(dateStr, format3, i18n) {
2386
+ function parse(dateStr, format4, i18n) {
2387
2387
  if (i18n === void 0) {
2388
2388
  i18n = {};
2389
2389
  }
2390
- if (typeof format3 !== "string") {
2390
+ if (typeof format4 !== "string") {
2391
2391
  throw new Error("Invalid format in fecha parse");
2392
2392
  }
2393
- format3 = globalMasks[format3] || format3;
2393
+ format4 = globalMasks[format4] || format4;
2394
2394
  if (dateStr.length > 1e3) {
2395
2395
  return null;
2396
2396
  }
@@ -2408,7 +2408,7 @@ function parse(dateStr, format3, i18n) {
2408
2408
  };
2409
2409
  var parseInfo = [];
2410
2410
  var literals = [];
2411
- var newFormat = format3.replace(literal, function($0, $1) {
2411
+ var newFormat = format4.replace(literal, function($0, $1) {
2412
2412
  literals.push(regexEscape($1));
2413
2413
  return "@@@";
2414
2414
  });
@@ -2770,8 +2770,8 @@ var require_timestamp = __commonJS({
2770
2770
  "../../node_modules/logform/timestamp.js"(exports2, module2) {
2771
2771
  "use strict";
2772
2772
  var fecha2 = (init_fecha(), __toCommonJS(fecha_exports));
2773
- var format3 = require_format();
2774
- module2.exports = format3((info, opts = {}) => {
2773
+ var format4 = require_format();
2774
+ module2.exports = format4((info, opts = {}) => {
2775
2775
  if (opts.format) {
2776
2776
  info.timestamp = typeof opts.format === "function" ? opts.format() : fecha2.format(/* @__PURE__ */ new Date(), opts.format);
2777
2777
  }
@@ -2791,9 +2791,9 @@ var require_uncolorize = __commonJS({
2791
2791
  "../../node_modules/logform/uncolorize.js"(exports2, module2) {
2792
2792
  "use strict";
2793
2793
  var colors = require_safe();
2794
- var format3 = require_format();
2794
+ var format4 = require_format();
2795
2795
  var { MESSAGE } = require_triple_beam();
2796
- module2.exports = format3((info, opts) => {
2796
+ module2.exports = format4((info, opts) => {
2797
2797
  if (opts.level !== false) {
2798
2798
  info.level = colors.strip(info.level);
2799
2799
  }
@@ -2812,10 +2812,10 @@ var require_uncolorize = __commonJS({
2812
2812
  var require_logform = __commonJS({
2813
2813
  "../../node_modules/logform/index.js"(exports2) {
2814
2814
  "use strict";
2815
- var format3 = exports2.format = require_format();
2815
+ var format4 = exports2.format = require_format();
2816
2816
  exports2.levels = require_levels();
2817
2817
  function exposeFormat(name, requireFormat) {
2818
- Object.defineProperty(format3, name, {
2818
+ Object.defineProperty(format4, name, {
2819
2819
  get() {
2820
2820
  return requireFormat();
2821
2821
  },
@@ -2880,17 +2880,17 @@ var require_logform = __commonJS({
2880
2880
  var require_common = __commonJS({
2881
2881
  "../../node_modules/winston/lib/winston/common.js"(exports2) {
2882
2882
  "use strict";
2883
- var { format: format3 } = require("util");
2883
+ var { format: format4 } = require("util");
2884
2884
  exports2.warn = {
2885
2885
  deprecated(prop) {
2886
2886
  return () => {
2887
- throw new Error(format3("{ %s } was removed in winston@3.0.0.", prop));
2887
+ throw new Error(format4("{ %s } was removed in winston@3.0.0.", prop));
2888
2888
  };
2889
2889
  },
2890
2890
  useFormat(prop) {
2891
2891
  return () => {
2892
2892
  throw new Error([
2893
- format3("{ %s } was removed in winston@3.0.0.", prop),
2893
+ format4("{ %s } was removed in winston@3.0.0.", prop),
2894
2894
  "Use a custom winston.format = winston.format(function) instead."
2895
2895
  ].join("\n"));
2896
2896
  };
@@ -4155,14 +4155,14 @@ var require_from = __commonJS({
4155
4155
  return (hint === "string" ? String : Number)(input);
4156
4156
  }
4157
4157
  var ERR_INVALID_ARG_TYPE = require_errors2().codes.ERR_INVALID_ARG_TYPE;
4158
- function from(Readable7, iterable, opts) {
4158
+ function from(Readable8, iterable, opts) {
4159
4159
  var iterator;
4160
4160
  if (iterable && typeof iterable.next === "function") {
4161
4161
  iterator = iterable;
4162
4162
  } else if (iterable && iterable[Symbol.asyncIterator]) iterator = iterable[Symbol.asyncIterator]();
4163
4163
  else if (iterable && iterable[Symbol.iterator]) iterator = iterable[Symbol.iterator]();
4164
4164
  else throw new ERR_INVALID_ARG_TYPE("iterable", ["Iterable"], iterable);
4165
- var readable = new Readable7(_objectSpread({
4165
+ var readable = new Readable8(_objectSpread({
4166
4166
  objectMode: true
4167
4167
  }, opts));
4168
4168
  var reading = false;
@@ -4202,9 +4202,9 @@ var require_from = __commonJS({
4202
4202
  var require_stream_readable = __commonJS({
4203
4203
  "../../node_modules/readable-stream/lib/_stream_readable.js"(exports2, module2) {
4204
4204
  "use strict";
4205
- module2.exports = Readable7;
4205
+ module2.exports = Readable8;
4206
4206
  var Duplex;
4207
- Readable7.ReadableState = ReadableState;
4207
+ Readable8.ReadableState = ReadableState;
4208
4208
  var EE = require("events").EventEmitter;
4209
4209
  var EElistenerCount = function EElistenerCount2(emitter, type) {
4210
4210
  return emitter.listeners(type).length;
@@ -4239,7 +4239,7 @@ var require_stream_readable = __commonJS({
4239
4239
  var StringDecoder;
4240
4240
  var createReadableStreamAsyncIterator;
4241
4241
  var from;
4242
- require_inherits()(Readable7, Stream);
4242
+ require_inherits()(Readable8, Stream);
4243
4243
  var errorOrDestroy = destroyImpl.errorOrDestroy;
4244
4244
  var kProxyEvents = ["error", "close", "destroy", "pause", "resume"];
4245
4245
  function prependListener(emitter, event, fn) {
@@ -4283,9 +4283,9 @@ var require_stream_readable = __commonJS({
4283
4283
  this.encoding = options.encoding;
4284
4284
  }
4285
4285
  }
4286
- function Readable7(options) {
4286
+ function Readable8(options) {
4287
4287
  Duplex = Duplex || require_stream_duplex();
4288
- if (!(this instanceof Readable7)) return new Readable7(options);
4288
+ if (!(this instanceof Readable8)) return new Readable8(options);
4289
4289
  var isDuplex = this instanceof Duplex;
4290
4290
  this._readableState = new ReadableState(options, this, isDuplex);
4291
4291
  this.readable = true;
@@ -4295,7 +4295,7 @@ var require_stream_readable = __commonJS({
4295
4295
  }
4296
4296
  Stream.call(this);
4297
4297
  }
4298
- Object.defineProperty(Readable7.prototype, "destroyed", {
4298
+ Object.defineProperty(Readable8.prototype, "destroyed", {
4299
4299
  // making it explicit this property is not enumerable
4300
4300
  // because otherwise some prototype manipulation in
4301
4301
  // userland will fail
@@ -4313,12 +4313,12 @@ var require_stream_readable = __commonJS({
4313
4313
  this._readableState.destroyed = value;
4314
4314
  }
4315
4315
  });
4316
- Readable7.prototype.destroy = destroyImpl.destroy;
4317
- Readable7.prototype._undestroy = destroyImpl.undestroy;
4318
- Readable7.prototype._destroy = function(err2, cb) {
4316
+ Readable8.prototype.destroy = destroyImpl.destroy;
4317
+ Readable8.prototype._undestroy = destroyImpl.undestroy;
4318
+ Readable8.prototype._destroy = function(err2, cb) {
4319
4319
  cb(err2);
4320
4320
  };
4321
- Readable7.prototype.push = function(chunk, encoding) {
4321
+ Readable8.prototype.push = function(chunk, encoding) {
4322
4322
  var state2 = this._readableState;
4323
4323
  var skipChunkCheck;
4324
4324
  if (!state2.objectMode) {
@@ -4335,7 +4335,7 @@ var require_stream_readable = __commonJS({
4335
4335
  }
4336
4336
  return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
4337
4337
  };
4338
- Readable7.prototype.unshift = function(chunk) {
4338
+ Readable8.prototype.unshift = function(chunk) {
4339
4339
  return readableAddChunk(this, chunk, null, true, false);
4340
4340
  };
4341
4341
  function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
@@ -4396,10 +4396,10 @@ var require_stream_readable = __commonJS({
4396
4396
  }
4397
4397
  return er2;
4398
4398
  }
4399
- Readable7.prototype.isPaused = function() {
4399
+ Readable8.prototype.isPaused = function() {
4400
4400
  return this._readableState.flowing === false;
4401
4401
  };
4402
- Readable7.prototype.setEncoding = function(enc) {
4402
+ Readable8.prototype.setEncoding = function(enc) {
4403
4403
  if (!StringDecoder) StringDecoder = require_string_decoder().StringDecoder;
4404
4404
  var decoder = new StringDecoder(enc);
4405
4405
  this._readableState.decoder = decoder;
@@ -4445,7 +4445,7 @@ var require_stream_readable = __commonJS({
4445
4445
  }
4446
4446
  return state2.length;
4447
4447
  }
4448
- Readable7.prototype.read = function(n4) {
4448
+ Readable8.prototype.read = function(n4) {
4449
4449
  debug("read", n4);
4450
4450
  n4 = parseInt(n4, 10);
4451
4451
  var state2 = this._readableState;
@@ -4554,10 +4554,10 @@ var require_stream_readable = __commonJS({
4554
4554
  }
4555
4555
  state2.readingMore = false;
4556
4556
  }
4557
- Readable7.prototype._read = function(n4) {
4557
+ Readable8.prototype._read = function(n4) {
4558
4558
  errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED("_read()"));
4559
4559
  };
4560
- Readable7.prototype.pipe = function(dest, pipeOpts) {
4560
+ Readable8.prototype.pipe = function(dest, pipeOpts) {
4561
4561
  var src = this;
4562
4562
  var state2 = this._readableState;
4563
4563
  switch (state2.pipesCount) {
@@ -4660,7 +4660,7 @@ var require_stream_readable = __commonJS({
4660
4660
  }
4661
4661
  };
4662
4662
  }
4663
- Readable7.prototype.unpipe = function(dest) {
4663
+ Readable8.prototype.unpipe = function(dest) {
4664
4664
  var state2 = this._readableState;
4665
4665
  var unpipeInfo = {
4666
4666
  hasUnpiped: false
@@ -4694,7 +4694,7 @@ var require_stream_readable = __commonJS({
4694
4694
  dest.emit("unpipe", this, unpipeInfo);
4695
4695
  return this;
4696
4696
  };
4697
- Readable7.prototype.on = function(ev, fn) {
4697
+ Readable8.prototype.on = function(ev, fn) {
4698
4698
  var res = Stream.prototype.on.call(this, ev, fn);
4699
4699
  var state2 = this._readableState;
4700
4700
  if (ev === "data") {
@@ -4715,15 +4715,15 @@ var require_stream_readable = __commonJS({
4715
4715
  }
4716
4716
  return res;
4717
4717
  };
4718
- Readable7.prototype.addListener = Readable7.prototype.on;
4719
- Readable7.prototype.removeListener = function(ev, fn) {
4718
+ Readable8.prototype.addListener = Readable8.prototype.on;
4719
+ Readable8.prototype.removeListener = function(ev, fn) {
4720
4720
  var res = Stream.prototype.removeListener.call(this, ev, fn);
4721
4721
  if (ev === "readable") {
4722
4722
  process.nextTick(updateReadableListening, this);
4723
4723
  }
4724
4724
  return res;
4725
4725
  };
4726
- Readable7.prototype.removeAllListeners = function(ev) {
4726
+ Readable8.prototype.removeAllListeners = function(ev) {
4727
4727
  var res = Stream.prototype.removeAllListeners.apply(this, arguments);
4728
4728
  if (ev === "readable" || ev === void 0) {
4729
4729
  process.nextTick(updateReadableListening, this);
@@ -4743,7 +4743,7 @@ var require_stream_readable = __commonJS({
4743
4743
  debug("readable nexttick read 0");
4744
4744
  self2.read(0);
4745
4745
  }
4746
- Readable7.prototype.resume = function() {
4746
+ Readable8.prototype.resume = function() {
4747
4747
  var state2 = this._readableState;
4748
4748
  if (!state2.flowing) {
4749
4749
  debug("resume");
@@ -4769,7 +4769,7 @@ var require_stream_readable = __commonJS({
4769
4769
  flow(stream);
4770
4770
  if (state2.flowing && !state2.reading) stream.read(0);
4771
4771
  }
4772
- Readable7.prototype.pause = function() {
4772
+ Readable8.prototype.pause = function() {
4773
4773
  debug("call pause flowing=%j", this._readableState.flowing);
4774
4774
  if (this._readableState.flowing !== false) {
4775
4775
  debug("pause");
@@ -4784,7 +4784,7 @@ var require_stream_readable = __commonJS({
4784
4784
  debug("flow", state2.flowing);
4785
4785
  while (state2.flowing && stream.read() !== null) ;
4786
4786
  }
4787
- Readable7.prototype.wrap = function(stream) {
4787
+ Readable8.prototype.wrap = function(stream) {
4788
4788
  var _this = this;
4789
4789
  var state2 = this._readableState;
4790
4790
  var paused = false;
@@ -4829,14 +4829,14 @@ var require_stream_readable = __commonJS({
4829
4829
  return this;
4830
4830
  };
4831
4831
  if (typeof Symbol === "function") {
4832
- Readable7.prototype[Symbol.asyncIterator] = function() {
4832
+ Readable8.prototype[Symbol.asyncIterator] = function() {
4833
4833
  if (createReadableStreamAsyncIterator === void 0) {
4834
4834
  createReadableStreamAsyncIterator = require_async_iterator();
4835
4835
  }
4836
4836
  return createReadableStreamAsyncIterator(this);
4837
4837
  };
4838
4838
  }
4839
- Object.defineProperty(Readable7.prototype, "readableHighWaterMark", {
4839
+ Object.defineProperty(Readable8.prototype, "readableHighWaterMark", {
4840
4840
  // making it explicit this property is not enumerable
4841
4841
  // because otherwise some prototype manipulation in
4842
4842
  // userland will fail
@@ -4845,7 +4845,7 @@ var require_stream_readable = __commonJS({
4845
4845
  return this._readableState.highWaterMark;
4846
4846
  }
4847
4847
  });
4848
- Object.defineProperty(Readable7.prototype, "readableBuffer", {
4848
+ Object.defineProperty(Readable8.prototype, "readableBuffer", {
4849
4849
  // making it explicit this property is not enumerable
4850
4850
  // because otherwise some prototype manipulation in
4851
4851
  // userland will fail
@@ -4854,7 +4854,7 @@ var require_stream_readable = __commonJS({
4854
4854
  return this._readableState && this._readableState.buffer;
4855
4855
  }
4856
4856
  });
4857
- Object.defineProperty(Readable7.prototype, "readableFlowing", {
4857
+ Object.defineProperty(Readable8.prototype, "readableFlowing", {
4858
4858
  // making it explicit this property is not enumerable
4859
4859
  // because otherwise some prototype manipulation in
4860
4860
  // userland will fail
@@ -4868,8 +4868,8 @@ var require_stream_readable = __commonJS({
4868
4868
  }
4869
4869
  }
4870
4870
  });
4871
- Readable7._fromList = fromList;
4872
- Object.defineProperty(Readable7.prototype, "readableLength", {
4871
+ Readable8._fromList = fromList;
4872
+ Object.defineProperty(Readable8.prototype, "readableLength", {
4873
4873
  // making it explicit this property is not enumerable
4874
4874
  // because otherwise some prototype manipulation in
4875
4875
  // userland will fail
@@ -4915,11 +4915,11 @@ var require_stream_readable = __commonJS({
4915
4915
  }
4916
4916
  }
4917
4917
  if (typeof Symbol === "function") {
4918
- Readable7.from = function(iterable, opts) {
4918
+ Readable8.from = function(iterable, opts) {
4919
4919
  if (from === void 0) {
4920
4920
  from = require_from();
4921
4921
  }
4922
- return from(Readable7, iterable, opts);
4922
+ return from(Readable8, iterable, opts);
4923
4923
  };
4924
4924
  }
4925
4925
  function indexOf(xs2, x2) {
@@ -4941,9 +4941,9 @@ var require_stream_duplex = __commonJS({
4941
4941
  return keys2;
4942
4942
  };
4943
4943
  module2.exports = Duplex;
4944
- var Readable7 = require_stream_readable();
4944
+ var Readable8 = require_stream_readable();
4945
4945
  var Writable2 = require_stream_writable();
4946
- require_inherits()(Duplex, Readable7);
4946
+ require_inherits()(Duplex, Readable8);
4947
4947
  {
4948
4948
  keys = objectKeys(Writable2.prototype);
4949
4949
  for (v3 = 0; v3 < keys.length; v3++) {
@@ -4956,7 +4956,7 @@ var require_stream_duplex = __commonJS({
4956
4956
  var v3;
4957
4957
  function Duplex(options) {
4958
4958
  if (!(this instanceof Duplex)) return new Duplex(options);
4959
- Readable7.call(this, options);
4959
+ Readable8.call(this, options);
4960
4960
  Writable2.call(this, options);
4961
4961
  this.allowHalfOpen = true;
4962
4962
  if (options) {
@@ -6498,7 +6498,7 @@ var require_pipeline = __commonJS({
6498
6498
  if (typeof streams[streams.length - 1] !== "function") return noop;
6499
6499
  return streams.pop();
6500
6500
  }
6501
- function pipeline5() {
6501
+ function pipeline6() {
6502
6502
  for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) {
6503
6503
  streams[_key] = arguments[_key];
6504
6504
  }
@@ -6521,7 +6521,7 @@ var require_pipeline = __commonJS({
6521
6521
  });
6522
6522
  return streams.reduce(pipe);
6523
6523
  }
6524
- module2.exports = pipeline5;
6524
+ module2.exports = pipeline6;
6525
6525
  }
6526
6526
  });
6527
6527
 
@@ -10275,7 +10275,7 @@ var require_logger = __commonJS({
10275
10275
  */
10276
10276
  configure({
10277
10277
  silent,
10278
- format: format3,
10278
+ format: format4,
10279
10279
  defaultMeta,
10280
10280
  levels,
10281
10281
  level = "info",
@@ -10294,7 +10294,7 @@ var require_logger = __commonJS({
10294
10294
  this.clear();
10295
10295
  }
10296
10296
  this.silent = silent;
10297
- this.format = format3 || this.format || require_json()();
10297
+ this.format = format4 || this.format || require_json()();
10298
10298
  this.defaultMeta = defaultMeta || null;
10299
10299
  this.levels = levels || this.levels || config.npm.levels;
10300
10300
  this.level = level;
@@ -11116,18 +11116,32 @@ ${stack}` : base;
11116
11116
  });
11117
11117
 
11118
11118
  // ../../packages/logger/src/logger/Logger.ts
11119
- var import_chalk, MAX_CAUSE_DEPTH, Logger, logger, Logger_default;
11119
+ var import_util, import_chalk, MAX_CAUSE_DEPTH, LOG_RECORD_VERSION, MAX_FIELD_CHARS, ANSI_PATTERN, nativeConsole, Logger, logger, Logger_default;
11120
11120
  var init_Logger = __esm({
11121
11121
  "../../packages/logger/src/logger/Logger.ts"() {
11122
+ import_util = require("util");
11123
+ init_src();
11122
11124
  import_chalk = __toESM(require("chalk"), 1);
11123
11125
  init_FileLogService();
11124
11126
  MAX_CAUSE_DEPTH = 10;
11127
+ LOG_RECORD_VERSION = 1;
11128
+ MAX_FIELD_CHARS = 3e4;
11129
+ ANSI_PATTERN = /\u001B\[[0-9;]*m/g;
11130
+ nativeConsole = {
11131
+ log: console.log.bind(console),
11132
+ info: console.info.bind(console),
11133
+ warn: console.warn.bind(console),
11134
+ error: console.error.bind(console)
11135
+ };
11125
11136
  Logger = class {
11126
11137
  constructor() {
11127
11138
  // Counts lines written to the console. In-place TTY renderers (the CLI progress bar) read it to
11128
11139
  // detect that something else has printed since their last frame, so they redraw on a new line
11129
11140
  // instead of moving the cursor up and overwriting a log message.
11130
11141
  this._consoleWrites = 0;
11142
+ // Whether console.* has been redirected into this logger. Once per process, and one-way: our
11143
+ // own writes use `nativeConsole`, so there is nothing to restore it for.
11144
+ this._consoleCaptured = false;
11131
11145
  this.setLevel = (level) => this._level = level;
11132
11146
  this.enableFileLogging = (folder, file) => {
11133
11147
  this._fileLoggingFolder = folder;
@@ -11161,9 +11175,28 @@ var init_Logger = __esm({
11161
11175
  this._level = "debug";
11162
11176
  if (fileLoggingFolder && process.env.NODE_ENV !== "development") {
11163
11177
  this.enableFileLogging(fileLoggingFolder);
11164
- console.error("Enabled file logger.");
11178
+ nativeConsole.error("Enabled file logger.");
11165
11179
  }
11166
11180
  };
11181
+ /**
11182
+ * Routes `console.*` through this logger, so code that never heard of it still writes one line
11183
+ * per record. Call once from a deployed process entrypoint; a no-op under the `text` format,
11184
+ * where a human is reading the console and Node's own formatting is the better rendering.
11185
+ *
11186
+ * Interception rather than a sweep of the call sites: the requirement is about the STREAM, not
11187
+ * about our code — an express handler, a driver and a dependency all write to the same stdout,
11188
+ * and a rule enforced at the call sites is a rule that the next `console.error` breaks.
11189
+ */
11190
+ this.captureConsole = () => {
11191
+ if (this._consoleCaptured) return;
11192
+ if (this.consoleFormat() !== "json") return;
11193
+ this._consoleCaptured = true;
11194
+ console.log = (...args) => this.info((0, import_util.format)(...args));
11195
+ console.info = console.log;
11196
+ console.debug = (...args) => this.log((0, import_util.format)(...args));
11197
+ console.warn = (...args) => this.warn((0, import_util.format)(...args));
11198
+ console.error = (...args) => args.length === 1 && args[0] instanceof Error ? this.error(args[0]) : this.error((0, import_util.format)(...args));
11199
+ };
11167
11200
  // The file sink replaces the console only for the CLI: there a human is watching the progress bar
11168
11201
  // and can read the log file afterwards. Anywhere else that file sits on an ephemeral container
11169
11202
  // layer nobody reads, and stdout is the only sink reaching the log driver (ECS -> CloudWatch), so
@@ -11174,18 +11207,15 @@ var init_Logger = __esm({
11174
11207
  if (myLevel !== "debug") return;
11175
11208
  FileLogService_default.write("DEBUG", String(message));
11176
11209
  if (this.isConsoleSuppressed()) return;
11177
- console.log(import_chalk.default.cyanBright("DEBUG"), message);
11178
- this._consoleWrites++;
11210
+ this.writeConsole("debug", message);
11179
11211
  };
11180
11212
  this.info = (message) => {
11181
11213
  FileLogService_default.write("INFO", String(message));
11182
11214
  if (this.isConsoleSuppressed()) return;
11183
- console.info(message);
11184
- this._consoleWrites++;
11215
+ this.writeConsole("info", message);
11185
11216
  };
11186
11217
  this.warn = (message) => {
11187
- console.warn(message);
11188
- this._consoleWrites++;
11218
+ this.writeConsole("warn", message);
11189
11219
  FileLogService_default.write("WARN", String(message));
11190
11220
  };
11191
11221
  this.flush = () => FileLogService_default.flush();
@@ -11203,11 +11233,88 @@ var init_Logger = __esm({
11203
11233
  message = String(error);
11204
11234
  }
11205
11235
  const suppressed = this.isConsoleSuppressed();
11206
- console.error(message);
11207
- this._consoleWrites++;
11236
+ this.writeConsole("error", message, suppressed ? void 0 : stack);
11208
11237
  FileLogService_default.write("ERROR", message, stack);
11209
- if (stack && !suppressed)
11210
- console.error(stack);
11238
+ };
11239
+ /**
11240
+ * How console records are rendered: `text` for a human at a terminal, `json` for a log pipeline.
11241
+ *
11242
+ * Deployed processes default to `json` because there ONE RECORD MUST BE ONE LINE: the awslogs
11243
+ * driver turns every newline on stdout into its own CloudWatch event, so a stack trace arrived as
11244
+ * thirty separate events, none of them carrying the message they belonged to, interleaved with
11245
+ * whatever the other threads were writing. `REMORA_LOG_FORMAT` overrides the default either way.
11246
+ * Same rule as StateEmitter, whose records share the stream.
11247
+ */
11248
+ this.consoleFormat = () => {
11249
+ const configured = process.env.REMORA_LOG_FORMAT?.toLowerCase();
11250
+ if (configured === "json" || configured === "text")
11251
+ return configured;
11252
+ return process.env.REMORA_RUNTIME_CONTEXT === "cli" ? "text" : "json";
11253
+ };
11254
+ /**
11255
+ * The one place anything of ours reaches the console.
11256
+ *
11257
+ * `stack` belongs to the record it explains: a second line in text mode, a field of the same JSON
11258
+ * object in json mode — never a record of its own, which is how it would lose its message.
11259
+ */
11260
+ this.writeConsole = (level, message, stack) => {
11261
+ this._consoleWrites++;
11262
+ if (this.consoleFormat() === "json")
11263
+ return this.writeJson(level, message, stack);
11264
+ this.writeText(level, message, stack);
11265
+ };
11266
+ this.writeText = (level, message, stack) => {
11267
+ if (level === "debug")
11268
+ nativeConsole.log(import_chalk.default.cyanBright("DEBUG"), message);
11269
+ else if (level === "info")
11270
+ nativeConsole.info(message);
11271
+ else if (level === "warn")
11272
+ nativeConsole.warn(message);
11273
+ else
11274
+ nativeConsole.error(message);
11275
+ if (stack)
11276
+ nativeConsole.error(stack);
11277
+ };
11278
+ /**
11279
+ * One JSON object, one line, one log event. Written straight to the stream rather than through
11280
+ * `console`, which reformats and re-wraps what it is given.
11281
+ */
11282
+ this.writeJson = (level, message, stack) => {
11283
+ const record = {
11284
+ remora: "log",
11285
+ v: LOG_RECORD_VERSION,
11286
+ ts: DSTE_default.now().toISOString(),
11287
+ level,
11288
+ message: this.asField(message),
11289
+ ...stack ? { stack: this.asField(stack) } : {}
11290
+ };
11291
+ const stream = level === "warn" || level === "error" ? process.stderr : process.stdout;
11292
+ stream.write(`${this.stringify(record)}
11293
+ `);
11294
+ };
11295
+ /** A loggable value as one clamped, colour-free string. */
11296
+ this.asField = (value) => {
11297
+ const plain = this.asText(value).replace(ANSI_PATTERN, "");
11298
+ if (plain.length <= MAX_FIELD_CHARS)
11299
+ return plain;
11300
+ return `${plain.slice(0, MAX_FIELD_CHARS)}\u2026[+${plain.length - MAX_FIELD_CHARS} chars]`;
11301
+ };
11302
+ this.asText = (value) => {
11303
+ if (typeof value === "string")
11304
+ return value;
11305
+ if (value instanceof Error)
11306
+ return value.stack ?? value.message;
11307
+ if (typeof value === "object" && value !== null)
11308
+ return this.stringify(value);
11309
+ return String(value);
11310
+ };
11311
+ /** JSON.stringify that cannot throw: a circular or unserializable value still has to be logged. */
11312
+ this.stringify = (value) => {
11313
+ try {
11314
+ return JSON.stringify(value);
11315
+ } catch {
11316
+ return String(value);
11317
+ }
11211
11318
  };
11212
11319
  // Node's Error.stack omits `cause` — only util.inspect renders it, and we log strings rather
11213
11320
  // than Error objects. Without unwrapping here the root reason of a wrapped error is lost on any
@@ -11527,7 +11634,7 @@ var CONSTANTS, Constants_default;
11527
11634
  var init_Constants = __esm({
11528
11635
  "../../packages/constants/src/Constants.ts"() {
11529
11636
  CONSTANTS = {
11530
- cliVersion: "2.0.3",
11637
+ cliVersion: "2.1.0",
11531
11638
  backendVersion: 1,
11532
11639
  backendPort: 5088,
11533
11640
  workerVersion: 2,
@@ -12577,10 +12684,10 @@ var init_Validator = __esm({
12577
12684
  errors.push(`There are outputs with the same type. (duplicates type: ${duplicatesTypes.join(" and ")})`);
12578
12685
  }
12579
12686
  for (const output of consumer.outputs) {
12580
- const format3 = output.format.toUpperCase();
12581
- if (format3 === "CSV" || format3 === "JSON" || format3 === "PARQUET" || format3 === "TXT") {
12687
+ const format4 = output.format.toUpperCase();
12688
+ if (format4 === "CSV" || format4 === "JSON" || format4 === "PARQUET" || format4 === "TXT") {
12582
12689
  if (!output.exportDestination)
12583
- errors.push(`A static file output must have an export destination set (${format3})`);
12690
+ errors.push(`A static file output must have an export destination set (${format4})`);
12584
12691
  else if (!Environment_default.getSource(output.exportDestination))
12585
12692
  errors.push(`The export destination "${output.exportDestination}" was not found in the sources.`);
12586
12693
  }
@@ -12652,14 +12759,14 @@ var init_Validator = __esm({
12652
12759
  const errors = [];
12653
12760
  const positionalFormats = ["CSV", "TXT", "PARQUET"];
12654
12761
  for (const output of (consumer.outputs ?? []).filter((x2) => x2.omitNull === true)) {
12655
- const format3 = output.format.toUpperCase();
12656
- if (positionalFormats.includes(format3)) {
12657
- errors.push(`The ${format3} output of consumer "${consumer.name}" declares "omitNull", which only applies to JSON/API output: a positional column can't be omitted from a row.`);
12762
+ const format4 = output.format.toUpperCase();
12763
+ if (positionalFormats.includes(format4)) {
12764
+ errors.push(`The ${format4} output of consumer "${consumer.name}" declares "omitNull", which only applies to JSON/API output: a positional column can't be omitted from a row.`);
12658
12765
  continue;
12659
12766
  }
12660
12767
  const positional = (consumer.outputs ?? []).filter((x2) => positionalFormats.includes(x2.format.toUpperCase()));
12661
12768
  if (positional.length > 0)
12662
- errors.push(`The ${format3} output of consumer "${consumer.name}" declares "omitNull", but the consumer also writes ${positional.map((x2) => x2.format.toUpperCase()).join(" and ")}. Every output is serialized from one record, so omitting fields would break the positional one \u2014 split them into two consumers.`);
12769
+ errors.push(`The ${format4} output of consumer "${consumer.name}" declares "omitNull", but the consumer also writes ${positional.map((x2) => x2.format.toUpperCase()).join(" and ")}. Every output is serialized from one record, so omitting fields would break the positional one \u2014 split them into two consumers.`);
12663
12770
  }
12664
12771
  return errors;
12665
12772
  };
@@ -17592,17 +17699,17 @@ var init_split_header = __esm({
17592
17699
  });
17593
17700
 
17594
17701
  // ../../node_modules/@smithy/core/dist-es/submodules/serde/value/NumericValue.js
17595
- var format2, NumericValue;
17702
+ var format3, NumericValue;
17596
17703
  var init_NumericValue = __esm({
17597
17704
  "../../node_modules/@smithy/core/dist-es/submodules/serde/value/NumericValue.js"() {
17598
- format2 = /^-?\d*(\.\d+)?$/;
17705
+ format3 = /^-?\d*(\.\d+)?$/;
17599
17706
  NumericValue = class _NumericValue {
17600
17707
  string;
17601
17708
  type;
17602
17709
  constructor(string, type) {
17603
17710
  this.string = string;
17604
17711
  this.type = type;
17605
- if (!format2.test(string)) {
17712
+ if (!format3.test(string)) {
17606
17713
  throw new Error(`@smithy/core/serde - NumericValue must only contain [0-9], at most one decimal point ".", and an optional negation prefix "-".`);
17607
17714
  }
17608
17715
  }
@@ -17614,7 +17721,7 @@ var init_NumericValue = __esm({
17614
17721
  return false;
17615
17722
  }
17616
17723
  const _nv = object;
17617
- return _NumericValue.prototype.isPrototypeOf(object) || _nv.type === "bigDecimal" && format2.test(_nv.string);
17724
+ return _NumericValue.prototype.isPrototypeOf(object) || _nv.type === "bigDecimal" && format3.test(_nv.string);
17618
17725
  }
17619
17726
  };
17620
17727
  }
@@ -21079,8 +21186,8 @@ var init_FromStringShapeDeserializer = __esm({
21079
21186
  return (this.serdeContext?.base64Decoder ?? fromBase64)(data);
21080
21187
  }
21081
21188
  if (ns2.isTimestampSchema()) {
21082
- const format3 = determineTimestampFormat(ns2, this.settings);
21083
- switch (format3) {
21189
+ const format4 = determineTimestampFormat(ns2, this.settings);
21190
+ switch (format4) {
21084
21191
  case 5:
21085
21192
  return _parseRfc3339DateTimeWithOffset(data);
21086
21193
  case 6:
@@ -21202,8 +21309,8 @@ var init_ToStringShapeSerializer = __esm({
21202
21309
  if (!(value instanceof Date)) {
21203
21310
  throw new Error(`@smithy/core/protocols - received non-Date value ${value} when schema expected Date in ${ns2.getName(true)}`);
21204
21311
  }
21205
- const format3 = determineTimestampFormat(ns2, this.settings);
21206
- switch (format3) {
21312
+ const format4 = determineTimestampFormat(ns2, this.settings);
21313
+ switch (format4) {
21207
21314
  case 5:
21208
21315
  this.stringBuffer = value.toISOString().replace(".000Z", "Z");
21209
21316
  break;
@@ -26437,8 +26544,8 @@ var init_JsonShapeDeserializer = __esm({
26437
26544
  return value;
26438
26545
  }
26439
26546
  if (ns2.isTimestampSchema() && value != null) {
26440
- const format3 = determineTimestampFormat(ns2, this.settings);
26441
- switch (format3) {
26547
+ const format4 = determineTimestampFormat(ns2, this.settings);
26548
+ switch (format4) {
26442
26549
  case 5:
26443
26550
  return parseRfc3339DateTimeWithOffset(value);
26444
26551
  case 6:
@@ -26662,8 +26769,8 @@ var init_JsonShapeSerializer = __esm({
26662
26769
  return (this.serdeContext?.base64Encoder ?? toBase64)(value);
26663
26770
  }
26664
26771
  if (value instanceof Date && (ns2.isTimestampSchema() || ns2.isDocumentSchema())) {
26665
- const format3 = determineTimestampFormat(ns2, this.settings);
26666
- switch (format3) {
26772
+ const format4 = determineTimestampFormat(ns2, this.settings);
26773
+ switch (format4) {
26667
26774
  case 5:
26668
26775
  return value.toISOString().replace(".000Z", "Z");
26669
26776
  case 6:
@@ -27291,8 +27398,8 @@ var init_QueryShapeSerializer = __esm({
27291
27398
  } else if (ns2.isTimestampSchema()) {
27292
27399
  if (value instanceof Date) {
27293
27400
  this.writeKey(prefix2);
27294
- const format3 = determineTimestampFormat(ns2, this.settings);
27295
- switch (format3) {
27401
+ const format4 = determineTimestampFormat(ns2, this.settings);
27402
+ switch (format4) {
27296
27403
  case 5:
27297
27404
  this.writeValue(value.toISOString().replace(".000Z", "Z"));
27298
27405
  break;
@@ -41727,11 +41834,13 @@ var init_src7 = __esm({
41727
41834
  });
41728
41835
 
41729
41836
  // ../../packages/drivers/src/DeltaShareDriver.ts
41730
- var fs10, import_promises7, MAX_LIMIT_HINT, DeltaShareSourceDriver, DeltaShareDriver_default;
41837
+ var fs10, import_promises7, import_stream, import_promises8, MAX_LIMIT_HINT, PARQUET_BATCH_ROWS, DeltaShareSourceDriver, DeltaShareDriver_default;
41731
41838
  var init_DeltaShareDriver = __esm({
41732
41839
  "../../packages/drivers/src/DeltaShareDriver.ts"() {
41733
41840
  fs10 = __toESM(require("fs"), 1);
41734
41841
  import_promises7 = __toESM(require("fs/promises"), 1);
41842
+ import_stream = require("stream");
41843
+ import_promises8 = require("stream/promises");
41735
41844
  init_src();
41736
41845
  init_src4();
41737
41846
  init_src2();
@@ -41739,6 +41848,7 @@ var init_DeltaShareDriver = __esm({
41739
41848
  init_DeltaSharePredicate();
41740
41849
  init_OidcTokenProvider();
41741
41850
  MAX_LIMIT_HINT = 2147483647;
41851
+ PARQUET_BATCH_ROWS = 5e4;
41742
41852
  DeltaShareSourceDriver = class {
41743
41853
  constructor() {
41744
41854
  this._query = "{prefix}/shares/{share}/schemas/{schema}/tables/{table}/query";
@@ -41748,6 +41858,9 @@ var init_DeltaShareDriver = __esm({
41748
41858
  // Column Delta types per table, for the predicate's literals. A table's schema does not change
41749
41859
  // under a run, and only a read with something to push ever asks for it.
41750
41860
  this._columnTypes = /* @__PURE__ */ new Map();
41861
+ // Rows held as objects at once. A run leaves this at PARQUET_BATCH_ROWS; the tests lower it so a
41862
+ // fixture small enough to read whole still splits its row groups the way a real part file does.
41863
+ this._batchRows = PARQUET_BATCH_ROWS;
41751
41864
  this.init = async (source) => {
41752
41865
  Affirm_default(source, "Invalid source");
41753
41866
  const { authentication } = source;
@@ -41808,12 +41921,11 @@ var init_DeltaShareDriver = __esm({
41808
41921
  Affirm_default(request, "Invalid download request");
41809
41922
  const table = this._resolveTable(request.fileKey);
41810
41923
  const deltaFiles = await this._getAllFilesInTable(table, request.disableHistory);
41811
- const hyparquet = await import("hyparquet");
41812
41924
  const lines = [];
41813
- for (const deltaFile of deltaFiles) {
41814
- const parquetRecords = await this._readParquetObjects(deltaFile);
41815
- lines.push(...parquetRecords.map((x2) => JSON.stringify(hyparquet.toJson(x2))));
41816
- }
41925
+ for (const deltaFile of deltaFiles)
41926
+ for await (const batch of this._readRemoteParquetBatches(deltaFile))
41927
+ for (const record of batch)
41928
+ lines.push(JSON.stringify(record));
41817
41929
  Logger_default.log(`Delta Share readAll: ${lines.length} record(s) from ${deltaFiles.length} file(s) of table "${table}"`);
41818
41930
  return lines;
41819
41931
  };
@@ -41823,22 +41935,41 @@ var init_DeltaShareDriver = __esm({
41823
41935
  Affirm_default(request.options.lineFrom !== void 0 && request.options.lineTo !== void 0, "Missing read range");
41824
41936
  const table = this._resolveTable(request.fileKey);
41825
41937
  const deltaFiles = await this._getAllFilesInTable(table, request.disableHistory);
41826
- const hyparquet = await import("hyparquet");
41827
41938
  const { options: { lineFrom, lineTo } } = request;
41939
+ const lines = await this._collectLinesInRange(deltaFiles, { from: lineFrom, to: lineTo });
41940
+ Logger_default.log(`Delta Share readLinesInRange [${lineFrom}, ${lineTo}) on table "${table}": ${lines.length} record(s)`);
41941
+ return lines;
41942
+ };
41943
+ /**
41944
+ * The records of the given range, serialized. Reading stops the moment the range is filled: a
41945
+ * part file holds hundreds of thousands of rows and a preview asks for a handful of them, so
41946
+ * decoding past `to` is both slow and the memory the batching above exists to avoid.
41947
+ */
41948
+ this._collectLinesInRange = async (deltaFiles, range2) => {
41949
+ if (range2.to <= range2.from)
41950
+ return [];
41828
41951
  const lines = [];
41829
41952
  let index = 0;
41830
41953
  for (const deltaFile of deltaFiles) {
41831
- const parquetRecords = await this._readParquetObjects(deltaFile);
41832
- for (const record of parquetRecords) {
41833
- if (index >= lineFrom && index < lineTo)
41834
- lines.push(JSON.stringify(hyparquet.toJson(record)));
41835
- index++;
41836
- if (index >= lineTo) break;
41954
+ for await (const batch of this._readRemoteParquetBatches(deltaFile)) {
41955
+ index = this._pushRecordsInRange(lines, batch, index, range2);
41956
+ if (index >= range2.to)
41957
+ return lines;
41837
41958
  }
41838
41959
  }
41839
- Logger_default.log(`Delta Share readLinesInRange [${lineFrom}, ${lineTo}) on table "${table}": ${lines.length} record(s)`);
41840
41960
  return lines;
41841
41961
  };
41962
+ // The index the batch ends on, so the next batch carries on counting where this one stopped.
41963
+ this._pushRecordsInRange = (lines, batch, index, range2) => {
41964
+ for (const record of batch) {
41965
+ if (index >= range2.from && index < range2.to)
41966
+ lines.push(JSON.stringify(record));
41967
+ index++;
41968
+ if (index >= range2.to)
41969
+ break;
41970
+ }
41971
+ return index;
41972
+ };
41842
41973
  this.exist = async (_producer) => {
41843
41974
  void _producer;
41844
41975
  let nextPageToken;
@@ -41982,20 +42113,48 @@ var init_DeltaShareDriver = __esm({
41982
42113
  return "(unparseable url)";
41983
42114
  }
41984
42115
  };
41985
- this._readParquetObjects = async (deltaFile) => {
42116
+ // Split out so the batch loop above stays one level of nesting, and so both failures name the file
42117
+ this._readParquetMetadata = async (file, label) => {
41986
42118
  const hyparquet = await import("hyparquet");
41987
- const { compressors: compressors2 } = await Promise.resolve().then(() => (init_src7(), src_exports));
41988
- const byteLength = deltaFile.file.deltaSingleAction.add?.size ?? deltaFile.file.deltaSingleAction.remove?.size;
41989
- const startedMs = Date.now();
41990
- let records;
41991
42119
  try {
41992
- const file = await hyparquet.asyncBufferFromUrl({ url: deltaFile.file.url, byteLength });
41993
- records = await hyparquet.parquetReadObjects({ file, compressors: compressors2 });
42120
+ return await hyparquet.parquetMetadataAsync(file);
41994
42121
  } catch (error) {
41995
- throw new Error(`Delta Share failed reading parquet from ${this._redactUrl(deltaFile.file.url)} (${byteLength ?? "?"} bytes)`, { cause: error });
42122
+ throw new Error(`Delta Share failed reading the parquet footer of ${label}`, { cause: error });
42123
+ }
42124
+ };
42125
+ this._readParquetBatch = async (options, label) => {
42126
+ const hyparquet = await import("hyparquet");
42127
+ try {
42128
+ return await hyparquet.parquetReadObjects(options);
42129
+ } catch (error) {
42130
+ throw new Error(`Delta Share failed reading parquet rows [${options.rowStart}, ${options.rowEnd}) of ${label}`, { cause: error });
41996
42131
  }
41997
- Logger_default.log(`Delta Share read ${records.length} record(s) from ${this._redactUrl(deltaFile.file.url)} (${byteLength ?? "?"} bytes) in ${Date.now() - startedMs}ms`);
41998
- return records;
42132
+ };
42133
+ // Reads straight from the pre-signed URL. Only for the bounded readers (preview, sample): every
42134
+ // batch refetches the row group, which is why `ready` stages the file locally instead.
42135
+ this._readRemoteParquetBatches = (deltaFile) => {
42136
+ const byteLength = deltaFile.file.deltaSingleAction.add?.size ?? deltaFile.file.deltaSingleAction.remove?.size;
42137
+ const label = `${this._redactUrl(deltaFile.file.url)} (${byteLength ?? "?"} bytes)`;
42138
+ const open = async () => {
42139
+ const hyparquet = await import("hyparquet");
42140
+ return await hyparquet.asyncBufferFromUrl({ url: deltaFile.file.url, byteLength });
42141
+ };
42142
+ return this._streamParquetBatchesFrom(open, label);
42143
+ };
42144
+ /**
42145
+ * Copies a part file to local disk, streamed, so nothing but the socket buffer is ever in memory.
42146
+ * `ready` re-reads the file once per batch and re-reading it over HTTP would refetch the same
42147
+ * bytes every time.
42148
+ */
42149
+ this._downloadParquet = async (deltaFile, localPath) => {
42150
+ const startedMs = Date.now();
42151
+ const res = await this._fetch(deltaFile.file.url, { method: "GET" }, `parquet download of ${this._redactUrl(deltaFile.file.url)}`);
42152
+ if (!res.ok)
42153
+ throw new Error(`Error downloading parquet from the delta share: ${res.status} ${res.statusText} (${this._redactUrl(deltaFile.file.url)})`);
42154
+ Affirm_default(res.body, `Empty response body downloading parquet from ${this._redactUrl(deltaFile.file.url)}`);
42155
+ await (0, import_promises8.pipeline)(import_stream.Readable.fromWeb(res.body), fs10.createWriteStream(localPath));
42156
+ const { size } = await import_promises7.default.stat(localPath);
42157
+ Logger_default.log(`Delta Share staged ${this._redactUrl(deltaFile.file.url)} (${size} bytes) in ${Date.now() - startedMs}ms`);
41999
42158
  };
42000
42159
  this._serializeDatasetValue = (value) => {
42001
42160
  if (value === null || value === void 0)
@@ -42009,17 +42168,41 @@ var init_DeltaShareDriver = __esm({
42009
42168
  this._getDeltaFileKey = (table, index) => {
42010
42169
  return `${this._resolveSchema()}/${table}/part-${index}.parquet`;
42011
42170
  };
42012
- this._writeDatasetFile = async (localPath, records, delimiter) => {
42013
- if (records.length === 0)
42014
- return false;
42015
- const header = Object.keys(records[0]);
42016
- const lines = [
42017
- CSVParser_default.stringifyRow(header, delimiter),
42018
- ...records.map((record) => CSVParser_default.stringifyRow(header.map((column) => this._serializeDatasetValue(record[column])), delimiter))
42019
- ];
42020
- await import_promises7.default.writeFile(localPath, `${lines.join("\n")}
42021
- `);
42022
- return true;
42171
+ /**
42172
+ * Writes the batches out as one CSV dataset file and reports how many records landed. Rows are
42173
+ * written as they arrive rather than joined into one string first: a file's worth of lines, and
42174
+ * the single string joining them, were each as large as the records themselves.
42175
+ *
42176
+ * The header is taken from the first record and reused for every later one, so a file whose rows
42177
+ * disagree on their columns still produces a rectangular dataset.
42178
+ */
42179
+ this._writeDatasetFile = async (localPath, batches, delimiter) => {
42180
+ const stream = fs10.createWriteStream(localPath);
42181
+ let header = null;
42182
+ let records = 0;
42183
+ try {
42184
+ for await (const batch of batches) {
42185
+ for (const record of batch) {
42186
+ if (!header) {
42187
+ header = Object.keys(record);
42188
+ await this._writeLine(stream, CSVParser_default.stringifyRow(header, delimiter));
42189
+ }
42190
+ await this._writeLine(stream, CSVParser_default.stringifyRow(header.map((column) => this._serializeDatasetValue(record[column])), delimiter));
42191
+ records++;
42192
+ }
42193
+ }
42194
+ } finally {
42195
+ await new Promise((resolve) => stream.end(resolve));
42196
+ }
42197
+ return records;
42198
+ };
42199
+ // A false from write() means the buffer is full; waiting for the drain just then keeps the queued
42200
+ // rows bounded instead of letting them pile up faster than the disk takes them.
42201
+ this._writeLine = async (stream, line) => {
42202
+ if (stream.write(`${line}
42203
+ `))
42204
+ return;
42205
+ await new Promise((resolve) => stream.once("drain", resolve));
42023
42206
  };
42024
42207
  /**
42025
42208
  * Every file the share reports for this table. `jsonPredicateHints` lets the server skip the
@@ -42083,30 +42266,22 @@ var init_DeltaShareDriver = __esm({
42083
42266
  const table = this._resolveTable(producer.settings.fileKey);
42084
42267
  const hints = await this._buildHints(producer, table, request.pushdown);
42085
42268
  const deltaFiles = await this._getAllFilesInTable(table, producer.settings.disableHistory, hints);
42086
- const hyparquet = await import("hyparquet");
42087
42269
  const delimiter = producer.settings.delimiter ?? ",";
42088
42270
  const files = [];
42089
42271
  let records = 0;
42090
42272
  let skipped = 0;
42091
42273
  for (const [index, deltaFile] of deltaFiles.entries()) {
42092
42274
  onProgress?.(index / deltaFiles.length);
42093
- const parquetRecords = await this._readParquetObjects(deltaFile);
42094
- if (parquetRecords.length === 0) {
42095
- skipped++;
42096
- Logger_default.log(`Delta Share ready: file ${index + 1}/${deltaFiles.length} of table "${table}" holds no records, skipping`);
42097
- continue;
42098
- }
42099
42275
  const sourceFileKey = this._getDeltaFileKey(table, index);
42100
42276
  const localPath = ExecutorScope_default.getProducerPath(scope, producer, sourceFileKey);
42101
42277
  ExecutorScope_default.ensurePath(localPath);
42102
- const jsonRecords = parquetRecords.map((record) => hyparquet.toJson(record));
42103
- const written = await this._writeDatasetFile(localPath, jsonRecords, delimiter);
42104
- if (written) {
42278
+ const written = await this._stageDeltaFile(deltaFile, localPath, delimiter);
42279
+ if (written > 0) {
42105
42280
  files.push({ fullUri: localPath, fileSize: fs10.statSync(localPath).size });
42106
- records += jsonRecords.length;
42281
+ records += written;
42107
42282
  } else {
42108
42283
  skipped++;
42109
- Logger_default.log(`Delta Share ready: nothing written for ${sourceFileKey}, discarding the staged file`);
42284
+ Logger_default.log(`Delta Share ready: file ${index + 1}/${deltaFiles.length} of table "${table}" (${sourceFileKey}) holds no records, discarding the staged file`);
42110
42285
  await import_promises7.default.unlink(localPath).catch(() => {
42111
42286
  });
42112
42287
  }
@@ -42117,6 +42292,57 @@ var init_DeltaShareDriver = __esm({
42117
42292
  Logger_default.log(`Delta Share ready: staged ${records} record(s) into ${files.length} dataset file(s) (${bytes} bytes) for producer "${producer.name}" from table "${table}"${skippedNote}`);
42118
42293
  return { files, filteredAtSource: !!hints?.jsonPredicateHints };
42119
42294
  };
42295
+ /**
42296
+ * One part file turned into one CSV dataset file, downloaded then converted a batch at a time so
42297
+ * that neither step's memory grows with the file. The download is dropped either way — it is the
42298
+ * dataset file the run reads from here on.
42299
+ */
42300
+ this._stageDeltaFile = async (deltaFile, localPath, delimiter) => {
42301
+ const downloadPath = `${localPath}.parquet`;
42302
+ await this._downloadParquet(deltaFile, downloadPath);
42303
+ try {
42304
+ const open = async () => {
42305
+ const hyparquet = await import("hyparquet");
42306
+ return await hyparquet.asyncBufferFromFile(downloadPath);
42307
+ };
42308
+ return await this._writeDatasetFile(localPath, this._streamParquetBatchesFrom(open, this._redactUrl(deltaFile.file.url)), delimiter);
42309
+ } finally {
42310
+ await import_promises7.default.unlink(downloadPath).catch(() => {
42311
+ });
42312
+ }
42313
+ };
42314
+ }
42315
+ /**
42316
+ * The rows of a part file, `_batchRows` at a time and already JSON-safe.
42317
+ *
42318
+ * hyparquet decodes a whole row group's columns per read either way, but only the requested rows
42319
+ * are turned into objects — and the objects are what dominates — so a row group larger than a
42320
+ * batch is read in several passes. Every pass re-reads the group's bytes, which is why `ready`
42321
+ * stages the file on disk first and only the small readers below stream it from its URL.
42322
+ */
42323
+ async *_streamParquetBatches(file, label) {
42324
+ const hyparquet = await import("hyparquet");
42325
+ const { compressors: compressors2 } = await Promise.resolve().then(() => (init_src7(), src_exports));
42326
+ const startedMs = Date.now();
42327
+ const metadata = await this._readParquetMetadata(file, label);
42328
+ let records = 0;
42329
+ let groupStart = 0;
42330
+ for (const rowGroup of metadata.row_groups) {
42331
+ const groupRows = Number(rowGroup.num_rows);
42332
+ const groupEnd = groupStart + groupRows;
42333
+ for (let rowStart = groupStart; rowStart < groupEnd; rowStart += this._batchRows) {
42334
+ const rowEnd = Math.min(rowStart + this._batchRows, groupEnd);
42335
+ const batch = await this._readParquetBatch({ file, metadata, compressors: compressors2, rowStart, rowEnd }, label);
42336
+ records += batch.length;
42337
+ yield batch.map((record) => hyparquet.toJson(record));
42338
+ }
42339
+ groupStart = groupEnd;
42340
+ }
42341
+ Logger_default.log(`Delta Share read ${records} record(s) from ${label} in ${Date.now() - startedMs}ms`);
42342
+ }
42343
+ // The buffer is opened inside the generator so nothing is fetched until the first batch is pulled
42344
+ async *_streamParquetBatchesFrom(open, label) {
42345
+ yield* this._streamParquetBatches(await open(), label);
42120
42346
  }
42121
42347
  };
42122
42348
  DeltaShareDriver_default = DeltaShareSourceDriver;
@@ -42450,12 +42676,12 @@ var init_HttpApiDriver = __esm({
42450
42676
  });
42451
42677
 
42452
42678
  // ../../packages/drivers/src/DriverHelper.ts
42453
- var import_stream, import_readline, import_promises8, import_fs9, DriverHelper, DriverHelper_default;
42679
+ var import_stream2, import_readline, import_promises9, import_fs9, DriverHelper, DriverHelper_default;
42454
42680
  var init_DriverHelper = __esm({
42455
42681
  "../../packages/drivers/src/DriverHelper.ts"() {
42456
- import_stream = require("stream");
42682
+ import_stream2 = require("stream");
42457
42683
  import_readline = require("readline");
42458
- import_promises8 = require("stream/promises");
42684
+ import_promises9 = require("stream/promises");
42459
42685
  import_fs9 = require("fs");
42460
42686
  init_src2();
42461
42687
  init_src();
@@ -42472,7 +42698,7 @@ var init_DriverHelper = __esm({
42472
42698
  let leftoverData = "";
42473
42699
  let globalIndex = 0;
42474
42700
  let lineCount = 0;
42475
- const headerValidationTransform = new import_stream.Transform({
42701
+ const headerValidationTransform = new import_stream2.Transform({
42476
42702
  transform(chunk, encoding, callback) {
42477
42703
  const chunkStr = leftoverData + chunk.toString();
42478
42704
  const lines = chunkStr.split("\n");
@@ -42548,7 +42774,7 @@ var init_DriverHelper = __esm({
42548
42774
  };
42549
42775
  const writeOptions = append ? { flags: "a" } : {};
42550
42776
  const writeStream = (0, import_fs9.createWriteStream)(destinationPath, writeOptions);
42551
- await (0, import_promises8.pipeline)(stream, headerValidationTransform, writeStream);
42777
+ await (0, import_promises9.pipeline)(stream, headerValidationTransform, writeStream);
42552
42778
  return lineCount;
42553
42779
  },
42554
42780
  appendObjectsToUnifiedFile: async (options) => {
@@ -42858,11 +43084,11 @@ var init_LocalSourceDriver = __esm({
42858
43084
  });
42859
43085
 
42860
43086
  // ../../packages/drivers/src/files/LocalDestinationDriver.ts
42861
- var fs12, import_promises9, import_readline3, import_path10, LocalDestinationDriver;
43087
+ var fs12, import_promises10, import_readline3, import_path10, LocalDestinationDriver;
42862
43088
  var init_LocalDestinationDriver = __esm({
42863
43089
  "../../packages/drivers/src/files/LocalDestinationDriver.ts"() {
42864
43090
  fs12 = __toESM(require("fs"), 1);
42865
- import_promises9 = __toESM(require("fs/promises"), 1);
43091
+ import_promises10 = __toESM(require("fs/promises"), 1);
42866
43092
  import_readline3 = __toESM(require("readline"), 1);
42867
43093
  import_path10 = __toESM(require("path"), 1);
42868
43094
  init_src();
@@ -42897,8 +43123,8 @@ var init_LocalDestinationDriver = __esm({
42897
43123
  this.move = async (fromPath, toName) => {
42898
43124
  try {
42899
43125
  const toFilePath = import_path10.default.join(this._path, toName);
42900
- await import_promises9.default.copyFile(fromPath, toFilePath);
42901
- await import_promises9.default.unlink(fromPath);
43126
+ await import_promises10.default.copyFile(fromPath, toFilePath);
43127
+ await import_promises10.default.unlink(fromPath);
42902
43128
  return { bucket: "", key: toFilePath, res: true };
42903
43129
  } catch (error) {
42904
43130
  Logger_default.error(error);
@@ -42934,14 +43160,14 @@ var init_LocalDestinationDriver = __esm({
42934
43160
  });
42935
43161
 
42936
43162
  // ../../packages/drivers/src/s3/S3SourceDriver.ts
42937
- var import_client_s32, import_stream2, import_promises10, import_readline4, import_path11, import_fs10, import_xlsx2, S3SourceDriver;
43163
+ var import_client_s32, import_stream3, import_promises11, import_readline4, import_path11, import_fs10, import_xlsx2, S3SourceDriver;
42938
43164
  var init_S3SourceDriver = __esm({
42939
43165
  "../../packages/drivers/src/s3/S3SourceDriver.ts"() {
42940
43166
  import_client_s32 = require("@aws-sdk/client-s3");
42941
43167
  init_src();
42942
43168
  init_AwsCredentials();
42943
- import_stream2 = require("stream");
42944
- import_promises10 = require("stream/promises");
43169
+ import_stream3 = require("stream");
43170
+ import_promises11 = require("stream/promises");
42945
43171
  import_readline4 = __toESM(require("readline"), 1);
42946
43172
  import_path11 = __toESM(require("path"), 1);
42947
43173
  import_fs10 = __toESM(require("fs"), 1);
@@ -43209,7 +43435,7 @@ var init_S3SourceDriver = __esm({
43209
43435
  }
43210
43436
  const totalBytes = response.ContentLength ?? 0;
43211
43437
  let stagedBytes = 0;
43212
- const meter = new import_stream2.Transform({
43438
+ const meter = new import_stream3.Transform({
43213
43439
  transform(chunk, _encoding, done) {
43214
43440
  stagedBytes += chunk.length;
43215
43441
  if (totalBytes > 0)
@@ -43218,7 +43444,7 @@ var init_S3SourceDriver = __esm({
43218
43444
  }
43219
43445
  });
43220
43446
  const writeStream = import_fs10.default.createWriteStream(localPath);
43221
- await (0, import_promises10.pipeline)(response.Body, meter, writeStream);
43447
+ await (0, import_promises11.pipeline)(response.Body, meter, writeStream);
43222
43448
  report3(1);
43223
43449
  };
43224
43450
  if (fileKey.includes("%")) {
@@ -44271,7 +44497,7 @@ var init_TypeCaster = __esm({
44271
44497
  * - Parsing dates (type 'date'/'datetime') from string with tokens: yyyy, mm, dd
44272
44498
  * - Formatting dates when casting to string with same tokens
44273
44499
  */
44274
- cast(value, type, format3) {
44500
+ cast(value, type, format4) {
44275
44501
  if (!Algo_default.hasVal(value)) return value;
44276
44502
  switch (type) {
44277
44503
  case "boolean": {
@@ -44282,8 +44508,8 @@ var init_TypeCaster = __esm({
44282
44508
  case "date": {
44283
44509
  let dateValue = null;
44284
44510
  try {
44285
- if (format3 && typeof value === "string")
44286
- dateValue = this.parseDate(value, format3, true).toDate();
44511
+ if (format4 && typeof value === "string")
44512
+ dateValue = this.parseDate(value, format4, true).toDate();
44287
44513
  else
44288
44514
  dateValue = new Date(value);
44289
44515
  return dateValue.toISOString();
@@ -44291,7 +44517,7 @@ var init_TypeCaster = __esm({
44291
44517
  dateValue = new Date(value);
44292
44518
  if (!isNaN(dateValue))
44293
44519
  return dateValue.toISOString();
44294
- throw new Error(`Error casting "${value}" to date with format "${format3}": ${error}`);
44520
+ throw new Error(`Error casting "${value}" to date with format "${format4}": ${error}`);
44295
44521
  }
44296
44522
  }
44297
44523
  case "number": {
@@ -44318,13 +44544,13 @@ var init_TypeCaster = __esm({
44318
44544
  * advancedFormat plugin, and then unpadded for `DDD`, while a positional ordinal date is always
44319
44545
  * 3 digits wide; the token is therefore rendered here rather than handed to dayjs.
44320
44546
  */
44321
- formatDate(value, format3) {
44547
+ formatDate(value, format4) {
44322
44548
  const date2 = import_dayjs.default.utc(value);
44323
- if (!DAY_OF_YEAR_TOKEN.test(this._stripLiterals(format3)))
44324
- return date2.format(format3);
44549
+ if (!DAY_OF_YEAR_TOKEN.test(this._stripLiterals(format4)))
44550
+ return date2.format(format4);
44325
44551
  const startOfYear = import_dayjs.default.utc(`${String(date2.year()).padStart(4, "0")}-01-01`, "YYYY-MM-DD", true);
44326
44552
  const dayOfYear = date2.diff(startOfYear, "day") + 1;
44327
- return date2.format(format3.replace(/D{3,4}/g, `[${String(dayOfYear).padStart(3, "0")}]`));
44553
+ return date2.format(format4.replace(/D{3,4}/g, `[${String(dayOfYear).padStart(3, "0")}]`));
44328
44554
  }
44329
44555
  /**
44330
44556
  * Parses a date string with a dayjs format, as UTC. Single entry point for every date parse, so
@@ -44333,13 +44559,13 @@ var init_TypeCaster = __esm({
44333
44559
  * ever FORMAT with are rejected outright — non-strict parsing would otherwise read `2007305` as
44334
44560
  * 2007-01-05 rather than 2007-11-01 and report no error at all.
44335
44561
  */
44336
- parseDate(value, format3, strict = true) {
44337
- if (DAY_OF_YEAR_TOKEN.test(this._stripLiterals(format3)))
44338
- return this._parseDayOfYear(value, format3);
44339
- this._assertParsableFormat(format3);
44340
- const parsed = import_dayjs.default.utc(value, format3, strict);
44562
+ parseDate(value, format4, strict = true) {
44563
+ if (DAY_OF_YEAR_TOKEN.test(this._stripLiterals(format4)))
44564
+ return this._parseDayOfYear(value, format4);
44565
+ this._assertParsableFormat(format4);
44566
+ const parsed = import_dayjs.default.utc(value, format4, strict);
44341
44567
  if (!parsed.isValid())
44342
- throw new Error(`Cannot parse "${value}" with input format "${format3}"`);
44568
+ throw new Error(`Cannot parse "${value}" with input format "${format4}"`);
44343
44569
  return parsed;
44344
44570
  }
44345
44571
  /**
@@ -44348,61 +44574,61 @@ var init_TypeCaster = __esm({
44348
44574
  * walked token by token against the format — every token of such a format has a fixed width, so
44349
44575
  * a plain cursor is enough — and the date is then built from the year plus the ordinal offset.
44350
44576
  */
44351
- _parseDayOfYear(value, format3) {
44577
+ _parseDayOfYear(value, format4) {
44352
44578
  const parts = {};
44353
44579
  let cursor = 0;
44354
44580
  let index = 0;
44355
- while (index < format3.length) {
44356
- if (format3[index] === "[") {
44357
- const close = format3.indexOf("]", index);
44581
+ while (index < format4.length) {
44582
+ if (format4[index] === "[") {
44583
+ const close = format4.indexOf("]", index);
44358
44584
  if (close < 0)
44359
- throw new Error(`Unterminated "[" literal in date format "${format3}"`);
44360
- const literal2 = format3.slice(index + 1, close);
44585
+ throw new Error(`Unterminated "[" literal in date format "${format4}"`);
44586
+ const literal2 = format4.slice(index + 1, close);
44361
44587
  if (value.slice(cursor, cursor + literal2.length) !== literal2)
44362
- throw new Error(`Cannot parse "${value}" with input format "${format3}": expected "${literal2}" at character ${cursor + 1}`);
44588
+ throw new Error(`Cannot parse "${value}" with input format "${format4}": expected "${literal2}" at character ${cursor + 1}`);
44363
44589
  cursor += literal2.length;
44364
44590
  index = close + 1;
44365
44591
  continue;
44366
44592
  }
44367
- const match = DATE_PARSE_TOKENS.find((x2) => format3.startsWith(x2.token, index));
44593
+ const match = DATE_PARSE_TOKENS.find((x2) => format4.startsWith(x2.token, index));
44368
44594
  if (!match) {
44369
- if (/[A-Za-z]/.test(format3[index]))
44370
- throw new Error(`Date format "${format3}" mixes a day-of-year token with "${format3[index]}", which can't be parsed alongside it. Use YYYY/YY, DDD/DDDD, HH, mm, ss and SSS only.`);
44371
- if (value[cursor] !== format3[index])
44372
- throw new Error(`Cannot parse "${value}" with input format "${format3}": expected "${format3[index]}" at character ${cursor + 1}`);
44595
+ if (/[A-Za-z]/.test(format4[index]))
44596
+ throw new Error(`Date format "${format4}" mixes a day-of-year token with "${format4[index]}", which can't be parsed alongside it. Use YYYY/YY, DDD/DDDD, HH, mm, ss and SSS only.`);
44597
+ if (value[cursor] !== format4[index])
44598
+ throw new Error(`Cannot parse "${value}" with input format "${format4}": expected "${format4[index]}" at character ${cursor + 1}`);
44373
44599
  cursor++;
44374
44600
  index++;
44375
44601
  continue;
44376
44602
  }
44377
44603
  const digits = value.slice(cursor, cursor + match.width);
44378
44604
  if (digits.length !== match.width || !/^\d+$/.test(digits))
44379
- throw new Error(`Cannot parse "${value}" with input format "${format3}": expected ${match.width} digit(s) for "${match.token}" at character ${cursor + 1}`);
44605
+ throw new Error(`Cannot parse "${value}" with input format "${format4}": expected ${match.width} digit(s) for "${match.token}" at character ${cursor + 1}`);
44380
44606
  parts[match.token] = Number(digits);
44381
44607
  cursor += match.width;
44382
44608
  index += match.token.length;
44383
44609
  }
44384
44610
  if (cursor !== value.length)
44385
- throw new Error(`Cannot parse "${value}" with input format "${format3}": ${value.length - cursor} unexpected trailing character(s)`);
44611
+ throw new Error(`Cannot parse "${value}" with input format "${format4}": ${value.length - cursor} unexpected trailing character(s)`);
44386
44612
  const year2 = Algo_default.hasVal(parts["YYYY"]) ? parts["YYYY"] : parts["YY"];
44387
44613
  const dayOfYear = Algo_default.hasVal(parts["DDDD"]) ? parts["DDDD"] : parts["DDD"];
44388
44614
  if (!Algo_default.hasVal(year2))
44389
- throw new Error(`Date format "${format3}" declares a day of year but no year, so the date is ambiguous.`);
44615
+ throw new Error(`Date format "${format4}" declares a day of year but no year, so the date is ambiguous.`);
44390
44616
  const startOfYear = import_dayjs.default.utc(`${String(year2).padStart(4, "0")}-01-01`, "YYYY-MM-DD", true);
44391
44617
  if (!startOfYear.isValid())
44392
- throw new Error(`Cannot parse "${value}" with input format "${format3}": "${year2}" is not a valid year`);
44618
+ throw new Error(`Cannot parse "${value}" with input format "${format4}": "${year2}" is not a valid year`);
44393
44619
  const parsed = startOfYear.add(dayOfYear - 1, "day").add(parts["HH"] ?? 0, "hour").add(parts["mm"] ?? 0, "minute").add(parts["ss"] ?? 0, "second").add(parts["SSS"] ?? 0, "millisecond");
44394
44620
  if (dayOfYear < 1 || parsed.year() !== startOfYear.year())
44395
- throw new Error(`Cannot parse "${value}" with input format "${format3}": day of year ${dayOfYear} is outside year ${year2} (which has ${startOfYear.add(1, "year").diff(startOfYear, "day")} days)`);
44621
+ throw new Error(`Cannot parse "${value}" with input format "${format4}": day of year ${dayOfYear} is outside year ${year2} (which has ${startOfYear.add(1, "year").diff(startOfYear, "day")} days)`);
44396
44622
  return parsed;
44397
44623
  }
44398
- _assertParsableFormat(format3) {
44399
- const stripped = this._stripLiterals(format3);
44624
+ _assertParsableFormat(format4) {
44625
+ const stripped = this._stripLiterals(format4);
44400
44626
  const offending = FORMAT_ONLY_TOKENS.find((token2) => stripped.includes(token2));
44401
44627
  if (offending)
44402
- throw new Error(`Date format "${format3}" uses the token "${offending}", which dayjs can only write, never read: parsing would silently produce the wrong date. Use a parseable token, or bracket it as a literal ("[${offending}]") if it is part of the text.`);
44628
+ throw new Error(`Date format "${format4}" uses the token "${offending}", which dayjs can only write, never read: parsing would silently produce the wrong date. Use a parseable token, or bracket it as a literal ("[${offending}]") if it is part of the text.`);
44403
44629
  }
44404
- _stripLiterals(format3) {
44405
- return String(format3 ?? "").replace(/\[[^\]]*\]/g, "");
44630
+ _stripLiterals(format4) {
44631
+ return String(format4 ?? "").replace(/\[[^\]]*\]/g, "");
44406
44632
  }
44407
44633
  };
44408
44634
  TypeCaster = new TypeCasterClass();
@@ -44794,7 +45020,7 @@ var init_ProducerEngine = __esm({
44794
45020
  });
44795
45021
 
44796
45022
  // ../../packages/engines/src/ai/DeveloperEngine.ts
44797
- var import_path19, import_promises11, import_dayjs2, import_customParseFormat2, DeveloperEngineClass, DeveloperEngine, DeveloperEngine_default;
45023
+ var import_path19, import_promises12, import_dayjs2, import_customParseFormat2, DeveloperEngineClass, DeveloperEngine, DeveloperEngine_default;
44798
45024
  var init_DeveloperEngine = __esm({
44799
45025
  "../../packages/engines/src/ai/DeveloperEngine.ts"() {
44800
45026
  init_src();
@@ -44802,7 +45028,7 @@ var init_DeveloperEngine = __esm({
44802
45028
  init_src4();
44803
45029
  init_src8();
44804
45030
  import_path19 = __toESM(require("path"), 1);
44805
- import_promises11 = __toESM(require("fs/promises"), 1);
45031
+ import_promises12 = __toESM(require("fs/promises"), 1);
44806
45032
  import_dayjs2 = __toESM(require("dayjs"), 1);
44807
45033
  import_customParseFormat2 = __toESM(require("dayjs/plugin/customParseFormat"), 1);
44808
45034
  import_dayjs2.default.extend(import_customParseFormat2.default);
@@ -44832,8 +45058,8 @@ var init_DeveloperEngine = __esm({
44832
45058
  };
44833
45059
  mappedProducer["$schema"] = producer["$schema"];
44834
45060
  const producerPath = Environment_default.resolveResourceFilePath("producers", producer.name);
44835
- await import_promises11.default.mkdir(import_path19.default.dirname(producerPath), { recursive: true });
44836
- await import_promises11.default.writeFile(producerPath, JSON.stringify(mappedProducer, null, 4), "utf-8");
45061
+ await import_promises12.default.mkdir(import_path19.default.dirname(producerPath), { recursive: true });
45062
+ await import_promises12.default.writeFile(producerPath, JSON.stringify(mappedProducer, null, 4), "utf-8");
44837
45063
  return { producer: mappedProducer, fields: typeDefinitions };
44838
45064
  };
44839
45065
  // Discover-only precondition: sampling real data requires a configured, readable file.
@@ -47370,10 +47596,10 @@ var init_MockDataFactory = __esm({
47370
47596
  });
47371
47597
 
47372
47598
  // ../../packages/engines/src/mock/SyntheticInputEngine.ts
47373
- var import_promises12, import_os, import_path20, import_dayjs4, import_customParseFormat3, import_utc3, POOL_CAP, SyntheticInputEngineClass, SyntheticInputEngine, SyntheticInputEngine_default;
47599
+ var import_promises13, import_os, import_path20, import_dayjs4, import_customParseFormat3, import_utc3, POOL_CAP, SyntheticInputEngineClass, SyntheticInputEngine, SyntheticInputEngine_default;
47374
47600
  var init_SyntheticInputEngine = __esm({
47375
47601
  "../../packages/engines/src/mock/SyntheticInputEngine.ts"() {
47376
- import_promises12 = __toESM(require("fs/promises"), 1);
47602
+ import_promises13 = __toESM(require("fs/promises"), 1);
47377
47603
  import_os = __toESM(require("os"), 1);
47378
47604
  import_path20 = __toESM(require("path"), 1);
47379
47605
  import_dayjs4 = __toESM(require("dayjs"), 1);
@@ -47399,7 +47625,7 @@ var init_SyntheticInputEngine = __esm({
47399
47625
  for (const cs2 of [...BUILTIN_CODE_SETS, ...codeSets]) codeSetMap.set(cs2.name.toLowerCase(), cs2);
47400
47626
  const producerMap = new Map(producers.map((p5) => [p5.name, p5]));
47401
47627
  const refTargets = this._collectReferences(producers, producerMap);
47402
- const dir = await import_promises12.default.mkdtemp(import_path20.default.join(import_os.default.tmpdir(), "remora-synth-"));
47628
+ const dir = await import_promises13.default.mkdtemp(import_path20.default.join(import_os.default.tmpdir(), "remora-synth-"));
47403
47629
  const poolSize = Math.min(Math.max(opts.records, 1), POOL_CAP);
47404
47630
  const registry = new MockKeyRegistry();
47405
47631
  const specs = producers.flatMap((p5) => this._specs(p5, codeSetMap, producerMap, refTargets));
@@ -47416,7 +47642,7 @@ var init_SyntheticInputEngine = __esm({
47416
47642
  return { inputs, dir };
47417
47643
  };
47418
47644
  this.cleanup = async (bundle) => {
47419
- if (bundle?.dir) await import_promises12.default.rm(bundle.dir, { recursive: true, force: true });
47645
+ if (bundle?.dir) await import_promises13.default.rm(bundle.dir, { recursive: true, force: true });
47420
47646
  };
47421
47647
  this._assertOpts = (opts) => {
47422
47648
  Affirm_default(opts, "Invalid options");
@@ -47466,8 +47692,8 @@ var init_SyntheticInputEngine = __esm({
47466
47692
  lines.push(JSON.stringify(row) + "\n");
47467
47693
  }
47468
47694
  const filePath = import_path20.default.join(dir, `${producer.name}.jsonl`);
47469
- await import_promises12.default.writeFile(filePath, lines.join(""), "utf-8");
47470
- const { size } = await import_promises12.default.stat(filePath);
47695
+ await import_promises13.default.writeFile(filePath, lines.join(""), "utf-8");
47696
+ const { size } = await import_promises13.default.stat(filePath);
47471
47697
  return { path: filePath, fileSize: size };
47472
47698
  };
47473
47699
  // Distinct structured code sets referenced by these specs -> their records (deduped by name).
@@ -47578,7 +47804,7 @@ var init_SyntheticInputEngine = __esm({
47578
47804
  // True when a date bound names a day rather than an instant — neither the value nor the dimension's
47579
47805
  // format carries a time. Both have to agree: the value alone can't tell `"20240131"` from a compact
47580
47806
  // `YYYYMMDDHHmmss` instant, and the format alone can't tell that an ISO value overrode it.
47581
- this._isDayGranular = (value, format3) => !/[T ]\d{1,2}:/.test(value) && !/[HhmsSAa]/.test(format3 ?? "");
47807
+ this._isDayGranular = (value, format4) => !/[T ]\d{1,2}:/.test(value) && !/[HhmsSAa]/.test(format4 ?? "");
47582
47808
  /**
47583
47809
  * One bound in the units the generator works in: the number itself, a count of characters for a
47584
47810
  * `string`, or epoch milliseconds for a `datetime`. A date bound is read with the dimension's own
@@ -48868,7 +49094,7 @@ var init_LineageRenderer = __esm({
48868
49094
  });
48869
49095
 
48870
49096
  // ../../packages/engines/src/lineage/ResourceView.ts
48871
- var VISIBLE_AUTH_KEYS, MAX_TABLE_ROWS, MAX_RAW_BYTES, MAX_CELL_CHARS, ResourceViewClass, ResourceView, ResourceView_default;
49097
+ var VISIBLE_AUTH_KEYS, MAX_TABLE_ROWS, MAX_RAW_BYTES, MAX_CELL_CHARS, MAX_NOTE_CHARS, ResourceViewClass, ResourceView, ResourceView_default;
48872
49098
  var init_ResourceView = __esm({
48873
49099
  "../../packages/engines/src/lineage/ResourceView.ts"() {
48874
49100
  init_src();
@@ -48907,6 +49133,7 @@ var init_ResourceView = __esm({
48907
49133
  MAX_TABLE_ROWS = 500;
48908
49134
  MAX_RAW_BYTES = 256 * 1024;
48909
49135
  MAX_CELL_CHARS = 200;
49136
+ MAX_NOTE_CHARS = 240;
48910
49137
  ResourceViewClass = class {
48911
49138
  constructor() {
48912
49139
  /**
@@ -49078,7 +49305,7 @@ var init_ResourceView = __esm({
49078
49305
  { key: "classification", label: "Classification" }
49079
49306
  ];
49080
49307
  const rows = dimensions.map((dimension) => [
49081
- { value: dimension.name },
49308
+ { value: dimension.name, note: this._note(dimension.description) },
49082
49309
  { value: this._text(dimension.type) },
49083
49310
  positioned ? { value: this._position(dimension.position) } : { value: this._text(dimension.alias), muted: !dimension.alias },
49084
49311
  { value: !!dimension.pk, muted: !dimension.pk },
@@ -49090,7 +49317,7 @@ var init_ResourceView = __esm({
49090
49317
  };
49091
49318
  this._measuresTable = (producer) => {
49092
49319
  const rows = (producer.measures ?? []).map((measure) => [
49093
- { value: measure.name },
49320
+ { value: measure.name, note: this._note(measure.description) },
49094
49321
  { value: measure.sql }
49095
49322
  ]);
49096
49323
  return this._table("Measures", [
@@ -49156,7 +49383,7 @@ var init_ResourceView = __esm({
49156
49383
  };
49157
49384
  this._consumerFieldsTable = (env2, consumer) => {
49158
49385
  const rows = (consumer.fields ?? []).map((field) => [
49159
- { value: field.key },
49386
+ { value: field.key, note: this._note(field.description) },
49160
49387
  { value: this._text(field.alias), muted: !field.alias },
49161
49388
  { value: this._text(field.from), link: field.from ? this._inputLink(env2, field.from) : void 0, muted: !field.from },
49162
49389
  { value: this._text(field.transform ? Object.keys(field.transform) : null), muted: !field.transform },
@@ -49245,7 +49472,7 @@ var init_ResourceView = __esm({
49245
49472
  const required = new Set(schema.required ?? []);
49246
49473
  const properties = Object.entries(schema.properties ?? {});
49247
49474
  const rows = properties.map(([property, definition]) => [
49248
- { value: property },
49475
+ { value: property, note: this._note(this._schemaKeyword(definition, "description")) },
49249
49476
  { value: this._schemaType(definition) },
49250
49477
  { value: required.has(property), muted: !required.has(property) },
49251
49478
  { value: this._text(this._schemaKeyword(definition, "format")), muted: !this._schemaKeyword(definition, "format") }
@@ -49351,6 +49578,15 @@ var init_ResourceView = __esm({
49351
49578
  const minutes = Math.floor(elapsedMS / 6e4);
49352
49579
  return `${minutes}m ${Math.round(elapsedMS % 6e4 / 1e3)}s`;
49353
49580
  };
49581
+ /**
49582
+ * A description as the secondary line of a cell. Blank prose is the same as none, so a field
49583
+ * documented with a stray space does not cost the row a line.
49584
+ */
49585
+ this._note = (description) => {
49586
+ const text = (description ?? "").trim();
49587
+ if (!text) return void 0;
49588
+ return text.length > MAX_NOTE_CHARS ? `${text.slice(0, MAX_NOTE_CHARS)}\u2026` : text;
49589
+ };
49354
49590
  /** Anything that is not already a scalar becomes readable text; absent becomes `null`. */
49355
49591
  this._text = (value) => {
49356
49592
  if (value === void 0 || value === null) return null;
@@ -49667,7 +49903,7 @@ var init_OpsHeartbeat = __esm({
49667
49903
  "../../packages/engines/src/ops/OpsHeartbeat.ts"() {
49668
49904
  init_src2();
49669
49905
  init_OpsService();
49670
- DEFAULT_INTERVAL_MS = 6e4;
49906
+ DEFAULT_INTERVAL_MS = 3e5;
49671
49907
  MIN_INTERVAL_MS = 5e3;
49672
49908
  MAX_INTERVAL_MS = 36e5;
49673
49909
  OpsHeartbeatClass = class {
@@ -49707,11 +49943,24 @@ var init_OpsHeartbeat = __esm({
49707
49943
  Logger_default.error(error);
49708
49944
  }
49709
49945
  };
49946
+ /**
49947
+ * Resolve the configured interval, in milliseconds. A value that is unusable or out of range is
49948
+ * reported rather than silently replaced: an operator who set an interval and got a different
49949
+ * one has no other way to find out.
49950
+ */
49710
49951
  this.resolveInterval = () => {
49711
- const configured = Number(process.env.REMORA_STATE_INTERVAL_MS);
49712
- if (!Number.isFinite(configured) || configured <= 0)
49952
+ const raw = process.env.REMORA_STATE_INTERVAL_MS;
49953
+ if (!raw)
49954
+ return DEFAULT_INTERVAL_MS;
49955
+ const configured = Number(raw);
49956
+ if (!Number.isFinite(configured) || configured <= 0) {
49957
+ Logger_default.warn(`REMORA_STATE_INTERVAL_MS is not a positive number of milliseconds ("${raw}"); using ${DEFAULT_INTERVAL_MS}ms.`);
49713
49958
  return DEFAULT_INTERVAL_MS;
49714
- return Math.min(Math.max(configured, MIN_INTERVAL_MS), MAX_INTERVAL_MS);
49959
+ }
49960
+ const clamped = Math.min(Math.max(configured, MIN_INTERVAL_MS), MAX_INTERVAL_MS);
49961
+ if (clamped !== configured)
49962
+ Logger_default.warn(`REMORA_STATE_INTERVAL_MS of ${configured}ms is outside ${MIN_INTERVAL_MS}ms..${MAX_INTERVAL_MS}ms; using ${clamped}ms.`);
49963
+ return clamped;
49715
49964
  };
49716
49965
  }
49717
49966
  };
@@ -50521,8 +50770,8 @@ var init_TransformationEngine = __esm({
50521
50770
  return result;
50522
50771
  }
50523
50772
  if ("cast" in transformations) {
50524
- const { cast, format: format3 } = transformations;
50525
- const casted = TypeCaster_default.cast(value, cast, format3);
50773
+ const { cast, format: format4 } = transformations;
50774
+ const casted = TypeCaster_default.cast(value, cast, format4);
50526
50775
  if (cast === "number" && isNaN(casted))
50527
50776
  throw new Error(`Cannot cast non-numeric value in field '${field.key}'`);
50528
50777
  if (cast === "datetime" && casted instanceof Date && isNaN(casted.getTime()))
@@ -51300,13 +51549,13 @@ var init_OutputExecutor = __esm({
51300
51549
  });
51301
51550
 
51302
51551
  // ../../packages/executors/src/ConsumerExecutor.ts
51303
- var import_path23, import_fs17, import_readline6, import_promises13, import_crypto7, LIMIT_SCAN_BYTES, NEWLINE_BYTE, ConsumerExecutorClass, ConsumerExecutor, ConsumerExecutor_default;
51552
+ var import_path23, import_fs17, import_readline6, import_promises14, import_crypto7, LIMIT_SCAN_BYTES, NEWLINE_BYTE, ConsumerExecutorClass, ConsumerExecutor, ConsumerExecutor_default;
51304
51553
  var init_ConsumerExecutor = __esm({
51305
51554
  "../../packages/executors/src/ConsumerExecutor.ts"() {
51306
51555
  import_path23 = __toESM(require("path"));
51307
51556
  import_fs17 = __toESM(require("fs"));
51308
51557
  import_readline6 = __toESM(require("readline"));
51309
- import_promises13 = __toESM(require("fs/promises"));
51558
+ import_promises14 = __toESM(require("fs/promises"));
51310
51559
  import_crypto7 = __toESM(require("crypto"));
51311
51560
  init_src10();
51312
51561
  init_src10();
@@ -51493,8 +51742,8 @@ var init_ConsumerExecutor = __esm({
51493
51742
  reader.destroy();
51494
51743
  });
51495
51744
  }
51496
- await import_promises13.default.unlink(datasetPath);
51497
- await import_promises13.default.rename(tempWorkPath, datasetPath);
51745
+ await import_promises14.default.unlink(datasetPath);
51746
+ await import_promises14.default.rename(tempWorkPath, datasetPath);
51498
51747
  return processedLineCount;
51499
51748
  };
51500
51749
  /**
@@ -51512,7 +51761,7 @@ var init_ConsumerExecutor = __esm({
51512
51761
  this.processLimit = async (datasetPath, limit) => {
51513
51762
  Affirm_default(datasetPath, "Invalid dataset path");
51514
51763
  Affirm_default(limit > 0, `Invalid record limit ${limit}`);
51515
- const handle = await import_promises13.default.open(datasetPath, "r+");
51764
+ const handle = await import_promises14.default.open(datasetPath, "r+");
51516
51765
  try {
51517
51766
  const buffer = Buffer.allocUnsafe(LIMIT_SCAN_BYTES);
51518
51767
  let newlines = 0;
@@ -51566,8 +51815,8 @@ var init_ConsumerExecutor = __esm({
51566
51815
  reader.destroy();
51567
51816
  });
51568
51817
  }
51569
- await import_promises13.default.unlink(datasetPath);
51570
- await import_promises13.default.rename(tempWorkPath, datasetPath);
51818
+ await import_promises14.default.unlink(datasetPath);
51819
+ await import_promises14.default.rename(tempWorkPath, datasetPath);
51571
51820
  return newLineCount;
51572
51821
  };
51573
51822
  this.processDistinctOn = async (consumer, datasetPath) => {
@@ -51611,8 +51860,8 @@ var init_ConsumerExecutor = __esm({
51611
51860
  reader.destroy();
51612
51861
  });
51613
51862
  }
51614
- await import_promises13.default.unlink(datasetPath);
51615
- await import_promises13.default.rename(tempWorkPath, datasetPath);
51863
+ await import_promises14.default.unlink(datasetPath);
51864
+ await import_promises14.default.rename(tempWorkPath, datasetPath);
51616
51865
  return winners.size;
51617
51866
  };
51618
51867
  this.processPivot = async (consumer, datasetPath) => {
@@ -51718,12 +51967,12 @@ var init_ConsumerExecutor = __esm({
51718
51967
  reader.destroy();
51719
51968
  });
51720
51969
  }
51721
- await import_promises13.default.unlink(datasetPath);
51722
- await import_promises13.default.rename(tempWorkPath, datasetPath);
51970
+ await import_promises14.default.unlink(datasetPath);
51971
+ await import_promises14.default.rename(tempWorkPath, datasetPath);
51723
51972
  return outputCount;
51724
51973
  };
51725
- this._parseLine = (line, format3, fields) => {
51726
- return format3 === "CSV" ? LineParser_default._internalParseCSV(line, fields) : LineParser_default._internalParseJSON(line);
51974
+ this._parseLine = (line, format4, fields) => {
51975
+ return format4 === "CSV" ? LineParser_default._internalParseCSV(line, fields) : LineParser_default._internalParseJSON(line);
51727
51976
  };
51728
51977
  /**
51729
51978
  * Determines if the new record should replace the existing record based on the resolution strategy
@@ -52192,11 +52441,11 @@ var init_OrchestratorHelper = __esm({
52192
52441
  });
52193
52442
 
52194
52443
  // ../../packages/executors/src/LookupResolver.ts
52195
- var import_fs18, import_promises14, import_path26, import_readline8, LookupResolverClass, LookupResolver, LookupResolver_default;
52444
+ var import_fs18, import_promises15, import_path26, import_readline8, LookupResolverClass, LookupResolver, LookupResolver_default;
52196
52445
  var init_LookupResolver = __esm({
52197
52446
  "../../packages/executors/src/LookupResolver.ts"() {
52198
52447
  import_fs18 = __toESM(require("fs"));
52199
- import_promises14 = __toESM(require("fs/promises"));
52448
+ import_promises15 = __toESM(require("fs/promises"));
52200
52449
  import_path26 = __toESM(require("path"));
52201
52450
  import_readline8 = __toESM(require("readline"));
52202
52451
  init_src();
@@ -52237,11 +52486,11 @@ var init_LookupResolver = __esm({
52237
52486
  this.cache.set(id, await this.buildDict(lookupConsumer, capturePath, ref));
52238
52487
  }
52239
52488
  ExecutorScope_default.ensurePath(outPath);
52240
- await import_promises14.default.writeFile(outPath, JSON.stringify(this.cache.get(id)));
52489
+ await import_promises15.default.writeFile(outPath, JSON.stringify(this.cache.get(id)));
52241
52490
  manifest.push({ id, consumer: ref.consumer, key: ref.key, value: ref.value, path: import_path26.default.resolve(outPath) });
52242
52491
  }
52243
52492
  for (const capturePath of captureByConsumer.values())
52244
- await import_promises14.default.rm(capturePath, { force: true });
52493
+ await import_promises15.default.rm(capturePath, { force: true });
52245
52494
  return manifest;
52246
52495
  };
52247
52496
  // Runs the source consumer through the real pipeline, capturing its merged output before cleanup.
@@ -52259,7 +52508,7 @@ var init_LookupResolver = __esm({
52259
52508
  };
52260
52509
  // Projects the captured dataset to a { code: value } dict, bounded by MAX_LOOKUP_ROWS.
52261
52510
  this.buildDict = async (lookupConsumer, capturePath, ref) => {
52262
- const format3 = OutputExecutor_default._getInternalRecordFormat(lookupConsumer);
52511
+ const format4 = OutputExecutor_default._getInternalRecordFormat(lookupConsumer);
52263
52512
  const visibleFields = ConsumerManager_default.getExpandedFields(lookupConsumer).filter((f7) => !f7.cField.hidden);
52264
52513
  const finalKeys = visibleFields.map((f7) => f7.finalKey);
52265
52514
  Affirm_default(finalKeys.includes(ref.key), `code_lookup key column "${ref.key}" is not in the output of consumer "${ref.consumer}"`);
@@ -52272,7 +52521,7 @@ var init_LookupResolver = __esm({
52272
52521
  if (!line.length) continue;
52273
52522
  rowsRead++;
52274
52523
  Affirm_default(rowsRead <= Constants_default.defaults.MAX_LOOKUP_ROWS, `code_lookup table from consumer "${ref.consumer}" exceeds MAX_LOOKUP_ROWS (${Constants_default.defaults.MAX_LOOKUP_ROWS})`);
52275
- const record = this.parseLine(line, format3, visibleFields);
52524
+ const record = this.parseLine(line, format4, visibleFields);
52276
52525
  const code = String(record[ref.key]);
52277
52526
  if (code in dict && !warnedDup) {
52278
52527
  Logger_default.warn(`code_lookup: duplicate key(s) in consumer "${ref.consumer}" for "${ref.key}"; last value wins`);
@@ -52283,8 +52532,8 @@ var init_LookupResolver = __esm({
52283
52532
  Logger_default.log(`[lookup] Built table "${ref.consumer}" (${ref.key}->${ref.value}): ${Object.keys(dict).length} entr(ies) from ${rowsRead} row(s)`);
52284
52533
  return dict;
52285
52534
  };
52286
- this.parseLine = (line, format3, visibleFields) => {
52287
- if (format3 === "CSV") return LineParser_default._internalParseCSV(line, visibleFields, ",");
52535
+ this.parseLine = (line, format4, visibleFields) => {
52536
+ if (format4 === "CSV") return LineParser_default._internalParseCSV(line, visibleFields, ",");
52288
52537
  return JSON.parse(line);
52289
52538
  };
52290
52539
  this.getCapturePath = (scope, consumerName) => {
@@ -52311,11 +52560,11 @@ var init_LookupResolver = __esm({
52311
52560
  });
52312
52561
 
52313
52562
  // ../../packages/executors/src/ConsumerInputResolver.ts
52314
- var import_fs19, import_promises15, import_path27, ConsumerInputResolverClass, ConsumerInputResolver, ConsumerInputResolver_default;
52563
+ var import_fs19, import_promises16, import_path27, ConsumerInputResolverClass, ConsumerInputResolver, ConsumerInputResolver_default;
52315
52564
  var init_ConsumerInputResolver = __esm({
52316
52565
  "../../packages/executors/src/ConsumerInputResolver.ts"() {
52317
52566
  import_fs19 = __toESM(require("fs"));
52318
- import_promises15 = __toESM(require("fs/promises"));
52567
+ import_promises16 = __toESM(require("fs/promises"));
52319
52568
  import_path27 = __toESM(require("path"));
52320
52569
  init_src();
52321
52570
  init_src3();
@@ -52346,7 +52595,7 @@ var init_ConsumerInputResolver = __esm({
52346
52595
  const capturePath = ExecutorScope_default.getConsumerInputPath(scope, name);
52347
52596
  ExecutorScope_default.ensurePath(capturePath);
52348
52597
  await this.runUpstreamConsumer(upstream, capturePath, stack, request);
52349
- const { size } = await import_promises15.default.stat(capturePath);
52598
+ const { size } = await import_promises16.default.stat(capturePath);
52350
52599
  this.cache.set(name, { consumer: name, path: import_path27.default.resolve(capturePath), fileSize: size });
52351
52600
  }
52352
52601
  manifest.set(name, this.cache.get(name));
@@ -52409,11 +52658,11 @@ var ExecutorOrchestrator_exports = {};
52409
52658
  __export(ExecutorOrchestrator_exports, {
52410
52659
  default: () => ExecutorOrchestrator_default
52411
52660
  });
52412
- var import_fs20, import_promises16, import_path28, import_readline9, import_workerpool, import_promises17, ExecutorOrchestratorClass, ExecutorOrchestrator, ExecutorOrchestrator_default;
52661
+ var import_fs20, import_promises17, import_path28, import_readline9, import_workerpool, import_promises18, ExecutorOrchestratorClass, ExecutorOrchestrator, ExecutorOrchestrator_default;
52413
52662
  var init_ExecutorOrchestrator = __esm({
52414
52663
  "../../packages/executors/src/ExecutorOrchestrator.ts"() {
52415
52664
  import_fs20 = __toESM(require("fs"));
52416
- import_promises16 = __toESM(require("fs/promises"));
52665
+ import_promises17 = __toESM(require("fs/promises"));
52417
52666
  import_path28 = __toESM(require("path"));
52418
52667
  import_readline9 = __toESM(require("readline"));
52419
52668
  import_workerpool = __toESM(require("workerpool"));
@@ -52431,7 +52680,7 @@ var init_ExecutorOrchestrator = __esm({
52431
52680
  init_src();
52432
52681
  init_src10();
52433
52682
  init_ExecutorWriter();
52434
- import_promises17 = require("stream/promises");
52683
+ import_promises18 = require("stream/promises");
52435
52684
  init_src2();
52436
52685
  init_ExecutorProgress2();
52437
52686
  init_src6();
@@ -52948,10 +53197,10 @@ var init_ExecutorOrchestrator = __esm({
52948
53197
  * format has no header row, so each row is reprojected. Without a captureFormat it's a verbatim copy.
52949
53198
  */
52950
53199
  this.captureDataset = async (consumer, fields, sourcePath, targetPath, captureFormat) => {
52951
- await import_promises16.default.mkdir(import_path28.default.dirname(targetPath), { recursive: true });
53200
+ await import_promises17.default.mkdir(import_path28.default.dirname(targetPath), { recursive: true });
52952
53201
  const internalFormat = OutputExecutor_default._getInternalRecordFormat(consumer);
52953
53202
  if (captureFormat !== "JSONL" || internalFormat !== "CSV") {
52954
- await import_promises16.default.copyFile(sourcePath, targetPath);
53203
+ await import_promises17.default.copyFile(sourcePath, targetPath);
52955
53204
  return;
52956
53205
  }
52957
53206
  const visibleFields = fields.filter((field) => !field.cField.hidden);
@@ -53054,22 +53303,22 @@ var init_ExecutorOrchestrator = __esm({
53054
53303
  startRow: prod.settings.startRow,
53055
53304
  startColumn: prod.settings.startColumn
53056
53305
  });
53057
- await (0, import_promises17.pipeline)(
53306
+ await (0, import_promises18.pipeline)(
53058
53307
  xlsCsvStream,
53059
53308
  import_fs20.default.createWriteStream(decodedPath)
53060
53309
  );
53061
- const fileStats = await import_promises16.default.stat(decodedPath);
53310
+ const fileStats = await import_promises17.default.stat(decodedPath);
53062
53311
  decodedFiles.push({ fullUri: decodedPath, fileSize: fileStats.size });
53063
53312
  decodedCount++;
53064
53313
  reportFile();
53065
53314
  continue;
53066
53315
  }
53067
53316
  if (inferredType === "XML") {
53068
- const fileContent = await import_promises16.default.readFile(file.fullUri, "utf-8");
53317
+ const fileContent = await import_promises17.default.readFile(file.fullUri, "utf-8");
53069
53318
  const jsonData = XMLParser_default.xmlToJson(fileContent);
53070
53319
  const records = normalizeXmlRows(jsonData);
53071
53320
  if (records.length === 0) {
53072
- await import_promises16.default.writeFile(decodedPath, "", "utf-8");
53321
+ await import_promises17.default.writeFile(decodedPath, "", "utf-8");
53073
53322
  } else {
53074
53323
  const columns = [];
53075
53324
  for (const record of records) {
@@ -53085,9 +53334,9 @@ var init_ExecutorOrchestrator = __esm({
53085
53334
  const row = columns.map((column) => csvSafeValue(record[column]));
53086
53335
  lines.push(CSVParser_default.stringifyRow(row));
53087
53336
  }
53088
- await import_promises16.default.writeFile(decodedPath, lines.join("\n"), "utf-8");
53337
+ await import_promises17.default.writeFile(decodedPath, lines.join("\n"), "utf-8");
53089
53338
  }
53090
- const fileStats = await import_promises16.default.stat(decodedPath);
53339
+ const fileStats = await import_promises17.default.stat(decodedPath);
53091
53340
  decodedFiles.push({ fullUri: decodedPath, fileSize: fileStats.size });
53092
53341
  decodedCount++;
53093
53342
  reportFile();
@@ -53115,20 +53364,20 @@ var init_ExecutorOrchestrator = __esm({
53115
53364
  Logger_default.log(`[${scope.id}] Merging ${executorResults.length} worker output files into ${mainPath}`);
53116
53365
  const perf = performance.now();
53117
53366
  for (const workerResult of executorResults) {
53118
- await (0, import_promises17.pipeline)(
53367
+ await (0, import_promises18.pipeline)(
53119
53368
  import_fs20.default.createReadStream(workerResult.resultUri),
53120
53369
  import_fs20.default.createWriteStream(mainPath, { flags: "a" })
53121
53370
  );
53122
- await import_promises16.default.unlink(workerResult.resultUri);
53371
+ await import_promises17.default.unlink(workerResult.resultUri);
53123
53372
  }
53124
53373
  tracker.measure("merge-workers", performance.now() - perf);
53125
53374
  Logger_default.log(`[${scope.id}] Merge complete in ${Math.round(performance.now() - perf)}ms`);
53126
53375
  } else if (executorResults.length === 1) {
53127
53376
  Logger_default.log(`[${scope.id}] Single worker \u2014 renaming output to ${mainPath}`);
53128
- await import_promises16.default.rename(executorResults[0].resultUri, mainPath);
53377
+ await import_promises17.default.rename(executorResults[0].resultUri, mainPath);
53129
53378
  } else {
53130
53379
  Logger_default.log(`[${scope.id}] No worker output \u2014 writing an empty dataset to ${mainPath}`);
53131
- await import_promises16.default.writeFile(mainPath, "");
53380
+ await import_promises17.default.writeFile(mainPath, "");
53132
53381
  }
53133
53382
  return mainPath;
53134
53383
  };
@@ -53851,7 +54100,7 @@ init_ProducerExecutor();
53851
54100
 
53852
54101
  // ../../packages/executors/src/SampleRunner.ts
53853
54102
  var import_fs21 = __toESM(require("fs"));
53854
- var import_promises18 = __toESM(require("fs/promises"));
54103
+ var import_promises19 = __toESM(require("fs/promises"));
53855
54104
  var import_path29 = __toESM(require("path"));
53856
54105
  var import_readline10 = __toESM(require("readline"));
53857
54106
  init_src();
@@ -53925,7 +54174,7 @@ var SampleRunnerClass = class {
53925
54174
  note: `${records.length} row(s) from the real pipeline \u2014 filters, transformations, masking and validation all applied, exactly as in a run. Nothing was written to the destination.`
53926
54175
  };
53927
54176
  } finally {
53928
- await import_promises18.default.rm(capturePath, { force: true });
54177
+ await import_promises19.default.rm(capturePath, { force: true });
53929
54178
  }
53930
54179
  };
53931
54180
  /**
@@ -54147,10 +54396,10 @@ init_src5();
54147
54396
  init_src2();
54148
54397
  var FORMATS = ["mermaid", "dot", "json"];
54149
54398
  var graph = async (options) => {
54150
- const format3 = options?.format ?? "mermaid";
54399
+ const format4 = options?.format ?? "mermaid";
54151
54400
  try {
54152
- if (!FORMATS.includes(format3)) {
54153
- console.error(import_chalk9.default.red(`Unknown format "${format3}". Use one of: ${FORMATS.join(", ")}.`));
54401
+ if (!FORMATS.includes(format4)) {
54402
+ console.error(import_chalk9.default.red(`Unknown format "${format4}". Use one of: ${FORMATS.join(", ")}.`));
54154
54403
  await Logger_default.flush();
54155
54404
  process.exit(1);
54156
54405
  }
@@ -54160,10 +54409,10 @@ var graph = async (options) => {
54160
54409
  generatedBy: `remora ${Constants_default.cliVersion}`,
54161
54410
  loadDiagnostics: Diagnostics_default.fromLoadProblems(problems),
54162
54411
  // The json format IS the viewer's contract, so every resource view ships with it.
54163
- resources: format3 === "json" ? "inline" : "lazy"
54412
+ resources: format4 === "json" ? "inline" : "lazy"
54164
54413
  });
54165
- process.stdout.write(render(format3, snapshot) + "\n");
54166
- if (format3 !== "json")
54414
+ process.stdout.write(render(format4, snapshot) + "\n");
54415
+ if (format4 !== "json")
54167
54416
  reportDiagnostics(snapshot.diagnostics);
54168
54417
  } catch (err2) {
54169
54418
  const myErr = Helper_default.asError(err2);
@@ -54173,9 +54422,9 @@ var graph = async (options) => {
54173
54422
  process.exit(1);
54174
54423
  }
54175
54424
  };
54176
- var render = (format3, snapshot) => {
54177
- if (format3 === "json") return JSON.stringify(snapshot, null, 4);
54178
- if (format3 === "dot") return LineageRenderer_default.toDot(snapshot.graph);
54425
+ var render = (format4, snapshot) => {
54426
+ if (format4 === "json") return JSON.stringify(snapshot, null, 4);
54427
+ if (format4 === "dot") return LineageRenderer_default.toDot(snapshot.graph);
54179
54428
  return LineageRenderer_default.toMermaid(snapshot.graph);
54180
54429
  };
54181
54430
  var reportDiagnostics = (diagnostics) => {
@@ -54312,12 +54561,12 @@ var PreviewProject = class {
54312
54561
  if (!this._has(nodeId)) return null;
54313
54562
  const { kind, name } = LineageEngine_default.parseNodeId(nodeId);
54314
54563
  if (!SAMPLEABLE_KINDS.includes(kind)) return null;
54315
- const pipeline5 = PIPELINE_SAMPLE_KINDS.includes(kind);
54316
- if (pipeline5 && this._running)
54564
+ const pipeline6 = PIPELINE_SAMPLE_KINDS.includes(kind);
54565
+ if (pipeline6 && this._running)
54317
54566
  throw new Error(`"${this._running}" is still running; one execution at a time`);
54318
- const blocking = pipeline5 ? this.snapshot.diagnostics.find((x2) => x2.node === nodeId && x2.severity === "error") : null;
54567
+ const blocking = pipeline6 ? this.snapshot.diagnostics.find((x2) => x2.node === nodeId && x2.severity === "error") : null;
54319
54568
  if (blocking) throw new Error(`Refusing to sample "${name}": ${blocking.message}`);
54320
- if (pipeline5) this._running = name;
54569
+ if (pipeline6) this._running = name;
54321
54570
  try {
54322
54571
  const licence = LicenceManager_default.validate(ProcessENVManager_default.getEnvVariable("REMORA_LICENCE_KEY"));
54323
54572
  const { records, note } = await SampleRunner_default.read(name, rows, {
@@ -54328,7 +54577,7 @@ var PreviewProject = class {
54328
54577
  });
54329
54578
  return ResourceView_default.buildSampleTable(records, note);
54330
54579
  } finally {
54331
- if (pipeline5) this._running = null;
54580
+ if (pipeline6) this._running = null;
54332
54581
  }
54333
54582
  };
54334
54583
  /**