@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.
package/README.md CHANGED
@@ -15,7 +15,7 @@
15
15
 
16
16
  <p align="center">
17
17
  <a href="https://truto.one" target="_blank" rel="noopener noreferrer">Website</a> •
18
- <a href="https://docs.truto.one "target="_blank" rel="noopener noreferrer">Docs</a>
18
+ <a href="https://truto.one/docs" target="_blank" rel="noopener noreferrer">Docs</a>
19
19
  </p>
20
20
 
21
21
  ---
@@ -35020,8 +35020,23 @@ var require_formats = __commonJS((exports, module) => {
35020
35020
  // node_modules/qs/lib/utils.js
35021
35021
  var require_utils2 = __commonJS((exports, module) => {
35022
35022
  var formats = require_formats();
35023
+ var getSideChannel = require_side_channel();
35023
35024
  var has2 = Object.prototype.hasOwnProperty;
35024
35025
  var isArray4 = Array.isArray;
35026
+ var overflowChannel = getSideChannel();
35027
+ var markOverflow = function markOverflow(obj, maxIndex) {
35028
+ overflowChannel.set(obj, maxIndex);
35029
+ return obj;
35030
+ };
35031
+ var isOverflow = function isOverflow(obj) {
35032
+ return overflowChannel.has(obj);
35033
+ };
35034
+ var getMaxIndex = function getMaxIndex(obj) {
35035
+ return overflowChannel.get(obj);
35036
+ };
35037
+ var setMaxIndex = function setMaxIndex(obj, maxIndex) {
35038
+ overflowChannel.set(obj, maxIndex);
35039
+ };
35025
35040
  var hexTable = function() {
35026
35041
  var array = [];
35027
35042
  for (var i2 = 0;i2 < 256; ++i2) {
@@ -35061,7 +35076,11 @@ var require_utils2 = __commonJS((exports, module) => {
35061
35076
  if (isArray4(target)) {
35062
35077
  target.push(source);
35063
35078
  } else if (target && typeof target === "object") {
35064
- if (options3 && (options3.plainObjects || options3.allowPrototypes) || !has2.call(Object.prototype, source)) {
35079
+ if (isOverflow(target)) {
35080
+ var newIndex = getMaxIndex(target) + 1;
35081
+ target[newIndex] = source;
35082
+ setMaxIndex(target, newIndex);
35083
+ } else if (options3 && (options3.plainObjects || options3.allowPrototypes) || !has2.call(Object.prototype, source)) {
35065
35084
  target[source] = true;
35066
35085
  }
35067
35086
  } else {
@@ -35070,6 +35089,15 @@ var require_utils2 = __commonJS((exports, module) => {
35070
35089
  return target;
35071
35090
  }
35072
35091
  if (!target || typeof target !== "object") {
35092
+ if (isOverflow(source)) {
35093
+ var sourceKeys = Object.keys(source);
35094
+ var result = options3 && options3.plainObjects ? { __proto__: null, 0: target } : { 0: target };
35095
+ for (var m = 0;m < sourceKeys.length; m++) {
35096
+ var oldKey = parseInt(sourceKeys[m], 10);
35097
+ result[oldKey + 1] = source[sourceKeys[m]];
35098
+ }
35099
+ return markOverflow(result, getMaxIndex(source) + 1);
35100
+ }
35073
35101
  return [target].concat(source);
35074
35102
  }
35075
35103
  var mergeTarget = target;
@@ -35192,8 +35220,18 @@ var require_utils2 = __commonJS((exports, module) => {
35192
35220
  }
35193
35221
  return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
35194
35222
  };
35195
- var combine = function combine(a, b) {
35196
- return [].concat(a, b);
35223
+ var combine = function combine(a, b, arrayLimit, plainObjects) {
35224
+ if (isOverflow(a)) {
35225
+ var newIndex = getMaxIndex(a) + 1;
35226
+ a[newIndex] = b;
35227
+ setMaxIndex(a, newIndex);
35228
+ return a;
35229
+ }
35230
+ var result = [].concat(a, b);
35231
+ if (result.length > arrayLimit) {
35232
+ return markOverflow(arrayToObject(result, { plainObjects }), result.length - 1);
35233
+ }
35234
+ return result;
35197
35235
  };
35198
35236
  var maybeMap = function maybeMap(val, fn) {
35199
35237
  if (isArray4(val)) {
@@ -35213,6 +35251,7 @@ var require_utils2 = __commonJS((exports, module) => {
35213
35251
  decode,
35214
35252
  encode,
35215
35253
  isBuffer: isBuffer3,
35254
+ isOverflow,
35216
35255
  isRegExp: isRegExp3,
35217
35256
  maybeMap,
35218
35257
  merge
@@ -35543,9 +35582,11 @@ var require_parse = __commonJS((exports, module) => {
35543
35582
  val = options3.strictNullHandling ? null : "";
35544
35583
  } else {
35545
35584
  key = options3.decoder(part.slice(0, pos), defaults.decoder, charset2, "key");
35546
- val = utils.maybeMap(parseArrayValue(part.slice(pos + 1), options3, isArray4(obj[key]) ? obj[key].length : 0), function(encodedVal) {
35547
- return options3.decoder(encodedVal, defaults.decoder, charset2, "value");
35548
- });
35585
+ if (key !== null) {
35586
+ val = utils.maybeMap(parseArrayValue(part.slice(pos + 1), options3, isArray4(obj[key]) ? obj[key].length : 0), function(encodedVal) {
35587
+ return options3.decoder(encodedVal, defaults.decoder, charset2, "value");
35588
+ });
35589
+ }
35549
35590
  }
35550
35591
  if (val && options3.interpretNumericEntities && charset2 === "iso-8859-1") {
35551
35592
  val = interpretNumericEntities(String(val));
@@ -35553,11 +35594,13 @@ var require_parse = __commonJS((exports, module) => {
35553
35594
  if (part.indexOf("[]=") > -1) {
35554
35595
  val = isArray4(val) ? [val] : val;
35555
35596
  }
35556
- var existing = has2.call(obj, key);
35557
- if (existing && options3.duplicates === "combine") {
35558
- obj[key] = utils.combine(obj[key], val);
35559
- } else if (!existing || options3.duplicates === "last") {
35560
- obj[key] = val;
35597
+ if (key !== null) {
35598
+ var existing = has2.call(obj, key);
35599
+ if (existing && options3.duplicates === "combine") {
35600
+ obj[key] = utils.combine(obj[key], val, options3.arrayLimit, options3.plainObjects);
35601
+ } else if (!existing || options3.duplicates === "last") {
35602
+ obj[key] = val;
35603
+ }
35561
35604
  }
35562
35605
  }
35563
35606
  return obj;
@@ -35573,7 +35616,11 @@ var require_parse = __commonJS((exports, module) => {
35573
35616
  var obj;
35574
35617
  var root3 = chain[i2];
35575
35618
  if (root3 === "[]" && options3.parseArrays) {
35576
- obj = options3.allowEmptyArrays && (leaf === "" || options3.strictNullHandling && leaf === null) ? [] : utils.combine([], leaf);
35619
+ if (utils.isOverflow(leaf)) {
35620
+ obj = leaf;
35621
+ } else {
35622
+ obj = options3.allowEmptyArrays && (leaf === "" || options3.strictNullHandling && leaf === null) ? [] : utils.combine([], leaf, options3.arrayLimit, options3.plainObjects);
35623
+ }
35577
35624
  } else {
35578
35625
  obj = options3.plainObjects ? { __proto__: null } : {};
35579
35626
  var cleanRoot = root3.charAt(0) === "[" && root3.charAt(root3.length - 1) === "]" ? root3.slice(1, -1) : root3;
@@ -35592,14 +35639,19 @@ var require_parse = __commonJS((exports, module) => {
35592
35639
  }
35593
35640
  return leaf;
35594
35641
  };
35595
- var parseKeys = function parseQueryStringKeys(givenKey, val, options3, valuesParsed) {
35596
- if (!givenKey) {
35597
- return;
35598
- }
35642
+ var splitKeyIntoSegments = function splitKeyIntoSegments(givenKey, options3) {
35599
35643
  var key = options3.allowDots ? givenKey.replace(/\.([^.[]+)/g, "[$1]") : givenKey;
35644
+ if (options3.depth <= 0) {
35645
+ if (!options3.plainObjects && has2.call(Object.prototype, key)) {
35646
+ if (!options3.allowPrototypes) {
35647
+ return;
35648
+ }
35649
+ }
35650
+ return [key];
35651
+ }
35600
35652
  var brackets = /(\[[^[\]]*])/;
35601
35653
  var child = /(\[[^[\]]*])/g;
35602
- var segment = options3.depth > 0 && brackets.exec(key);
35654
+ var segment = brackets.exec(key);
35603
35655
  var parent2 = segment ? key.slice(0, segment.index) : key;
35604
35656
  var keys2 = [];
35605
35657
  if (parent2) {
@@ -35611,9 +35663,10 @@ var require_parse = __commonJS((exports, module) => {
35611
35663
  keys2.push(parent2);
35612
35664
  }
35613
35665
  var i2 = 0;
35614
- while (options3.depth > 0 && (segment = child.exec(key)) !== null && i2 < options3.depth) {
35666
+ while ((segment = child.exec(key)) !== null && i2 < options3.depth) {
35615
35667
  i2 += 1;
35616
- if (!options3.plainObjects && has2.call(Object.prototype, segment[1].slice(1, -1))) {
35668
+ var segmentContent = segment[1].slice(1, -1);
35669
+ if (!options3.plainObjects && has2.call(Object.prototype, segmentContent)) {
35617
35670
  if (!options3.allowPrototypes) {
35618
35671
  return;
35619
35672
  }
@@ -35626,6 +35679,16 @@ var require_parse = __commonJS((exports, module) => {
35626
35679
  }
35627
35680
  keys2.push("[" + key.slice(segment.index) + "]");
35628
35681
  }
35682
+ return keys2;
35683
+ };
35684
+ var parseKeys = function parseQueryStringKeys(givenKey, val, options3, valuesParsed) {
35685
+ if (!givenKey) {
35686
+ return;
35687
+ }
35688
+ var keys2 = splitKeyIntoSegments(givenKey, options3);
35689
+ if (!keys2) {
35690
+ return;
35691
+ }
35629
35692
  return parseObject(keys2, val, options3, valuesParsed);
35630
35693
  };
35631
35694
  var normalizeParseOptions = function normalizeParseOptions(opts) {
@@ -75926,62 +75989,38 @@ async function encodingForModel(model) {
75926
75989
  }
75927
75990
 
75928
75991
  // node_modules/@langchain/textsplitters/dist/text_splitter.js
75929
- class TextSplitter extends BaseDocumentTransformer {
75992
+ var TextSplitter = class extends BaseDocumentTransformer {
75993
+ lc_namespace = [
75994
+ "langchain",
75995
+ "document_transformers",
75996
+ "text_splitters"
75997
+ ];
75998
+ chunkSize = 1000;
75999
+ chunkOverlap = 200;
76000
+ keepSeparator = false;
76001
+ lengthFunction;
75930
76002
  constructor(fields) {
75931
76003
  super(fields);
75932
- Object.defineProperty(this, "lc_namespace", {
75933
- enumerable: true,
75934
- configurable: true,
75935
- writable: true,
75936
- value: ["langchain", "document_transformers", "text_splitters"]
75937
- });
75938
- Object.defineProperty(this, "chunkSize", {
75939
- enumerable: true,
75940
- configurable: true,
75941
- writable: true,
75942
- value: 1000
75943
- });
75944
- Object.defineProperty(this, "chunkOverlap", {
75945
- enumerable: true,
75946
- configurable: true,
75947
- writable: true,
75948
- value: 200
75949
- });
75950
- Object.defineProperty(this, "keepSeparator", {
75951
- enumerable: true,
75952
- configurable: true,
75953
- writable: true,
75954
- value: false
75955
- });
75956
- Object.defineProperty(this, "lengthFunction", {
75957
- enumerable: true,
75958
- configurable: true,
75959
- writable: true,
75960
- value: undefined
75961
- });
75962
76004
  this.chunkSize = fields?.chunkSize ?? this.chunkSize;
75963
76005
  this.chunkOverlap = fields?.chunkOverlap ?? this.chunkOverlap;
75964
76006
  this.keepSeparator = fields?.keepSeparator ?? this.keepSeparator;
75965
76007
  this.lengthFunction = fields?.lengthFunction ?? ((text) => text.length);
75966
- if (this.chunkOverlap >= this.chunkSize) {
76008
+ if (this.chunkOverlap >= this.chunkSize)
75967
76009
  throw new Error("Cannot have chunkOverlap >= chunkSize");
75968
- }
75969
76010
  }
75970
76011
  async transformDocuments(documents, chunkHeaderOptions = {}) {
75971
76012
  return this.splitDocuments(documents, chunkHeaderOptions);
75972
76013
  }
75973
76014
  splitOnSeparator(text, separator) {
75974
76015
  let splits;
75975
- if (separator) {
76016
+ if (separator)
75976
76017
  if (this.keepSeparator) {
75977
76018
  const regexEscapedSeparator = separator.replace(/[/\-\\^$*+?.()|[\]{}]/g, "\\$&");
75978
- splits = text.split(new RegExp(`(?=${regexEscapedSeparator})`));
75979
- } else {
76019
+ splits = text.split(/* @__PURE__ */ new RegExp(`(?=${regexEscapedSeparator})`));
76020
+ } else
75980
76021
  splits = text.split(separator);
75981
- }
75982
- } else {
76022
+ else
75983
76023
  splits = text.split("");
75984
- }
75985
76024
  return splits.filter((s2) => s2 !== "");
75986
76025
  }
75987
76026
  async createDocuments(texts, metadatas = [], chunkHeaderOptions = {}) {
@@ -76008,9 +76047,8 @@ class TextSplitter extends BaseDocumentTransformer {
76008
76047
  const numberOfIntermediateNewLines = this.numberOfNewLines(text, indexChunk, indexEndPrevChunk);
76009
76048
  lineCounterIndex -= numberOfIntermediateNewLines;
76010
76049
  }
76011
- if (appendChunkOverlapHeader) {
76050
+ if (appendChunkOverlapHeader)
76012
76051
  pageContent += chunkOverlapHeader;
76013
- }
76014
76052
  }
76015
76053
  const newLinesCount = this.numberOfNewLines(chunk2);
76016
76054
  const loc = _metadatas[i3].loc && typeof _metadatas[i3].loc === "object" ? { ..._metadatas[i3].loc } : {};
@@ -76055,15 +76093,13 @@ class TextSplitter extends BaseDocumentTransformer {
76055
76093
  for (const d of splits) {
76056
76094
  const _len = await this.lengthFunction(d);
76057
76095
  if (total + _len + currentDoc.length * separator.length > this.chunkSize) {
76058
- if (total > this.chunkSize) {
76096
+ if (total > this.chunkSize)
76059
76097
  console.warn(`Created a chunk of size ${total}, +
76060
76098
  which is longer than the specified ${this.chunkSize}`);
76061
- }
76062
76099
  if (currentDoc.length > 0) {
76063
- const doc3 = this.joinDocs(currentDoc, separator);
76064
- if (doc3 !== null) {
76065
- docs.push(doc3);
76066
- }
76100
+ const doc$1 = this.joinDocs(currentDoc, separator);
76101
+ if (doc$1 !== null)
76102
+ docs.push(doc$1);
76067
76103
  while (total > this.chunkOverlap || total + _len + currentDoc.length * separator.length > this.chunkSize && total > 0) {
76068
76104
  total -= await this.lengthFunction(currentDoc[0]);
76069
76105
  currentDoc.shift();
@@ -76074,27 +76110,26 @@ which is longer than the specified ${this.chunkSize}`);
76074
76110
  total += _len;
76075
76111
  }
76076
76112
  const doc2 = this.joinDocs(currentDoc, separator);
76077
- if (doc2 !== null) {
76113
+ if (doc2 !== null)
76078
76114
  docs.push(doc2);
76079
- }
76080
76115
  return docs;
76081
76116
  }
76082
- }
76083
- class RecursiveCharacterTextSplitter extends TextSplitter {
76117
+ };
76118
+ var RecursiveCharacterTextSplitter = class RecursiveCharacterTextSplitter2 extends TextSplitter {
76084
76119
  static lc_name() {
76085
76120
  return "RecursiveCharacterTextSplitter";
76086
76121
  }
76122
+ separators = [
76123
+ `
76124
+
76125
+ `,
76126
+ `
76127
+ `,
76128
+ " ",
76129
+ ""
76130
+ ];
76087
76131
  constructor(fields) {
76088
76132
  super(fields);
76089
- Object.defineProperty(this, "separators", {
76090
- enumerable: true,
76091
- configurable: true,
76092
- writable: true,
76093
- value: [`
76094
-
76095
- `, `
76096
- `, " ", ""]
76097
- });
76098
76133
  this.separators = fields?.separators ?? this.separators;
76099
76134
  this.keepSeparator = fields?.keepSeparator ?? true;
76100
76135
  }
@@ -76117,23 +76152,22 @@ class RecursiveCharacterTextSplitter extends TextSplitter {
76117
76152
  const splits = this.splitOnSeparator(text, separator);
76118
76153
  let goodSplits = [];
76119
76154
  const _separator = this.keepSeparator ? "" : separator;
76120
- for (const s2 of splits) {
76121
- if (await this.lengthFunction(s2) < this.chunkSize) {
76155
+ for (const s2 of splits)
76156
+ if (await this.lengthFunction(s2) < this.chunkSize)
76122
76157
  goodSplits.push(s2);
76123
- } else {
76158
+ else {
76124
76159
  if (goodSplits.length) {
76125
76160
  const mergedText = await this.mergeSplits(goodSplits, _separator);
76126
76161
  finalChunks.push(...mergedText);
76127
76162
  goodSplits = [];
76128
76163
  }
76129
- if (!newSeparators) {
76164
+ if (!newSeparators)
76130
76165
  finalChunks.push(s2);
76131
- } else {
76166
+ else {
76132
76167
  const otherInfo = await this._splitText(s2, newSeparators);
76133
76168
  finalChunks.push(...otherInfo);
76134
76169
  }
76135
76170
  }
76136
- }
76137
76171
  if (goodSplits.length) {
76138
76172
  const mergedText = await this.mergeSplits(goodSplits, _separator);
76139
76173
  finalChunks.push(...mergedText);
@@ -76144,13 +76178,13 @@ class RecursiveCharacterTextSplitter extends TextSplitter {
76144
76178
  return this._splitText(text, this.separators);
76145
76179
  }
76146
76180
  static fromLanguage(language, options3) {
76147
- return new RecursiveCharacterTextSplitter({
76181
+ return new RecursiveCharacterTextSplitter2({
76148
76182
  ...options3,
76149
- separators: RecursiveCharacterTextSplitter.getSeparatorsForLanguage(language)
76183
+ separators: RecursiveCharacterTextSplitter2.getSeparatorsForLanguage(language)
76150
76184
  });
76151
76185
  }
76152
76186
  static getSeparatorsForLanguage(language) {
76153
- if (language === "cpp") {
76187
+ if (language === "cpp")
76154
76188
  return [
76155
76189
  `
76156
76190
  class `,
@@ -76180,7 +76214,7 @@ case `,
76180
76214
  " ",
76181
76215
  ""
76182
76216
  ];
76183
- } else if (language === "go") {
76217
+ else if (language === "go")
76184
76218
  return [
76185
76219
  `
76186
76220
  func `,
@@ -76206,7 +76240,7 @@ case `,
76206
76240
  " ",
76207
76241
  ""
76208
76242
  ];
76209
- } else if (language === "java") {
76243
+ else if (language === "java")
76210
76244
  return [
76211
76245
  `
76212
76246
  class `,
@@ -76236,7 +76270,7 @@ case `,
76236
76270
  " ",
76237
76271
  ""
76238
76272
  ];
76239
- } else if (language === "js") {
76273
+ else if (language === "js")
76240
76274
  return [
76241
76275
  `
76242
76276
  function `,
@@ -76268,7 +76302,7 @@ default `,
76268
76302
  " ",
76269
76303
  ""
76270
76304
  ];
76271
- } else if (language === "php") {
76305
+ else if (language === "php")
76272
76306
  return [
76273
76307
  `
76274
76308
  function `,
@@ -76294,7 +76328,7 @@ case `,
76294
76328
  " ",
76295
76329
  ""
76296
76330
  ];
76297
- } else if (language === "proto") {
76331
+ else if (language === "proto")
76298
76332
  return [
76299
76333
  `
76300
76334
  message `,
@@ -76316,7 +76350,7 @@ syntax `,
76316
76350
  " ",
76317
76351
  ""
76318
76352
  ];
76319
- } else if (language === "python") {
76353
+ else if (language === "python")
76320
76354
  return [
76321
76355
  `
76322
76356
  class `,
@@ -76332,7 +76366,7 @@ def `,
76332
76366
  " ",
76333
76367
  ""
76334
76368
  ];
76335
- } else if (language === "rst") {
76369
+ else if (language === "rst")
76336
76370
  return [
76337
76371
  `
76338
76372
  ===
@@ -76353,7 +76387,7 @@ def `,
76353
76387
  " ",
76354
76388
  ""
76355
76389
  ];
76356
- } else if (language === "ruby") {
76390
+ else if (language === "ruby")
76357
76391
  return [
76358
76392
  `
76359
76393
  def `,
@@ -76381,7 +76415,7 @@ rescue `,
76381
76415
  " ",
76382
76416
  ""
76383
76417
  ];
76384
- } else if (language === "rust") {
76418
+ else if (language === "rust")
76385
76419
  return [
76386
76420
  `
76387
76421
  fn `,
@@ -76409,7 +76443,7 @@ const `,
76409
76443
  " ",
76410
76444
  ""
76411
76445
  ];
76412
- } else if (language === "scala") {
76446
+ else if (language === "scala")
76413
76447
  return [
76414
76448
  `
76415
76449
  class `,
@@ -76439,7 +76473,7 @@ case `,
76439
76473
  " ",
76440
76474
  ""
76441
76475
  ];
76442
- } else if (language === "swift") {
76476
+ else if (language === "swift")
76443
76477
  return [
76444
76478
  `
76445
76479
  func `,
@@ -76469,7 +76503,7 @@ case `,
76469
76503
  " ",
76470
76504
  ""
76471
76505
  ];
76472
- } else if (language === "markdown") {
76506
+ else if (language === "markdown")
76473
76507
  return [
76474
76508
  `
76475
76509
  ## `,
@@ -76505,7 +76539,7 @@ ___
76505
76539
  " ",
76506
76540
  ""
76507
76541
  ];
76508
- } else if (language === "latex") {
76542
+ else if (language === "latex")
76509
76543
  return [
76510
76544
  `
76511
76545
  \\chapter{`,
@@ -76543,7 +76577,7 @@ ___
76543
76577
  " ",
76544
76578
  ""
76545
76579
  ];
76546
- } else if (language === "html") {
76580
+ else if (language === "html")
76547
76581
  return [
76548
76582
  "<body>",
76549
76583
  "<div>",
@@ -76574,7 +76608,7 @@ ___
76574
76608
  " ",
76575
76609
  ""
76576
76610
  ];
76577
- } else if (language === "sol") {
76611
+ else if (language === "sol")
76578
76612
  return [
76579
76613
  `
76580
76614
  pragma `,
@@ -76620,11 +76654,11 @@ assembly `,
76620
76654
  " ",
76621
76655
  ""
76622
76656
  ];
76623
- } else {
76657
+ else
76624
76658
  throw new Error(`Language ${language} is not supported.`);
76625
- }
76626
76659
  }
76627
- }
76660
+ };
76661
+
76628
76662
  // src/functions/recursiveCharacterTextSplitter.ts
76629
76663
  async function recursiveCharacterTextSplitter(text, options3 = { chunkSize: 200, chunkOverlap: 60 }) {
76630
76664
  let textToSplit;
@@ -76892,4 +76926,4 @@ export {
76892
76926
  trutoJsonata as default
76893
76927
  };
76894
76928
 
76895
- //# debugId=6DD9A5186EEBCF8964756E2164756E21
76929
+ //# debugId=C7EDD6D99293C92E64756E2164756E21