Giter Club home page Giter Club logo

fauna-shell's People

Contributors

0xflotus avatar adambollen avatar alvarofauna avatar brunoquaresma avatar cleve-fauna avatar cynicaljoy avatar danieltodonnell avatar dependabot-preview[bot] avatar dependabot[bot] avatar elersong avatar erickpintor avatar fauna-chase avatar fauna-rodrigo avatar fireridlle avatar henryfauna avatar jdcryans avatar jrodewig avatar macmv avatar macnealefauna avatar marrony avatar n400 avatar ncaudill27 avatar parkhomenko avatar ptpaterson avatar rodrimaia avatar ryancharris avatar twobitunicorn avatar wdberkeley avatar wusatosi avatar zvictor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fauna-shell's Issues

Feature request: add hook for database auth

I have my Fauna database secret keys stored in a secrets storage solution. In this case I use AWS Secrets Manager, but I could see this applying to other solutions such as Vault. It would be useful in a CI/CD or even local development environment to be able to define a script to grab the relevant secret required for the fauna shell session.

I imagine this would be like some kind of hook tied into either the $HOME/.fauna-shell configuration file or the new project configuration file. Those configuration files could point to a JS script to be used to grab the secret key authentication for the endpoint. In my CI/CD environments and local environments I have the required AWS credentials files already set up to allow for retrieving the secret.

My current workaround plan is to run a script in CI/CD to grab the secret from AWS Secrets Manager and then write that out to a temporary fauna-shell configuration file.

Fauna shell add-endpoint gives error: ECONNREFUSED

Hello,

I installed fauna shell and tried to add a new endpoint and when I run the command it gives this error: Error: Error: connect ECONNREFUSED 127.0.0.1:8433

image
I use Windows and I have run this command in cmd and PowerShell also.

I am not sure if this error has to do with fauna shell or some windows configuration but I would appreciate if you have any idea how to debug or fix this.

Thanks!

run-queries ignores dbname

Now that run-queries is an alias for eval, it ignores dbname. I know this command is deprecated but this is now a busted command with incorrect documentation.

I'm guessing the fix for this is just removing run-queries, but that doesn't support a dbname argument sadly.

Fauna shell crashes while typing

Hello,

The crashes happen once I type the . to fill the email on the login command, below the crash info:

behorse> Login(Match(Index("users_by_email), "[email protected] TypeError: Cannot read property 'length' of undefined
    at runQueries (/usr/local/Cellar/fauna-shell/0.11.5/libexec/lib/node_modules/fauna-shell/src/lib/misc.js:384:19)
behorse> /usr/local/Cellar/fauna-shell/0.11.5/libexec/lib/node_modules/fauna-shell/src/lib/misc.js:384
  if (expressions.length == 1) {
                  ^

TypeError: Cannot read property 'length' of undefined
    at runQueries (/usr/local/Cellar/fauna-shell/0.11.5/libexec/lib/node_modules/fauna-shell/src/lib/misc.js:384:19)
    at /usr/local/Cellar/fauna-shell/0.11.5/libexec/lib/node_modules/fauna-shell/src/commands/shell.js:86:16
    at finishExecution (repl.js:411:7)
    at defaultEval (repl.js:497:7)
    at bound (domain.js:426:14)
    at runBound (domain.js:439:12)
    at REPLServer.replEvalPromise [as eval] (/usr/local/Cellar/fauna-shell/0.11.5/libexec/lib/node_modules/fauna-shell/src/commands/shell.js:71:5)
    at REPLServer.complete (repl.js:1277:10)
    at REPLServer.completer (repl.js:620:14)
    at showCompletionPreview (internal/repl/utils.js:191:10)
    at showPreview (internal/repl/utils.js:328:5)
    at REPLServer.repl._refreshLine (internal/repl/utils.js:419:5)
    at REPLServer.Interface.prompt (readline.js:301:10)
    at REPLServer.displayPrompt (repl.js:1036:8)
    at Domain.debugDomainError (repl.js:597:12)
    at Domain.emit (events.js:315:20)
    at Domain.EventEmitter.emit (domain.js:482:12)
    at Domain._errorHandler (domain.js:246:23)
    at Object.<anonymous> (domain.js:156:29)
    at process._fatalException (internal/process/execution.js:164:29)

image

Versino: fauna-shell/0.11.5 darwin-x64 node-v12.17.0

Let me know if you need further info.

Eval ignoring child db argument

Hello! I'm having trouble doing an eval on a child DB:

yarn fauna eval childDB "Paginate(Collections())"
›   Error: Unexpected argument: Paginate(Collections())

This is the command from the doc. Eval works fine without the child db arg. Any ideas?

Homebrew fauna-shell 0.9.3 upgrade issue

Relates to Homebrew/homebrew-core#41662

Console log:

==> /usr/local/Cellar/fauna-shell/0.9.3/bin/fauna add-endpoint https://endpoint1:8443
Endpoint Key: 
Endpoint Alias [endpoint1]: Error: Cannot read property 'headers' of undefined
==> /usr/local/Cellar/fauna-shell/0.9.3/bin/fauna list-endpoints
Error: No endpoints defined.
See fauna add-endpoint --help for more details.

Need some help on how to use fauna add-endpoint.

You need to update the sample codes. Sample codes don't work

my_app> CreateClass({ name: "posts" })
{ ref: Class("posts"),
ts: 1532624109799742,
history_days: 30,
name: 'posts' }

CreateCollection({ name: "posts" })
{ ref: Collection("posts"),
ts: 1532624109799742,
history_days: 30,
name: 'posts' }

Replace request-promise

From request-promise github: https://github.com/request/request-promise/blob/4bc186dec9e32bdfe0c4944e50f7ad3e65bb7037/README.md

Deprecated!

As of Feb 11th 2020, request is fully deprecated. No new changes are expected to land. In fact, none have landed for some time. This package is also deprecated because it depends on request.

My recommendation would be either:

Wrong error handling and wrong `exitCode`

Description

The way errors are handled by this tool make it near impossible to build other tools or scripts on top of it in a reliable manner.
As soon as an error is thrown, the script calling fauna is broken.

Here is an example of intended behaviour, but that fails as soon as an error is thrown.

Steps to reproduce the error:

1- Copy the code below into /tmp/role.fql:

CreateRole({ name: "user",
  membership: [{ resource: Collection('User') }],
  privileges: [
    {
      resource: Function('logout'),
      actions: { call: true }
    }
  ]
})

2- Run the code below (or any code that would trigger a remote error within fauna):

npx fauna eval --format=json --file=/tmp/role.fql && echo '\nSuccess! No error code!'

Output:

{
  errors: [
    ...
    ...
  ]
}

Success! No error code!

Desired behaviour

  1. The exitCode should clearly never be 0 when the output is an error (which would then not let Success! No error code! be shown).
  2. The error message should go in the stderr but instead goes in stdout.
  3. The message has a JSON-like structure, but can't be parsed by any script because is not valid JSON.

Why is prettier not a devDependency?

Is there any reason why prettier, eslint-plugin-prettier and eslint-config-prettier are listed as normal dependencies? eslint itself is a devDependency.

fauna list-keys crashes

Running fauna list-keys crashes with:

Error: Cannot read property 'id' of undefined

Fauna shell version:

fauna-shell/0.11.5 darwin-x64 node-v12.16.2

Importing a large dataset with unique Index constraints results in missing documents

I have created a collection to store all my data (88k rows), which has MANY duplicate entries. I originally imported them all, but want to ensure that only unique rows are stored so I used an Index to create a Unique field and started with a fresh collection again, but when I import, I get the following expected error:

Warning: item numbers: 54819,54820,54821,54822 (zero-indexed) in your input file './imports/streamers.csv' failed to persist in Fauna due to: 'document is not unique.' - Continuing ...

Then this is the end result:

62158 rows/object failed to import. 26787 rows/object succeeded.

This is understandable as I would expect it to skip over any duplicates, but the rows succeeded seems awfully low. When I then query the Index after import, the document doesn't exist. I've done about 10 different searches at random, and only 2 results came back.

I reran the import with --append, and got 88742 rows/object failed to import. 203 rows/object succeeded, so it seems to be an issue with duplicate rows in the same batch?

fauna cloud-login error in 0.12.5

Ubuntu LTS 18.04
After update from fauna-shell 0.12.4 to 0.12.5, fauna cloud-login returns
SyntaxError: Unexpected token < in JSON at position 1
Rollback to 0.12.4 -> works ok.

fauna --version
fauna-shell/0.12.5 linux-x64 node-v14.17.6

fauna cloud-login
? The endpoint alias prefix (to combine with a region): cloud
? The endpoint alias already exists. Overwrite? Yes
? How do you prefer to authenticate? Email and Password
? Email address: [redacted]
? Password: [hidden]
    SyntaxError: Unexpected token < in JSON at position 1

[FE-2671] `shell` and `eval` throw error if handling error not an FaunaHTTPError

Error handling for the shell and eval commands assumes that the error contains a requestResult field. This field is only present in the FaunaHTTPError sub class. If the error is not a FaunaHTTPError, then the console output is

Cannot read properties of undefined (reading 'responseRaw')

triggered here:

util.inspect(JSON.parse(error.faunaError.requestResult.responseRaw), {

and here:

util.inspect(JSON.parse(error.faunaError.requestResult.responseRaw), {

example

An example is in the event the client handles a timeout (rather than receiving a 503 http response). In that case, the js driver returns a TimeoutError.

other notes

The runQueries function always throws a QueryError object, so checking if error is a FaunaHTTPError will always return false here

if (error instanceof faunadb.errors.FaunaHTTPError) {

though error.faunaError could be.

create-key should return its name

In addition to the value, the response should also return its name (so it will be possible to cache it for delete command)

Also won't be needed to make yet another request to list-keys (which are broken btw: #68)

list-keys broken

$ fauna list-keys 
listing keys
Error: Cannot read property 'id' of undefined

fauna-shell needs all the other optional flags

I'm trying to use fauna-shell to upload schema.graphql:

fauna upload-graphql-schema fauna/schema.graphql --domain db.us.fauna.com --secret SECRET_HERE --mode override

But I keep getting:

UPLOADING SCHEMA (mode=override): fauna/schema.graphql
    TypeError: Only HTTP(S) protocols are supported

I finally got it to work by running:

fauna upload-graphql-schema fauna/schema.graphql \
  --domain db.us.fauna.com \
  --secret asdasd \
  --mode override \
  --graphqlHost graphql.us.fauna.com \
  --scheme https \
  --graphqlPort 443

notice how I had to provide all options which were supposed to be optional -- which I think is a bug.

PS: DON'T USE --method override!! IT WILL CLEAR ALL RECORDS IN ALL YOUR COLLECTIONS, IT'S ESSENTIALLY THE SAME AS STARTING FROM SCRATCH.

FULL STORY HERE: https://forums.fauna.com/t/using-fauna-shell-to-upload-graphql-schema-for-ci-cd/2826

1.2.0 - no way to specify authentication method

With 1.1.2 I could select either credentials or secret authentication upon 1st cloud-login invocation, now 1.2.0 allows only credentials authentication. The issue is, I'm logging in to dashboard with Github auth and I don't have password.

fauna eval --file can't run multiple queries

I'd like to use fauna eval to reset my dev database by issuing some CreateCollection commands, but it doesn't seem to work, hmm.

Command: fauna eval db --file schema.fql --endpoint=localhost
Output: Error: Line 2: Unexpected identifier

schema.fql contains:

CreateCollection({ name: "patterns" })
CreateCollection({ name: "users" })

Batch delete

Hi, thanks for making fauna-shell for us.

A batch delete doesn't seem to be in fauna-shell and is not available in the web dashboard either, so I'm finding myself writing UI that fetches the data and iterates over all items in a collection should I want to clean it.

If there was a delete that could accept a wildcard in development mode that'd be awesome, or a way to drop entire collection.

Cheers!

upload-graphql-schema command prints "RESPONSE: undefined"

Problem

running fauna upload-graphql-schema prints "RESPONSE: undefined" in the console. The schema is successfully uploaded, but this console output is very confusing. I'm not sure what should be returned instead.

Env

> fauna --version

fauna-shell/0.12.6 darwin-x64 node-v16.11.1

Steps to reproduce

log in to a database. I used a secret key, rather than email+password.

> fauna cloud-login

once logged in, run the command

> fauna upload-graphql-schema ./schema.gql
UPLOADING SCHEMA (mode=merge): ./schema.gql
RESPONSE:
undefined

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.