@port-labs/jq-node-bindings 0.0.13 → 0.0.15-dev1

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.
Files changed (453) hide show
  1. package/README.md +6 -1
  2. package/binding.gyp +41 -19
  3. package/configure +1 -1
  4. package/deps/jq/.gitattributes +12 -0
  5. package/deps/jq/AUTHORS +149 -43
  6. package/deps/jq/COPYING +75 -1
  7. package/deps/jq/ChangeLog +2 -2
  8. package/deps/jq/Makefile.am +106 -65
  9. package/deps/jq/NEWS.md +391 -0
  10. package/deps/jq/README.md +54 -52
  11. package/deps/jq/SECURITY.md +7 -0
  12. package/deps/jq/compile-ios.sh +106 -102
  13. package/deps/jq/configure.ac +72 -59
  14. package/deps/jq/docs/Pipfile +14 -0
  15. package/deps/jq/docs/Pipfile.lock +415 -0
  16. package/deps/jq/docs/README.md +15 -14
  17. package/deps/jq/docs/build_manpage.py +251 -0
  18. package/deps/jq/docs/build_mantests.py +21 -0
  19. package/deps/jq/docs/build_website.py +95 -0
  20. package/deps/jq/docs/content/download/default.yml +249 -0
  21. package/deps/jq/docs/content/index.yml +83 -0
  22. package/deps/jq/docs/content/{3.manual/v1.6 → manual/dev}/manual.yml +992 -452
  23. package/deps/jq/docs/content/{3.manual → manual}/v1.3/manual.yml +105 -116
  24. package/deps/jq/docs/content/{3.manual → manual}/v1.4/manual.yml +122 -129
  25. package/deps/jq/docs/content/{3.manual → manual}/v1.5/manual.yml +313 -262
  26. package/deps/jq/docs/content/{3.manual → manual/v1.6}/manual.yml +407 -332
  27. package/deps/jq/docs/content/manual/v1.7/manual.yml +3697 -0
  28. package/deps/jq/docs/content/tutorial/default.yml +337 -0
  29. package/deps/jq/docs/manual_schema.yml +60 -0
  30. package/deps/jq/docs/public/css/style.css +99 -0
  31. package/deps/jq/docs/public/icon.png +0 -0
  32. package/deps/jq/docs/public/icon.svg +1 -0
  33. package/deps/jq/docs/public/jq.svg +1 -0
  34. package/deps/jq/docs/public/js/manual-search.js +31 -49
  35. package/deps/jq/docs/templates/default.html.j2 +31 -0
  36. package/deps/jq/docs/templates/index.html.j2 +58 -0
  37. package/deps/jq/docs/templates/manual.html.j2 +120 -0
  38. package/deps/jq/docs/templates/shared/_footer.html.j2 +14 -0
  39. package/deps/jq/docs/templates/shared/_head.html.j2 +23 -0
  40. package/deps/jq/docs/templates/shared/_navbar.html.j2 +40 -0
  41. package/deps/jq/docs/validate_manual_schema.py +19 -0
  42. package/deps/jq/jq.1.prebuilt +1102 -294
  43. package/deps/jq/jq.spec +2 -3
  44. package/deps/jq/libjq.pc.in +11 -0
  45. package/deps/jq/m4/ax_pthread.m4 +522 -0
  46. package/deps/jq/modules/oniguruma/.travis.yml +17 -0
  47. package/deps/jq/modules/oniguruma/CMakeLists.txt +206 -41
  48. package/deps/jq/modules/oniguruma/COPYING +23 -25
  49. package/deps/jq/modules/oniguruma/HISTORY +368 -23
  50. package/deps/jq/modules/oniguruma/Makefile.am +61 -7
  51. package/deps/jq/modules/oniguruma/README +34 -20
  52. package/deps/jq/modules/oniguruma/README.md +106 -33
  53. package/deps/jq/modules/oniguruma/README_japanese +183 -0
  54. package/deps/jq/modules/oniguruma/autogen.sh +9 -0
  55. package/deps/jq/modules/oniguruma/cmake/Config.cmake.in +4 -0
  56. package/deps/jq/modules/oniguruma/configure.ac +66 -55
  57. package/deps/jq/modules/oniguruma/doc/API +485 -42
  58. package/deps/jq/modules/oniguruma/doc/API.ja +732 -293
  59. package/deps/jq/modules/oniguruma/doc/CALLOUTS.API +397 -0
  60. package/deps/jq/modules/oniguruma/doc/CALLOUTS.API.ja +393 -0
  61. package/deps/jq/modules/oniguruma/doc/CALLOUTS.BUILTIN +95 -0
  62. package/deps/jq/modules/oniguruma/doc/CALLOUTS.BUILTIN.ja +93 -0
  63. package/deps/jq/modules/oniguruma/doc/FAQ +3 -3
  64. package/deps/jq/modules/oniguruma/doc/FAQ.ja +8 -8
  65. package/deps/jq/modules/oniguruma/doc/RE +223 -63
  66. package/deps/jq/modules/oniguruma/doc/RE.ja +420 -265
  67. package/deps/jq/modules/oniguruma/doc/SYNTAX.md +1091 -0
  68. package/deps/jq/modules/oniguruma/doc/UNICODE_PROPERTIES +840 -697
  69. package/deps/jq/modules/oniguruma/harnesses/ascii_compatible.dict +113 -0
  70. package/deps/jq/modules/oniguruma/harnesses/base.c +749 -0
  71. package/deps/jq/modules/oniguruma/harnesses/deluxe.c +206 -0
  72. package/deps/jq/modules/oniguruma/harnesses/dict_conv.py +72 -0
  73. package/deps/jq/modules/oniguruma/harnesses/fuzzer.options +2 -0
  74. package/deps/jq/modules/oniguruma/harnesses/libfuzzer-onig.cpp +45 -0
  75. package/deps/jq/modules/oniguruma/harnesses/regset.c +392 -0
  76. package/deps/jq/modules/oniguruma/index.html +16 -5
  77. package/deps/jq/modules/oniguruma/index_ja.html +16 -5
  78. package/deps/jq/modules/oniguruma/make_win.bat +5 -0
  79. package/deps/jq/modules/oniguruma/make_win32.bat +5 -3
  80. package/deps/jq/modules/oniguruma/make_win64.bat +5 -3
  81. package/deps/jq/modules/oniguruma/onig-config.cmake.in +80 -0
  82. package/deps/jq/modules/oniguruma/onig-config.in +1 -1
  83. package/deps/jq/modules/oniguruma/oniguruma.pc.cmake.in +1 -1
  84. package/deps/jq/modules/oniguruma/oniguruma.pc.in +0 -1
  85. package/deps/jq/modules/oniguruma/sample/CMakeLists.txt +9 -2
  86. package/deps/jq/modules/oniguruma/sample/Makefile.am +24 -5
  87. package/deps/jq/modules/oniguruma/sample/bug_fix.c +13 -51
  88. package/deps/jq/modules/oniguruma/sample/callback_each_match.c +168 -0
  89. package/deps/jq/modules/oniguruma/sample/callout.c +268 -0
  90. package/deps/jq/modules/oniguruma/sample/count.c +125 -0
  91. package/deps/jq/modules/oniguruma/sample/crnl.c +6 -4
  92. package/deps/jq/modules/oniguruma/sample/echo.c +136 -0
  93. package/deps/jq/modules/oniguruma/sample/encode.c +53 -146
  94. package/deps/jq/modules/oniguruma/sample/listcap.c +18 -10
  95. package/deps/jq/modules/oniguruma/sample/names.c +10 -6
  96. package/deps/jq/modules/oniguruma/sample/posix.c +13 -2
  97. package/deps/jq/modules/oniguruma/sample/regset.c +95 -0
  98. package/deps/jq/modules/oniguruma/sample/scan.c +20 -6
  99. package/deps/jq/modules/oniguruma/sample/simple.c +8 -4
  100. package/deps/jq/modules/oniguruma/sample/sql.c +13 -8
  101. package/deps/jq/modules/oniguruma/sample/syntax.c +11 -10
  102. package/deps/jq/modules/oniguruma/sample/user_property.c +12 -7
  103. package/deps/jq/modules/oniguruma/src/Makefile.am +41 -15
  104. package/deps/jq/modules/oniguruma/src/Makefile.windows +196 -183
  105. package/deps/jq/modules/oniguruma/src/ascii.c +64 -7
  106. package/deps/jq/modules/oniguruma/src/big5.c +25 -15
  107. package/deps/jq/modules/oniguruma/src/config.h.cmake.in +7 -22
  108. package/deps/jq/modules/oniguruma/src/config.h.win32 +56 -84
  109. package/deps/jq/modules/oniguruma/src/config.h.win64 +56 -84
  110. package/deps/jq/modules/oniguruma/src/config.h.windows.in +62 -0
  111. package/deps/jq/modules/oniguruma/src/cp1251.c +14 -8
  112. package/deps/jq/modules/oniguruma/src/euc_jp.c +28 -30
  113. package/deps/jq/modules/oniguruma/src/euc_jp_prop.c +25 -32
  114. package/deps/jq/modules/oniguruma/src/euc_jp_prop.gperf +1 -2
  115. package/deps/jq/modules/oniguruma/src/euc_kr.c +27 -15
  116. package/deps/jq/modules/oniguruma/src/euc_tw.c +40 -17
  117. package/deps/jq/modules/oniguruma/src/gb18030.c +177 -119
  118. package/deps/jq/modules/oniguruma/src/gperf_fold_key_conv.py +12 -8
  119. package/deps/jq/modules/oniguruma/src/gperf_unfold_key_conv.py +8 -6
  120. package/deps/jq/modules/oniguruma/src/iso8859_1.c +92 -91
  121. package/deps/jq/modules/oniguruma/src/iso8859_10.c +13 -29
  122. package/deps/jq/modules/oniguruma/src/iso8859_11.c +4 -2
  123. package/deps/jq/modules/oniguruma/src/iso8859_13.c +13 -33
  124. package/deps/jq/modules/oniguruma/src/iso8859_14.c +13 -30
  125. package/deps/jq/modules/oniguruma/src/iso8859_15.c +13 -34
  126. package/deps/jq/modules/oniguruma/src/iso8859_16.c +13 -29
  127. package/deps/jq/modules/oniguruma/src/iso8859_2.c +13 -29
  128. package/deps/jq/modules/oniguruma/src/iso8859_3.c +13 -33
  129. package/deps/jq/modules/oniguruma/src/iso8859_4.c +13 -32
  130. package/deps/jq/modules/oniguruma/src/iso8859_5.c +16 -23
  131. package/deps/jq/modules/oniguruma/src/iso8859_6.c +4 -2
  132. package/deps/jq/modules/oniguruma/src/iso8859_7.c +14 -29
  133. package/deps/jq/modules/oniguruma/src/iso8859_8.c +4 -2
  134. package/deps/jq/modules/oniguruma/src/iso8859_9.c +13 -33
  135. package/deps/jq/modules/oniguruma/src/koi8.c +14 -27
  136. package/deps/jq/modules/oniguruma/src/koi8_r.c +12 -19
  137. package/deps/jq/modules/oniguruma/src/make_property.sh +21 -0
  138. package/deps/jq/modules/oniguruma/src/make_unicode_egcb.sh +7 -0
  139. package/deps/jq/modules/oniguruma/src/make_unicode_egcb_data.py +267 -0
  140. package/deps/jq/modules/oniguruma/src/make_unicode_fold.sh +25 -11
  141. package/deps/jq/modules/oniguruma/src/make_unicode_fold_data.py +206 -26
  142. package/deps/jq/modules/oniguruma/src/make_unicode_property.sh +19 -10
  143. package/deps/jq/modules/oniguruma/src/make_unicode_property_data.py +474 -375
  144. package/deps/jq/modules/oniguruma/src/make_unicode_wb.sh +7 -0
  145. package/deps/jq/modules/oniguruma/src/make_unicode_wb_data.py +267 -0
  146. package/deps/jq/modules/oniguruma/src/mktable.c +28 -24
  147. package/deps/jq/modules/oniguruma/src/onig_init.c +2 -2
  148. package/deps/jq/modules/oniguruma/src/oniggnu.h +7 -5
  149. package/deps/jq/modules/oniguruma/src/onigposix.h +40 -16
  150. package/deps/jq/modules/oniguruma/src/oniguruma.h +357 -107
  151. package/deps/jq/modules/oniguruma/src/regcomp.c +6214 -3933
  152. package/deps/jq/modules/oniguruma/src/regenc.c +197 -120
  153. package/deps/jq/modules/oniguruma/src/regenc.h +106 -63
  154. package/deps/jq/modules/oniguruma/src/regerror.c +112 -91
  155. package/deps/jq/modules/oniguruma/src/regexec.c +4876 -2010
  156. package/deps/jq/modules/oniguruma/src/regext.c +8 -8
  157. package/deps/jq/modules/oniguruma/src/reggnu.c +13 -17
  158. package/deps/jq/modules/oniguruma/src/regint.h +757 -491
  159. package/deps/jq/modules/oniguruma/src/regparse.c +7204 -3240
  160. package/deps/jq/modules/oniguruma/src/regparse.h +361 -218
  161. package/deps/jq/modules/oniguruma/src/regposerr.c +49 -9
  162. package/deps/jq/modules/oniguruma/src/regposix.c +106 -24
  163. package/deps/jq/modules/oniguruma/src/regsyntax.c +66 -13
  164. package/deps/jq/modules/oniguruma/src/regtrav.c +1 -1
  165. package/deps/jq/modules/oniguruma/src/regversion.c +6 -4
  166. package/deps/jq/modules/oniguruma/src/sjis.c +23 -52
  167. package/deps/jq/modules/oniguruma/src/sjis_prop.c +25 -32
  168. package/deps/jq/modules/oniguruma/src/sjis_prop.gperf +1 -2
  169. package/deps/jq/modules/oniguruma/src/st.c +248 -249
  170. package/deps/jq/modules/oniguruma/src/st.h +4 -5
  171. package/deps/jq/modules/oniguruma/src/unicode.c +869 -294
  172. package/deps/jq/modules/oniguruma/src/unicode_egcb_data.c +1419 -0
  173. package/deps/jq/modules/oniguruma/src/unicode_fold1_key.c +1829 -1300
  174. package/deps/jq/modules/oniguruma/src/unicode_fold2_key.c +32 -9
  175. package/deps/jq/modules/oniguruma/src/unicode_fold3_key.c +32 -9
  176. package/deps/jq/modules/oniguruma/src/unicode_fold_data.c +1210 -984
  177. package/deps/jq/modules/oniguruma/src/unicode_property_data.c +22480 -15198
  178. package/deps/jq/modules/oniguruma/src/unicode_property_data_posix.c +1463 -591
  179. package/deps/jq/modules/oniguruma/src/unicode_unfold_key.c +1958 -1418
  180. package/deps/jq/modules/oniguruma/src/unicode_wb_data.c +1106 -0
  181. package/deps/jq/modules/oniguruma/src/utf16_be.c +90 -49
  182. package/deps/jq/modules/oniguruma/src/utf16_le.c +80 -49
  183. package/deps/jq/modules/oniguruma/src/utf32_be.c +14 -42
  184. package/deps/jq/modules/oniguruma/src/utf32_le.c +13 -40
  185. package/deps/jq/modules/oniguruma/src/utf8.c +33 -78
  186. package/deps/jq/modules/oniguruma/test/CMakeLists.txt +55 -0
  187. package/deps/jq/modules/oniguruma/test/Makefile.am +65 -10
  188. package/deps/jq/modules/oniguruma/test/test.sh +17 -0
  189. package/deps/jq/modules/oniguruma/test/test_back.c +1450 -0
  190. package/deps/jq/modules/oniguruma/test/test_options.c +228 -0
  191. package/deps/jq/modules/oniguruma/test/test_regset.c +466 -0
  192. package/deps/jq/modules/oniguruma/test/test_syntax.c +365 -0
  193. package/deps/jq/modules/oniguruma/test/test_utf8.c +1761 -0
  194. package/deps/jq/modules/oniguruma/test/testc.c +128 -88
  195. package/deps/jq/modules/oniguruma/test/testp.c +613 -0
  196. package/deps/jq/modules/oniguruma/test/testu.c +75 -28
  197. package/deps/jq/modules/oniguruma/tis-ci/stub.c +3 -0
  198. package/deps/jq/modules/oniguruma/tis-ci/test_back.config +26 -0
  199. package/deps/jq/modules/oniguruma/tis-ci/test_regset.config +20 -0
  200. package/deps/jq/modules/oniguruma/tis-ci/test_syntax.config +26 -0
  201. package/deps/jq/modules/oniguruma/tis-ci/test_utf8.config +25 -0
  202. package/deps/jq/modules/oniguruma/tis-ci/testc.config +26 -0
  203. package/deps/jq/modules/oniguruma/tis-ci/testu.config +24 -0
  204. package/deps/jq/modules/oniguruma/tis.config +1336 -0
  205. package/deps/jq/modules/oniguruma/windows/CMakeLists.txt +8 -0
  206. package/deps/jq/modules/oniguruma/windows/testc.c +865 -869
  207. package/deps/jq/scripts/update-website +6 -5
  208. package/deps/jq/scripts/version +10 -7
  209. package/deps/jq/sig/jq-release-new.key +29 -0
  210. package/deps/jq/sig/v1.4/sha256sum.txt +1 -0
  211. package/deps/jq/sig/v1.5/sha256sum.txt +2 -0
  212. package/deps/jq/sig/v1.5rc1/sha256sum.txt +1 -0
  213. package/deps/jq/sig/v1.5rc2/sha256sum.txt +2 -0
  214. package/deps/jq/sig/v1.6/sha256sum.txt +2 -0
  215. package/deps/jq/sig/v1.7/jq-1.7.tar.gz.asc +16 -0
  216. package/deps/jq/sig/v1.7/jq-1.7.zip.asc +16 -0
  217. package/deps/jq/sig/v1.7/jq-linux-amd64.asc +16 -0
  218. package/deps/jq/sig/v1.7/jq-linux-arm64.asc +16 -0
  219. package/deps/jq/sig/v1.7/jq-linux-armel.asc +16 -0
  220. package/deps/jq/sig/v1.7/jq-linux-armhf.asc +16 -0
  221. package/deps/jq/sig/v1.7/jq-linux-i386.asc +16 -0
  222. package/deps/jq/sig/v1.7/jq-linux-mips.asc +16 -0
  223. package/deps/jq/sig/v1.7/jq-linux-mips64.asc +16 -0
  224. package/deps/jq/sig/v1.7/jq-linux-mips64el.asc +16 -0
  225. package/deps/jq/sig/v1.7/jq-linux-mips64r6.asc +16 -0
  226. package/deps/jq/sig/v1.7/jq-linux-mips64r6el.asc +16 -0
  227. package/deps/jq/sig/v1.7/jq-linux-mipsel.asc +16 -0
  228. package/deps/jq/sig/v1.7/jq-linux-mipsr6.asc +16 -0
  229. package/deps/jq/sig/v1.7/jq-linux-mipsr6el.asc +16 -0
  230. package/deps/jq/sig/v1.7/jq-linux-powerpc.asc +16 -0
  231. package/deps/jq/sig/v1.7/jq-linux-ppc64el.asc +16 -0
  232. package/deps/jq/sig/v1.7/jq-linux-riscv64.asc +16 -0
  233. package/deps/jq/sig/v1.7/jq-linux-s390x.asc +16 -0
  234. package/deps/jq/sig/v1.7/jq-macos-amd64.asc +16 -0
  235. package/deps/jq/sig/v1.7/jq-macos-arm64.asc +16 -0
  236. package/deps/jq/sig/v1.7/jq-windows-amd64.exe.asc +16 -0
  237. package/deps/jq/sig/v1.7/jq-windows-i386.exe.asc +16 -0
  238. package/deps/jq/sig/v1.7/sha256sum.txt +23 -0
  239. package/deps/jq/sig/v1.7.1/jq-1.7.1.tar.gz.asc +16 -0
  240. package/deps/jq/sig/v1.7.1/jq-1.7.1.zip.asc +16 -0
  241. package/deps/jq/sig/v1.7.1/jq-linux-amd64.asc +16 -0
  242. package/deps/jq/sig/v1.7.1/jq-linux-arm64.asc +16 -0
  243. package/deps/jq/sig/v1.7.1/jq-linux-armel.asc +16 -0
  244. package/deps/jq/sig/v1.7.1/jq-linux-armhf.asc +16 -0
  245. package/deps/jq/sig/v1.7.1/jq-linux-i386.asc +16 -0
  246. package/deps/jq/sig/v1.7.1/jq-linux-mips.asc +16 -0
  247. package/deps/jq/sig/v1.7.1/jq-linux-mips64.asc +16 -0
  248. package/deps/jq/sig/v1.7.1/jq-linux-mips64el.asc +16 -0
  249. package/deps/jq/sig/v1.7.1/jq-linux-mips64r6.asc +16 -0
  250. package/deps/jq/sig/v1.7.1/jq-linux-mips64r6el.asc +16 -0
  251. package/deps/jq/sig/v1.7.1/jq-linux-mipsel.asc +16 -0
  252. package/deps/jq/sig/v1.7.1/jq-linux-mipsr6.asc +16 -0
  253. package/deps/jq/sig/v1.7.1/jq-linux-mipsr6el.asc +16 -0
  254. package/deps/jq/sig/v1.7.1/jq-linux-powerpc.asc +16 -0
  255. package/deps/jq/sig/v1.7.1/jq-linux-ppc64el.asc +16 -0
  256. package/deps/jq/sig/v1.7.1/jq-linux-riscv64.asc +16 -0
  257. package/deps/jq/sig/v1.7.1/jq-linux-s390x.asc +16 -0
  258. package/deps/jq/sig/v1.7.1/jq-linux64.asc +16 -0
  259. package/deps/jq/sig/v1.7.1/jq-macos-amd64.asc +16 -0
  260. package/deps/jq/sig/v1.7.1/jq-macos-arm64.asc +16 -0
  261. package/deps/jq/sig/v1.7.1/jq-osx-amd64.asc +16 -0
  262. package/deps/jq/sig/v1.7.1/jq-win64.exe.asc +16 -0
  263. package/deps/jq/sig/v1.7.1/jq-windows-amd64.exe.asc +16 -0
  264. package/deps/jq/sig/v1.7.1/jq-windows-i386.exe.asc +16 -0
  265. package/deps/jq/sig/v1.7.1/sha256sum.txt +26 -0
  266. package/deps/jq/sig/v1.7rc1/jq-1.7rc1.tar.gz.asc +16 -0
  267. package/deps/jq/sig/v1.7rc1/jq-1.7rc1.zip.asc +16 -0
  268. package/deps/jq/sig/v1.7rc1/jq-linux-amd64.asc +16 -0
  269. package/deps/jq/sig/v1.7rc1/jq-linux-arm64.asc +16 -0
  270. package/deps/jq/sig/v1.7rc1/jq-linux-armel.asc +16 -0
  271. package/deps/jq/sig/v1.7rc1/jq-linux-armhf.asc +16 -0
  272. package/deps/jq/sig/v1.7rc1/jq-linux-i386.asc +16 -0
  273. package/deps/jq/sig/v1.7rc1/jq-linux-mips.asc +16 -0
  274. package/deps/jq/sig/v1.7rc1/jq-linux-mips64.asc +16 -0
  275. package/deps/jq/sig/v1.7rc1/jq-linux-mips64el.asc +16 -0
  276. package/deps/jq/sig/v1.7rc1/jq-linux-mips64r6.asc +16 -0
  277. package/deps/jq/sig/v1.7rc1/jq-linux-mips64r6el.asc +16 -0
  278. package/deps/jq/sig/v1.7rc1/jq-linux-mipsel.asc +16 -0
  279. package/deps/jq/sig/v1.7rc1/jq-linux-mipsr6.asc +16 -0
  280. package/deps/jq/sig/v1.7rc1/jq-linux-mipsr6el.asc +16 -0
  281. package/deps/jq/sig/v1.7rc1/jq-linux-powerpc.asc +16 -0
  282. package/deps/jq/sig/v1.7rc1/jq-linux-ppc64el.asc +16 -0
  283. package/deps/jq/sig/v1.7rc1/jq-linux-riscv64.asc +16 -0
  284. package/deps/jq/sig/v1.7rc1/jq-linux-s390x.asc +16 -0
  285. package/deps/jq/sig/v1.7rc1/jq-macos-amd64.asc +16 -0
  286. package/deps/jq/sig/v1.7rc1/jq-macos-arm64.asc +16 -0
  287. package/deps/jq/sig/v1.7rc1/jq-windows-amd64.exe.asc +16 -0
  288. package/deps/jq/sig/v1.7rc1/jq-windows-i386.exe.asc +16 -0
  289. package/deps/jq/sig/v1.7rc1/sha256sum.txt +23 -0
  290. package/deps/jq/sig/v1.7rc2/jq-1.7rc2.tar.gz.asc +16 -0
  291. package/deps/jq/sig/v1.7rc2/jq-1.7rc2.zip.asc +16 -0
  292. package/deps/jq/sig/v1.7rc2/jq-linux-amd64.asc +16 -0
  293. package/deps/jq/sig/v1.7rc2/jq-linux-arm64.asc +16 -0
  294. package/deps/jq/sig/v1.7rc2/jq-linux-armel.asc +16 -0
  295. package/deps/jq/sig/v1.7rc2/jq-linux-armhf.asc +16 -0
  296. package/deps/jq/sig/v1.7rc2/jq-linux-i386.asc +16 -0
  297. package/deps/jq/sig/v1.7rc2/jq-linux-mips.asc +16 -0
  298. package/deps/jq/sig/v1.7rc2/jq-linux-mips64.asc +16 -0
  299. package/deps/jq/sig/v1.7rc2/jq-linux-mips64el.asc +16 -0
  300. package/deps/jq/sig/v1.7rc2/jq-linux-mips64r6.asc +16 -0
  301. package/deps/jq/sig/v1.7rc2/jq-linux-mips64r6el.asc +16 -0
  302. package/deps/jq/sig/v1.7rc2/jq-linux-mipsel.asc +16 -0
  303. package/deps/jq/sig/v1.7rc2/jq-linux-mipsr6.asc +16 -0
  304. package/deps/jq/sig/v1.7rc2/jq-linux-mipsr6el.asc +16 -0
  305. package/deps/jq/sig/v1.7rc2/jq-linux-powerpc.asc +16 -0
  306. package/deps/jq/sig/v1.7rc2/jq-linux-ppc64el.asc +16 -0
  307. package/deps/jq/sig/v1.7rc2/jq-linux-riscv64.asc +16 -0
  308. package/deps/jq/sig/v1.7rc2/jq-linux-s390x.asc +16 -0
  309. package/deps/jq/sig/v1.7rc2/jq-macos-amd64.asc +16 -0
  310. package/deps/jq/sig/v1.7rc2/jq-macos-arm64.asc +16 -0
  311. package/deps/jq/sig/v1.7rc2/jq-windows-amd64.exe.asc +16 -0
  312. package/deps/jq/sig/v1.7rc2/jq-windows-i386.exe.asc +16 -0
  313. package/deps/jq/sig/v1.7rc2/sha256sum.txt +23 -0
  314. package/deps/jq/src/builtin.c +537 -343
  315. package/deps/jq/src/builtin.h +18 -0
  316. package/deps/jq/src/builtin.jq +116 -143
  317. package/deps/jq/src/bytecode.h +8 -4
  318. package/deps/jq/src/compile.c +157 -143
  319. package/deps/jq/src/compile.h +3 -4
  320. package/deps/jq/src/decNumber/ICU-license.html +45 -0
  321. package/deps/jq/src/decNumber/decBasic.c +3908 -0
  322. package/deps/jq/src/decNumber/decCommon.c +1835 -0
  323. package/deps/jq/src/decNumber/decContext.c +437 -0
  324. package/deps/jq/src/decNumber/decContext.h +254 -0
  325. package/deps/jq/src/decNumber/decDPD.h +1185 -0
  326. package/deps/jq/src/decNumber/decDouble.c +140 -0
  327. package/deps/jq/src/decNumber/decDouble.h +155 -0
  328. package/deps/jq/src/decNumber/decNumber.c +8143 -0
  329. package/deps/jq/src/decNumber/decNumber.h +182 -0
  330. package/deps/jq/src/decNumber/decNumberLocal.h +757 -0
  331. package/deps/jq/src/decNumber/decPacked.c +220 -0
  332. package/deps/jq/src/decNumber/decPacked.h +52 -0
  333. package/deps/jq/src/decNumber/decQuad.c +135 -0
  334. package/deps/jq/src/decNumber/decQuad.h +177 -0
  335. package/deps/jq/src/decNumber/decSingle.c +71 -0
  336. package/deps/jq/src/decNumber/decSingle.h +86 -0
  337. package/deps/jq/src/decNumber/decimal128.c +553 -0
  338. package/deps/jq/src/decNumber/decimal128.h +81 -0
  339. package/deps/jq/src/decNumber/decimal32.c +476 -0
  340. package/deps/jq/src/decNumber/decimal32.h +81 -0
  341. package/deps/jq/src/decNumber/decimal64.c +839 -0
  342. package/deps/jq/src/decNumber/decimal64.h +83 -0
  343. package/deps/jq/src/decNumber/decnumber.pdf +0 -0
  344. package/deps/jq/src/decNumber/example1.c +38 -0
  345. package/deps/jq/src/decNumber/example2.c +52 -0
  346. package/deps/jq/src/decNumber/example3.c +64 -0
  347. package/deps/jq/src/decNumber/example4.c +61 -0
  348. package/deps/jq/src/decNumber/example5.c +36 -0
  349. package/deps/jq/src/decNumber/example6.c +61 -0
  350. package/deps/jq/src/decNumber/example7.c +35 -0
  351. package/deps/jq/src/decNumber/example8.c +39 -0
  352. package/deps/jq/src/decNumber/readme.txt +81 -0
  353. package/deps/jq/src/exec_stack.h +5 -3
  354. package/deps/jq/src/execute.c +126 -44
  355. package/deps/jq/src/inject_errors.c +0 -2
  356. package/deps/jq/src/jq.h +10 -1
  357. package/deps/jq/src/jq_test.c +222 -11
  358. package/deps/jq/src/jv.c +807 -176
  359. package/deps/jq/src/jv.h +22 -1
  360. package/deps/jq/src/jv_alloc.c +33 -26
  361. package/deps/jq/src/jv_alloc.h +0 -11
  362. package/deps/jq/src/jv_aux.c +153 -67
  363. package/deps/jq/src/jv_dtoa.c +12 -2
  364. package/deps/jq/src/jv_dtoa_tsd.c +51 -0
  365. package/deps/jq/src/jv_dtoa_tsd.h +4 -0
  366. package/deps/jq/src/jv_parse.c +70 -15
  367. package/deps/jq/src/jv_print.c +56 -60
  368. package/deps/jq/src/jv_private.h +7 -0
  369. package/deps/jq/src/jv_thread.h +76 -0
  370. package/deps/jq/src/jv_unicode.c +18 -0
  371. package/deps/jq/src/jv_unicode.h +2 -0
  372. package/deps/jq/src/lexer.c +782 -543
  373. package/deps/jq/src/lexer.h +438 -64
  374. package/deps/jq/src/lexer.l +10 -3
  375. package/deps/jq/src/libm.h +16 -6
  376. package/deps/jq/src/linker.c +97 -40
  377. package/deps/jq/src/locfile.c +2 -1
  378. package/deps/jq/src/main.c +384 -336
  379. package/deps/jq/src/opcode_list.h +5 -2
  380. package/deps/jq/src/parser.c +2260 -1898
  381. package/deps/jq/src/parser.h +115 -98
  382. package/deps/jq/src/parser.y +124 -89
  383. package/deps/jq/src/util.c +854 -55
  384. package/deps/jq/src/util.h +6 -4
  385. package/deps/jq/tests/jq.test +762 -26
  386. package/deps/jq/tests/jq_fuzz_compile.c +27 -0
  387. package/deps/jq/tests/jq_fuzz_execute.cpp +42 -0
  388. package/deps/jq/tests/jq_fuzz_fixed.cpp +297 -0
  389. package/deps/jq/tests/jq_fuzz_load_file.c +28 -0
  390. package/deps/jq/tests/jq_fuzz_parse.c +21 -0
  391. package/deps/jq/tests/jq_fuzz_parse_extended.c +36 -0
  392. package/deps/jq/tests/jq_fuzz_parse_stream.c +21 -0
  393. package/deps/jq/tests/local.supp +14 -0
  394. package/deps/jq/tests/man.test +979 -0
  395. package/deps/jq/tests/manonig.test +76 -0
  396. package/deps/jq/tests/manonigtest +5 -0
  397. package/deps/jq/tests/mantest +1 -2
  398. package/deps/jq/tests/modules/home2/.jq/g.jq +1 -0
  399. package/deps/jq/tests/modules/shadow1.jq +2 -0
  400. package/deps/jq/tests/modules/shadow2.jq +1 -0
  401. package/deps/jq/tests/modules/test_bind_order0.jq +1 -0
  402. package/deps/jq/tests/modules/test_bind_order1.jq +1 -1
  403. package/deps/jq/tests/modules/test_bind_order2.jq +0 -1
  404. package/deps/jq/tests/no-main-program.jq +1 -0
  405. package/deps/jq/tests/onig.test +77 -2
  406. package/deps/jq/tests/setup +7 -2
  407. package/deps/jq/tests/shtest +478 -59
  408. package/deps/jq/tests/uri.test +38 -0
  409. package/deps/jq/tests/uritest +5 -0
  410. package/deps/jq/tests/yes-main-program.jq +2 -0
  411. package/lib/index.js +3 -0
  412. package/lib/jq.js +15 -1
  413. package/lib/templateAsync.js +137 -0
  414. package/package.json +7 -7
  415. package/src/binding.cc +623 -146
  416. package/src/binding.h +3 -4
  417. package/test/santiy-async.test.js +171 -0
  418. package/test/santiy.test.js +2 -2
  419. package/test/template-async.test.js +182 -0
  420. package/test/template.test.js +3 -3
  421. package/deps/jq/.travis.yml +0 -202
  422. package/deps/jq/NEWS +0 -89
  423. package/deps/jq/appveyor.yml +0 -53
  424. package/deps/jq/docs/Gemfile +0 -7
  425. package/deps/jq/docs/Gemfile.lock +0 -63
  426. package/deps/jq/docs/Rakefile +0 -24
  427. package/deps/jq/docs/Rakefile.manual +0 -49
  428. package/deps/jq/docs/Rakefile.website +0 -76
  429. package/deps/jq/docs/content/1.tutorial/default.yml +0 -327
  430. package/deps/jq/docs/content/2.download/default.yml +0 -193
  431. package/deps/jq/docs/content/index/index.yml +0 -73
  432. package/deps/jq/docs/public/css/base.scss +0 -181
  433. package/deps/jq/docs/public/jq.png +0 -0
  434. package/deps/jq/docs/site.yml +0 -9
  435. package/deps/jq/docs/templates/default.liquid +0 -34
  436. package/deps/jq/docs/templates/index.liquid +0 -73
  437. package/deps/jq/docs/templates/manual.liquid +0 -99
  438. package/deps/jq/docs/templates/shared/_footer.liquid +0 -10
  439. package/deps/jq/docs/templates/shared/_head.liquid +0 -17
  440. package/deps/jq/docs/templates/shared/_navbar.liquid +0 -27
  441. package/deps/jq/modules/oniguruma/README.ja +0 -195
  442. package/deps/jq/modules/oniguruma/cmake/dist.cmake +0 -321
  443. package/deps/jq/modules/oniguruma/contributed/libfuzzer-onig.cpp +0 -31
  444. package/deps/jq/modules/oniguruma/dist.info +0 -10
  445. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold1_key.c +0 -2250
  446. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold2_key.c +0 -203
  447. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold3_key.c +0 -113
  448. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold_data.c +0 -1225
  449. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_property_data.c +0 -24742
  450. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_property_data_posix.c +0 -4846
  451. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_unfold_key.c +0 -2571
  452. /package/deps/jq/sig/{jq-release.key → jq-release-old.key} +0 -0
  453. /package/deps/jq/tests/modules/{.jq → home1/.jq} +0 -0
package/src/binding.cc CHANGED
@@ -1,128 +1,60 @@
1
- #include "src/binding.h"
2
1
  #include <list>
3
2
  #include <unordered_map>
4
3
  #include <assert.h>
4
+ #include <string>
5
+ #include <stdio.h>
6
+ #include <string.h>
7
+ #include <pthread.h>
5
8
 
6
- using namespace std;
9
+ #include "src/binding.h"
7
10
 
8
- // LRUCache to save filter to the compiled jq_state
9
- template <class KEY_T, class VAL_T> class LRUCache{
10
- private:
11
- list< pair<KEY_T,VAL_T> > item_list;
12
- unordered_map<KEY_T, decltype(item_list.begin()) > item_map;
13
- size_t cache_size;
14
- private:
15
- void clean(void){
16
- while(item_map.size()>cache_size){
17
- auto last_it = item_list.end(); last_it --;
18
- item_map.erase(last_it->first);
19
- item_list.pop_back();
20
- jq_teardown(&last_it->second);
21
- }
22
- };
23
- public:
24
- LRUCache(int cache_size_):cache_size(cache_size_){
25
- ;
26
- };
27
-
28
- void put(const KEY_T &key, const VAL_T &val){
29
- auto it = item_map.find(key);
30
- if(it != item_map.end()){
31
- item_list.erase(it->second);
32
- item_map.erase(it);
33
- }
34
- item_list.push_front(make_pair(key,val));
35
- item_map.insert(make_pair(key, item_list.begin()));
36
- clean();
37
- };
38
- bool exist(const KEY_T &key){
39
- return (item_map.count(key)>0);
40
- };
41
- VAL_T get(const KEY_T &key){
42
- assert(exist(key));
43
- auto it = item_map.find(key);
44
- item_list.splice(item_list.begin(), item_list, it->second);
45
- return it->second->second;
46
- };
47
11
 
48
- };
12
+ #ifdef DEBUG_MODE
13
+ static bool debug_enabled = true;
14
+ #else
15
+ static bool debug_enabled = false;
16
+ #endif
49
17
 
50
- LRUCache<std::string, jq_state*> cache(100);
18
+ #define DEBUG_LOG(fmt, ...) \
19
+ do { if (debug_enabled) printf("[DEBUG] " fmt "\n", ##__VA_ARGS__); } while (0)
51
20
 
52
- void jv_object_to_v8(std::string key, jv actual, v8::Local<v8::Object> ret) {
53
- jv_kind k = jv_get_kind(actual);
21
+ #define ASYNC_DEBUG_LOG(work, fmt, ...) \
22
+ do { if (debug_enabled) printf("[DEBUG][ASYNC][%p] " fmt "\n", (jv*)work, ##__VA_ARGS__); } while (0)
54
23
 
55
- v8::Local<v8::String> v8_key = Nan::New(key).ToLocalChecked();
56
- v8::Local<v8::Value> v8_val;
24
+ #define CACHE_DEBUG_LOG(cache, fmt, ...) \
25
+ do { if (debug_enabled) printf("[DEBUG][CACHE][%p] " fmt "\n", (void*)cache, ##__VA_ARGS__); } while (0)
57
26
 
58
- switch (k) {
59
- case JV_KIND_INVALID: {
60
- jv msg = jv_invalid_get_msg(jv_copy(actual));
61
- char err[4096];
62
- if (jv_get_kind(msg) == JV_KIND_STRING) {
63
- snprintf(err, sizeof(err), "jq: error: %s", jv_string_value(msg));
64
- jv_free(msg);
65
- jv_free(actual);
66
- Nan::ThrowError(err);
67
- return;
68
- }
69
- jv_free(msg);
70
- jv_free(actual);
71
- break;
72
- }
73
- case JV_KIND_NULL: {
74
- v8_val = Nan::Null();
75
- break;
76
- }
77
- case JV_KIND_TRUE: {
78
- v8_val = Nan::True();
79
- break;
80
- }
81
- case JV_KIND_FALSE: {
82
- v8_val = Nan::False();
83
- break;
84
- }
85
- case JV_KIND_NUMBER: {
86
- v8_val = Nan::New(jv_number_value(actual));
87
- break;
88
- }
89
- case JV_KIND_STRING: {
90
- v8_val = Nan::New(jv_string_value(actual)).ToLocalChecked();
91
- jv_free(actual);
92
- break;
93
- }
94
- case JV_KIND_ARRAY: {
95
- v8::Local<v8::Array> ret_arr = Nan::New<v8::Array>();
96
- for (int i = 0; i < jv_array_length(jv_copy(actual)); i++) {
97
- jv_object_to_v8(std::to_string(i), jv_array_get(jv_copy(actual), i), ret_arr);
98
- }
99
- Nan::Set(ret, v8_key, ret_arr);
100
- jv_free(actual);
101
- break;
102
- }
103
- case JV_KIND_OBJECT: {
104
- v8::Local<v8::Object> ret_obj = Nan::New<v8::Object>();
105
- jv_object_foreach(actual, itr_key, value) {
106
- jv_object_to_v8(jv_string_value(itr_key), value, ret_obj);
107
- }
108
- jv_free(actual);
109
- Nan::Set(ret, v8_key, ret_obj);
110
- break;
111
- }
112
- }
113
-
114
- if (v8_val.IsEmpty()) {
115
- return;
27
+ #define WRAPPER_DEBUG_LOG(wrapper, fmt, ...) \
28
+ do { if (debug_enabled) printf("[DEBUG][WRAPPER:%p] " fmt "\n", (void*)wrapper, ##__VA_ARGS__); } while (0)
29
+
30
+ static size_t global_cache_size = 100;
31
+
32
+ static size_t get_uv_thread_pool_size() {
33
+ const char* uv_threads = getenv("UV_THREADPOOL_SIZE");
34
+ if (uv_threads != nullptr) {
35
+ int thread_count = atoi(uv_threads);
36
+ if (thread_count > 0) {
37
+ return static_cast<size_t>(thread_count);
38
+ }
116
39
  }
40
+ return global_cache_size;
41
+ }
117
42
 
118
- Nan::Set(ret, v8_key, v8_val);
43
+ static size_t validate_cache_size(size_t requested_size) {
44
+ size_t min_size = get_uv_thread_pool_size();
45
+ size_t new_size = std::max(requested_size, min_size);
46
+ if(requested_size < min_size){
47
+ DEBUG_LOG("Requested cache size %zu adjusted to minimum %zu (UV thread pool size)",requested_size,min_size);
48
+ return min_size;
49
+ }
50
+ return new_size;
119
51
  }
120
52
 
53
+ /* err_data and throw_err_cb to get jq error message*/
121
54
  struct err_data {
122
- char buf[4096];
55
+ char buf[4096];
123
56
  };
124
-
125
- void throw_err_cb(void *data, jv msg) {
57
+ void throw_err_cb(void* data, jv msg) {
126
58
  struct err_data *err_data = (struct err_data *)data;
127
59
  if (jv_get_kind(msg) != JV_KIND_STRING)
128
60
  msg = jv_dump_string(msg, JV_PRINT_INVALID);
@@ -133,72 +65,617 @@ void throw_err_cb(void *data, jv msg) {
133
65
  jv_free(msg);
134
66
  }
135
67
 
136
- void jq_exec(std::string json, std::string filter,const Nan::FunctionCallbackInfo<v8::Value>& info) {
137
- jq_state *jq = NULL;
68
+ /* check napi status to throw error if napi_status is not ok */
69
+ inline bool CheckNapiStatus(napi_env env, napi_status status, const char* message) {
70
+ if (status != napi_ok) {
71
+ napi_throw_error(env, nullptr, message);
72
+ return false;
73
+ }
74
+ return true;
75
+ }
76
+
77
+ template <class KEY_T> class LRUCache;
78
+
79
+ struct JqFilterWrapper {
80
+ friend class LRUCache<std::string>;
81
+ public:
82
+ std::string filter_name;
83
+ std::list<JqFilterWrapper*>::iterator cache_pos;
84
+
85
+ /* init mutex and set filter_name */
86
+ explicit JqFilterWrapper(jq_state* jq_, std::string filter_name_) :
87
+ filter_name(filter_name_),
88
+ jq(jq_) {
89
+ DEBUG_LOG("[WRAPPER:%p] Creating wrapper for filter: %s", (void*)this, filter_name_.c_str());
90
+ pthread_mutex_init(&filter_mutex, nullptr);
91
+ }
92
+
93
+ /* free jq and destroy mutex */
94
+ ~JqFilterWrapper() {
95
+ WRAPPER_DEBUG_LOG(this, "Destroying wrapper: %s", filter_name.c_str());
96
+ if (jq) {
97
+ WRAPPER_DEBUG_LOG(this, "Tearing down jq state");
98
+ jq_teardown(&jq);
99
+ }
100
+ pthread_mutex_destroy(&filter_mutex);
101
+ WRAPPER_DEBUG_LOG(this, "Destroyed");
102
+ }
103
+ jq_state* get_jq(){
104
+ return jq;
105
+ }
106
+ void lock(){
107
+ WRAPPER_DEBUG_LOG(this, "Attempting to lock mutex");
108
+ pthread_mutex_lock(&filter_mutex);
109
+ WRAPPER_DEBUG_LOG(this, "Mutex locked");
110
+ }
111
+ void unlock(){
112
+ WRAPPER_DEBUG_LOG(this, "Unlocking mutex");
113
+ pthread_mutex_unlock(&filter_mutex);
114
+ WRAPPER_DEBUG_LOG(this, "Mutex unlocked");
115
+ }
116
+ private:
117
+ jq_state* jq;
118
+ pthread_mutex_t filter_mutex;
119
+
120
+ };
121
+
122
+ template <class KEY_T> class LRUCache {
123
+ private:
124
+ pthread_mutex_t cache_mutex;
125
+ std::list<JqFilterWrapper*> item_list;
126
+ std::unordered_map<KEY_T, JqFilterWrapper*> item_map;
127
+ std::unordered_map<JqFilterWrapper*, bool> is_item_in_use;
128
+
129
+ size_t cache_size;
130
+
131
+ void clean() {
132
+ pthread_mutex_lock(&cache_mutex);
133
+ CACHE_DEBUG_LOG(nullptr, "Starting cleanup. Current size=%zu, target=%zu", item_map.size(), cache_size);
134
+ if(item_map.size() < cache_size){
135
+ pthread_mutex_unlock(&cache_mutex);
136
+ return;
137
+ }
138
+ while (item_list.size() > cache_size) {
139
+ auto last_it = item_list.end();
140
+ last_it--;
141
+ JqFilterWrapper* wrapper = *last_it;
142
+ CACHE_DEBUG_LOG((void*)wrapper, "Examining wrapper: name='%s', is_in_use=%zu", wrapper->filter_name.c_str(), is_item_in_use[wrapper]);
143
+ if(is_item_in_use[wrapper]){
144
+ CACHE_DEBUG_LOG((void*)wrapper, "Wrapper is busy, skipping");
145
+ break;
146
+ }
147
+ if(wrapper->filter_name == ""){
148
+ CACHE_DEBUG_LOG((void*)wrapper, "WARNING: Empty filter name found");
149
+ }
150
+ CACHE_DEBUG_LOG((void*)wrapper, "attempting to remove wrapper from cache");
151
+ if(item_map.find(wrapper->filter_name)->second == wrapper){
152
+ CACHE_DEBUG_LOG((void*)wrapper, "Removing wrapper from cache");
153
+ item_map.erase(wrapper->filter_name);
154
+ };
155
+ is_item_in_use.erase(wrapper);
156
+ item_list.pop_back();
157
+ CACHE_DEBUG_LOG((void*)wrapper, "Deleting wrapper");
158
+ delete wrapper;
159
+
160
+ }
161
+ CACHE_DEBUG_LOG(this, "Cleanup complete. New size=%zu", item_map.size());
162
+ pthread_mutex_unlock(&cache_mutex);
163
+ }
164
+
165
+ public:
166
+ LRUCache(int cache_size_) : cache_size(global_cache_size) {
167
+ pthread_mutex_init(&cache_mutex, nullptr);
168
+ CACHE_DEBUG_LOG(this, "Created cache with size %zu", cache_size);
169
+ }
170
+ ~LRUCache() {
171
+ //clear cache
172
+ pthread_mutex_destroy(&cache_mutex);
173
+ }
174
+ void set_item_in_use_true(JqFilterWrapper* val){
175
+ CACHE_DEBUG_LOG((void*)val, "Incrementing refcnt for wrapper:%p", (void*)val);
176
+ is_item_in_use[val] = true;
177
+ }
178
+ void set_item_in_use_false(JqFilterWrapper* val){
179
+ pthread_mutex_lock(&cache_mutex);
180
+ CACHE_DEBUG_LOG((void*)val, "Decrementing refcnt for wrapper:%p", (void*)val);
181
+ is_item_in_use[val] = false;
182
+ pthread_mutex_unlock(&cache_mutex);
183
+ }
184
+ void put(const KEY_T &key, JqFilterWrapper* val) {
185
+ CACHE_DEBUG_LOG((void*)val, "Putting key='%s' wrapper:%p", key.c_str(), (void*)val);
186
+ pthread_mutex_lock(&cache_mutex);
187
+ set_item_in_use_true(val);
188
+ CACHE_DEBUG_LOG((void*)val, "Got cache lock for put operation");
189
+
190
+ auto it = item_map.find(key);
191
+ if (it != item_map.end()) {
192
+ CACHE_DEBUG_LOG((void*)val, "Replacing existing entry for key='%s', old_ptr=%p , new_ptr=%p", key.c_str(), (void*)it->second, (void*)val);
193
+ item_map.erase(it);
194
+ }
195
+ item_list.push_front(val);
196
+ val->cache_pos = item_list.begin();
197
+
198
+ item_map.insert(std::make_pair(key, val));
199
+ CACHE_DEBUG_LOG((void*)val, "Added wrapper:%p to cache", (void*)val);
200
+ pthread_mutex_unlock(&cache_mutex);
201
+ CACHE_DEBUG_LOG((void*)val, "Released cache lock after put");
202
+ clean();
203
+ }
204
+
205
+ JqFilterWrapper* get(const KEY_T &key) {
206
+ pthread_mutex_lock(&cache_mutex);
207
+ CACHE_DEBUG_LOG(nullptr, "Got cache lock for get operation, key='%s'", key.c_str());
208
+
209
+ if(!(item_map.count(key) > 0)){
210
+ CACHE_DEBUG_LOG(nullptr, "Cache miss for key='%s'", key.c_str());
211
+ pthread_mutex_unlock(&cache_mutex);
212
+ return nullptr;
213
+ }
214
+
215
+ auto it = item_map.find(key);
216
+ JqFilterWrapper* wrapper = it->second;
217
+ item_list.erase(wrapper->cache_pos);
218
+ item_list.push_front(wrapper);
219
+ wrapper->cache_pos = item_list.begin();
220
+ set_item_in_use_true(wrapper);
221
+ CACHE_DEBUG_LOG((void*)wrapper, "Cache hit for jq wrapper,pointer=%p,name=%s",
222
+ (void*)wrapper, wrapper->filter_name.c_str());
223
+ pthread_mutex_unlock(&cache_mutex);
224
+ CACHE_DEBUG_LOG((void*)wrapper, "Released cache lock after get");
225
+ return wrapper;
226
+ }
227
+ void resize(size_t new_size) {
228
+ pthread_mutex_lock(&cache_mutex);
229
+ CACHE_DEBUG_LOG(this, "Resizing cache from %zu to %zu", cache_size, new_size);
230
+ cache_size = new_size;
231
+ pthread_mutex_unlock(&cache_mutex);
232
+ clean(); // Trigger cleanup if needed
233
+ }
234
+ };
235
+
236
+ LRUCache<std::string> cache(100);
237
+
238
+ std::string FromNapiString(napi_env env, napi_value value) {
239
+ size_t str_size;
240
+ size_t str_size_out;
241
+ napi_status status;
242
+ status=napi_get_value_string_utf8(env, value, nullptr, 0, &str_size);
243
+ if(!CheckNapiStatus(env,status,"error loading string lenth")){
244
+ return "";
245
+ }
246
+ char* str = new char[str_size + 1];
247
+ status=napi_get_value_string_utf8(env, value, str, str_size + 1, &str_size_out);
248
+ if(!CheckNapiStatus(env,status,"error loading string")){
249
+ delete[] str;
250
+ return "";
251
+ }
252
+
253
+ std::string result(str);
254
+ delete[] str;
255
+ return result;
256
+ }
257
+
258
+ bool jv_object_to_napi(std::string key, napi_env env, jv actual, napi_value ret,std::string& err_msg) {
259
+ jv_kind kind = jv_get_kind(actual);
260
+ napi_value value;
261
+ napi_status status = napi_invalid_arg;
262
+ switch (kind) {
263
+ case JV_KIND_INVALID: {
264
+ jv msg = jv_invalid_get_msg(jv_copy(actual));
265
+
266
+ if (jv_get_kind(msg) == JV_KIND_STRING) {
267
+ err_msg = std::string("jq: error: ") + jv_string_value(msg);
268
+ jv_free(msg);
269
+ return false;
270
+ }
271
+ napi_get_undefined(env, &ret);
272
+ return true;
273
+ }
274
+ case JV_KIND_NULL: {
275
+ status=napi_get_null(env, &value);
276
+ break;
277
+ }
278
+ case JV_KIND_TRUE: {
279
+ status=napi_get_boolean(env, true, &value);
280
+ break;
281
+ }
282
+ case JV_KIND_FALSE: {
283
+ status=napi_get_boolean(env, false, &value);
284
+ break;
285
+ }
286
+ case JV_KIND_NUMBER: {
287
+ double num = jv_number_value(actual);
288
+ status=napi_create_double(env, num, &value);
289
+ break;
290
+ }
291
+ case JV_KIND_STRING: {
292
+ status=napi_create_string_utf8(env, jv_string_value(actual), NAPI_AUTO_LENGTH, &value);
293
+ break;
294
+ }
295
+ case JV_KIND_ARRAY: {
296
+ size_t arr_len = jv_array_length(jv_copy(actual));
297
+ status=napi_create_array_with_length(env, arr_len, &value);
298
+
299
+ for (size_t i = 0; i < arr_len; i++) {
300
+ jv v = jv_array_get(jv_copy(actual), i);
301
+ bool success = jv_object_to_napi(std::to_string(i), env, v, value,err_msg);
302
+ if(!success){
303
+ jv_free(v);
304
+ return false;
305
+ }
306
+ jv_free(v);
307
+ }
308
+ break;
309
+ }
310
+ case JV_KIND_OBJECT: {
311
+ status=napi_create_object(env, &value);
312
+
313
+ int iter = jv_object_iter(actual);
314
+ while (jv_object_iter_valid(actual, iter)) {
315
+
316
+ jv obj_key = jv_object_iter_key(actual, iter);
317
+ jv obj_value = jv_object_iter_value(actual, iter);
318
+
319
+ bool success = jv_object_to_napi(jv_string_value(obj_key), env, obj_value, value,err_msg);
320
+ if(!success){
321
+ jv_free(obj_key);
322
+ jv_free(obj_value);
323
+ return false;
324
+ }
325
+
326
+ jv_free(obj_key);
327
+ jv_free(obj_value);
328
+
329
+ iter = jv_object_iter_next(actual, iter);
330
+ }
331
+ break;
332
+ }
333
+ // default:
334
+ // napi_throw_error(env, nullptr, "Unsupported jv type");
335
+ // break;
336
+ }
337
+ if(status != napi_ok){
338
+ err_msg = "error creating napi object";
339
+ return false;
340
+ }
341
+ napi_set_named_property(env, ret, key.c_str(), value);
342
+ return true;
343
+ }
344
+
345
+
346
+
347
+
348
+ napi_value ExecSync(napi_env env, napi_callback_info info) {
349
+ size_t argc = 2;
350
+ napi_value args[2];
351
+ napi_status status;
352
+ status=napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
353
+ CheckNapiStatus(env,status,"Error loading info");
354
+
355
+ if (argc < 2) {
356
+ napi_throw_type_error(env, nullptr, "Wrong number of arguments. Expected 2.");
357
+ return nullptr;
358
+ }
359
+
360
+ std::string json = FromNapiString(env, args[0]);
361
+ if(json == ""){
362
+ napi_throw_error(env, nullptr, "Invalid JSON input");
363
+ return nullptr;
364
+ }
365
+ std::string filter = FromNapiString(env, args[1]);
366
+ if(filter == ""){
367
+ napi_throw_error(env, nullptr, "Invalid filter input");
368
+ return nullptr;
369
+ }
370
+
138
371
  struct err_data err_msg;
372
+ JqFilterWrapper* wrapper;
139
373
 
140
- if (cache.exist(filter)) {
141
- jq = cache.get(filter);
142
- } else {
374
+ DEBUG_LOG("[SYNC] ExecSync called with filter='%s'", filter.c_str());
375
+
376
+ wrapper = cache.get(filter);
377
+ if (wrapper == nullptr) {
378
+ DEBUG_LOG("[SYNC] Creating new wrapper for filter='%s'", filter.c_str());
379
+ jq_state* jq;
143
380
  jq = jq_init();
144
381
  jq_set_error_cb(jq, throw_err_cb, &err_msg);
145
382
  if (!jq_compile(jq, filter.c_str())) {
146
- Nan::ThrowError(err_msg.buf);
147
- return;
383
+ napi_throw_error(env, nullptr, err_msg.buf);
384
+ return nullptr;
385
+ }
386
+ if (jq == nullptr) {
387
+ napi_throw_error(env, nullptr, "Failed to initialize jq");
388
+ return nullptr;
148
389
  }
149
- cache.put(filter, jq);
390
+ wrapper = new JqFilterWrapper(jq, filter);
391
+ cache.put(filter, wrapper );
150
392
  }
151
393
 
152
- if (jq == NULL) {
153
- info.GetReturnValue().Set(Nan::Null());
154
- return;
394
+ jv input = jv_parse(json.c_str());
395
+ if (!jv_is_valid(input)) {
396
+ jv_free(input);
397
+ napi_throw_error(env, nullptr, "Invalid JSON input");
398
+ wrapper->unlock();
399
+ return nullptr;
155
400
  }
156
401
 
157
- jv input = jv_parse(json.c_str());
402
+ wrapper->lock();
403
+
404
+ jq_start(wrapper->get_jq(), input, 0);
405
+ jv result = jq_next(wrapper->get_jq());
406
+
407
+ napi_value ret;
408
+ napi_create_object(env, &ret);
409
+ std::string err_msg_conversion;
410
+ bool success = jv_object_to_napi("value",env,result,ret,err_msg_conversion);
411
+ if(!success){
412
+ napi_throw_error(env, nullptr, err_msg_conversion.c_str());
413
+ jv_free(result);
414
+ wrapper->unlock();
415
+ cache.set_item_in_use_false(wrapper);
416
+ return nullptr;
417
+ }
418
+
419
+ jv_free(result);
420
+ wrapper->unlock();
421
+ cache.set_item_in_use_false(wrapper);
422
+ return ret;
423
+ }
424
+
425
+ struct AsyncWork {
426
+ /* input */
427
+ std::string json;
428
+ std::string filter;
429
+ /* promise */
430
+ napi_deferred deferred;
431
+ napi_async_work async_work;
432
+ /* output */
433
+ jv result;
434
+ std::string error;
435
+ bool success;
436
+ };
437
+
438
+ void ExecuteAsync(napi_env env, void* data) {
439
+ AsyncWork* work = static_cast<AsyncWork*>(data);
440
+ ASYNC_DEBUG_LOG(work, "ExecuteAsync started for filter='%s'", work->filter.c_str());
441
+
442
+ struct err_data err_msg;
443
+ JqFilterWrapper* wrapper;
444
+
445
+ wrapper = cache.get(work->filter);
446
+ if (wrapper == nullptr) {
447
+ ASYNC_DEBUG_LOG(work, "Creating new jq wrapper for filter='%s'", work->filter.c_str());
448
+ jq_state* jq;
449
+ jq = jq_init();
450
+ jq_set_error_cb(jq, throw_err_cb, &err_msg);
451
+ if (!jq_compile(jq, work->filter.c_str())) {
452
+ ASYNC_DEBUG_LOG(work, "jq compilation failed");
453
+ work->error = err_msg.buf;
454
+ work->success = false;
455
+ return;
456
+ }
457
+ wrapper=new JqFilterWrapper(jq, work->filter);
458
+ cache.put(work->filter, wrapper );
459
+ }
460
+
461
+ jv input = jv_parse_sized(work->json.c_str(), work->json.size());
462
+ ASYNC_DEBUG_LOG(work, "JSON input parsed");
158
463
 
159
464
  if (!jv_is_valid(input)) {
160
- info.GetReturnValue().Set(Nan::Null());
465
+ ASYNC_DEBUG_LOG(work, "Invalid JSON input");
466
+ work->error = "Invalid JSON input";
467
+ work->success = false;
161
468
  jv_free(input);
469
+ wrapper->unlock();
470
+ cache.set_item_in_use_false(wrapper);
471
+
162
472
  return;
163
473
  }
474
+ wrapper->lock();
475
+ jq_start(wrapper->get_jq(), input, 0);
476
+ ASYNC_DEBUG_LOG(work, "jq execution started");
164
477
 
165
- jq_start(jq, input, 0);
166
- jv result = jq_next(jq);
167
-
168
- v8::Local<v8::Object> ret = Nan::New<v8::Object>();
169
- jv_object_to_v8("value", result, ret);
478
+ jv result=jq_next(wrapper->get_jq());
479
+ work->result = result;
480
+ work->success = true;
481
+ wrapper->unlock();
170
482
 
171
- info.GetReturnValue().Set(ret);
483
+ cache.set_item_in_use_false(wrapper);
484
+ ASYNC_DEBUG_LOG(work, "jq execution finished - got result, %p", work->result);
172
485
  }
173
486
 
174
487
 
175
- std::string FromV8String(v8::Local<v8::String> val) {
176
- Nan::Utf8String keyUTF8(val);
177
- return std::string(*keyUTF8);
178
- }
488
+ void CompleteAsync(napi_env env, napi_status status, void* data) {
489
+ AsyncWork* work = static_cast<AsyncWork*>(data);
490
+ bool cleanup_done = false;
491
+
492
+ auto cleanup = [&]() {
493
+ if (!cleanup_done) {
494
+ DEBUG_LOG("Freeing result, %p,refcnt %zu", work->result, jv_get_refcnt(work->result));
495
+ jv_free(work->result);
496
+ napi_delete_async_work(env, work->async_work);
497
+ ASYNC_DEBUG_LOG(work, "Deleting AsyncWork");
498
+ delete work;
499
+ cleanup_done = true;
500
+ }
501
+ };
502
+ if(status != napi_ok){
503
+ napi_throw_type_error(env, nullptr, "Got error from async work");
504
+ napi_reject_deferred(env, work->deferred, nullptr);
505
+ cleanup();
506
+ return;
507
+ }
508
+ napi_handle_scope scope;
509
+ status = napi_open_handle_scope(env, &scope);
510
+ if (status != napi_ok) {
511
+ napi_throw_type_error(env, nullptr, "Failed to create handle scope");
512
+ napi_reject_deferred(env, work->deferred, nullptr);
513
+ cleanup();
514
+ return;
515
+ }
516
+
517
+ if (work->success) {
518
+ napi_value ret;
179
519
 
180
- void Exec(const Nan::FunctionCallbackInfo<v8::Value>& info) {
181
- if (info.Length() < 2) {
182
- Nan::ThrowTypeError("Wrong number of arguments");
520
+ status=napi_create_object(env, &ret);
521
+ if(status != napi_ok){
522
+ napi_throw_error(env, nullptr, "Failed to create object");
523
+ napi_close_handle_scope(env, scope);
524
+ napi_resolve_deferred(env, work->deferred, ret);
525
+ cleanup();
183
526
  return;
184
527
  }
528
+ DEBUG_LOG("[COMPLETE ASYNC][%p] result %p", work, work->result);
529
+ std::string err_msg_conversion;
530
+ bool success = jv_object_to_napi("value", env, work->result, ret,err_msg_conversion);
531
+ if(!success){
532
+ napi_value error;
533
+ napi_create_string_utf8(env, err_msg_conversion.c_str(), NAPI_AUTO_LENGTH, &error);
185
534
 
186
- if (!info[0]->IsString() || !info[1]->IsString()) {
187
- Nan::ThrowTypeError("Wrong arguments");
535
+ napi_value error_obj;
536
+ napi_create_object(env, &error_obj);
537
+ napi_set_named_property(env, error_obj, "message", error);
538
+ // napi_create_error(env, nullptr, error, &error_obj);
539
+ napi_reject_deferred(env, work->deferred, error_obj);
540
+
541
+ jv_free(work->result);
542
+ napi_close_handle_scope(env, scope);
188
543
  return;
189
544
  }
545
+ napi_resolve_deferred(env, work->deferred, ret);
546
+ } else {
547
+ napi_value error;
548
+ napi_create_string_utf8(env, work->error.c_str(), NAPI_AUTO_LENGTH, &error);
190
549
 
191
- std::string json = FromV8String(Nan::To<v8::String>(info[0]).ToLocalChecked());
192
- std::string filter = FromV8String(Nan::To<v8::String>(info[1]).ToLocalChecked());
550
+ napi_value error_obj;
551
+ napi_create_object(env, &error_obj);
552
+ napi_set_named_property(env, error_obj, "message", error);
193
553
 
194
- jq_exec(json, filter, info);
554
+ // napi_create_error(env, nullptr, error, &error_obj);
555
+ napi_reject_deferred(env, work->deferred, error_obj);
556
+ }
557
+ cleanup();
558
+ napi_close_handle_scope(env, scope);
195
559
  }
196
560
 
197
- void Init(v8::Local<v8::Object> exports) {
198
- v8::Local<v8::Context> context = exports->GetCreationContext().ToLocalChecked();
199
- (void)exports->Set(context,
200
- Nan::New("exec").ToLocalChecked(),
201
- Nan::New<v8::FunctionTemplate>(Exec)->GetFunction(context).ToLocalChecked());
561
+
562
+
563
+ napi_value ExecAsync(napi_env env, napi_callback_info info) {
564
+ napi_handle_scope scope;
565
+
566
+ size_t argc = 2;
567
+ napi_value args[2];
568
+ napi_value promise;
569
+
570
+ napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
571
+
572
+ if (argc < 2) {
573
+ napi_throw_type_error(env, nullptr, "Wrong number of arguments. Expected 2.");
574
+ return nullptr;
575
+ }
576
+
577
+ AsyncWork* work = new AsyncWork();
578
+ work->json = FromNapiString(env, args[0]);
579
+ if(work->json == ""){
580
+ napi_throw_error(env, nullptr, "Invalid JSON input");
581
+ return nullptr;
582
+ }
583
+ work->filter = FromNapiString(env, args[1]);
584
+ if(work->filter == ""){
585
+ napi_throw_error(env, nullptr, "Invalid filter input");
586
+ return nullptr;
587
+ }
588
+ work->success = false;
589
+
590
+ napi_create_promise(env, &work->deferred, &promise);
591
+
592
+ napi_value resource_name;
593
+ napi_create_string_utf8(env, "ExecAsync", NAPI_AUTO_LENGTH, &resource_name);
594
+
595
+ napi_create_async_work(env, nullptr, resource_name, ExecuteAsync, CompleteAsync, work, &work->async_work);
596
+ napi_queue_async_work(env, work->async_work);
597
+
598
+ return promise;
599
+ }
600
+
601
+ napi_value SetDebugMode(napi_env env, napi_callback_info info) {
602
+ size_t argc = 1;
603
+ napi_value args[1];
604
+ bool enable;
605
+
606
+ napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
607
+
608
+ if (argc < 1) {
609
+ napi_throw_type_error(env, nullptr, "Wrong number of arguments");
610
+ return nullptr;
611
+ }
612
+
613
+ napi_get_value_bool(env, args[0], &enable);
614
+ debug_enabled = enable;
615
+ DEBUG_LOG("Debug mode %s", enable ? "enabled" : "disabled");
616
+
617
+ napi_value result;
618
+ napi_get_boolean(env, debug_enabled, &result);
619
+ return result;
620
+ }
621
+
622
+ // napi_value GetCacheStats(napi_env env, napi_callback_info info) {
623
+ // napi_value result;
624
+ // napi_create_object(env, &result);
625
+ // struct rusage usage;
626
+ // getrusage(RUSAGE_SELF, &usage);
627
+ // napi_value maxrss;
628
+ // napi_create_int64(env, usage.ru_maxrss, &maxrss);
629
+ // napi_set_named_property(env, result, "max_rss", maxrss);
630
+ // return result;
631
+ // }
632
+
633
+ napi_value SetCacheSize(napi_env env, napi_callback_info info) {
634
+ size_t argc = 1;
635
+ napi_value args[1];
636
+ int64_t new_size;
637
+
638
+ napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
639
+ napi_status status;
640
+ if (argc < 1) {
641
+ napi_throw_type_error(env, nullptr, "Wrong number of arguments");
642
+ return nullptr;
643
+ }
644
+
645
+ status=napi_get_value_int64(env, args[0], &new_size);
646
+ if(!CheckNapiStatus(env,status,"error loading int64")){
647
+ return nullptr;
648
+ }
649
+ if (new_size <= 0) {
650
+ napi_throw_error(env, nullptr, "Cache size must be positive");
651
+ return nullptr;
652
+ }
653
+
654
+ DEBUG_LOG("Changing cache size from %zu to %lld", global_cache_size, new_size);
655
+ size_t old_size = global_cache_size;
656
+
657
+ global_cache_size = validate_cache_size(static_cast<size_t>(new_size));
658
+ cache.resize(global_cache_size); // Update cache size
659
+
660
+ napi_value result;
661
+ napi_create_int64(env, global_cache_size, &result);
662
+ return result;
663
+ }
664
+
665
+ napi_value Init(napi_env env, napi_value exports) {
666
+ napi_value exec_sync, exec_async, debug_fn, cache_size_fn,cache_stats_fn;
667
+
668
+ napi_create_function(env, "execSync", NAPI_AUTO_LENGTH, ExecSync, nullptr, &exec_sync);
669
+ napi_create_function(env, "execAsync", NAPI_AUTO_LENGTH, ExecAsync, nullptr, &exec_async);
670
+ napi_create_function(env, "setDebugMode", NAPI_AUTO_LENGTH, SetDebugMode, nullptr, &debug_fn);
671
+ napi_create_function(env, "setCacheSize", NAPI_AUTO_LENGTH, SetCacheSize, nullptr, &cache_size_fn);
672
+ // napi_create_function(env, "getCacheStats", NAPI_AUTO_LENGTH, GetCacheStats, nullptr, &cache_stats_fn);
673
+ napi_set_named_property(env, exports, "execSync", exec_sync);
674
+ napi_set_named_property(env, exports, "execAsync", exec_async);
675
+ napi_set_named_property(env, exports, "setDebugMode", debug_fn);
676
+ napi_set_named_property(env, exports, "setCacheSize", cache_size_fn);
677
+ // napi_set_named_property(env, exports, "getCacheStats", cache_stats_fn);
678
+ return exports;
202
679
  }
203
680
 
204
- NODE_MODULE(exec, Init)
681
+ NAPI_MODULE(NODE_GYP_MODULE_NAME, Init)