Git Product home page Git Product logo

js-sdk's People

Contributors

aluisyo avatar antho1404 avatar dependabot-preview[bot] avatar ilgooz avatar krhubert avatar nicolasmahe avatar roms1383 avatar uivlis avatar williamzmorgan avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

js-sdk's Issues

Add logs

It could be good to add more logs like when an event is received or a task executed, that would be really helpful for development

Service definition should export `Service`

The service/index.ts should also export the class Service.

The v2 of mesg-js breaks import path:

This import path doesn't work:

import Service from "mesg-js/lib/service"

it have to be replaced by:

import Service from "mesg-js/lib/service/service";

I suggest to export the service in service/index.ts to be able to import it like any other type:

import { Service, TaskInputs, TaskOutputs } from "mesg-js/lib/service";

File:
https://github.com/mesg-foundation/mesg-js/blob/94236fa5e8d845022774d26e4db3531d1e35a50b/src/service/index.ts#L20-L29

Command core start should wait for all system service to be deployed

The command core start should wait for all system service to be deployed and for the gRPC server to be up and running.

➜  ./mesg-core start
✔ Core started
➜  ./mesg-core logs
time="2019-04-26T07:11:15Z" level=info msg="Deploying service \"ethwallet\" from \"http://ipfs.app.mesg.com:8080/ipfs/QmcZXaVaZbzQ8nPfohwmjVdoWvut3HAtDHyv2cScwxdcnE\""

Tag version 2.1.0

The version 2.1.0 was published on NPM but not tagged in the repository

Do not publish src folder and useless files!

Current content of archive v4.0.0

npm notice === Tarball Contents === 
npm notice 1.3kB  package.json                       
npm notice 5.2kB  CHANGELOG.md                       
npm notice 186B   codecov.yml                        
npm notice 557B   copy-proto                         
npm notice 11.3kB LICENSE                            
npm notice 10.0kB logo.svg                           
npm notice 8.5kB  README.md                          
npm notice 535B   tsconfig-istanbul.json             
npm notice 508B   tsconfig.json                      
npm notice 387B   .circleci/config.yml               
npm notice 232B   .github/main.workflow              
npm notice 132B   lib/api/index.d.ts                 
npm notice 1.9kB  lib/api/index.js                   
npm notice 1.7kB  lib/api/index.js.map               
npm notice 609B   lib/api/mock.d.ts                  
npm notice 2.2kB  lib/api/mock.js                    
npm notice 2.1kB  lib/api/mock.js.map                
npm notice 4.9kB  lib/api/types.d.ts                 
npm notice 577B   lib/api/types.js                   
npm notice 269B   lib/api/types.js.map               
npm notice 636B   lib/application/application.d.ts   
npm notice 2.4kB  lib/application/application.js     
npm notice 1.7kB  lib/application/application.js.map 
npm notice 221B   lib/application/index.d.ts         
npm notice 508B   lib/application/index.js           
npm notice 433B   lib/application/index.js.map       
npm notice 107B   lib/index.d.ts                     
npm notice 276B   lib/index.js                       
npm notice 173B   lib/index.js.map                   
npm notice 1.3kB  lib/protobuf/api/core.proto        
npm notice 1.4kB  lib/protobuf/api/event.proto       
npm notice 2.5kB  lib/protobuf/api/execution.proto   
npm notice 2.0kB  lib/protobuf/api/instance.proto    
npm notice 2.4kB  lib/protobuf/api/service.proto     
npm notice 448B   lib/protobuf/types/event.proto     
npm notice 1.6kB  lib/protobuf/types/execution.proto 
npm notice 217B   lib/protobuf/types/instance.proto  
npm notice 3.6kB  lib/protobuf/types/service.proto   
npm notice 177B   lib/service/index.d.ts             
npm notice 645B   lib/service/index.js               
npm notice 582B   lib/service/index.js.map           
npm notice 725B   lib/service/service.d.ts           
npm notice 6.1kB  lib/service/service.js             
npm notice 2.4kB  lib/service/service.js.map         
npm notice 793B   lib/util/grpc.d.ts                 
npm notice 1.2kB  lib/util/grpc.js                   
npm notice 1.0kB  lib/util/grpc.js.map               
npm notice 2.8kB  src/api/index.ts                   
npm notice 1.7kB  src/api/mock.ts                    
npm notice 4.2kB  src/api/types.ts                   
npm notice 4.2kB  src/application/application_test.ts
npm notice 1.9kB  src/application/application.ts     
npm notice 405B   src/application/index.ts           
npm notice 108B   src/index.ts                       
npm notice 1.3kB  src/protobuf/api/core.proto        
npm notice 1.4kB  src/protobuf/api/event.proto       
npm notice 2.5kB  src/protobuf/api/execution.proto   
npm notice 2.0kB  src/protobuf/api/instance.proto    
npm notice 2.4kB  src/protobuf/api/service.proto     
npm notice 448B   src/protobuf/types/event.proto     
npm notice 1.6kB  src/protobuf/types/execution.proto 
npm notice 217B   src/protobuf/types/instance.proto  
npm notice 3.6kB  src/protobuf/types/service.proto   
npm notice 532B   src/service/index.ts               
npm notice 3.8kB  src/service/service_test.ts        
npm notice 2.5kB  src/service/service.ts             
npm notice 670B   src/util/grpc_test.ts              
npm notice 1.9kB  src/util/grpc.ts    

Remove deprecated warning on the daemon commands

Every daemon command display the same deprecated warning:

(node:32944) [DEP0123] DeprecationWarning: Setting the TLS ServerName to an IP address is not permitted by RFC 6066. This will be ignored in a future version.

This might be related to docker-machine and might not occurs with normal installation of the engine

Update Hash type from string to bytes

Because of mesg-foundation/engine#1270, hashes are now in bytes instead of string over the gRPC API.
The lib needs to be updated to reflect it.

The hashes should still be display to the user as base58 but also parsed from base58.
So it would make sense to add helpers function directly in the lib.

The marketplace service is using base-x to convert buffer to and from base58.

Better management of the credentials

For now, all APIs have an optional credential object. Some APIs don't even implement the credential system and some other like service.create require it.

We should have more granularity and put this argument as required when it is and remove it when it's not useful

Command proposition doesn't work

When entering the a command with a typo, the cli is proposing the correct one, but there is no way to confirm it...

I enter y and the command just exit:

➜  cli git:(fix/error-response) ./bin/run service:log marketplace
 ›   Warning: service:log is not a mesg-cli command.
Did you mean service:logs? [y/n]: 
Did you mean service:logs? [y/n]: 
Did you mean service:logs? [y/n]: y

Ux cli desing improvment/errors

  • *:* - parse flags fails when given before arguments
  • *:* - print help for command: - for example when someone type cli service it prints help for service subcommands, but service: gives warning oclif/plugin-help#42
./bin/run service:
 ›   Warning: service: is not a mesg-cli command.
Did you mean service:rm? [y/n]: 
 ›   Error: Run mesg-cli help service for a list of available commands.
  • *:* - a suggestion for invalid command is displayed only for few seconds oclif/plugin-not-found#29
  • *:* - use only lower|upper case letter when start flags help description mesg-foundation/cli#90
  • *:* - use ... for one or more arguments (see: http://docopt.org/) mesg-foundation/cli#91
  • *:* - UnhandledPromiseRejectionWarning probably on all api calls. you can test it by setting iptables to drop traffic to ipfs.app.mesg.com or to localhost:50052
  • *:* - remove --silent option and leave only -q|--quiet or vice versa mesg-foundation/cli#92
  • *:* - do not make --quiet as gobal flag - pass it only for commands that can make use of it
  • *:* - --quiet - no help description mesg-foundation/cli#92
  • *:* - replace --confirm flag with -y|--yes as it's more common
  • *:* - s/Are you sure?:/Are you sure [y/n]?/ - remove : + add options to choose https://github.com/mesg-foundation/cli/issues/73
  • *:* - print default value for argument/flag after the description, not before
  • *:* - print required info for argument/flag after the description, not before
  • daemon:logs - print logs from the begging, but should print from moment it was called (and in general should have more flags like service:logs has)
  • service:list - flag descirption --sort=sort - key should be renamed to column
  • service:list - no error|warning on invalid column to sort/display (flags --sort --columns) oclif/cli-ux#115
  • service:list - support --cvs format but cli dosen't need it, do it?
  • service:list - no support --json
  • service:list - flag --no-truncate dose not work
  • service:list - flag --extended do nothing, so it should be removed. There is no extra column to display
  • service:dev - hit ctrl+c when service run a long time or on engine exit
(node:12917) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit
  • service:dev - no cleanup handler on error
./bin/run service:dev ../test-service                                 
Create service... 39PfjfnVWSnNLFGc6jdwr88PZ6dbFfToTeiH84GdtxgV
Start instance... 4bNBqmJQoGKdHbtdY6Dtushy1aMdnLDtnA1U4EBt35Vr
Error: cannot ...
./bin/run service:dev ../test-service
Create service... !
Error: 2 UNKNOWN: service "39PfjfnVWSnNLFGc6jdwr88PZ6dbFfToTeiH84GdtxgV" already exists
  • servcie:compile - missing option --oneline for printing json as one liner
  • servcie:compile - no option for get source from ipfs
  • service:doc - extra empty lines between header task/events and table
  • service:doc - no info about possible env variables in readme https://github.com/mesg-foundation/cli/issues/23
  • service:doc - in alias section service:doc is repeated - should be removed mesg-foundation/cli#89
  • service:doc - update command description to "Generate the documentation for the service" (remove the part about readme file, because it just works with --save flag)
  • service:doc - update --save flag description to "save documentation to README.md`
  • service:doc - --save overwrites an existing README.md without permission
  • service:logs - --no-follow flag does not work
  • service:logs - --no-tail flag does not work
  • service:logs - --task or --events has no option to filter multiple tasks/events
  • service:start - missing short flag (-e) for envs
  • account:* - try to invoce command with --help flag passed at the end (last one) - should display help message https://github.com/mesg-foundation/cli/pull/84/files
  • account:list - has the same issues as servcie:list - columns/sort/no-truncate/extended`
  • account:list - remove ls alias mesg-foundation/cli#89
  • account:create - can't specify passpharse flag - mesg-foundation/cli#84
./bin/run --passphrase=1234 account:create
 ›   Warning: --passphrase=1234 is not a mesg-cli command.
Did you mean account:export? [y/n]: ^C
./bin/run account:create --passphrase=1234
 ›   Error: Unexpected argument: --passphrase=1234
 ›   See more help with --help
$./bin/run marketplace:publish -a 0x00bfd8604654210a52833fdf946d5c78f13e4ffc ../test-service
 ›   Error: Unexpected arguments: 0x00bfd8604654210a52833fdf946d5c78f13e4ffc, ../test-service
 ›   See more help with --help
$ ./bin/run marketplace:publish ../test-service -a 0x00bfd8604654210a52833fdf946d5c78f13e4ffc                
 ›   Error: Unexpected arguments: -a, 0x00bfd8604654210a52833fdf946d5c78f13e4ffc
 ›   See more help with --help
  • instance:* - missing commands to manage instances - service:start|service:stop|service:logs should be moved under instance command

ListenTask cannot be called twice

For now we cannot create our service calling listenTask multiple times and if we do we don't have any clear error message.

Solutions:

  • Support multiple call
  • Do not support multiple calls but have a better documentation about it and a error message to let the user know that multiple calls are not possible

More user friendly message from `service logs` when service is stopped

If there is no service

➜  core git:(benchmark/service) ✗ ./dev-cli service logs generator
rpc error: code = Unknown desc = database: service generator not found

If service is stopped

➜  core git:(benchmark/service) ✗ ./dev-cli service logs generator
rpc error: code = Unknown desc = Error response from daemon: service core-38c7311fabcd9b51e36f7bc33f725ff2be6fd502-prometheus not found

Could be replaced with service generator is stopped

Add friendly user message at the end of install

When users install the CLI they should be guided to all the resources they need with a friendly message at the end of the installation.

Example of such an install message for nuxt.

nuxt install

In our case, we could have something like we initially had on the website while doing a curl

███╗   ███╗███████╗███████╗ ██████╗ 
████╗ ████║██╔════╝██╔════╝██╔════╝ 
██╔████╔██║█████╗  ███████╗██║  ███╗
██║╚██╔╝██║██╔══╝  ╚════██║██║   ██║
██║ ╚═╝ ██║███████╗███████║╚██████╔╝
╚═╝     ╚═╝╚══════╝╚══════╝ ╚═════╝ 

Website: https://mesg.com
Documentation: https://docs.mesg.com
Github: https://github.com/mesg-foundation
Forum: https://forum.mesg.com
Discord: https://discord.gg/wmjYzmh

HAPPY CODING :)

Protofiles not updated

The proto for the core api is obsolete, it has the workflow api that is not in the core anymore and it is missing the Info api that is not yet deployed but will be on the next version.

Add tags for the generated content of the command gen-doc

Command gen-doc is great but it overwrites any existing README.md.

Could you add surrounding tags for the generated content of the command gen-doc ?
This way the content can be seamlessly updated in a specific part of the README.

Issue when installing on Linux (on DigitalOcean)

After a fresh install of node on DigitalOcean I can't install the mesg-cli

root@marketplace-service:~# npm i -g mesg-cli
/usr/bin/mesg-cli -> /usr/lib/node_modules/mesg-cli/bin/run

> [email protected] install /usr/lib/node_modules/mesg-cli/node_modules/secp256k1
> npm run rebuild || echo "Secp256k1 bindings compilation fail. Pure JS implementation will be used."

npm ERR! path /root/.npm/_logs
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall scandir
npm ERR! Error: EACCES: permission denied, scandir '/root/.npm/_logs'
npm ERR!  { [Error: EACCES: permission denied, scandir '/root/.npm/_logs']
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, scandir \'/root/.npm/_logs\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'scandir',
npm ERR!   path: '/root/.npm/_logs' }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
glob error { [Error: EACCES: permission denied, scandir '/root/.npm/_logs']
  stack:
   'Error: EACCES: permission denied, scandir \'/root/.npm/_logs\'',
  errno: -13,
  code: 'EACCES',
  syscall: 'scandir',
  path: '/root/.npm/_logs' }

> [email protected] rebuild /usr/lib/node_modules/mesg-cli/node_modules/secp256k1
> node-gyp rebuild

gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/10.16.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/mesg-cli/node_modules/secp256k1/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/mesg-cli/node_modules/secp256k1/.node-gyp'
gyp ERR! System Linux 4.15.0-46-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/lib/node_modules/mesg-cli/node_modules/secp256k1
gyp ERR! node -v v10.16.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] rebuild: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Secp256k1 bindings compilation fail. Pure JS implementation will be used.

> [email protected] install /usr/lib/node_modules/mesg-cli/node_modules/ursa-optional
> node rebuild.js

ursaNative bindings compilation fail. This is not an issue. Modules that depend on it will use fallbacks.
fs.js:114
    throw err;
    ^

Error: EACCES: permission denied, open './stdout.log'
    at Object.openSync (fs.js:443:3)
    at Object.writeFileSync (fs.js:1194:35)
    at Object.<anonymous> (/usr/lib/node_modules/mesg-cli/node_modules/ursa-optional/rebuild.js:13:10)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
    at startup (internal/bootstrap/node.js:283:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node rebuild.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-06-16T13_32_15_041Z-debug.log

Improve boolean question

The questions that ask for a confirmation (boolean yes / no) doesn't show the possible answer:

Ready to send a transaction to 0x0C6e8d0eC4770fDa8A56CD912392d2ff14822952 with the account 0x350091623d8acaf424c5c584c37744749ac2a514?

they should.

Resolve service hash

The CLI is able to resolve the instanceHash based on a sid, it could be good to also have the resolution of the instanceHash based on the serviceHash and SID

Create a test command

We can already run tests with npm test but it's a bit complicated

"pretest": "mesg-cli daemon:start && mesg-cli service:create \"$(mesg-cli service:compile ./)\" --start",
"test": "mocha,
"posttest": "mesg-cli daemon:stop",

We could add a new set of commands service:test:start and service:test:stop to start the test environment with the right config, maybe we pre-generated accounts etc...

Better CI and release process

Similar to https://github.com/mesg-foundation/mesg-js/issues/118:

I released a version 4.2.1 with the CI and the version was published but without the sources.
The CI should be able to publish with the sources.

The workflow should be the following:

  • Increase version (manually or with npm version)
  • Create a tag with the version
  • Push the tag on Github
  • The CI test the sources
  • The CI build the sources
  • The CI publish the version with the build

After we push on the tags on git we shouldn't have any manual action to do

Choose CI

Now we use Circle CI and Github we should choose only one

Better CI and release process

I released a version 4.2.1 with the CI and the version was published but without the sources.
The CI should be able to publish with the sources.

The workflow should be the following:

  • Increase version (manually or with npm version)
  • Create a tag with the version
  • Push the tag on Github
  • The CI test the sources
  • The CI build the sources
  • The CI publish the version with the build

After we push on the tags on git we shouldn't have any manual action to do

Arguments not read when passed after flags

Commands now work correctly when using the format

mesg-cli command ...ARGS --flags

but not when using the format

mesg-cli command --flags ...ARGS

This should be flexible and we should accept both format.

Service output, add error when output function is called without object

In a service, if the output function is called without parameter, the error is not explanatory.
The lib should check for this and return a nice error.

export default async (inputs: TaskInputs, outputs: TaskOutputs): Promise<void> => {
    return outputs.success() // forgot to put return something
}

Add validation on the compilation

Service compilation command should validate the data from the yaml first and then compile the data. With this validation, we could enable a command service:validate

Improve command service:doc

The current service:doc command displays only events and tasks with only first level parameters.

The command needs to also generate the following:

  • Environmental variables from the configuration: This is useful for the user to know what can be overridden and to know how the service is "configured" by default.
  • List attributes (repeated): For the different data (event, inputs, outputs), we need to be able to display that the attribute is actually repeated or no.
  • Nested data: For the different data (event, inputs, outputs), when the type is Object and the object property is defined, we need to display the nested data.

The API documentation could be used as a guideline to display the List and Nested data

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.