From a1dee394ecdb548a7a882a69d934d5ae996ba95a Mon Sep 17 00:00:00 2001 From: Joel Chu Date: Mon, 22 Jul 2019 11:16:53 +0800 Subject: [PATCH 1/3] setup the server side for contract-console --- packages/contract-console/tests/fixtures/server.js | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 packages/contract-console/tests/fixtures/server.js diff --git a/packages/contract-console/tests/fixtures/server.js b/packages/contract-console/tests/fixtures/server.js new file mode 100644 index 00000000..0933d312 --- /dev/null +++ b/packages/contract-console/tests/fixtures/server.js @@ -0,0 +1,2 @@ +const serverIo = require('server-io-core') +const jsonqlKoa = require('jsonql-koa') -- Gitee From 0904f744e3ea62383250445533a4e594824fac5a Mon Sep 17 00:00:00 2001 From: Joel Chu Date: Mon, 22 Jul 2019 12:10:03 +0800 Subject: [PATCH 2/3] add a new SHOW_CONTRACT_DESC_PARAM to contants --- packages/constants/main.js | 1 + packages/constants/package.json | 2 +- packages/http-client/package.json | 2 +- packages/http-client/src/lib/base/http-cls.js | 10 ++++++++-- packages/http-client/src/lib/options/base-options.js | 4 +++- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/constants/main.js b/packages/constants/main.js index 0a8ace76..9bfda742 100644 --- a/packages/constants/main.js +++ b/packages/constants/main.js @@ -80,6 +80,7 @@ export const CLIENT_AUTH_KEY = 'authKey'; export const INDEX_KEY = 'index'; // contract key export const CONTRACT_KEY_NAME = 'X-JSONQL-CV-KEY'; +export const SHOW_CONTRACT_DESC_PARAM = {desc: 'y'}; // directories export const DEFAULT_RESOLVER_DIR = 'resolvers'; export const DEFAULT_CONTRACT_DIR = 'contracts'; diff --git a/packages/constants/package.json b/packages/constants/package.json index 52459d70..7c7d615f 100755 --- a/packages/constants/package.json +++ b/packages/constants/package.json @@ -1,6 +1,6 @@ { "name": "jsonql-constants", - "version": "1.7.8", + "version": "1.7.9", "description": "All the share constants for json:ql tools", "main": "index.js", "module": "main.js", diff --git a/packages/http-client/package.json b/packages/http-client/package.json index 418070d2..2255b4b9 100755 --- a/packages/http-client/package.json +++ b/packages/http-client/package.json @@ -1,6 +1,6 @@ { "name": "jsonql-client", - "version": "1.2.0", + "version": "1.2.1", "description": "json:ql client package for javascript using superagent", "main": "index.js", "module": "src/index.js", diff --git a/packages/http-client/src/lib/base/http-cls.js b/packages/http-client/src/lib/base/http-cls.js index a3634320..4a34102b 100644 --- a/packages/http-client/src/lib/base/http-cls.js +++ b/packages/http-client/src/lib/base/http-cls.js @@ -29,6 +29,8 @@ export default class HttpClass { this.fly = flyio; this.opts = opts; this.extraHeader = {}; + // @1.2.1 for adding query to the call on the fly + this.extraParams = {}; // run the set debug this.debug() // console.info('start up opts', opts); @@ -50,7 +52,7 @@ export default class HttpClass { */ request(payload, options = {}, headers = {}) { this.headers = headers; - let params = cacheBurst() + let params = merge({}, cacheBurst(), this.extraParams) // @TODO need to add a jsonp url and payload if (this.opts.enableJsonp) { let resolverName = getNameFromPayload(payload) @@ -132,12 +134,16 @@ export default class HttpClass { */ cleanUp() { this.extraHeader = {} + this.extraParams = {} } /** * GET for contract only */ get() { + if (this.opts.showContractDesc) { + this.extraParams = merge(this.extraParams, {desc: 'y'}) + } return this.request({}, {method: 'GET'}, this.contractHeader) .then(clientErrorsHandler) .then(result => { @@ -148,7 +154,7 @@ export default class HttpClass { if (result.cache && result.contract) { return result.contract; } - // just the normal result + // just the normal result return result }) } diff --git a/packages/http-client/src/lib/options/base-options.js b/packages/http-client/src/lib/options/base-options.js index c62f78d1..fd742749 100644 --- a/packages/http-client/src/lib/options/base-options.js +++ b/packages/http-client/src/lib/options/base-options.js @@ -50,8 +50,10 @@ export const appProps = { contractExpired: createConfig(0, [NUMBER_TYPE]),// -1 always fetch contract, // 0 never expired, // > 0 then compare the timestamp with the current one to see if we need to get contract again - // useful during development + // useful during development keepContract: createConfig(true, [BOOLEAN_TYPE]), + // @1.2.1 new option for the contract-console to fetch the contract with description + showContractDesc: createConfig(false, [BOOLEAN_TYPE]), contractKey: createConfig(false, [BOOLEAN_TYPE]), // if the server side is lock by the key you need this contractKeyName: createConfig(CONTRACT_KEY_NAME, [STRING_TYPE]), // same as above they go in pairs enableTimeout: createConfig(false, [BOOLEAN_TYPE]), // @TODO -- Gitee From 6d56f95124900e35e51ea3ea7b3f3b237e399c79 Mon Sep 17 00:00:00 2001 From: Joel Chu Date: Mon, 22 Jul 2019 12:10:44 +0800 Subject: [PATCH 3/3] jsonql-constants v1.7.9 release --- packages/constants/constants.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/constants/constants.json b/packages/constants/constants.json index 9a4a7658..30fcf7df 100644 --- a/packages/constants/constants.json +++ b/packages/constants/constants.json @@ -69,6 +69,9 @@ "CLIENT_AUTH_KEY": "authKey", "INDEX_KEY": "index", "CONTRACT_KEY_NAME": "X-JSONQL-CV-KEY", + "SHOW_CONTRACT_DESC_PARAM": { + "desc": "y" + }, "DEFAULT_RESOLVER_DIR": "resolvers", "DEFAULT_CONTRACT_DIR": "contracts", "DEFAULT_KEYS_DIR": "keys", -- Gitee