diff --git a/packages/@jsonql/client/README.md b/packages/@jsonql/client/README.md index 8f93fc36f698ce3d37b38ce823d3e57fdff01309..3c685fb3ab7f70d8abf0459c378fd40616aec434 100644 --- a/packages/@jsonql/client/README.md +++ b/packages/@jsonql/client/README.md @@ -1,7 +1,13 @@ # @jsonql/client -> This is jsonql browser client with socket client, for pure HTTP client please use @jsonql/http-client +> This is jsonql browser client comes with jsonql-client (http) and optional socket clients + +## Example + +Coming soon --- +https://jsonql.org + NEWBRAN LTD UK & T01SOURCE CN diff --git a/packages/@jsonql/client/index.js b/packages/@jsonql/client/index.js new file mode 100644 index 0000000000000000000000000000000000000000..06189780a8f5a9dee80d5e90d86b1b5f50cc270f --- /dev/null +++ b/packages/@jsonql/client/index.js @@ -0,0 +1,2 @@ +// this is the default export entry point +import jsonqlClient from 'jsonql-client/module' diff --git a/packages/@jsonql/client/package.json b/packages/@jsonql/client/package.json index 0807de539a71f188d2e147e48c6dfb8355686c07..e6fa570ad552b8732502d7e279e508984a3cb098 100644 --- a/packages/@jsonql/client/package.json +++ b/packages/@jsonql/client/package.json @@ -2,7 +2,7 @@ "name": "@jsonql/client", "version": "0.1.0", "description": "jsonql js http client for browser with socket client, for pure Http client please use @jsonql/http-client", - "main": "dist/jsonql-client.umd.js", + "main": "dist/jsonql-client.cjs.js", "module": "index.js", "browser": "dist/jsonql-client.umd.js", "files": [ @@ -49,10 +49,12 @@ }, "license": "MIT", "dependencies": { - + "jsonql-client": "^1.4.0" + }, + "optionalDependencies": { + "jsonql-ws-client": "^1.3.3" }, "devDependencies": { - "@jsonql/koa": "^0.2.6", "ava": "^2.4.0", "browser-env": "^3.2.6", "debug": "^4.1.1", diff --git a/packages/@jsonql/client/rollup.config.js b/packages/@jsonql/client/rollup.config.js new file mode 100644 index 0000000000000000000000000000000000000000..a73ef6dc33eb109727e25d72b24a3fa7dd7a9df4 --- /dev/null +++ b/packages/@jsonql/client/rollup.config.js @@ -0,0 +1,95 @@ +/** + * Rollup config for building the slim version + */ +import { join } from 'path' +import buble from 'rollup-plugin-buble' +import { terser } from "rollup-plugin-terser" +import replace from 'rollup-plugin-replace' +import commonjs from 'rollup-plugin-commonjs' +import nodeResolve from 'rollup-plugin-node-resolve' +import nodeGlobals from 'rollup-plugin-node-globals' +import builtins from 'rollup-plugin-node-builtins' +import size from 'rollup-plugin-bundle-size' +import async from 'rollup-plugin-async' + +import pkg from './package.json' + +const env = process.env.NODE_ENV; +const target = process.env.TARGET; // 1.4.0 add new prop to control the build + +let plugins = [ + buble({ + objectAssign: 'Object.assign' + }), + nodeResolve({ + preferBuiltins: true, + mainFields: ['module', 'browser'] + }), + commonjs({ + include: 'node_modules/**' + }), + nodeGlobals(), + builtins(), + async(), + replace({ + 'process.env.NODE_ENV': JSON.stringify('production'), + '__VERSION__': pkg.version + }) +] + +let globals = { + 'debug': 'debug', + 'promise-polyfill': 'Promise', + 'flyio': 'Fly' +} +let external = [ + 'flyio', + 'debug', + 'fetch', + 'Promise', + 'promise-polyfill', + 'superagent', + 'handlebars', + 'tty' +] +let moduleName = 'jsonqlClient' +let sourceFile = 'index.js' +let distFile = 'core.js' +switch (target) { + case 'BROWSER': + sourceFile = 'full.js' + distFile = join('dist', 'jsonql-client.umd.js') + break; + case 'STATIC': + moduleName = 'jsonqlClientStatic' + sourceFile = join('src', 'static.js') + distFile = 'static.js' + break; + case 'FULL': + moduleName = 'jsonqlClientStatic' + sourceFile = join('src', 'static-full.js') + distFile = join('dist', 'jsonql-client.static.js') + break; + default: + sourceFile = 'index.js' + +} +if (env === 'production') { + plugins.push(terser()) +} +plugins.push(size()) + +let config = { + input: join(__dirname, sourceFile), + output: { + name: moduleName, + file: join(__dirname, distFile), + format: 'umd', + sourcemap: true, + globals + }, + plugins, + external +} + +export default config diff --git a/packages/@jsonql/client/static.js b/packages/@jsonql/client/static.js new file mode 100644 index 0000000000000000000000000000000000000000..728bf310ff42bb69aef28e88dd04c0df55155ff1 --- /dev/null +++ b/packages/@jsonql/client/static.js @@ -0,0 +1 @@ +// this will export the static version diff --git a/packages/@jsonql/client/tests/auth.test.js b/packages/@jsonql/client/tests/auth.test.js new file mode 100644 index 0000000000000000000000000000000000000000..fab0ac3d8b95112cdabd8ae8d65cdddeb080d20b --- /dev/null +++ b/packages/@jsonql/client/tests/auth.test.js @@ -0,0 +1,6 @@ +// test the basic static connection with already existed token +const test = require('ava') + +test.todo(`It should able to connect to the backend with existing token`) + +test.todo(`Socket client should able to connect to the existing backend using the same token from http client`) diff --git a/packages/@jsonql/client/tests/basic.test.js b/packages/@jsonql/client/tests/basic.test.js new file mode 100644 index 0000000000000000000000000000000000000000..ea017ce00407066e4a8d264f924831084af92960 --- /dev/null +++ b/packages/@jsonql/client/tests/basic.test.js @@ -0,0 +1,5 @@ +// basic test to check if the socket client get included +const test = require('ava') + + +test.todo(`The client should also have a socket client included`) diff --git a/packages/@jsonql/client/tests/login.test.js b/packages/@jsonql/client/tests/login.test.js new file mode 100644 index 0000000000000000000000000000000000000000..4dfe0c36e9258e0fce192d59fc11eb59e49f989c --- /dev/null +++ b/packages/@jsonql/client/tests/login.test.js @@ -0,0 +1,6 @@ +// e2e test to see if we can call the login and make both client authorized +const test = require('ava') + +test.todo(`It should not able to call the private method because its not login yet`) + +test.todo(`It should able to call the login method and authorized both the http and socket client`) diff --git a/packages/http-client/module.js b/packages/http-client/module.js index 396c662a567d43e654d2d4a8bf2a1a07b911bd79..9d116f15c1db8c0330e4b9c39fe08145c12efcca 100644 --- a/packages/http-client/module.js +++ b/packages/http-client/module.js @@ -23,13 +23,14 @@ const initSocketClient = function(client, contract, config, socketClient) { } /** + * @1.4.1 change to name export * When pass a static contract then it return a static interface * otherwise it will become the async interface * @param {object} Fly the http engine * @param {object} config configuration * @return {object} jsonqlClient */ -export default function jsonqlClient(Fly, config) { +export function jsonqlClient(Fly, config) { // @NOTE we pass the socket client via the config, that save us the headache to try to dynamicly load the dep const { contract, socketClient, debugOn } = config; const ee = getEventEmitter(debugOn) diff --git a/packages/http-client/package.json b/packages/http-client/package.json index 032421774eeda62439207b46711052a8e2b00025..e02fa970d51a8127dc0330f2501d3afa46a87b4c 100755 --- a/packages/http-client/package.json +++ b/packages/http-client/package.json @@ -1,6 +1,6 @@ { "name": "jsonql-client", - "version": "1.4.0", + "version": "1.4.1", "description": "jsonql http browser client using Fly.js", "main": "core.js", "module": "index.js",