@port-labs/jq-node-bindings 1.0.5 → 1.1.0-dev.1
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/.claude/settings.local.json +12 -0
- package/configure +6 -5
- package/deps/jq/.claude/settings.local.json +7 -0
- package/deps/jq/.gitattributes +1 -3
- package/deps/jq/AUTHORS +55 -1
- package/deps/jq/COPYING +40 -0
- package/deps/jq/Makefile.am +40 -36
- package/deps/jq/NEWS.md +277 -2
- package/deps/jq/README.md +23 -5
- package/deps/jq/compile-ios.sh +1 -1
- package/deps/jq/config/m4/check-math-func.m4 +2 -2
- package/deps/jq/config/m4/find-func-no-libs2.m4 +3 -3
- package/deps/jq/configure.ac +10 -18
- package/deps/jq/docs/Pipfile.lock +368 -313
- package/deps/jq/docs/README.md +3 -4
- package/deps/jq/docs/build_manpage.py +1 -1
- package/deps/jq/docs/build_mantests.py +1 -1
- package/deps/jq/docs/build_website.py +1 -8
- package/deps/jq/docs/content/download/default.yml +49 -9
- package/deps/jq/docs/content/index.yml +9 -0
- package/deps/jq/docs/content/manual/{manual.yml → dev/manual.yml} +218 -61
- package/deps/jq/docs/content/manual/v1.3/manual.yml +0 -5
- package/deps/jq/docs/content/manual/v1.4/manual.yml +0 -5
- package/deps/jq/docs/content/manual/v1.5/manual.yml +3 -8
- package/deps/jq/docs/content/manual/v1.6/manual.yml +3 -8
- package/deps/jq/docs/content/manual/v1.7/manual.yml +499 -500
- package/deps/jq/docs/content/manual/v1.8/manual.yml +3858 -0
- package/deps/jq/docs/content/tutorial/default.yml +3 -3
- package/deps/jq/docs/manual_schema.yml +0 -3
- package/deps/jq/docs/public/CNAME +1 -0
- package/deps/jq/docs/templates/index.html.j2 +10 -10
- package/deps/jq/docs/templates/manual.html.j2 +14 -3
- package/deps/jq/docs/templates/shared/_head.html.j2 +8 -3
- package/deps/jq/docs/templates/shared/_navbar.html.j2 +4 -4
- package/deps/jq/jq.1.prebuilt +219 -44
- package/deps/jq/jq.spec +2 -2
- package/deps/jq/libjq.pc.in +1 -1
- package/deps/jq/scripts/version +1 -1
- package/deps/jq/sig/v1.7.1/jq-1.7.1.tar.gz.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-1.7.1.zip.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-amd64.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-arm64.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-armel.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-armhf.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-i386.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-mips.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-mips64.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-mips64el.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-mips64r6.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-mips64r6el.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-mipsel.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-mipsr6.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-mipsr6el.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-powerpc.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-ppc64el.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-riscv64.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-s390x.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux64.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-macos-amd64.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-macos-arm64.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-osx-amd64.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-win64.exe.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-windows-amd64.exe.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-windows-i386.exe.asc +16 -0
- package/deps/jq/sig/v1.7.1/sha256sum.txt +26 -0
- package/deps/jq/sig/v1.8.0/jq-1.8.0.tar.gz.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-1.8.0.zip.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-amd64.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-arm64.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-armel.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-armhf.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-i386.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-mips.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-mips64.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-mips64el.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-mips64r6.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-mips64r6el.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-mipsel.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-mipsr6.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-mipsr6el.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-powerpc.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-ppc64el.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-riscv64.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-s390x.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux64.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-macos-amd64.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-macos-arm64.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-osx-amd64.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-win64.exe.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-windows-amd64.exe.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-windows-i386.exe.asc +16 -0
- package/deps/jq/sig/v1.8.0/sha256sum.txt +26 -0
- package/deps/jq/src/builtin.c +446 -271
- package/deps/jq/src/builtin.jq +25 -60
- package/deps/jq/src/bytecode.h +8 -3
- package/deps/jq/src/compile.c +22 -43
- package/deps/jq/src/compile.h +1 -1
- package/deps/jq/src/execute.c +20 -25
- package/deps/jq/src/jq_test.c +113 -44
- package/deps/jq/src/jv.c +134 -42
- package/deps/jq/src/jv.h +10 -3
- package/deps/jq/src/jv_alloc.c +8 -5
- package/deps/jq/src/jv_alloc.h +0 -1
- package/deps/jq/src/jv_aux.c +41 -8
- package/deps/jq/src/jv_dtoa.c +4 -12
- package/deps/jq/src/jv_dtoa_tsd.c +5 -4
- package/deps/jq/src/jv_dtoa_tsd.h +1 -1
- package/deps/jq/src/jv_parse.c +5 -3
- package/deps/jq/src/jv_print.c +87 -65
- package/deps/jq/src/jv_unicode.c +18 -0
- package/deps/jq/src/jv_unicode.h +2 -0
- package/deps/jq/src/lexer.c +303 -278
- package/deps/jq/src/lexer.h +5 -4
- package/deps/jq/src/lexer.l +8 -2
- package/deps/jq/src/libm.h +15 -5
- package/deps/jq/src/linker.c +6 -4
- package/deps/jq/src/locfile.c +12 -12
- package/deps/jq/src/main.c +204 -270
- package/deps/jq/src/parser.c +1105 -1273
- package/deps/jq/src/parser.y +149 -181
- package/deps/jq/src/util.c +46 -48
- package/deps/jq/src/util.h +1 -1
- package/deps/jq/tests/base64.test +12 -0
- package/deps/jq/tests/jq.test +429 -37
- package/deps/jq/tests/jq_fuzz_load_file.c +1 -0
- package/deps/jq/tests/man.test +46 -13
- package/deps/jq/tests/manonig.test +13 -0
- package/deps/jq/tests/onig.test +40 -2
- package/deps/jq/tests/optional.test +4 -12
- package/deps/jq/tests/setup +5 -1
- package/deps/jq/tests/shtest +358 -130
- package/deps/jq/tests/uri.test +38 -0
- package/deps/jq/tests/uritest +5 -0
- package/deps/jq/{src → vendor}/decNumber/decBasic.c +1 -1
- package/deps/jq/{src → vendor}/decNumber/decCommon.c +1 -1
- package/deps/jq/{src → vendor}/decNumber/decNumber.c +4 -4
- package/deps/jq/{modules → vendor}/oniguruma/CMakeLists.txt +5 -3
- package/deps/jq/{modules → vendor}/oniguruma/HISTORY +45 -7
- package/deps/jq/{modules → vendor}/oniguruma/Makefile.am +1 -1
- package/deps/jq/{modules → vendor}/oniguruma/README.md +10 -23
- package/deps/jq/{modules → vendor}/oniguruma/compile +29 -13
- package/deps/jq/{modules → vendor}/oniguruma/config.guess +91 -27
- package/deps/jq/{modules → vendor}/oniguruma/config.sub +716 -242
- package/deps/jq/{modules → vendor}/oniguruma/configure.ac +2 -2
- package/deps/jq/{modules → vendor}/oniguruma/depcomp +10 -9
- package/deps/jq/{modules → vendor}/oniguruma/doc/API +3 -1
- package/deps/jq/{modules → vendor}/oniguruma/doc/API.ja +3 -1
- package/deps/jq/{modules → vendor}/oniguruma/doc/CALLOUTS.BUILTIN +10 -1
- package/deps/jq/{modules → vendor}/oniguruma/doc/CALLOUTS.BUILTIN.ja +9 -1
- package/deps/jq/{modules → vendor}/oniguruma/doc/RE +12 -13
- package/deps/jq/{modules → vendor}/oniguruma/doc/RE.ja +12 -13
- package/deps/jq/{modules → vendor}/oniguruma/doc/SYNTAX.md +202 -167
- package/deps/jq/{modules → vendor}/oniguruma/doc/UNICODE_PROPERTIES +33 -1
- package/deps/jq/vendor/oniguruma/doc/onig_syn_md.c +667 -0
- package/deps/jq/{modules → vendor}/oniguruma/harnesses/base.c +1 -1
- package/deps/jq/{modules → vendor}/oniguruma/install-sh +9 -9
- package/deps/jq/{modules → vendor}/oniguruma/missing +50 -29
- package/deps/jq/{modules → vendor}/oniguruma/sample/callback_each_match.c +1 -3
- package/deps/jq/vendor/oniguruma/sbom.cdx.json +44 -0
- package/deps/jq/{modules → vendor}/oniguruma/src/ascii.c +4 -1
- package/deps/jq/{modules → vendor}/oniguruma/src/gperf_fold_key_conv.py +4 -4
- package/deps/jq/{modules → vendor}/oniguruma/src/gperf_unfold_key_conv.py +4 -4
- package/deps/jq/vendor/oniguruma/src/make_unicode_egcb.sh +7 -0
- package/deps/jq/{modules → vendor}/oniguruma/src/make_unicode_egcb_data.py +20 -19
- package/deps/jq/{modules → vendor}/oniguruma/src/make_unicode_fold.sh +5 -5
- package/deps/jq/{modules → vendor}/oniguruma/src/make_unicode_fold_data.py +37 -37
- package/deps/jq/{modules → vendor}/oniguruma/src/make_unicode_property.sh +2 -2
- package/deps/jq/{modules → vendor}/oniguruma/src/make_unicode_property_data.py +66 -65
- package/deps/jq/vendor/oniguruma/src/make_unicode_wb.sh +7 -0
- package/deps/jq/{modules → vendor}/oniguruma/src/make_unicode_wb_data.py +20 -19
- package/deps/jq/{modules → vendor}/oniguruma/src/oniguruma.h +6 -3
- package/deps/jq/{modules → vendor}/oniguruma/src/regcomp.c +14 -6
- package/deps/jq/{modules → vendor}/oniguruma/src/regerror.c +2 -2
- package/deps/jq/{modules → vendor}/oniguruma/src/regexec.c +85 -14
- package/deps/jq/{modules → vendor}/oniguruma/src/regint.h +17 -4
- package/deps/jq/{modules → vendor}/oniguruma/src/regparse.c +115 -27
- package/deps/jq/{modules → vendor}/oniguruma/src/regsyntax.c +10 -7
- package/deps/jq/{modules → vendor}/oniguruma/src/st.c +49 -75
- package/deps/jq/{modules → vendor}/oniguruma/src/st.h +3 -10
- package/deps/jq/{modules → vendor}/oniguruma/src/unicode_egcb_data.c +54 -49
- package/deps/jq/{modules → vendor}/oniguruma/src/unicode_fold1_key.c +1567 -1507
- package/deps/jq/{modules → vendor}/oniguruma/src/unicode_fold2_key.c +1 -1
- package/deps/jq/{modules → vendor}/oniguruma/src/unicode_fold3_key.c +1 -1
- package/deps/jq/vendor/oniguruma/src/unicode_fold_data.c +1619 -0
- package/deps/jq/{modules → vendor}/oniguruma/src/unicode_property_data.c +5520 -4178
- package/deps/jq/{modules → vendor}/oniguruma/src/unicode_property_data_posix.c +239 -83
- package/deps/jq/vendor/oniguruma/src/unicode_unfold_key.c +3497 -0
- package/deps/jq/{modules → vendor}/oniguruma/src/unicode_wb_data.c +51 -19
- package/deps/jq/{modules → vendor}/oniguruma/src/utf16_be.c +3 -2
- package/deps/jq/{modules → vendor}/oniguruma/src/utf16_le.c +3 -2
- package/deps/jq/{modules → vendor}/oniguruma/test/test_back.c +3 -3
- package/deps/jq/{modules → vendor}/oniguruma/test/test_options.c +2 -2
- package/deps/jq/{modules → vendor}/oniguruma/test/test_syntax.c +54 -2
- package/deps/jq/{modules → vendor}/oniguruma/test/test_utf8.c +19 -5
- package/deps/jq/{modules → vendor}/oniguruma/test/testc.c +1 -1
- package/deps/jq/{modules → vendor}/oniguruma/test/testp.c +1 -1
- package/deps/jq/{modules → vendor}/oniguruma/test-driver +13 -6
- package/deps/jq/{modules → vendor}/oniguruma/windows/CMakeLists.txt +1 -1
- package/lib/index.js +5 -4
- package/lib/jq.js +61 -25
- package/lib/parse.js +79 -0
- package/lib/template.js +93 -95
- package/lib/templateAsync.js +115 -99
- package/package.json +3 -3
- package/test/santiy-async.test.js +4 -4
- package/test/santiy.test.js +4 -4
- package/test/template-async.test.js +6 -6
- package/test/template.test.js +6 -6
- package/deps/jq/modules/oniguruma/src/make_unicode_egcb.sh +0 -7
- package/deps/jq/modules/oniguruma/src/make_unicode_wb.sh +0 -7
- package/deps/jq/modules/oniguruma/src/unicode_fold_data.c +0 -1592
- package/deps/jq/modules/oniguruma/src/unicode_unfold_key.c +0 -3394
- package/deps/jq/scripts/update-website +0 -30
- /package/deps/jq/{src → vendor}/decNumber/ICU-license.html +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decContext.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decContext.h +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decDPD.h +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decDouble.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decDouble.h +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decNumber.h +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decNumberLocal.h +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decPacked.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decPacked.h +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decQuad.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decQuad.h +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decSingle.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decSingle.h +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decimal128.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decimal128.h +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decimal32.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decimal32.h +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decimal64.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decimal64.h +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decnumber.pdf +0 -0
- /package/deps/jq/{src → vendor}/decNumber/example1.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/example2.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/example3.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/example4.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/example5.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/example6.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/example7.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/example8.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/readme.txt +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/.travis.yml +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/AUTHORS +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/COPYING +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/ChangeLog +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/NEWS +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/README +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/README_japanese +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/autogen.sh +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/cmake/Config.cmake.in +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/doc/CALLOUTS.API +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/doc/CALLOUTS.API.ja +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/doc/FAQ +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/doc/FAQ.ja +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/harnesses/ascii_compatible.dict +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/harnesses/deluxe.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/harnesses/dict_conv.py +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/harnesses/fuzzer.options +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/harnesses/libfuzzer-onig.cpp +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/harnesses/regset.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/index.html +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/index_ja.html +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/m4/.whatever +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/make_win.bat +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/make_win32.bat +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/make_win64.bat +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/onig-config.cmake.in +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/onig-config.in +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/oniguruma.pc.cmake.in +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/oniguruma.pc.in +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/CMakeLists.txt +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/Makefile.am +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/bug_fix.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/callout.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/count.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/crnl.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/echo.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/encode.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/listcap.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/names.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/posix.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/regset.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/scan.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/simple.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/sql.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/syntax.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/user_property.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/Makefile.am +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/Makefile.windows +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/big5.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/config.h.cmake.in +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/config.h.win32 +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/config.h.win64 +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/config.h.windows.in +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/cp1251.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/euc_jp.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/euc_jp_prop.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/euc_jp_prop.gperf +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/euc_kr.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/euc_tw.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/gb18030.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_1.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_10.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_11.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_13.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_14.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_15.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_16.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_2.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_3.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_4.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_5.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_6.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_7.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_8.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_9.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/koi8.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/koi8_r.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/make_property.sh +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/mktable.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/onig_init.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/oniggnu.h +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/onigposix.h +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/regenc.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/regenc.h +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/regext.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/reggnu.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/regparse.h +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/regposerr.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/regposix.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/regtrav.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/regversion.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/sjis.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/sjis_prop.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/sjis_prop.gperf +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/unicode.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/utf32_be.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/utf32_le.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/utf8.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/test/CMakeLists.txt +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/test/Makefile.am +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/test/test.sh +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/test/test_regset.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/test/testu.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/tis-ci/stub.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/tis-ci/test_back.config +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/tis-ci/test_regset.config +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/tis-ci/test_syntax.config +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/tis-ci/test_utf8.config +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/tis-ci/testc.config +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/tis-ci/testu.config +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/tis.config +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/windows/testc.c +0 -0
package/lib/jq.js
CHANGED
|
@@ -1,47 +1,83 @@
|
|
|
1
|
-
const nativeJq = require(
|
|
2
|
-
nativeJq.setCacheSize(1000)
|
|
1
|
+
const nativeJq = require("bindings")("jq-node-bindings");
|
|
2
|
+
nativeJq.setCacheSize(1000);
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// Conditionally enable access to env
|
|
8
|
-
return enableEnv ? formattedFilter : `def env: {}; {} as $ENV | ${formattedFilter}`;
|
|
9
|
-
}
|
|
4
|
+
const SINGLE_QUOTE_RE = /(^|\s)'(?!\s|")|(?<!\s|")'(\s|$)/g;
|
|
5
|
+
const COMPILE_ERROR_PREFIX = "jq: compile error";
|
|
6
|
+
const ENV_DISABLE_PREFIX = "def env: {}; {} as $ENV | ";
|
|
10
7
|
|
|
8
|
+
const formatFilter = (filter, enableEnv) => {
|
|
9
|
+
const formattedFilter = filter.replace(SINGLE_QUOTE_RE, '$1"$2');
|
|
10
|
+
return enableEnv ? formattedFilter : ENV_DISABLE_PREFIX + formattedFilter;
|
|
11
|
+
};
|
|
11
12
|
|
|
12
|
-
class JqExecError extends Error {
|
|
13
|
-
}
|
|
13
|
+
class JqExecError extends Error {}
|
|
14
14
|
|
|
15
|
-
class JqExecCompileError extends JqExecError {
|
|
16
|
-
}
|
|
15
|
+
class JqExecCompileError extends JqExecError {}
|
|
17
16
|
|
|
18
|
-
const
|
|
17
|
+
const execRaw = (jsonStr, filter, execOptions) => {
|
|
19
18
|
try {
|
|
20
|
-
const data = nativeJq.execSync(
|
|
21
|
-
|
|
19
|
+
const data = nativeJq.execSync(
|
|
20
|
+
jsonStr,
|
|
21
|
+
formatFilter(filter, execOptions.enableEnv)
|
|
22
|
+
);
|
|
22
23
|
return data?.value;
|
|
23
24
|
} catch (err) {
|
|
24
|
-
if (throwOnError) {
|
|
25
|
-
|
|
25
|
+
if (execOptions.throwOnError) {
|
|
26
|
+
const msg = err?.message;
|
|
27
|
+
throw new (
|
|
28
|
+
msg && msg.startsWith(COMPILE_ERROR_PREFIX)
|
|
29
|
+
? JqExecCompileError
|
|
30
|
+
: JqExecError
|
|
31
|
+
)(msg);
|
|
26
32
|
}
|
|
27
|
-
return null
|
|
33
|
+
return null;
|
|
28
34
|
}
|
|
29
|
-
}
|
|
35
|
+
};
|
|
30
36
|
|
|
31
|
-
const
|
|
37
|
+
const execRawAsync = async (jsonStr, filter, execOptions) => {
|
|
32
38
|
try {
|
|
33
|
-
const data = await nativeJq.execAsync(
|
|
39
|
+
const data = await nativeJq.execAsync(
|
|
40
|
+
jsonStr,
|
|
41
|
+
formatFilter(filter, execOptions.enableEnv),
|
|
42
|
+
execOptions.timeoutSec
|
|
43
|
+
);
|
|
34
44
|
return data?.value;
|
|
35
45
|
} catch (err) {
|
|
36
|
-
if (throwOnError) {
|
|
37
|
-
|
|
46
|
+
if (execOptions.throwOnError) {
|
|
47
|
+
const msg = err?.message;
|
|
48
|
+
throw new (
|
|
49
|
+
msg && msg.startsWith(COMPILE_ERROR_PREFIX)
|
|
50
|
+
? JqExecCompileError
|
|
51
|
+
: JqExecError
|
|
52
|
+
)(msg);
|
|
38
53
|
}
|
|
39
|
-
return null
|
|
54
|
+
return null;
|
|
40
55
|
}
|
|
41
|
-
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const DEFAULT_OPTIONS = { enableEnv: false, throwOnError: false };
|
|
59
|
+
|
|
60
|
+
const exec = (object, filter, execOptions) => {
|
|
61
|
+
return execRaw(
|
|
62
|
+
JSON.stringify(object),
|
|
63
|
+
filter,
|
|
64
|
+
execOptions || DEFAULT_OPTIONS
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const execAsync = async (object, filter, execOptions) => {
|
|
69
|
+
return execRawAsync(
|
|
70
|
+
JSON.stringify(object),
|
|
71
|
+
filter,
|
|
72
|
+
execOptions || DEFAULT_OPTIONS
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
42
76
|
module.exports = {
|
|
43
77
|
exec,
|
|
44
78
|
execAsync,
|
|
79
|
+
execRaw,
|
|
80
|
+
execRawAsync,
|
|
45
81
|
setCacheSize: nativeJq.setCacheSize,
|
|
46
82
|
JqExecError,
|
|
47
83
|
JqExecCompileError,
|
package/lib/parse.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
const CH_BACKSLASH = 92; // '\'
|
|
2
|
+
const CH_DOUBLE_QUOTE = 34; // '"'
|
|
3
|
+
const CH_SINGLE_QUOTE = 39; // "'"
|
|
4
|
+
const CH_OPEN_BRACE = 123; // '{'
|
|
5
|
+
const CH_CLOSE_BRACE = 125; // '}'
|
|
6
|
+
|
|
7
|
+
const findInsideDoubleBracesIndices = (input) => {
|
|
8
|
+
let wrappingQuote = 0;
|
|
9
|
+
let insideDoubleBracesStart = -1;
|
|
10
|
+
const indices = [];
|
|
11
|
+
const len = input.length;
|
|
12
|
+
|
|
13
|
+
for (let i = 0; i < len; i++) {
|
|
14
|
+
const cc = input.charCodeAt(i);
|
|
15
|
+
|
|
16
|
+
if (insideDoubleBracesStart !== -1 && cc === CH_BACKSLASH) {
|
|
17
|
+
i++;
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (
|
|
21
|
+
insideDoubleBracesStart !== -1 &&
|
|
22
|
+
(cc === CH_DOUBLE_QUOTE || cc === CH_SINGLE_QUOTE)
|
|
23
|
+
) {
|
|
24
|
+
if (!wrappingQuote) {
|
|
25
|
+
wrappingQuote = cc;
|
|
26
|
+
} else if (wrappingQuote === cc) {
|
|
27
|
+
wrappingQuote = 0;
|
|
28
|
+
}
|
|
29
|
+
} else if (
|
|
30
|
+
!wrappingQuote &&
|
|
31
|
+
cc === CH_OPEN_BRACE &&
|
|
32
|
+
i > 0 &&
|
|
33
|
+
input.charCodeAt(i - 1) === CH_OPEN_BRACE
|
|
34
|
+
) {
|
|
35
|
+
if (insideDoubleBracesStart !== -1) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
`Found double braces in index ${i - 1} inside other one in index ${
|
|
38
|
+
insideDoubleBracesStart - 2
|
|
39
|
+
}`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
insideDoubleBracesStart = i + 1;
|
|
43
|
+
if (i + 1 < len && input.charCodeAt(i + 1) === CH_OPEN_BRACE) {
|
|
44
|
+
i++;
|
|
45
|
+
}
|
|
46
|
+
} else if (
|
|
47
|
+
!wrappingQuote &&
|
|
48
|
+
cc === CH_CLOSE_BRACE &&
|
|
49
|
+
i > 0 &&
|
|
50
|
+
input.charCodeAt(i - 1) === CH_CLOSE_BRACE
|
|
51
|
+
) {
|
|
52
|
+
if (insideDoubleBracesStart !== -1) {
|
|
53
|
+
indices.push({ start: insideDoubleBracesStart, end: i - 1 });
|
|
54
|
+
insideDoubleBracesStart = -1;
|
|
55
|
+
if (i + 1 < len && input.charCodeAt(i + 1) === CH_CLOSE_BRACE) {
|
|
56
|
+
i++;
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
throw new Error(
|
|
60
|
+
`Found closing double braces in index ${
|
|
61
|
+
i - 1
|
|
62
|
+
} without opening double braces`
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (insideDoubleBracesStart !== -1) {
|
|
69
|
+
throw new Error(
|
|
70
|
+
`Found opening double braces in index ${
|
|
71
|
+
insideDoubleBracesStart - 2
|
|
72
|
+
} without closing double braces`
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return indices;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
module.exports = findInsideDoubleBracesIndices;
|
package/lib/template.js
CHANGED
|
@@ -1,125 +1,123 @@
|
|
|
1
|
-
const jq = require(
|
|
1
|
+
const jq = require("./jq");
|
|
2
|
+
const findInsideDoubleBracesIndices = require("./parse");
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const indices = [];
|
|
4
|
+
const CH_OPEN_BRACE = 123; // '{'
|
|
5
|
+
const CH_CLOSE_BRACE = 125; // '}'
|
|
6
|
+
const BRACE_PAIR_LEN = 2; // length of '{{' or '}}'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
const char = input[i];
|
|
8
|
+
const SPREAD_KEYWORD_PATTERN = /^\s*\{\{\s*spreadValue\(\s*\)\s*\}\}\s*$/;
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
i += 1;
|
|
14
|
-
}
|
|
15
|
-
if (insideDoubleBracesStart && (char === '"' || char === "'")) {
|
|
16
|
-
// If inside double braces and inside quotes, ignore braces
|
|
17
|
-
if (!wrappingQuote) {
|
|
18
|
-
wrappingQuote = char;
|
|
19
|
-
} else if (wrappingQuote === char) {
|
|
20
|
-
wrappingQuote = null;
|
|
21
|
-
}
|
|
22
|
-
} else if (!wrappingQuote && char === '{' && i > 0 && input[i - 1] === '{') {
|
|
23
|
-
// if opening double braces that not wrapped with quotes
|
|
24
|
-
if (insideDoubleBracesStart) {
|
|
25
|
-
throw new Error(`Found double braces in index ${i - 1} inside other one in index ${insideDoubleBracesStart - '{{'.length}`);
|
|
26
|
-
}
|
|
27
|
-
insideDoubleBracesStart = i + 1;
|
|
28
|
-
if (input[i + 1] === '{') {
|
|
29
|
-
// To overcome three "{" in a row considered as two different opening double braces
|
|
30
|
-
i += 1;
|
|
31
|
-
}
|
|
32
|
-
} else if (!wrappingQuote && char === '}' && i > 0 && input[i - 1] === '}') {
|
|
33
|
-
// if closing double braces that not wrapped with quotes
|
|
34
|
-
if (insideDoubleBracesStart) {
|
|
35
|
-
indices.push({start: insideDoubleBracesStart, end: i - 1});
|
|
36
|
-
insideDoubleBracesStart = null;
|
|
37
|
-
if (input[i + 1] === '}') {
|
|
38
|
-
// To overcome three "}" in a row considered as two different closing double braces
|
|
39
|
-
i += 1;
|
|
40
|
-
}
|
|
41
|
-
} else {
|
|
42
|
-
throw new Error(`Found closing double braces in index ${i - 1} without opening double braces`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (insideDoubleBracesStart) {
|
|
48
|
-
throw new Error(`Found opening double braces in index ${insideDoubleBracesStart - '{{'.length} without closing double braces`);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return indices;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const render = (inputJson, template, execOptions = {}) => {
|
|
55
|
-
if (typeof template !== 'string') {
|
|
10
|
+
const render = (jsonStr, template, execOptions) => {
|
|
11
|
+
if (typeof template !== "string") {
|
|
56
12
|
return null;
|
|
57
13
|
}
|
|
58
14
|
const indices = findInsideDoubleBracesIndices(template);
|
|
59
15
|
if (!indices.length) {
|
|
60
|
-
// If no jq templates in string, return it
|
|
61
16
|
return template;
|
|
62
17
|
}
|
|
63
18
|
|
|
64
19
|
const firstIndex = indices[0];
|
|
65
|
-
if (indices.length === 1
|
|
66
|
-
|
|
67
|
-
|
|
20
|
+
if (indices.length === 1) {
|
|
21
|
+
const trimmed = template.trim();
|
|
22
|
+
if (
|
|
23
|
+
trimmed.charCodeAt(0) === CH_OPEN_BRACE &&
|
|
24
|
+
trimmed.charCodeAt(1) === CH_OPEN_BRACE &&
|
|
25
|
+
trimmed.charCodeAt(trimmed.length - 1) === CH_CLOSE_BRACE &&
|
|
26
|
+
trimmed.charCodeAt(trimmed.length - BRACE_PAIR_LEN) === CH_CLOSE_BRACE
|
|
27
|
+
) {
|
|
28
|
+
return jq.execRaw(
|
|
29
|
+
jsonStr,
|
|
30
|
+
template.slice(firstIndex.start, firstIndex.end),
|
|
31
|
+
execOptions
|
|
32
|
+
);
|
|
33
|
+
}
|
|
68
34
|
}
|
|
69
35
|
|
|
70
|
-
let result = template.slice(0, firstIndex.start -
|
|
71
|
-
indices.
|
|
72
|
-
const
|
|
36
|
+
let result = template.slice(0, firstIndex.start - BRACE_PAIR_LEN);
|
|
37
|
+
for (let i = 0; i < indices.length; i++) {
|
|
38
|
+
const index = indices[i];
|
|
39
|
+
const jqResult = jq.execRaw(
|
|
40
|
+
jsonStr,
|
|
41
|
+
template.slice(index.start, index.end),
|
|
42
|
+
execOptions
|
|
43
|
+
);
|
|
73
44
|
result +=
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
45
|
+
typeof jqResult === "string" ? jqResult : JSON.stringify(jqResult);
|
|
46
|
+
result += template.slice(
|
|
47
|
+
index.end + BRACE_PAIR_LEN,
|
|
48
|
+
i + 1 === indices.length
|
|
49
|
+
? template.length
|
|
50
|
+
: indices[i + 1].start - BRACE_PAIR_LEN
|
|
51
|
+
);
|
|
52
|
+
}
|
|
82
53
|
|
|
83
54
|
return result;
|
|
84
|
-
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const renderRecursively = (inputJson, template, execOptions) => {
|
|
58
|
+
if (!execOptions) execOptions = {};
|
|
59
|
+
const jsonStr = JSON.stringify(inputJson);
|
|
60
|
+
return _renderRecursively(jsonStr, template, execOptions);
|
|
61
|
+
};
|
|
85
62
|
|
|
86
|
-
const
|
|
87
|
-
if (typeof template ===
|
|
88
|
-
return render(
|
|
63
|
+
const _renderRecursively = (jsonStr, template, execOptions) => {
|
|
64
|
+
if (typeof template === "string") {
|
|
65
|
+
return render(jsonStr, template, execOptions);
|
|
89
66
|
}
|
|
90
67
|
if (Array.isArray(template)) {
|
|
91
|
-
|
|
68
|
+
const len = template.length;
|
|
69
|
+
const result = new Array(len);
|
|
70
|
+
for (let i = 0; i < len; i++) {
|
|
71
|
+
result[i] = _renderRecursively(jsonStr, template[i], execOptions);
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
92
74
|
}
|
|
93
|
-
if (typeof template ===
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (key.trim().match(keywordMatcher)) {
|
|
100
|
-
const evaluatedValue = renderRecursively(inputJson, value, execOptions);
|
|
101
|
-
if (typeof evaluatedValue !== "object") {
|
|
102
|
-
throw new Error(
|
|
103
|
-
`Evaluated value should be an object if the key is ${key}. Original value: ${value}, evaluated to: ${JSON.stringify(evaluatedValue)}`
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
return Object.entries(evaluatedValue);
|
|
107
|
-
}
|
|
75
|
+
if (typeof template === "object" && template !== null) {
|
|
76
|
+
const keys = Object.keys(template);
|
|
77
|
+
const result = {};
|
|
78
|
+
for (let i = 0; i < keys.length; i++) {
|
|
79
|
+
const key = keys[i];
|
|
80
|
+
const value = template[key];
|
|
108
81
|
|
|
109
|
-
|
|
110
|
-
|
|
82
|
+
if (SPREAD_KEYWORD_PATTERN.test(key)) {
|
|
83
|
+
const evaluatedValue = _renderRecursively(jsonStr, value, execOptions);
|
|
84
|
+
if (typeof evaluatedValue !== "object") {
|
|
111
85
|
throw new Error(
|
|
112
|
-
`Evaluated
|
|
86
|
+
`Evaluated value should be an object if the key is ${key}. Original value: ${value}, evaluated to: ${JSON.stringify(
|
|
87
|
+
evaluatedValue
|
|
88
|
+
)}`
|
|
113
89
|
);
|
|
114
90
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
91
|
+
const spreadKeys = Object.keys(evaluatedValue);
|
|
92
|
+
for (let j = 0; j < spreadKeys.length; j++) {
|
|
93
|
+
result[spreadKeys[j]] = evaluatedValue[spreadKeys[j]];
|
|
94
|
+
}
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const evaluatedKey = _renderRecursively(jsonStr, key, execOptions);
|
|
99
|
+
const keyType = typeof evaluatedKey;
|
|
100
|
+
if (
|
|
101
|
+
keyType !== "undefined" &&
|
|
102
|
+
keyType !== "string" &&
|
|
103
|
+
evaluatedKey !== null
|
|
104
|
+
) {
|
|
105
|
+
throw new Error(
|
|
106
|
+
`Evaluated object key should be undefined, null or string. Original key: ${key}, evaluated to: ${JSON.stringify(
|
|
107
|
+
evaluatedKey
|
|
108
|
+
)}`
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
if (evaluatedKey) {
|
|
112
|
+
result[evaluatedKey] = _renderRecursively(jsonStr, value, execOptions);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return result;
|
|
118
116
|
}
|
|
119
117
|
|
|
120
118
|
return template;
|
|
121
|
-
}
|
|
119
|
+
};
|
|
122
120
|
|
|
123
121
|
module.exports = {
|
|
124
|
-
renderRecursively
|
|
122
|
+
renderRecursively,
|
|
125
123
|
};
|
package/lib/templateAsync.js
CHANGED
|
@@ -1,129 +1,145 @@
|
|
|
1
|
-
const jq = require(
|
|
1
|
+
const jq = require("./jq");
|
|
2
|
+
const findInsideDoubleBracesIndices = require("./parse");
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
+
const CH_OPEN_BRACE = 123; // '{'
|
|
5
|
+
const CH_CLOSE_BRACE = 125; // '}'
|
|
6
|
+
const BRACE_PAIR_LEN = 2; // length of '{{' or '}}'
|
|
4
7
|
|
|
5
|
-
const
|
|
6
|
-
let wrappingQuote = null;
|
|
7
|
-
let insideDoubleBracesStart = null;
|
|
8
|
-
const indices = [];
|
|
8
|
+
const SPREAD_KEYWORD_PATTERN = /^\s*\{\{\s*spreadValue\(\s*\)\s*\}\}\s*$/;
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (insideDoubleBracesStart && char === '\\') {
|
|
14
|
-
// If next character is escaped, skip it
|
|
15
|
-
i += 1;
|
|
16
|
-
}
|
|
17
|
-
if (insideDoubleBracesStart && (char === '"' || char === "'")) {
|
|
18
|
-
// If inside double braces and inside quotes, ignore braces
|
|
19
|
-
if (!wrappingQuote) {
|
|
20
|
-
wrappingQuote = char;
|
|
21
|
-
} else if (wrappingQuote === char) {
|
|
22
|
-
wrappingQuote = null;
|
|
23
|
-
}
|
|
24
|
-
} else if (!wrappingQuote && char === '{' && i > 0 && input[i - 1] === '{') {
|
|
25
|
-
// if opening double braces that not wrapped with quotes
|
|
26
|
-
if (insideDoubleBracesStart) {
|
|
27
|
-
throw new Error(`Found double braces in index ${i - 1} inside other one in index ${insideDoubleBracesStart - '{{'.length}`);
|
|
28
|
-
}
|
|
29
|
-
insideDoubleBracesStart = i + 1;
|
|
30
|
-
if (input[i + 1] === '{') {
|
|
31
|
-
// To overcome three "{" in a row considered as two different opening double braces
|
|
32
|
-
i += 1;
|
|
33
|
-
}
|
|
34
|
-
} else if (!wrappingQuote && char === '}' && i > 0 && input[i - 1] === '}') {
|
|
35
|
-
// if closing double braces that not wrapped with quotes
|
|
36
|
-
if (insideDoubleBracesStart) {
|
|
37
|
-
indices.push({start: insideDoubleBracesStart, end: i - 1});
|
|
38
|
-
insideDoubleBracesStart = null;
|
|
39
|
-
if (input[i + 1] === '}') {
|
|
40
|
-
// To overcome three "}" in a row considered as two different closing double braces
|
|
41
|
-
i += 1;
|
|
42
|
-
}
|
|
43
|
-
} else {
|
|
44
|
-
throw new Error(`Found closing double braces in index ${i - 1} without opening double braces`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (insideDoubleBracesStart) {
|
|
50
|
-
throw new Error(`Found opening double braces in index ${insideDoubleBracesStart - '{{'.length} without closing double braces`);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return indices;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const renderAsync =async (inputJson, template, execOptions = {}) => {
|
|
57
|
-
if (typeof template !== 'string') {
|
|
10
|
+
const renderAsync = async (jsonStr, template, execOptions) => {
|
|
11
|
+
if (typeof template !== "string") {
|
|
58
12
|
return null;
|
|
59
13
|
}
|
|
60
14
|
const indices = findInsideDoubleBracesIndices(template);
|
|
61
15
|
if (!indices.length) {
|
|
62
|
-
// If no jq templates in string, return it
|
|
63
16
|
return template;
|
|
64
17
|
}
|
|
65
18
|
|
|
66
19
|
const firstIndex = indices[0];
|
|
67
|
-
if (indices.length === 1
|
|
68
|
-
|
|
69
|
-
|
|
20
|
+
if (indices.length === 1) {
|
|
21
|
+
const trimmed = template.trim();
|
|
22
|
+
if (
|
|
23
|
+
trimmed.charCodeAt(0) === CH_OPEN_BRACE &&
|
|
24
|
+
trimmed.charCodeAt(1) === CH_OPEN_BRACE &&
|
|
25
|
+
trimmed.charCodeAt(trimmed.length - 1) === CH_CLOSE_BRACE &&
|
|
26
|
+
trimmed.charCodeAt(trimmed.length - BRACE_PAIR_LEN) === CH_CLOSE_BRACE
|
|
27
|
+
) {
|
|
28
|
+
return jq.execRawAsync(
|
|
29
|
+
jsonStr,
|
|
30
|
+
template.slice(firstIndex.start, firstIndex.end),
|
|
31
|
+
execOptions
|
|
32
|
+
);
|
|
33
|
+
}
|
|
70
34
|
}
|
|
71
35
|
|
|
72
|
-
let result = template.slice(0, firstIndex.start -
|
|
36
|
+
let result = template.slice(0, firstIndex.start - BRACE_PAIR_LEN);
|
|
73
37
|
for (let i = 0; i < indices.length; i++) {
|
|
74
38
|
const index = indices[i];
|
|
75
|
-
const jqResult = await jq.
|
|
39
|
+
const jqResult = await jq.execRawAsync(
|
|
40
|
+
jsonStr,
|
|
41
|
+
template.slice(index.start, index.end),
|
|
42
|
+
execOptions
|
|
43
|
+
);
|
|
76
44
|
result +=
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
45
|
+
typeof jqResult === "string" ? jqResult : JSON.stringify(jqResult);
|
|
46
|
+
result += template.slice(
|
|
47
|
+
index.end + BRACE_PAIR_LEN,
|
|
48
|
+
i + 1 === indices.length
|
|
49
|
+
? template.length
|
|
50
|
+
: indices[i + 1].start - BRACE_PAIR_LEN
|
|
51
|
+
);
|
|
52
|
+
}
|
|
85
53
|
|
|
86
54
|
return result;
|
|
87
|
-
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const renderRecursivelyAsync = async (inputJson, template, execOptions) => {
|
|
58
|
+
if (!execOptions) execOptions = {};
|
|
59
|
+
const jsonStr = JSON.stringify(inputJson);
|
|
60
|
+
return _renderRecursivelyAsync(jsonStr, template, execOptions);
|
|
61
|
+
};
|
|
88
62
|
|
|
89
|
-
const
|
|
90
|
-
if (typeof template ===
|
|
91
|
-
return renderAsync(
|
|
63
|
+
const _renderRecursivelyAsync = async (jsonStr, template, execOptions) => {
|
|
64
|
+
if (typeof template === "string") {
|
|
65
|
+
return renderAsync(jsonStr, template, execOptions);
|
|
92
66
|
}
|
|
93
67
|
if (Array.isArray(template)) {
|
|
94
|
-
|
|
68
|
+
const len = template.length;
|
|
69
|
+
const promises = new Array(len);
|
|
70
|
+
for (let i = 0; i < len; i++) {
|
|
71
|
+
promises[i] = _renderRecursivelyAsync(jsonStr, template[i], execOptions);
|
|
72
|
+
}
|
|
73
|
+
return Promise.all(promises);
|
|
95
74
|
}
|
|
96
|
-
if (typeof template ===
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
`Evaluated object key should be undefined, null or string. Original key: ${key}, evaluated to: ${JSON.stringify(evaluatedKey)}`,
|
|
113
|
-
);
|
|
75
|
+
if (typeof template === "object" && template !== null) {
|
|
76
|
+
const keys = Object.keys(template);
|
|
77
|
+
const len = keys.length;
|
|
78
|
+
const promises = new Array(len);
|
|
79
|
+
for (let i = 0; i < len; i++) {
|
|
80
|
+
const key = keys[i];
|
|
81
|
+
promises[i] = _processKeyAsync(jsonStr, key, template[key], execOptions);
|
|
82
|
+
}
|
|
83
|
+
const entries = await Promise.all(promises);
|
|
84
|
+
const result = {};
|
|
85
|
+
for (let i = 0; i < entries.length; i++) {
|
|
86
|
+
const entry = entries[i];
|
|
87
|
+
if (entry) {
|
|
88
|
+
const pairs = entry.pairs;
|
|
89
|
+
for (let j = 0; j < pairs.length; j++) {
|
|
90
|
+
result[pairs[j][0]] = pairs[j][1];
|
|
114
91
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return Object.fromEntries((await Promise.all(t)).flat());
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
120
96
|
|
|
97
|
+
return template;
|
|
98
|
+
};
|
|
121
99
|
|
|
100
|
+
const _processKeyAsync = async (jsonStr, key, value, execOptions) => {
|
|
101
|
+
if (SPREAD_KEYWORD_PATTERN.test(key)) {
|
|
102
|
+
const evaluatedValue = await _renderRecursivelyAsync(
|
|
103
|
+
jsonStr,
|
|
104
|
+
value,
|
|
105
|
+
execOptions
|
|
106
|
+
);
|
|
107
|
+
if (typeof evaluatedValue !== "object") {
|
|
108
|
+
throw new Error(
|
|
109
|
+
`Evaluated value should be an object if the key is ${key}. Original value: ${value}, evaluated to: ${JSON.stringify(
|
|
110
|
+
evaluatedValue
|
|
111
|
+
)}`
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
const spreadKeys = Object.keys(evaluatedValue);
|
|
115
|
+
const pairs = new Array(spreadKeys.length);
|
|
116
|
+
for (let i = 0; i < spreadKeys.length; i++) {
|
|
117
|
+
pairs[i] = [spreadKeys[i], evaluatedValue[spreadKeys[i]]];
|
|
118
|
+
}
|
|
119
|
+
return { pairs };
|
|
122
120
|
}
|
|
123
121
|
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
const evaluatedKey = await _renderRecursivelyAsync(jsonStr, key, execOptions);
|
|
123
|
+
if (typeof evaluatedKey !== "string" && evaluatedKey != null) {
|
|
124
|
+
throw new Error(
|
|
125
|
+
`Evaluated object key should be undefined, null or string. Original key: ${key}, evaluated to: ${JSON.stringify(
|
|
126
|
+
evaluatedKey
|
|
127
|
+
)}`
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
if (evaluatedKey) {
|
|
131
|
+
return {
|
|
132
|
+
pairs: [
|
|
133
|
+
[
|
|
134
|
+
evaluatedKey,
|
|
135
|
+
await _renderRecursivelyAsync(jsonStr, value, execOptions),
|
|
136
|
+
],
|
|
137
|
+
],
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
return null;
|
|
141
|
+
};
|
|
126
142
|
|
|
127
143
|
module.exports = {
|
|
128
|
-
renderRecursivelyAsync
|
|
144
|
+
renderRecursivelyAsync,
|
|
129
145
|
};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@port-labs/jq-node-bindings",
|
|
3
|
-
"version": "v1.0.
|
|
3
|
+
"version": "v1.1.0-dev.1",
|
|
4
4
|
"description": "Node.js bindings for JQ",
|
|
5
|
-
"jq-node-bindings": "1.0
|
|
5
|
+
"jq-node-bindings": "v1.1.0-dev",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"configure": "node-gyp configure",
|
|
@@ -44,4 +44,4 @@
|
|
|
44
44
|
"engines": {
|
|
45
45
|
"node": ">=6.0.0"
|
|
46
46
|
}
|
|
47
|
-
}
|
|
47
|
+
}
|