@truto/truto-jsonata 1.0.50 → 1.0.52

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.
@@ -35068,8 +35068,23 @@ var require_formats = __commonJS((exports2, module2) => {
35068
35068
  // node_modules/qs/lib/utils.js
35069
35069
  var require_utils2 = __commonJS((exports2, module2) => {
35070
35070
  var formats = require_formats();
35071
+ var getSideChannel = require_side_channel();
35071
35072
  var has2 = Object.prototype.hasOwnProperty;
35072
35073
  var isArray4 = Array.isArray;
35074
+ var overflowChannel = getSideChannel();
35075
+ var markOverflow = function markOverflow(obj, maxIndex) {
35076
+ overflowChannel.set(obj, maxIndex);
35077
+ return obj;
35078
+ };
35079
+ var isOverflow = function isOverflow(obj) {
35080
+ return overflowChannel.has(obj);
35081
+ };
35082
+ var getMaxIndex = function getMaxIndex(obj) {
35083
+ return overflowChannel.get(obj);
35084
+ };
35085
+ var setMaxIndex = function setMaxIndex(obj, maxIndex) {
35086
+ overflowChannel.set(obj, maxIndex);
35087
+ };
35073
35088
  var hexTable = function() {
35074
35089
  var array = [];
35075
35090
  for (var i2 = 0;i2 < 256; ++i2) {
@@ -35109,7 +35124,11 @@ var require_utils2 = __commonJS((exports2, module2) => {
35109
35124
  if (isArray4(target)) {
35110
35125
  target.push(source);
35111
35126
  } else if (target && typeof target === "object") {
35112
- if (options3 && (options3.plainObjects || options3.allowPrototypes) || !has2.call(Object.prototype, source)) {
35127
+ if (isOverflow(target)) {
35128
+ var newIndex = getMaxIndex(target) + 1;
35129
+ target[newIndex] = source;
35130
+ setMaxIndex(target, newIndex);
35131
+ } else if (options3 && (options3.plainObjects || options3.allowPrototypes) || !has2.call(Object.prototype, source)) {
35113
35132
  target[source] = true;
35114
35133
  }
35115
35134
  } else {
@@ -35118,6 +35137,15 @@ var require_utils2 = __commonJS((exports2, module2) => {
35118
35137
  return target;
35119
35138
  }
35120
35139
  if (!target || typeof target !== "object") {
35140
+ if (isOverflow(source)) {
35141
+ var sourceKeys = Object.keys(source);
35142
+ var result = options3 && options3.plainObjects ? { __proto__: null, 0: target } : { 0: target };
35143
+ for (var m = 0;m < sourceKeys.length; m++) {
35144
+ var oldKey = parseInt(sourceKeys[m], 10);
35145
+ result[oldKey + 1] = source[sourceKeys[m]];
35146
+ }
35147
+ return markOverflow(result, getMaxIndex(source) + 1);
35148
+ }
35121
35149
  return [target].concat(source);
35122
35150
  }
35123
35151
  var mergeTarget = target;
@@ -35240,8 +35268,18 @@ var require_utils2 = __commonJS((exports2, module2) => {
35240
35268
  }
35241
35269
  return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
35242
35270
  };
35243
- var combine = function combine(a, b) {
35244
- return [].concat(a, b);
35271
+ var combine = function combine(a, b, arrayLimit, plainObjects) {
35272
+ if (isOverflow(a)) {
35273
+ var newIndex = getMaxIndex(a) + 1;
35274
+ a[newIndex] = b;
35275
+ setMaxIndex(a, newIndex);
35276
+ return a;
35277
+ }
35278
+ var result = [].concat(a, b);
35279
+ if (result.length > arrayLimit) {
35280
+ return markOverflow(arrayToObject(result, { plainObjects }), result.length - 1);
35281
+ }
35282
+ return result;
35245
35283
  };
35246
35284
  var maybeMap = function maybeMap(val, fn) {
35247
35285
  if (isArray4(val)) {
@@ -35261,6 +35299,7 @@ var require_utils2 = __commonJS((exports2, module2) => {
35261
35299
  decode,
35262
35300
  encode,
35263
35301
  isBuffer: isBuffer3,
35302
+ isOverflow,
35264
35303
  isRegExp: isRegExp3,
35265
35304
  maybeMap,
35266
35305
  merge
@@ -35591,9 +35630,11 @@ var require_parse = __commonJS((exports2, module2) => {
35591
35630
  val = options3.strictNullHandling ? null : "";
35592
35631
  } else {
35593
35632
  key = options3.decoder(part.slice(0, pos), defaults.decoder, charset2, "key");
35594
- val = utils.maybeMap(parseArrayValue(part.slice(pos + 1), options3, isArray4(obj[key]) ? obj[key].length : 0), function(encodedVal) {
35595
- return options3.decoder(encodedVal, defaults.decoder, charset2, "value");
35596
- });
35633
+ if (key !== null) {
35634
+ val = utils.maybeMap(parseArrayValue(part.slice(pos + 1), options3, isArray4(obj[key]) ? obj[key].length : 0), function(encodedVal) {
35635
+ return options3.decoder(encodedVal, defaults.decoder, charset2, "value");
35636
+ });
35637
+ }
35597
35638
  }
35598
35639
  if (val && options3.interpretNumericEntities && charset2 === "iso-8859-1") {
35599
35640
  val = interpretNumericEntities(String(val));
@@ -35601,11 +35642,13 @@ var require_parse = __commonJS((exports2, module2) => {
35601
35642
  if (part.indexOf("[]=") > -1) {
35602
35643
  val = isArray4(val) ? [val] : val;
35603
35644
  }
35604
- var existing = has2.call(obj, key);
35605
- if (existing && options3.duplicates === "combine") {
35606
- obj[key] = utils.combine(obj[key], val);
35607
- } else if (!existing || options3.duplicates === "last") {
35608
- obj[key] = val;
35645
+ if (key !== null) {
35646
+ var existing = has2.call(obj, key);
35647
+ if (existing && options3.duplicates === "combine") {
35648
+ obj[key] = utils.combine(obj[key], val, options3.arrayLimit, options3.plainObjects);
35649
+ } else if (!existing || options3.duplicates === "last") {
35650
+ obj[key] = val;
35651
+ }
35609
35652
  }
35610
35653
  }
35611
35654
  return obj;
@@ -35621,7 +35664,11 @@ var require_parse = __commonJS((exports2, module2) => {
35621
35664
  var obj;
35622
35665
  var root3 = chain[i2];
35623
35666
  if (root3 === "[]" && options3.parseArrays) {
35624
- obj = options3.allowEmptyArrays && (leaf === "" || options3.strictNullHandling && leaf === null) ? [] : utils.combine([], leaf);
35667
+ if (utils.isOverflow(leaf)) {
35668
+ obj = leaf;
35669
+ } else {
35670
+ obj = options3.allowEmptyArrays && (leaf === "" || options3.strictNullHandling && leaf === null) ? [] : utils.combine([], leaf, options3.arrayLimit, options3.plainObjects);
35671
+ }
35625
35672
  } else {
35626
35673
  obj = options3.plainObjects ? { __proto__: null } : {};
35627
35674
  var cleanRoot = root3.charAt(0) === "[" && root3.charAt(root3.length - 1) === "]" ? root3.slice(1, -1) : root3;
@@ -35640,14 +35687,19 @@ var require_parse = __commonJS((exports2, module2) => {
35640
35687
  }
35641
35688
  return leaf;
35642
35689
  };
35643
- var parseKeys = function parseQueryStringKeys(givenKey, val, options3, valuesParsed) {
35644
- if (!givenKey) {
35645
- return;
35646
- }
35690
+ var splitKeyIntoSegments = function splitKeyIntoSegments(givenKey, options3) {
35647
35691
  var key = options3.allowDots ? givenKey.replace(/\.([^.[]+)/g, "[$1]") : givenKey;
35692
+ if (options3.depth <= 0) {
35693
+ if (!options3.plainObjects && has2.call(Object.prototype, key)) {
35694
+ if (!options3.allowPrototypes) {
35695
+ return;
35696
+ }
35697
+ }
35698
+ return [key];
35699
+ }
35648
35700
  var brackets = /(\[[^[\]]*])/;
35649
35701
  var child = /(\[[^[\]]*])/g;
35650
- var segment = options3.depth > 0 && brackets.exec(key);
35702
+ var segment = brackets.exec(key);
35651
35703
  var parent2 = segment ? key.slice(0, segment.index) : key;
35652
35704
  var keys2 = [];
35653
35705
  if (parent2) {
@@ -35659,9 +35711,10 @@ var require_parse = __commonJS((exports2, module2) => {
35659
35711
  keys2.push(parent2);
35660
35712
  }
35661
35713
  var i2 = 0;
35662
- while (options3.depth > 0 && (segment = child.exec(key)) !== null && i2 < options3.depth) {
35714
+ while ((segment = child.exec(key)) !== null && i2 < options3.depth) {
35663
35715
  i2 += 1;
35664
- if (!options3.plainObjects && has2.call(Object.prototype, segment[1].slice(1, -1))) {
35716
+ var segmentContent = segment[1].slice(1, -1);
35717
+ if (!options3.plainObjects && has2.call(Object.prototype, segmentContent)) {
35665
35718
  if (!options3.allowPrototypes) {
35666
35719
  return;
35667
35720
  }
@@ -35674,6 +35727,16 @@ var require_parse = __commonJS((exports2, module2) => {
35674
35727
  }
35675
35728
  keys2.push("[" + key.slice(segment.index) + "]");
35676
35729
  }
35730
+ return keys2;
35731
+ };
35732
+ var parseKeys = function parseQueryStringKeys(givenKey, val, options3, valuesParsed) {
35733
+ if (!givenKey) {
35734
+ return;
35735
+ }
35736
+ var keys2 = splitKeyIntoSegments(givenKey, options3);
35737
+ if (!keys2) {
35738
+ return;
35739
+ }
35677
35740
  return parseObject(keys2, val, options3, valuesParsed);
35678
35741
  };
35679
35742
  var normalizeParseOptions = function normalizeParseOptions(opts) {
@@ -75968,62 +76031,38 @@ async function encodingForModel(model) {
75968
76031
  }
75969
76032
 
75970
76033
  // node_modules/@langchain/textsplitters/dist/text_splitter.js
75971
- class TextSplitter extends BaseDocumentTransformer {
76034
+ var TextSplitter = class extends BaseDocumentTransformer {
76035
+ lc_namespace = [
76036
+ "langchain",
76037
+ "document_transformers",
76038
+ "text_splitters"
76039
+ ];
76040
+ chunkSize = 1000;
76041
+ chunkOverlap = 200;
76042
+ keepSeparator = false;
76043
+ lengthFunction;
75972
76044
  constructor(fields) {
75973
76045
  super(fields);
75974
- Object.defineProperty(this, "lc_namespace", {
75975
- enumerable: true,
75976
- configurable: true,
75977
- writable: true,
75978
- value: ["langchain", "document_transformers", "text_splitters"]
75979
- });
75980
- Object.defineProperty(this, "chunkSize", {
75981
- enumerable: true,
75982
- configurable: true,
75983
- writable: true,
75984
- value: 1000
75985
- });
75986
- Object.defineProperty(this, "chunkOverlap", {
75987
- enumerable: true,
75988
- configurable: true,
75989
- writable: true,
75990
- value: 200
75991
- });
75992
- Object.defineProperty(this, "keepSeparator", {
75993
- enumerable: true,
75994
- configurable: true,
75995
- writable: true,
75996
- value: false
75997
- });
75998
- Object.defineProperty(this, "lengthFunction", {
75999
- enumerable: true,
76000
- configurable: true,
76001
- writable: true,
76002
- value: undefined
76003
- });
76004
76046
  this.chunkSize = fields?.chunkSize ?? this.chunkSize;
76005
76047
  this.chunkOverlap = fields?.chunkOverlap ?? this.chunkOverlap;
76006
76048
  this.keepSeparator = fields?.keepSeparator ?? this.keepSeparator;
76007
76049
  this.lengthFunction = fields?.lengthFunction ?? ((text) => text.length);
76008
- if (this.chunkOverlap >= this.chunkSize) {
76050
+ if (this.chunkOverlap >= this.chunkSize)
76009
76051
  throw new Error("Cannot have chunkOverlap >= chunkSize");
76010
- }
76011
76052
  }
76012
76053
  async transformDocuments(documents, chunkHeaderOptions = {}) {
76013
76054
  return this.splitDocuments(documents, chunkHeaderOptions);
76014
76055
  }
76015
76056
  splitOnSeparator(text, separator) {
76016
76057
  let splits;
76017
- if (separator) {
76058
+ if (separator)
76018
76059
  if (this.keepSeparator) {
76019
76060
  const regexEscapedSeparator = separator.replace(/[/\-\\^$*+?.()|[\]{}]/g, "\\$&");
76020
- splits = text.split(new RegExp(`(?=${regexEscapedSeparator})`));
76021
- } else {
76061
+ splits = text.split(/* @__PURE__ */ new RegExp(`(?=${regexEscapedSeparator})`));
76062
+ } else
76022
76063
  splits = text.split(separator);
76023
- }
76024
- } else {
76064
+ else
76025
76065
  splits = text.split("");
76026
- }
76027
76066
  return splits.filter((s2) => s2 !== "");
76028
76067
  }
76029
76068
  async createDocuments(texts, metadatas = [], chunkHeaderOptions = {}) {
@@ -76050,9 +76089,8 @@ class TextSplitter extends BaseDocumentTransformer {
76050
76089
  const numberOfIntermediateNewLines = this.numberOfNewLines(text, indexChunk, indexEndPrevChunk);
76051
76090
  lineCounterIndex -= numberOfIntermediateNewLines;
76052
76091
  }
76053
- if (appendChunkOverlapHeader) {
76092
+ if (appendChunkOverlapHeader)
76054
76093
  pageContent += chunkOverlapHeader;
76055
- }
76056
76094
  }
76057
76095
  const newLinesCount = this.numberOfNewLines(chunk2);
76058
76096
  const loc = _metadatas[i3].loc && typeof _metadatas[i3].loc === "object" ? { ..._metadatas[i3].loc } : {};
@@ -76097,15 +76135,13 @@ class TextSplitter extends BaseDocumentTransformer {
76097
76135
  for (const d of splits) {
76098
76136
  const _len = await this.lengthFunction(d);
76099
76137
  if (total + _len + currentDoc.length * separator.length > this.chunkSize) {
76100
- if (total > this.chunkSize) {
76138
+ if (total > this.chunkSize)
76101
76139
  console.warn(`Created a chunk of size ${total}, +
76102
76140
  which is longer than the specified ${this.chunkSize}`);
76103
- }
76104
76141
  if (currentDoc.length > 0) {
76105
- const doc3 = this.joinDocs(currentDoc, separator);
76106
- if (doc3 !== null) {
76107
- docs.push(doc3);
76108
- }
76142
+ const doc$1 = this.joinDocs(currentDoc, separator);
76143
+ if (doc$1 !== null)
76144
+ docs.push(doc$1);
76109
76145
  while (total > this.chunkOverlap || total + _len + currentDoc.length * separator.length > this.chunkSize && total > 0) {
76110
76146
  total -= await this.lengthFunction(currentDoc[0]);
76111
76147
  currentDoc.shift();
@@ -76116,27 +76152,26 @@ which is longer than the specified ${this.chunkSize}`);
76116
76152
  total += _len;
76117
76153
  }
76118
76154
  const doc2 = this.joinDocs(currentDoc, separator);
76119
- if (doc2 !== null) {
76155
+ if (doc2 !== null)
76120
76156
  docs.push(doc2);
76121
- }
76122
76157
  return docs;
76123
76158
  }
76124
- }
76125
- class RecursiveCharacterTextSplitter extends TextSplitter {
76159
+ };
76160
+ var RecursiveCharacterTextSplitter = class RecursiveCharacterTextSplitter2 extends TextSplitter {
76126
76161
  static lc_name() {
76127
76162
  return "RecursiveCharacterTextSplitter";
76128
76163
  }
76164
+ separators = [
76165
+ `
76166
+
76167
+ `,
76168
+ `
76169
+ `,
76170
+ " ",
76171
+ ""
76172
+ ];
76129
76173
  constructor(fields) {
76130
76174
  super(fields);
76131
- Object.defineProperty(this, "separators", {
76132
- enumerable: true,
76133
- configurable: true,
76134
- writable: true,
76135
- value: [`
76136
-
76137
- `, `
76138
- `, " ", ""]
76139
- });
76140
76175
  this.separators = fields?.separators ?? this.separators;
76141
76176
  this.keepSeparator = fields?.keepSeparator ?? true;
76142
76177
  }
@@ -76159,23 +76194,22 @@ class RecursiveCharacterTextSplitter extends TextSplitter {
76159
76194
  const splits = this.splitOnSeparator(text, separator);
76160
76195
  let goodSplits = [];
76161
76196
  const _separator = this.keepSeparator ? "" : separator;
76162
- for (const s2 of splits) {
76163
- if (await this.lengthFunction(s2) < this.chunkSize) {
76197
+ for (const s2 of splits)
76198
+ if (await this.lengthFunction(s2) < this.chunkSize)
76164
76199
  goodSplits.push(s2);
76165
- } else {
76200
+ else {
76166
76201
  if (goodSplits.length) {
76167
76202
  const mergedText = await this.mergeSplits(goodSplits, _separator);
76168
76203
  finalChunks.push(...mergedText);
76169
76204
  goodSplits = [];
76170
76205
  }
76171
- if (!newSeparators) {
76206
+ if (!newSeparators)
76172
76207
  finalChunks.push(s2);
76173
- } else {
76208
+ else {
76174
76209
  const otherInfo = await this._splitText(s2, newSeparators);
76175
76210
  finalChunks.push(...otherInfo);
76176
76211
  }
76177
76212
  }
76178
- }
76179
76213
  if (goodSplits.length) {
76180
76214
  const mergedText = await this.mergeSplits(goodSplits, _separator);
76181
76215
  finalChunks.push(...mergedText);
@@ -76186,13 +76220,13 @@ class RecursiveCharacterTextSplitter extends TextSplitter {
76186
76220
  return this._splitText(text, this.separators);
76187
76221
  }
76188
76222
  static fromLanguage(language, options3) {
76189
- return new RecursiveCharacterTextSplitter({
76223
+ return new RecursiveCharacterTextSplitter2({
76190
76224
  ...options3,
76191
- separators: RecursiveCharacterTextSplitter.getSeparatorsForLanguage(language)
76225
+ separators: RecursiveCharacterTextSplitter2.getSeparatorsForLanguage(language)
76192
76226
  });
76193
76227
  }
76194
76228
  static getSeparatorsForLanguage(language) {
76195
- if (language === "cpp") {
76229
+ if (language === "cpp")
76196
76230
  return [
76197
76231
  `
76198
76232
  class `,
@@ -76222,7 +76256,7 @@ case `,
76222
76256
  " ",
76223
76257
  ""
76224
76258
  ];
76225
- } else if (language === "go") {
76259
+ else if (language === "go")
76226
76260
  return [
76227
76261
  `
76228
76262
  func `,
@@ -76248,7 +76282,7 @@ case `,
76248
76282
  " ",
76249
76283
  ""
76250
76284
  ];
76251
- } else if (language === "java") {
76285
+ else if (language === "java")
76252
76286
  return [
76253
76287
  `
76254
76288
  class `,
@@ -76278,7 +76312,7 @@ case `,
76278
76312
  " ",
76279
76313
  ""
76280
76314
  ];
76281
- } else if (language === "js") {
76315
+ else if (language === "js")
76282
76316
  return [
76283
76317
  `
76284
76318
  function `,
@@ -76310,7 +76344,7 @@ default `,
76310
76344
  " ",
76311
76345
  ""
76312
76346
  ];
76313
- } else if (language === "php") {
76347
+ else if (language === "php")
76314
76348
  return [
76315
76349
  `
76316
76350
  function `,
@@ -76336,7 +76370,7 @@ case `,
76336
76370
  " ",
76337
76371
  ""
76338
76372
  ];
76339
- } else if (language === "proto") {
76373
+ else if (language === "proto")
76340
76374
  return [
76341
76375
  `
76342
76376
  message `,
@@ -76358,7 +76392,7 @@ syntax `,
76358
76392
  " ",
76359
76393
  ""
76360
76394
  ];
76361
- } else if (language === "python") {
76395
+ else if (language === "python")
76362
76396
  return [
76363
76397
  `
76364
76398
  class `,
@@ -76374,7 +76408,7 @@ def `,
76374
76408
  " ",
76375
76409
  ""
76376
76410
  ];
76377
- } else if (language === "rst") {
76411
+ else if (language === "rst")
76378
76412
  return [
76379
76413
  `
76380
76414
  ===
@@ -76395,7 +76429,7 @@ def `,
76395
76429
  " ",
76396
76430
  ""
76397
76431
  ];
76398
- } else if (language === "ruby") {
76432
+ else if (language === "ruby")
76399
76433
  return [
76400
76434
  `
76401
76435
  def `,
@@ -76423,7 +76457,7 @@ rescue `,
76423
76457
  " ",
76424
76458
  ""
76425
76459
  ];
76426
- } else if (language === "rust") {
76460
+ else if (language === "rust")
76427
76461
  return [
76428
76462
  `
76429
76463
  fn `,
@@ -76451,7 +76485,7 @@ const `,
76451
76485
  " ",
76452
76486
  ""
76453
76487
  ];
76454
- } else if (language === "scala") {
76488
+ else if (language === "scala")
76455
76489
  return [
76456
76490
  `
76457
76491
  class `,
@@ -76481,7 +76515,7 @@ case `,
76481
76515
  " ",
76482
76516
  ""
76483
76517
  ];
76484
- } else if (language === "swift") {
76518
+ else if (language === "swift")
76485
76519
  return [
76486
76520
  `
76487
76521
  func `,
@@ -76511,7 +76545,7 @@ case `,
76511
76545
  " ",
76512
76546
  ""
76513
76547
  ];
76514
- } else if (language === "markdown") {
76548
+ else if (language === "markdown")
76515
76549
  return [
76516
76550
  `
76517
76551
  ## `,
@@ -76547,7 +76581,7 @@ ___
76547
76581
  " ",
76548
76582
  ""
76549
76583
  ];
76550
- } else if (language === "latex") {
76584
+ else if (language === "latex")
76551
76585
  return [
76552
76586
  `
76553
76587
  \\chapter{`,
@@ -76585,7 +76619,7 @@ ___
76585
76619
  " ",
76586
76620
  ""
76587
76621
  ];
76588
- } else if (language === "html") {
76622
+ else if (language === "html")
76589
76623
  return [
76590
76624
  "<body>",
76591
76625
  "<div>",
@@ -76616,7 +76650,7 @@ ___
76616
76650
  " ",
76617
76651
  ""
76618
76652
  ];
76619
- } else if (language === "sol") {
76653
+ else if (language === "sol")
76620
76654
  return [
76621
76655
  `
76622
76656
  pragma `,
@@ -76662,11 +76696,11 @@ assembly `,
76662
76696
  " ",
76663
76697
  ""
76664
76698
  ];
76665
- } else {
76699
+ else
76666
76700
  throw new Error(`Language ${language} is not supported.`);
76667
- }
76668
76701
  }
76669
- }
76702
+ };
76703
+
76670
76704
  // src/functions/recursiveCharacterTextSplitter.ts
76671
76705
  async function recursiveCharacterTextSplitter(text, options3 = { chunkSize: 200, chunkOverlap: 60 }) {
76672
76706
  let textToSplit;
@@ -76931,4 +76965,4 @@ function trutoJsonata(expression) {
76931
76965
  return registerJsonataExtensions(import_jsonata.default(expression));
76932
76966
  }
76933
76967
 
76934
- //# debugId=650A0F5DE8EB77ED64756E2164756E21
76968
+ //# debugId=D25F93F30C06ABA764756E2164756E21