mesg-foundation / js-sdk Goto Github PK
View Code? Open in Web Editor NEWJavascript mono-repo with all the tools to interact with MESG
Home Page: https://mesg.com
Javascript mono-repo with all the tools to interact with MESG
Home Page: https://mesg.com
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
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";
Related to mesg-foundation/engine#1350
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\""
The version 2.1.0 was published on NPM but not tagged in the repository
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
Implement modif of mesg-foundation/engine#1473
Related to issue https://github.com/mesg-foundation/mesg-js/issues/147
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
And do the changelog
Implement modif of mesg-foundation/engine#1473
current output of daemon:logs
when engine is not running is empty:
$ ./bin/run daemon:status
Engine is... stopped
$ ./bin/run daemon:logs
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.
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
Currently, the generated docs doesn't show that an input or output is repeated.
Related to mesg-foundation/explorer#28
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
related to mesg-foundation/engine#1358
*:*
- 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 beforedaemon: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 columnservice:list
- no error|warning on invalid column to sort/display (flags --sort
--columns
) oclif/cli-ux#115service:list
- support --cvs
format but cli dosen't need it, do it?service:list
- no support --json
service:list
- flag --no-truncate
dose not workservice:list
- flag --extended
do nothing, so it should be removed. There is no extra column to displayservice: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 linerservcie:compile
- no option for get source
from ipfsservice:doc
- extra empty lines between header task/events and tableservice:doc
- no info about possible env variables in readme https://github.com/mesg-foundation/cli/issues/23service:doc
- in alias section service:doc
is repeated - should be removed mesg-foundation/cli#89service: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 permissionservice:logs
- --no-follow
flag does not workservice:logs
- --no-tail
flag does not workservice:logs
- --task
or --events
has no option to filter multiple tasks/eventsservice:start
- missing short flag (-e
) for envsaccount:*
- 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/filesaccount:list
- has the same issues as servcie:list
- columns/sort/no-truncate/extended`account:list
- remove ls alias mesg-foundation/cli#89account: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
marketplace:publish
- running in empty directory gives unclear error " TypeError: Cannot read property 'addresses' of undefined" mesg-foundation/cli#86marketplace:*
- support -p
short flag for passpharse while account
does not mesg-foundation/cli#84marketplace:*
- can't pass --account
argument mesg-foundation/cli#88$./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
commandFor now we cannot create our service calling listenTask
multiple times and if we do we don't have any clear error message.
Solutions:
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
The cli should remove the folder containing the downloading service sources.
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.
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 :)
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.
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.
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
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.
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
I ran npm update
and it broke the test: https://circleci.com/gh/mesg-foundation/mesg-js/171
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...
Let's not start to specify how to encode every special type.
The lib should check if the function toJSON
is implemented and call it if it is. Otherwise, maybe simple call JSON.stringify
?
Function to improve:
https://github.com/mesg-foundation/mesg-js/blob/d0844fde085d3b797f076a56152a867c7dc3ac4f/src/util/encoder.ts#L3-L30
Originally posted by @NicolasMahe in https://github.com/mesg-foundation/mesg-js/pull/116/files#r309583299
The command daemon:logs
doesn't display any error when the engine is not running, it just return:
➜ cli git:(bug/log-lines) ./bin/run daemon:logs
Parse is done into float64
and it should be into big.Float
Let's make a list of stuff that depends on the v2
Remove core api when mesg-foundation/engine#1362 is done.
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
Now we use Circle CI and Github we should choose only one
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:
After we push on the tags on git we shouldn't have any manual action to do
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.
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
}
Similar to mesg-foundation/engine#739
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
The current service:doc
command displays only events and tasks with only first level parameters.
The command needs to also generate the following:
configuration
: This is useful for the user to know what can be overridden and to know how the service is "configured" by default.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
With the transition from json to proto struct, big numbers were not converted
The lib is returning an error when a task is defined in the service definition but not in the service code itself.
Is it something we want to keep?
A developer reports this on discord.
If we keep it, the error message should be way more explicit and maybe just a warning.
PR mesg-foundation/mesg-js#102 is breaking some structure definition on the Application side.
The doc should be updated to reflect it
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.