Giter Site home page Giter Site logo

jq-web's Issues

This dependency was not found: fs

Hello-

I'm trying to use this in my Vue.js app, but when I import like:

import jq from 'jq-web';

I get this error:

ERROR  Failed to compile with 1 errors

This dependency was not found:

* fs in ./node_modules/jq-web/jq.min.js

To install it, you can run: npm install --save fs

I think this is because fs is not available in a browser window. I already have fs in my package.json file and saved to node_modules.

Should I be doing something else instead? The same thing happens if I use require.

Failure to include jq files

Hello, I want to use jq-web with my own .jq files where I have defined functions. Is this possible? I have tried using:

include "migrations" {search: "$ORIGIN/../../src/migrate/internal"}; [usage of functions inside .jq]

But it fails to find the files I need.

Project dead?

Hey @fiatjaf can we assume this project is dead?

...or is it just stable because jq releases are that old?

jq-web module suddenly stops working

Hello!

I'm using the jq-web module to validate some jq expressions on my NodeJS application. Application was working as expected for a few days on K8s cluster and I validated ~1000 expressions. Then, out of nowhere, this happened.

There is an error in expression: ".IG_PKT_DROP__NO_FLOW > 0". Message: Error\n at Object.ensureErrnoError (/usr/src/app/node_modules/jq-web/jq.asm.bundle.min.js:1:1722236)\n at Object.staticInit (/usr/src/app/node_modules/jq-web/jq.asm.bundle.min.js:1:1722445)\n at /usr/src/app/node_modules/jq-web/jq.asm.bundle.min.js:1:1734039\n at Object. (/usr/src/app/node_modules/jq-web/jq.asm.bundle.min.js:1:1751789)\n at Module._compile (internal/modules/cjs/loader.js:1147:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)\n at Module.load (internal/modules/cjs/loader.js:996:32)\n at Function.Module._load (internal/modules/cjs/loader.js:896:14)\n at Module.require (internal/modules/cjs/loader.js:1036:19)\n at require (internal/modules/cjs/helpers.js:72:18)\n at Object. (/usr/src/app/jq/jq-validator.js:3:12)\n at Module._compile (internal/modules/cjs/loader.js:1147:30)\n at`` Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)\n at Module.load (internal/modules/cjs/loader.js:996:32)\n at Function.Module._load (internal/modules/cjs/loader.js:896:14)\n at Module.require (internal/modules/cjs/loader.js:1036:19)\n at require (internal/modules/cjs/helpers.js:72:18)\n at Object. (/usr/src/app/service/AggregatingAlertRuleService.js:10:21)\n at Module._compile (internal/modules/cjs/loader.js:1147:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)\n at Module.load (internal/modules/cjs/loader.js:996:32)\n at Function.Module._load (internal/modules/cjs/loader.js:896:14)

const validate = (expression, example, skipSemantic=false) => {
    let result;
    try {
        result = jq.json(example, expression);

        if (result === null) {
            return new JqInvalidResult(expression, "Expression returned no result.")
        }
    } catch (e) {
        return new JqSyntaxErrorResult(expression, e);
    }

   //other logic
}

Can you help me? I tried to go through the source code using the lines:offsets but it is all minified js code.

Cannot access full jq error details

Hello,

I recently took a look at this library and it appears that the error details are stripped a bit before being passed to the Promise.reject?

The error I get is a string of Error: 1 compile error when the error I want is the verbose error that jq would normally provide:

jq: error: syntax error, unexpected '$', expecting IDENT or __loc__ (Unix shell quoting issues?) at <top-level>, line 1:
$$ 
jq: 1 compile error

I can see that the full error is actually returned by the WASM:
Screen Shot 2019-11-02 at 5 54 44 PM

But it appears its stripped in the source maybe here?:

jq-web/post.js

Line 30 in a9b0a2d

if (errString.indexOf(':') > -1) {

With the error being stripped down it makes it pretty painful to debug issues with the JQ syntax. In my specific case users are providing them so I'd like to give somewhat helpful feedback about what they can change instead of a vague compile error string.

I think fixing this should be easy? Just don't split on the :? Let me know if I'm reading this correctly.

Upgrade path for jq 1.7

jq 1.7 has now been released.

Is there an upgrade path to getting jq-web using this new jq version?

I can't quite tell, but it looks like jq-web is using jq 1.5?

jq version?

Sorry if it's already in the repo/release info somewhere, but could you tell me which version of jq the current release uses?
Thanks.

Intermittent `<generic error, no stack>` exception using jq.promised.json

Include TypeScript types

When importing jq-web in a TypeScript project I get this error, which I then have to ignore:

Could not find a declaration file for module 'jq-web'. ./node_modules/jq-web/jq.asm.bundle.min.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/jq-web` if it exists or add a new declaration (.d.ts) file containing `declare module 'jq-web';`ts(7016)

Is it possible to add some basic types to this package?

doesn't run on Node.js

Due to a totally unexpected issue with process.platform being reported as nonexistent in the instantiation of emscripten's NODEFS, an error is thrown when jq-web is run on Node.js.

I imagine that an easy solution (already tried by me with manual compiled code editing) would be to not instantiate NODEFS in any way, but perhaps fixing the process.platform would be better.

I'm asking for help on this topic at https://groups.google.com/forum/#!topic/emscripten-discuss/Ikl3qxPoFAk

If anyone seeing this has any solution or clue to a solution it will be highly appreciated.

Sync function

Returning {} when .mem/.wasm are not loaded yet is good, but it'd be even better to have a sync call. (One that would block until the loading finished and maybe fail after a timeout)

Error message gets cut off when parsing a malformed date

Describe the bug
Error message gets cut off when applying fromdate to an empty string

To Reproduce

  1. Set a filter "" | fromdate.
  2. Get the error with the message: %SZ".

The sandbox: https://codesandbox.io/s/exciting-curie-k6yccy?file=/src/index.js

Expected behavior
The error object should have a message describing the error, for example: Date "" does not match format "%Y-%m-%dT%H:%M:%SZ"

Environment
Google Chrome Version 100.0.4896.127 (Official Build) (x86_64)
jq-web v0.5.1

Unclosed streams caused FS error after calling jq.json 2048 times.

I've got FS error after 2048 times calling jq.json.
I debugged and found unclosed streams in FS.streams caused by https://github.com/fiatjaf/jq-web/blob/master/post.js#L20.
Below code can show the error.

jq.onInitialized.addListener(()=>{
    for (var i =0;i<4098;i++) {
        console.log(jq.json({ok:i},'.'));
    }
    console.log('ok')
})

You'll get
...
{ ok: 2046 }
Error: FS error
Error: FS error
..../jq.asm.bundle1.js:122
throw ex
^

Error: abort(Error: FS error). Build with -s ASSERTIONS=1 for more info.

jq flags `-r` effect seems can't cancel between calls ?

version: release-0.5.1 jq.wasm.js

run in chrome F12.

// ------ worked well
> jq.raw('{"a":"hello"}', '.a')
< ""hello""

> jq.raw('{"a":"hello"}', '.a', ['-c'])
< ""hello""

// ------ once call with `-r`, 
> jq.raw('{"a":"hello"}', '.a', ['-r'])
< "hello"

// ------ somethings err? following call can't cancel `-r` flag
> jq.raw('{"a":"hello"}', '.a')
< "hello"

> jq.raw('{"a":"hello"}', '.a', ['-c'])
< "hello"

then refresh page,
and worked well again.

If invalid JSON is passed to jq.promised.raw all future runs an empty string

When using jq.promised.raw, if you pass an invalid <json-string> as input then all future calls to jq.promised.raw will return an empty string "".

Example:

// Pass invalid JSON in
await jq.promised.raw('{#@#}', '.');
// Result of the above is an empty string still.

// Pass in valid JSON
await jq.promised.raw('{"test":"test"}', '.');
// Result of the above is an empty string still.

This bug tripped me up but I figured out what causes it, let me know if you need more reproduction information.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.