From c4607fc4f7002d52d98b7008a3a1584de368fc6f Mon Sep 17 00:00:00 2001 From: joelchu Date: Mon, 18 Nov 2019 13:31:39 +0800 Subject: [PATCH 01/14] rename the init.js to init-dir.js to make more sense --- packages/@jsonql/koa/package.json | 4 ++-- packages/@jsonql/koa/src/index.js | 4 ++-- packages/@jsonql/koa/src/{init.js => init-dir.js} | 1 + packages/koa/src/middlewares/public-method-middleware.js | 3 ++- 4 files changed, 7 insertions(+), 5 deletions(-) rename packages/@jsonql/koa/src/{init.js => init-dir.js} (89%) diff --git a/packages/@jsonql/koa/package.json b/packages/@jsonql/koa/package.json index ce31e5f2..2794c625 100644 --- a/packages/@jsonql/koa/package.json +++ b/packages/@jsonql/koa/package.json @@ -7,7 +7,7 @@ "test": "ava --verbose", "test:basic": "DEBUG=jsonql-koa* ava --verbose ./tests/basic.test.js", "test:auth": "DEBUG=jsonql-* ava --verbose ./tests/auth.test.js", - "test:socket": "DEBUG=jsonql-koa*,jsonql-ws* ava --verbose ./tests/socket.test.js", + "test:socket": "DEBUG=jsonql-* ava --verbose ./tests/socket.test.js", "test:ms": "DEBUG=jsonql-koa* ava --verbose ./tests/ms.test.js", "test:cli": "DEBUG=jsonql-koa* node ./cli.js" }, @@ -53,7 +53,7 @@ "debug": "^4.1.1", "fs-extra": "^8.1.0", "jsonql-constants": "^1.8.10", - "jsonql-koa": "^1.4.12", + "jsonql-koa": "^1.4.13", "jsonql-params-validator": "^1.4.11", "koa": "^2.11.0", "koa-bodyparser": "^4.2.1", diff --git a/packages/@jsonql/koa/src/index.js b/packages/@jsonql/koa/src/index.js index 72262572..f872b1e2 100644 --- a/packages/@jsonql/koa/src/index.js +++ b/packages/@jsonql/koa/src/index.js @@ -3,8 +3,8 @@ const http = require('http') const Koa = require('koa') const bodyparser = require('koa-bodyparser') const cors = require('koa-cors') -// const { jsonqlKoa } = require('../../../koa/main') -const { jsonqlKoa } = require('jsonql-koa') +const { jsonqlKoa } = require('../../../koa/main') +// const { jsonqlKoa } = require('jsonql-koa') const { getSocketServer } = require('./get-socket-server') /** diff --git a/packages/@jsonql/koa/src/init.js b/packages/@jsonql/koa/src/init-dir.js similarity index 89% rename from packages/@jsonql/koa/src/init.js rename to packages/@jsonql/koa/src/init-dir.js index 29408a92..cab2a0a9 100644 --- a/packages/@jsonql/koa/src/init.js +++ b/packages/@jsonql/koa/src/init-dir.js @@ -1,3 +1,4 @@ +// init the project structure // when run for the first time, check those important folder exists or not // if not exist (especially resolver directory) then we run this init and create the structure // for the developer diff --git a/packages/koa/src/middlewares/public-method-middleware.js b/packages/koa/src/middlewares/public-method-middleware.js index 801dedfd..f682bc48 100644 --- a/packages/koa/src/middlewares/public-method-middleware.js +++ b/packages/koa/src/middlewares/public-method-middleware.js @@ -19,7 +19,8 @@ export default function publicMethodMiddleware(opts) { return resolveMethod(ctx, resolverType, opts, contract) } } else if (resolverType === AUTH_TYPE && resolverName === opts.loginHandlerName) { - debug(`This is an auth ${opts.loginHandlerName} call`) + debug(`This is an auth [${opts.loginHandlerName}] call`, contract) + // ctx, resolverName, payload, opts, contract return handleAuthMethods(ctx, resolverName, payload, opts, contract) } } -- Gitee From be98df0ffdaac4c8f94133b6982b94246d6a11af Mon Sep 17 00:00:00 2001 From: joelchu Date: Mon, 18 Nov 2019 13:34:28 +0800 Subject: [PATCH 02/14] point the jsonql-ws-server to the local dev version during debuggin --- packages/@jsonql/koa/src/get-socket-server.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/@jsonql/koa/src/get-socket-server.js b/packages/@jsonql/koa/src/get-socket-server.js index 670d0300..8459e681 100644 --- a/packages/@jsonql/koa/src/get-socket-server.js +++ b/packages/@jsonql/koa/src/get-socket-server.js @@ -10,7 +10,8 @@ function getSocketServer(config, server) { if (config.serverType) { switch (config.serverType) { case JS_WS_NAME: - const { jsonqlWsServer } = require('jsonql-ws-server') + // @NOTE replace the module name later jsonql-ws-server + const { jsonqlWsServer } = require('../../../ws-server') wsServer = jsonqlWsServer break; case JS_WS_SOCKET_IO_NAME: -- Gitee From f74e5e52f5dbd90b256dfcbb947c4a2137737826 Mon Sep 17 00:00:00 2001 From: joelchu Date: Mon, 18 Nov 2019 13:51:26 +0800 Subject: [PATCH 03/14] since we dont use default export therefore the file name should follow the function name to make it easier to find --- packages/@jsonql/koa/index.js | 2 +- packages/@jsonql/koa/src/{index.js => init-server.js} | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) rename packages/@jsonql/koa/src/{index.js => init-server.js} (89%) diff --git a/packages/@jsonql/koa/index.js b/packages/@jsonql/koa/index.js index b5a487d7..3fe031d5 100644 --- a/packages/@jsonql/koa/index.js +++ b/packages/@jsonql/koa/index.js @@ -1,7 +1,7 @@ // main const debug = require('debug')('jsonql-koa:main') const checkOptions = require('./src/options') -const { initServer } = require('./src') +const { initServer } = require('./src/init-server') const { version } = require('./package.json') let started = false; /** diff --git a/packages/@jsonql/koa/src/index.js b/packages/@jsonql/koa/src/init-server.js similarity index 89% rename from packages/@jsonql/koa/src/index.js rename to packages/@jsonql/koa/src/init-server.js index f872b1e2..6b2d4e96 100644 --- a/packages/@jsonql/koa/src/index.js +++ b/packages/@jsonql/koa/src/init-server.js @@ -4,8 +4,9 @@ const Koa = require('koa') const bodyparser = require('koa-bodyparser') const cors = require('koa-cors') const { jsonqlKoa } = require('../../../koa/main') -// const { jsonqlKoa } = require('jsonql-koa') +// const { jsonqlKoa } = require('jsonql-koa') const { getSocketServer } = require('./get-socket-server') +const debug = require('debug')('jsonql-koa:init-server') /** * @param {object} config configuration -- Gitee From 5fd1387f09de40ac386a8b4caaaf22c2780a281d Mon Sep 17 00:00:00 2001 From: joelchu Date: Mon, 18 Nov 2019 14:15:46 +0800 Subject: [PATCH 04/14] moving the things around inside the init-middleware --- packages/@jsonql/koa/src/init-server.js | 4 +- .../contract/socket-keys/privateKey.pem | 15 + .../contract/socket-keys/publicKey.pem | 6 + .../fixtures/contract/socket/contract.json | 305 ++++++++++++++++++ .../contract/socket/public-contract.json | 287 ++++++++++++++++ .../koa/src/contracts/process-contract.js | 2 +- .../src/middlewares/contract-middleware.js | 6 +- .../koa/src/middlewares/init-middleware.js | 67 +--- .../middlewares/public-method-middleware.js | 2 + packages/koa/src/options/options.js | 6 +- 10 files changed, 634 insertions(+), 66 deletions(-) create mode 100644 packages/@jsonql/koa/tests/fixtures/contract/socket-keys/privateKey.pem create mode 100644 packages/@jsonql/koa/tests/fixtures/contract/socket-keys/publicKey.pem create mode 100644 packages/@jsonql/koa/tests/fixtures/contract/socket/contract.json create mode 100644 packages/@jsonql/koa/tests/fixtures/contract/socket/public-contract.json diff --git a/packages/@jsonql/koa/src/init-server.js b/packages/@jsonql/koa/src/init-server.js index 6b2d4e96..1e4ea508 100644 --- a/packages/@jsonql/koa/src/init-server.js +++ b/packages/@jsonql/koa/src/init-server.js @@ -6,7 +6,7 @@ const cors = require('koa-cors') const { jsonqlKoa } = require('../../../koa/main') // const { jsonqlKoa } = require('jsonql-koa') const { getSocketServer } = require('./get-socket-server') -const debug = require('debug')('jsonql-koa:init-server') +// const debug = require('debug')('jsonql-koa:init-server') /** * @param {object} config configuration @@ -28,6 +28,8 @@ function initServer(config, middlewares) { const server = http.createServer(app.callback()) + // debug('config for socket server', config) + const ws = getSocketServer(config, server) // return it return { server, app, ws } diff --git a/packages/@jsonql/koa/tests/fixtures/contract/socket-keys/privateKey.pem b/packages/@jsonql/koa/tests/fixtures/contract/socket-keys/privateKey.pem new file mode 100644 index 00000000..e7a1bcc6 --- /dev/null +++ b/packages/@jsonql/koa/tests/fixtures/contract/socket-keys/privateKey.pem @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICXgIBAAKBgQCn+OM/ttUkDvsQuioEjBNo0ZqvFDjU0P0U9xFnC0xEFX3QE8Mv +54UyymL/ReVxOFhHK4lN431uugVmPqIzmAa/wdxb/6APX4dF/Bfkb4y8yxDH11Ur ++8GpMz8cRCzkwlS1ZTseJalVP6MeLPotT0cK6Rmpl2Ixg4xqpgayzcXi/QIDAQAB +AoGBAKSWy04OQBGiID8Gu89S1l36LMDrZriZw7M8WTAIMQXxrSMrijGxgaIAEDsk +aSuk01OBhHvusmTCIDJMozE9ATZjfCwohBTLuum8FCrx4DtCOGDtsPjwEnw2Q6a8 +0gLYfdDA54rPKTyCVpwzy7Dx9gRYhNv8e0U+NHlHEqjBYNt9AkEA3JmRwqVZfLkl +ZhuNc0BNwQ/rCnNWcld9AmxB3UnE2MwD5qNJ3Sj7Q+DF6veb55JTllFpLSzfy9rb +t2nhbCeJ1wJBAMLtVEV8TEC8YbBtre00fYpEE/gPZq84ii5YN4lGjo4Z8JwQYK0m +5GNKqQ/vrVTxEwCbqCRN5JsJL/Gnjd69Z0sCQQCUG+M6PUvcqm4KpRsOMzFBGw/i +f1eeA1FiLA74pMuuByPjWOSBwT8Z7rLTNBWPn7XRKa2k8Aj91F5KQaNguxcXAkBI +MT2UvoQ/NYW4oeZYg6g7HRuIM6wEGRyULXfkD42cc175bddgSZcsbupOTKYVX3N6 +Niv/xhl0keJ/zV5tsBghAkEAo6NOvUlyCErWgJWFwPnuwpkRer1Lu9x1ECynXutc +VVwl6qXYmd9ySF1kTx0kfE/MdYPO28EmXRm0Guy3hnGuJQ== +-----END RSA PRIVATE KEY----- diff --git a/packages/@jsonql/koa/tests/fixtures/contract/socket-keys/publicKey.pem b/packages/@jsonql/koa/tests/fixtures/contract/socket-keys/publicKey.pem new file mode 100644 index 00000000..97b3b45d --- /dev/null +++ b/packages/@jsonql/koa/tests/fixtures/contract/socket-keys/publicKey.pem @@ -0,0 +1,6 @@ +-----BEGIN PUBLIC KEY----- +MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCn+OM/ttUkDvsQuioEjBNo0Zqv +FDjU0P0U9xFnC0xEFX3QE8Mv54UyymL/ReVxOFhHK4lN431uugVmPqIzmAa/wdxb +/6APX4dF/Bfkb4y8yxDH11Ur+8GpMz8cRCzkwlS1ZTseJalVP6MeLPotT0cK6Rmp +l2Ixg4xqpgayzcXi/QIDAQAB +-----END PUBLIC KEY----- diff --git a/packages/@jsonql/koa/tests/fixtures/contract/socket/contract.json b/packages/@jsonql/koa/tests/fixtures/contract/socket/contract.json new file mode 100644 index 00000000..5360f6b7 --- /dev/null +++ b/packages/@jsonql/koa/tests/fixtures/contract/socket/contract.json @@ -0,0 +1,305 @@ +{ + "query": { + "causeError": { + "file": "/home/joel/projects/open-source/jsonql/packages/@jsonql/koa/tests/fixtures/resolvers/query/cause-error.js", + "description": false, + "params": [ + { + "type": [ + "any" + ], + "name": "x", + "description": "param" + } + ], + "returns": [ + { + "type": [ + "any" + ], + "description": "unknown" + } + ] + }, + "getUser": { + "file": "/home/joel/projects/open-source/jsonql/packages/@jsonql/koa/tests/fixtures/resolvers/query/get-user.js", + "description": "This use a spread as parameter", + "params": [ + { + "type": [ + "string" + ], + "name": "args", + "variable": true, + "description": "passing unknown number of param" + } + ], + "returns": [ + { + "type": [ + "any" + ], + "description": "extract from last of the args" + } + ] + }, + "getSecretMsg": { + "file": "/home/joel/projects/open-source/jsonql/packages/@jsonql/koa/tests/fixtures/resolvers/query/private/get-secret-msg.js", + "description": "a hidden private method", + "params": [], + "returns": [ + { + "type": [ + "string" + ], + "description": "a secret message" + } + ] + }, + "alwaysAvailable": { + "public": true, + "file": "/home/joel/projects/open-source/jsonql/packages/@jsonql/koa/tests/fixtures/resolvers/query/public/always-available.js", + "description": "This is a public method that is always available", + "params": [], + "returns": [ + { + "type": [ + "string" + ], + "description": "a message" + } + ] + }, + "testList": { + "file": "/home/joel/projects/open-source/jsonql/packages/@jsonql/koa/tests/fixtures/resolvers/query/test-list.js", + "description": false, + "params": [ + { + "type": [ + "number" + ], + "name": "num", + "description": "a number" + } + ], + "returns": [ + { + "type": [ + "object" + ], + "description": "@TODO need to figure out how to give keys to the returns" + } + ] + } + }, + "mutation": { + "updateList": { + "file": "/home/joel/projects/open-source/jsonql/packages/@jsonql/koa/tests/fixtures/resolvers/mutation/update-list.js", + "description": false, + "params": [ + { + "type": [ + "object" + ], + "name": "payload", + "keys": [ + { + "type": [ + "number" + ], + "name": "user", + "parent": "payload" + } + ] + }, + { + "type": [ + "object" + ], + "name": "condition" + } + ], + "returns": [ + { + "type": [ + "object" + ], + "description": "with user as key" + } + ] + } + }, + "auth": { + "login": { + "file": "/home/joel/projects/open-source/jsonql/packages/@jsonql/koa/tests/fixtures/resolvers/auth/login.js", + "description": "login method", + "params": [ + { + "type": [ + "string" + ], + "name": "name", + "description": "give it a name" + } + ], + "returns": [ + { + "type": [ + "object" + ], + "description": "a userdata object with timestamp" + } + ] + } + }, + "timestamp": 1574056345, + "sourceType": "script", + "socket": { + "causeError": { + "namespace": "jsonql/private", + "file": "/home/joel/projects/open-source/jsonql/packages/@jsonql/koa/tests/fixtures/resolvers/socket/cause-error.js", + "description": false, + "params": [ + { + "type": [ + "string" + ], + "name": "msg", + "description": "a message" + } + ], + "returns": [ + { + "type": [ + "string" + ], + "description": "a message but here we throw an error" + } + ] + }, + "chatroom": { + "namespace": "jsonql/private", + "file": "/home/joel/projects/open-source/jsonql/packages/@jsonql/koa/tests/fixtures/resolvers/socket/chatroom.js", + "description": false, + "params": [ + { + "type": [ + "string" + ], + "name": "msg", + "description": "message" + }, + { + "type": [ + "number" + ], + "name": "timestamp", + "description": "for checking the time" + } + ], + "returns": [ + { + "type": [ + "string" + ], + "description": "reply" + } + ] + }, + "delayFn": { + "namespace": "jsonql/private", + "file": "/home/joel/projects/open-source/jsonql/packages/@jsonql/koa/tests/fixtures/resolvers/socket/delay-fn.js", + "description": false, + "params": [ + { + "type": [ + "string" + ], + "name": "msg", + "description": "a message" + }, + { + "type": [ + "number" + ], + "name": "timestamp", + "description": "a timestamp" + } + ], + "returns": false + }, + "secretChatroom": { + "namespace": "jsonql/private", + "file": "/home/joel/projects/open-source/jsonql/packages/@jsonql/koa/tests/fixtures/resolvers/socket/private/secret-chatroom.js", + "description": false, + "params": [ + { + "type": [ + "string" + ], + "name": "room", + "description": "room name" + }, + { + "type": [ + "any" + ], + "name": "msg", + "description": "message to that room" + } + ], + "returns": [ + { + "type": [ + "any" + ], + "description": "depends" + } + ] + }, + "availableToEveryone": { + "namespace": "jsonql/public", + "public": true, + "file": "/home/joel/projects/open-source/jsonql/packages/@jsonql/koa/tests/fixtures/resolvers/socket/public/available-to-everyone/index.js", + "description": "There is no parameter require for this call", + "params": [], + "returns": [ + { + "type": [ + "string" + ], + "description": "a message" + } + ] + }, + "wsHandler": { + "namespace": "jsonql/private", + "file": "/home/joel/projects/open-source/jsonql/packages/@jsonql/koa/tests/fixtures/resolvers/socket/ws-handler.js", + "description": "method just for testing the ws", + "params": [ + { + "type": [ + "string" + ], + "name": "msg", + "description": "message" + }, + { + "type": [ + "number" + ], + "name": "timestamp", + "description": "timestamp" + } + ], + "returns": [ + { + "type": [ + "string" + ], + "description": "msg + time lapsed" + } + ] + } + } +} diff --git a/packages/@jsonql/koa/tests/fixtures/contract/socket/public-contract.json b/packages/@jsonql/koa/tests/fixtures/contract/socket/public-contract.json new file mode 100644 index 00000000..6e20a64e --- /dev/null +++ b/packages/@jsonql/koa/tests/fixtures/contract/socket/public-contract.json @@ -0,0 +1,287 @@ +{ + "query": { + "helloWorld": { + "params": [], + "returns": [ + { + "type": "string", + "description": "stock message" + } + ] + }, + "causeError": { + "params": [ + { + "type": [ + "any" + ], + "name": "x", + "description": "param" + } + ], + "returns": [ + { + "type": [ + "any" + ], + "description": "unknown" + } + ] + }, + "getUser": { + "params": [ + { + "type": [ + "string" + ], + "name": "args", + "variable": true, + "description": "passing unknown number of param" + } + ], + "returns": [ + { + "type": [ + "any" + ], + "description": "extract from last of the args" + } + ] + }, + "getSecretMsg": { + "params": [], + "returns": [ + { + "type": [ + "string" + ], + "description": "a secret message" + } + ] + }, + "alwaysAvailable": { + "public": true, + "params": [], + "returns": [ + { + "type": [ + "string" + ], + "description": "a message" + } + ] + }, + "testList": { + "params": [ + { + "type": [ + "number" + ], + "name": "num", + "description": "a number" + } + ], + "returns": [ + { + "type": [ + "object" + ], + "description": "@TODO need to figure out how to give keys to the returns" + } + ] + } + }, + "mutation": { + "updateList": { + "params": [ + { + "type": [ + "object" + ], + "name": "payload", + "keys": [ + { + "type": [ + "number" + ], + "name": "user", + "parent": "payload" + } + ] + }, + { + "type": [ + "object" + ], + "name": "condition" + } + ], + "returns": [ + { + "type": [ + "object" + ], + "description": "with user as key" + } + ] + } + }, + "auth": { + "login": { + "params": [ + { + "type": [ + "string" + ], + "name": "name", + "description": "give it a name" + } + ], + "returns": [ + { + "type": [ + "object" + ], + "description": "a userdata object with timestamp" + } + ] + } + }, + "timestamp": 1574056345, + "socket": { + "causeError": { + "namespace": "jsonql/private", + "params": [ + { + "type": [ + "string" + ], + "name": "msg", + "description": "a message" + } + ], + "returns": [ + { + "type": [ + "string" + ], + "description": "a message but here we throw an error" + } + ] + }, + "chatroom": { + "namespace": "jsonql/private", + "params": [ + { + "type": [ + "string" + ], + "name": "msg", + "description": "message" + }, + { + "type": [ + "number" + ], + "name": "timestamp", + "description": "for checking the time" + } + ], + "returns": [ + { + "type": [ + "string" + ], + "description": "reply" + } + ] + }, + "delayFn": { + "namespace": "jsonql/private", + "params": [ + { + "type": [ + "string" + ], + "name": "msg", + "description": "a message" + }, + { + "type": [ + "number" + ], + "name": "timestamp", + "description": "a timestamp" + } + ], + "returns": false + }, + "secretChatroom": { + "namespace": "jsonql/private", + "params": [ + { + "type": [ + "string" + ], + "name": "room", + "description": "room name" + }, + { + "type": [ + "any" + ], + "name": "msg", + "description": "message to that room" + } + ], + "returns": [ + { + "type": [ + "any" + ], + "description": "depends" + } + ] + }, + "availableToEveryone": { + "namespace": "jsonql/public", + "public": true, + "params": [], + "returns": [ + { + "type": [ + "string" + ], + "description": "a message" + } + ] + }, + "wsHandler": { + "namespace": "jsonql/private", + "params": [ + { + "type": [ + "string" + ], + "name": "msg", + "description": "message" + }, + { + "type": [ + "number" + ], + "name": "timestamp", + "description": "timestamp" + } + ], + "returns": [ + { + "type": [ + "string" + ], + "description": "msg + time lapsed" + } + ] + } + } +} diff --git a/packages/koa/src/contracts/process-contract.js b/packages/koa/src/contracts/process-contract.js index 076f1a6f..b5fe754a 100644 --- a/packages/koa/src/contracts/process-contract.js +++ b/packages/koa/src/contracts/process-contract.js @@ -28,8 +28,8 @@ export default function processContract(ctx, opts) { .then(c => { if (!c) { if (!ctx.state.jsonql.contract && opts.initContract && opts.initContract.then) { - debug('calling the initContract to get the contract') return opts.initContract.then(c => { + debug('calling the initContract to get the contract', c) // disable the cache for the time being // setter('contract', c) return c; diff --git a/packages/koa/src/middlewares/contract-middleware.js b/packages/koa/src/middlewares/contract-middleware.js index e144c4a8..09806ab3 100644 --- a/packages/koa/src/middlewares/contract-middleware.js +++ b/packages/koa/src/middlewares/contract-middleware.js @@ -1,7 +1,5 @@ -// This is the first part of the middlewares that try to work out the contract -// the reason is, it will get re-use by subsequences middlewares -// so we might as well do this here -// Also we could hijack it off and serve the html files up for documentation purpose +// This is ONLY for serving up the contract +// the processing contract for internal use is in the init middleware import { CONTRACT_NAME } from 'jsonql-constants' import { getContract, handleContract, contractAuth } from '../contracts' import { getDebug, ctxErrorHandler } from '../utils' diff --git a/packages/koa/src/middlewares/init-middleware.js b/packages/koa/src/middlewares/init-middleware.js index f325e033..d7c09395 100644 --- a/packages/koa/src/middlewares/init-middleware.js +++ b/packages/koa/src/middlewares/init-middleware.js @@ -1,78 +1,28 @@ // this will be the first part of the middleware that checkout the // headers and request and extract the parts that we need for the operation import { - inArray, getDebug, isJsonqlRequest, - isObject, ctxErrorHandler, processJwtKeys, getQueryFromPayload, getMutationFromPayload } from '../utils' import { - AUTH_TYPE, QUERY_NAME, MUTATION_NAME, CONTRACT_NAME, - CONTRACT_REQUEST_METHODS, - API_REQUEST_METHODS, - PAYLOAD_PARAM_NAME, - CONDITION_PARAM_NAME, - RESOLVER_PARAM_NAME, - JSONP_CALLBACK_NAME + RESOLVER_PARAM_NAME } from 'jsonql-constants' -import { Jsonql406Error } from 'jsonql-errors' import processContract from '../contracts/process-contract' -// should move to the utils as well +import { + getBaseResolverType, + isAuthType, + isJsonpCall +} from '../utils/init-middleware-helpers' const debug = getDebug('init-middleware') -/** - * Just figure out what is the calling methods here - * @param {object} ctx koa context - * @return {*} false on unknown - */ -const getBaseResolverType = function(ctx) { - const [ POST, PUT ] = API_REQUEST_METHODS; - const { method } = ctx; - switch (true) { - case inArray(CONTRACT_REQUEST_METHODS, method): - return CONTRACT_NAME; - case method === POST: - return QUERY_NAME; - case method === PUT: - return MUTATION_NAME; - } -} - -/** - * check if it is auth type - * @param {string} type we need this to be the QUERY_TYPE - * @param {string} name from ctx.request.body to find the issuer name present or not - * @param {object} opts config we need that to find the custom names - */ -const isAuthType = function(type, name, opts) { - const { logoutHandlerName, loginHandlerName } = opts; - const AUTH_TYPE_METHODS = [loginHandlerName, logoutHandlerName] - if (type === QUERY_NAME) { - return inArray(AUTH_TYPE_METHODS, name) ? AUTH_TYPE : type; - } - return type; -} - -/** - * new in v1.3.0 jsonp handler - * @param {object} ctx koa context - * @return {boolean|string} return resolverName or false when its not - */ -const isJsonpCall = function(ctx) { - if (ctx.query && ctx.query[JSONP_CALLBACK_NAME]) { - return ctx.query[JSONP_CALLBACK_NAME] - } - return false; -} - /** * v1.2.0 add setter and getter and store in the ctx for use later * @param {object} opts configuration @@ -92,7 +42,10 @@ export default function initMiddleware(opts) { ctx.state.jsonql.isReq = isJsonql; if (isJsonql) { // its only call once - ctx.state.jsonql.contract = await processContract(ctx, opts) + let __contract__ = await processContract(ctx, opts) + // @NOTE see if this works or not to make sure the contract prop is not writable + ctx.state.jsonql = injectToFn(ctx.state.jsonql, 'contract', __contract__) + // v1.2.0 grabbing the public / private keys opts = await processJwtKeys(ctx, opts) // debug('processJwtKeys', opts) diff --git a/packages/koa/src/middlewares/public-method-middleware.js b/packages/koa/src/middlewares/public-method-middleware.js index f682bc48..64e0a081 100644 --- a/packages/koa/src/middlewares/public-method-middleware.js +++ b/packages/koa/src/middlewares/public-method-middleware.js @@ -19,6 +19,8 @@ export default function publicMethodMiddleware(opts) { return resolveMethod(ctx, resolverType, opts, contract) } } else if (resolverType === AUTH_TYPE && resolverName === opts.loginHandlerName) { + // @BUG some how the contract here becomes true instead of an object + // somewhere changed it! debug(`This is an auth [${opts.loginHandlerName}] call`, contract) // ctx, resolverName, payload, opts, contract return handleAuthMethods(ctx, resolverName, payload, opts, contract) diff --git a/packages/koa/src/options/options.js b/packages/koa/src/options/options.js index b904ad4e..99546645 100644 --- a/packages/koa/src/options/options.js +++ b/packages/koa/src/options/options.js @@ -40,15 +40,15 @@ import { const dirname = process.cwd() // @TODO we need to create the same fn to clear out the options like I did in server-io-core const constProps = { - // __checked__: true, we don't do this here, see index.js + // __checked__: true, we don't do this here, see index.js contentType: CONTENT_TYPE, contract: false, initContract: false, useDoc: true, returnAs: RETURN_AS_JSON, privateKey: false, - publicKey: false, - initJwtKeys: false + publicKey: false + // initJwtKeys: false // this is not use see below for the constant key } const appProps = { -- Gitee From 15724ca3770ba1e7dadb0198cd4a83e58fd27ef4 Mon Sep 17 00:00:00 2001 From: joelchu Date: Mon, 18 Nov 2019 14:16:10 +0800 Subject: [PATCH 05/14] move everything out from the init-middleware and put them int the init-middleware-helpers --- .../koa/src/utils/init-middleware-helpers.js | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 packages/koa/src/utils/init-middleware-helpers.js diff --git a/packages/koa/src/utils/init-middleware-helpers.js b/packages/koa/src/utils/init-middleware-helpers.js new file mode 100644 index 00000000..75c33ba5 --- /dev/null +++ b/packages/koa/src/utils/init-middleware-helpers.js @@ -0,0 +1,75 @@ +// move all the functions in the init-middleware here to keep it clean + +import { + inArray, + getDebug, + isJsonqlRequest, + isObject, + ctxErrorHandler, + processJwtKeys, + getQueryFromPayload, + getMutationFromPayload, + injectToFn +} from './index' +import { + AUTH_TYPE, + QUERY_NAME, + MUTATION_NAME, + CONTRACT_NAME, + CONTRACT_REQUEST_METHODS, + API_REQUEST_METHODS, + PAYLOAD_PARAM_NAME, + CONDITION_PARAM_NAME, + RESOLVER_PARAM_NAME, + JSONP_CALLBACK_NAME +} from 'jsonql-constants' +import { Jsonql406Error } from 'jsonql-errors' +import processContract from '../contracts/process-contract' +// should move to the utils as well + +const debug = getDebug('init-middleware-helpers') + +/** + * Just figure out what is the calling methods here + * @param {object} ctx koa context + * @return {*} false on unknown + */ +const getBaseResolverType = function(ctx) { + const [ POST, PUT ] = API_REQUEST_METHODS; + const { method } = ctx; + switch (true) { + case inArray(CONTRACT_REQUEST_METHODS, method): + return CONTRACT_NAME; + case method === POST: + return QUERY_NAME; + case method === PUT: + return MUTATION_NAME; + } +} + +/** + * check if it is auth type + * @param {string} type we need this to be the QUERY_TYPE + * @param {string} name from ctx.request.body to find the issuer name present or not + * @param {object} opts config we need that to find the custom names + */ +const isAuthType = function(type, name, opts) { + const { logoutHandlerName, loginHandlerName } = opts; + const AUTH_TYPE_METHODS = [loginHandlerName, logoutHandlerName] + if (type === QUERY_NAME) { + return inArray(AUTH_TYPE_METHODS, name) ? AUTH_TYPE : type; + } + return type; +} + +/** + * new in v1.3.0 jsonp handler + * @param {object} ctx koa context + * @return {boolean|string} return resolverName or false when its not + */ +const isJsonpCall = function(ctx) { + if (ctx.query && ctx.query[JSONP_CALLBACK_NAME]) { + return ctx.query[JSONP_CALLBACK_NAME] + } + return false; +} -- Gitee From e13d73d5fdf705787c9d36898cb1356af7dc0c0c Mon Sep 17 00:00:00 2001 From: joelchu Date: Mon, 18 Nov 2019 14:29:46 +0800 Subject: [PATCH 06/14] still no idea where the problem is --- packages/@jsonql/koa/package.json | 2 +- .../koa/src/middlewares/init-middleware.js | 15 ++++++------- .../koa/src/utils/init-middleware-helpers.js | 22 +++++-------------- packages/ws-server/src/options/index.js | 4 ++-- packages/ws-server/src/share/get-contract.js | 8 +++++-- 5 files changed, 21 insertions(+), 30 deletions(-) diff --git a/packages/@jsonql/koa/package.json b/packages/@jsonql/koa/package.json index 2794c625..3ca1e436 100644 --- a/packages/@jsonql/koa/package.json +++ b/packages/@jsonql/koa/package.json @@ -7,7 +7,7 @@ "test": "ava --verbose", "test:basic": "DEBUG=jsonql-koa* ava --verbose ./tests/basic.test.js", "test:auth": "DEBUG=jsonql-* ava --verbose ./tests/auth.test.js", - "test:socket": "DEBUG=jsonql-* ava --verbose ./tests/socket.test.js", + "test:socket": "DEBUG=jsonql-koa* ava --verbose ./tests/socket.test.js", "test:ms": "DEBUG=jsonql-koa* ava --verbose ./tests/ms.test.js", "test:cli": "DEBUG=jsonql-koa* node ./cli.js" }, diff --git a/packages/koa/src/middlewares/init-middleware.js b/packages/koa/src/middlewares/init-middleware.js index d7c09395..11c05436 100644 --- a/packages/koa/src/middlewares/init-middleware.js +++ b/packages/koa/src/middlewares/init-middleware.js @@ -1,5 +1,7 @@ // this will be the first part of the middleware that checkout the // headers and request and extract the parts that we need for the operation +import { QUERY_NAME, MUTATION_NAME, CONTRACT_NAME, RESOLVER_PARAM_NAME } from 'jsonql-constants' +import { injectToFn } from 'jsonql-utils' import { getDebug, isJsonqlRequest, @@ -8,12 +10,7 @@ import { getQueryFromPayload, getMutationFromPayload } from '../utils' -import { - QUERY_NAME, - MUTATION_NAME, - CONTRACT_NAME, - RESOLVER_PARAM_NAME -} from 'jsonql-constants' + import processContract from '../contracts/process-contract' import { getBaseResolverType, @@ -42,9 +39,11 @@ export default function initMiddleware(opts) { ctx.state.jsonql.isReq = isJsonql; if (isJsonql) { // its only call once - let __contract__ = await processContract(ctx, opts) + ctx.state.jsonql.contract = await processContract(ctx, opts) + debug('ctx.state.jsonql.contract', ctx.state.jsonql.contract) + // @BUG makes no different to define the contract as a property, somewhere still overwrite it // @NOTE see if this works or not to make sure the contract prop is not writable - ctx.state.jsonql = injectToFn(ctx.state.jsonql, 'contract', __contract__) + // ctx.state.jsonql = injectToFn(ctx.state.jsonql, 'contract', __contract__) // v1.2.0 grabbing the public / private keys opts = await processJwtKeys(ctx, opts) diff --git a/packages/koa/src/utils/init-middleware-helpers.js b/packages/koa/src/utils/init-middleware-helpers.js index 75c33ba5..2a55bbb6 100644 --- a/packages/koa/src/utils/init-middleware-helpers.js +++ b/packages/koa/src/utils/init-middleware-helpers.js @@ -1,16 +1,5 @@ // move all the functions in the init-middleware here to keep it clean - -import { - inArray, - getDebug, - isJsonqlRequest, - isObject, - ctxErrorHandler, - processJwtKeys, - getQueryFromPayload, - getMutationFromPayload, - injectToFn -} from './index' +import { inArray, isObject, getDebug } from './index' import { AUTH_TYPE, QUERY_NAME, @@ -18,13 +7,10 @@ import { CONTRACT_NAME, CONTRACT_REQUEST_METHODS, API_REQUEST_METHODS, - PAYLOAD_PARAM_NAME, - CONDITION_PARAM_NAME, - RESOLVER_PARAM_NAME, JSONP_CALLBACK_NAME } from 'jsonql-constants' -import { Jsonql406Error } from 'jsonql-errors' -import processContract from '../contracts/process-contract' +// import { Jsonql406Error } from 'jsonql-errors' +// import processContract from '../contracts/process-contract' // should move to the utils as well const debug = getDebug('init-middleware-helpers') @@ -73,3 +59,5 @@ const isJsonpCall = function(ctx) { } return false; } + +export { getBaseResolverType, isAuthType, isJsonpCall } diff --git a/packages/ws-server/src/options/index.js b/packages/ws-server/src/options/index.js index 41b9a212..ca188e0b 100644 --- a/packages/ws-server/src/options/index.js +++ b/packages/ws-server/src/options/index.js @@ -36,7 +36,7 @@ const { AVAILABLE_SERVERS, SECRET_MISSING_ERR } = require('../share/constants') -const getContract = require('../share/get-contract') +const { getContract } = require('../share/get-contract') const { getDebug } = require('../share/helpers') const debug = getDebug('options') // base options @@ -77,7 +77,7 @@ const constProps = { secret: false, publicNamespace: PUBLIC_KEY, privateNamespace: PRIVATE_KEY, - initContract: false // this is from the koa middleware + // initContract: false // this is from the koa middleware } /** diff --git a/packages/ws-server/src/share/get-contract.js b/packages/ws-server/src/share/get-contract.js index 47e39006..5a6f3661 100644 --- a/packages/ws-server/src/share/get-contract.js +++ b/packages/ws-server/src/share/get-contract.js @@ -36,7 +36,9 @@ function getContractFromFile(config) { if (!c) { if (config.initContract && config.initContract.then) { // this is a pending promise from the middleware (koa or express) - return config.initContract.then(resolver) + return config.initContract.then(contract => { + resolver(contract) + }) } /* the final fallback */ setTimeout(() => { @@ -60,7 +62,7 @@ function getContractFromFile(config) { * @param {object} config configuration * @return {promise} resolve the config with the contract as prop */ -module.exports = function getContract(config) { +function getContract(config) { return new Promise((resolver, rejecter) => { if (config.contract && isContract(config.contract)) { return resolver(config) @@ -73,3 +75,5 @@ module.exports = function getContract(config) { .catch(rejecter) }) } + +module.exports = { getContract } -- Gitee From 9770bd99f34a03f5eb168ddb0f7b4d8284384ebe Mon Sep 17 00:00:00 2001 From: joelchu Date: Tue, 19 Nov 2019 11:22:23 +0800 Subject: [PATCH 07/14] add the new jsonql struct to hold immutatble data --- packages/koa/package.json | 3 ++- packages/koa/src/utils/jsonql-struct.js | 13 +++++++++++++ packages/koa/tests/jsonql.test.js | 19 +++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 packages/koa/src/utils/jsonql-struct.js create mode 100644 packages/koa/tests/jsonql.test.js diff --git a/packages/koa/package.json b/packages/koa/package.json index 9c39e417..1f353e79 100644 --- a/packages/koa/package.json +++ b/packages/koa/package.json @@ -1,6 +1,6 @@ { "name": "jsonql-koa", - "version": "1.4.13", + "version": "1.4.14", "description": "jsonql Koa middleware", "main": "main.js", "module": "index.js", @@ -29,6 +29,7 @@ "test:throw": "DEBUG=jsonql-* ava ./tests/throw.test.js", "test:gen": "DEBUG=jsonql* ava ./tests/contract.test.js", "test:jsonp": "DEBUG=jsonql* ava --verbose ./tests/jsonp.test.js", + "test:jsonql": "DEBUG=jsonql-koa* ava --verbose ./tests/jsonql.test.js", "test:chain": "DEBUG=jsonql* ava --verbose ./tests/chain-fn.test.js", "test:clients": "DEBUG=jsonql* ava --verbose ./tests/node-client.test.js", "web-console": "DEBUG=jsonql-koa*,jsonql-web-console* node ./tests/helpers/browser.js", diff --git a/packages/koa/src/utils/jsonql-struct.js b/packages/koa/src/utils/jsonql-struct.js new file mode 100644 index 00000000..10429a37 --- /dev/null +++ b/packages/koa/src/utils/jsonql-struct.js @@ -0,0 +1,13 @@ +// this is a struct like class to hold the property that we don't want to get overwrite + +export default class JsonqlStruct { + + constructor() { + this.__private__ = new Set() + } + + get contract() { + + } + +} diff --git a/packages/koa/tests/jsonql.test.js b/packages/koa/tests/jsonql.test.js new file mode 100644 index 00000000..4efec659 --- /dev/null +++ b/packages/koa/tests/jsonql.test.js @@ -0,0 +1,19 @@ +// testing the new jsonqlStruct class + +const test = require('ava') + +const JsonqlStruct = require('../src/utils/jsonql-struct') + +test.before(t => { + + t.context.cls = new JsonqlStruct() +}) + +test(`It should able to set some value`, t => { + + +}) + +test(`It should not able to overwrite some value` t => { + +}) -- Gitee From c4e95ecc985c2074c37c35df63609c5d242074cb Mon Sep 17 00:00:00 2001 From: joelchu Date: Tue, 19 Nov 2019 12:53:59 +0800 Subject: [PATCH 08/14] The strange thing is the set phrase is always in the init but why the contract value change half way --- packages/koa/src/utils/jsonql-struct.js | 13 +++++++++++-- packages/koa/tests/jsonql.test.js | 9 ++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/koa/src/utils/jsonql-struct.js b/packages/koa/src/utils/jsonql-struct.js index 10429a37..4c69c8e5 100644 --- a/packages/koa/src/utils/jsonql-struct.js +++ b/packages/koa/src/utils/jsonql-struct.js @@ -3,11 +3,20 @@ export default class JsonqlStruct { constructor() { - this.__private__ = new Set() + this.__private__ = new Map() + } + + set(key, value) { + if (this.__private__.has(key)) { + console.error(`${key} already existed! overwrite with`, value) + } + this.__private__.set(key, value) } get contract() { - + return this.__private__.get('contract') } + + } diff --git a/packages/koa/tests/jsonql.test.js b/packages/koa/tests/jsonql.test.js index 4efec659..9b604f6e 100644 --- a/packages/koa/tests/jsonql.test.js +++ b/packages/koa/tests/jsonql.test.js @@ -9,11 +9,6 @@ test.before(t => { t.context.cls = new JsonqlStruct() }) -test(`It should able to set some value`, t => { +test.todo(`It should able to set some value`) - -}) - -test(`It should not able to overwrite some value` t => { - -}) +test.todo(`It should not able to overwrite some value`) -- Gitee From 7bda8e28a4be75ba55d37c56bd60329cfd6cc561 Mon Sep 17 00:00:00 2001 From: joelchu Date: Wed, 20 Nov 2019 11:22:39 +0800 Subject: [PATCH 09/14] Fix the isContract should return the contract instead of boolean --- packages/koa/src/contracts/process-contract.js | 5 ++++- packages/utils/index.js | 2 -- packages/utils/module.js | 7 ++----- packages/utils/package.json | 2 +- packages/utils/src/contract.js | 9 +++++++++ 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/packages/koa/src/contracts/process-contract.js b/packages/koa/src/contracts/process-contract.js index b5fe754a..90039028 100644 --- a/packages/koa/src/contracts/process-contract.js +++ b/packages/koa/src/contracts/process-contract.js @@ -23,7 +23,10 @@ const getFromOpts = opts => { export default function processContract(ctx, opts) { // const { setter, getter } = ctx.state.jsonql; return getFromOpts(opts) - .then(c => c || false) + .then(c => { + debug(`getFromOpts`, c) + return c || false + }) // .then(c => !c ? getter('contract') : c) .then(c => { if (!c) { diff --git a/packages/utils/index.js b/packages/utils/index.js index 339e7d1e..5c61db5d 100644 --- a/packages/utils/index.js +++ b/packages/utils/index.js @@ -9,7 +9,6 @@ import { // contract extractArgsFromPayload, extractParamsFromContract, - checkIsContract, extractSocketPart, groupByNamespace, getNamespaceInOrder, @@ -103,7 +102,6 @@ export { // contract extractArgsFromPayload, extractParamsFromContract, - checkIsContract, extractSocketPart, groupByNamespace, getNamespaceInOrder, diff --git a/packages/utils/module.js b/packages/utils/module.js index 35838a99..4710f889 100644 --- a/packages/utils/module.js +++ b/packages/utils/module.js @@ -4,7 +4,7 @@ import { chainFns } from './src/chain-fns' import { chainPromises, chainProcessPromises } from './src/chain-promises' import { injectToFn, objDefineProps, objHasProp } from './src/obj-define-props' import { - checkIsContract, + isContract, extractSocketPart, groupByNamespace, getNamespaceInOrder, @@ -47,8 +47,6 @@ import { isJsonqlErrorObj } from './src/results' -// alias -const isContract = checkIsContract; const VERSION = '__VERSION__' // exports export { @@ -64,11 +62,10 @@ export { // contract extractArgsFromPayload, extractParamsFromContract, - checkIsContract, extractSocketPart, groupByNamespace, getNamespaceInOrder, - isContract, // alias + isContract, // generic inArray, toArray, diff --git a/packages/utils/package.json b/packages/utils/package.json index 7c017131..945b07b4 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "jsonql-utils", - "version": "0.8.4", + "version": "0.8.5", "description": "This is a jsonql dependency module, not for generate use.", "main": "main.js", "module": "index.js", diff --git a/packages/utils/src/contract.js b/packages/utils/src/contract.js index a3afa34e..59d592ae 100644 --- a/packages/utils/src/contract.js +++ b/packages/utils/src/contract.js @@ -24,6 +24,15 @@ export function checkIsContract(contract) { ) } +/** + * Wrapper method that check if it's contract then return the contract or false + * @param {object} contract the object to check + * @return {boolean | object} false when it's not + */ +export function isContract(contract) { + return checkIsContract(contract) ? contract : false; +} + /** * Ported from jsonql-params-validator but different * if we don't find the socket part then return false -- Gitee From 21a98b51be9436333df1e67ee97322e6f05fed30 Mon Sep 17 00:00:00 2001 From: joelchu Date: Wed, 20 Nov 2019 11:23:47 +0800 Subject: [PATCH 10/14] jsonql-utils build 0.8.5 --- packages/utils/browser.js | 2 +- packages/utils/main.js | 2 +- packages/utils/main.js.map | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/utils/browser.js b/packages/utils/browser.js index 75db5156..051e0852 100644 --- a/packages/utils/browser.js +++ b/packages/utils/browser.js @@ -1,2 +1,2 @@ -!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t=t||self).jsonqlUtils={})}(this,(function(t){"use strict";var r=Array.isArray,e="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},n="object"==typeof e&&e&&e.Object===Object&&e,o="object"==typeof self&&self&&self.Object===Object&&self,u=n||o||Function("return this")(),i=u.Symbol,a=Object.prototype,c=a.hasOwnProperty,f=a.toString,s=i?i.toStringTag:void 0;var l=Object.prototype.toString;var p="[object Null]",v="[object Undefined]",d=i?i.toStringTag:void 0;function y(t){return null==t?void 0===t?v:p:d&&d in Object(t)?function(t){var r=c.call(t,s),e=t[s];try{t[s]=void 0;var n=!0}catch(t){}var o=f.call(t);return n&&(r?t[s]=e:delete t[s]),o}(t):function(t){return l.call(t)}(t)}var h,b,g=(h=Object.getPrototypeOf,b=Object,function(t){return h(b(t))});function _(t){return null!=t&&"object"==typeof t}var j="[object Object]",m=Function.prototype,O=Object.prototype,w=m.toString,P=O.hasOwnProperty,S=w.call(Object);function A(t){if(!_(t)||y(t)!=j)return!1;var r=g(t);if(null===r)return!0;var e=P.call(r,"constructor")&&r.constructor;return"function"==typeof e&&e instanceof e&&w.call(e)==S}var N="[object Symbol]";var z=1/0,F=i?i.prototype:void 0,k=F?F.toString:void 0;function x(t){if("string"==typeof t)return t;if(r(t))return function(t,r){for(var e=-1,n=null==t?0:t.length,o=Array(n);++e=n?t:function(t,r,e){var n=-1,o=t.length;r<0&&(r=-r>o?0:o+r),(e=e>o?o:e)<0&&(e+=o),o=r>e?0:e-r>>>0,r>>>=0;for(var u=Array(o);++n-1;);return e}(o,u),function(t,r){for(var e=t.length;e--&&C(r,t[e],0)>-1;);return e}(o,u)+1).join("")}var K=function(t,r){return!!t.filter((function(t){return t===r})).length},W=function(t){return r(t)?t:[t]},Z=function(t,r){try{var e=Object.keys(t);return K(e,r)}catch(t){return!1}},X=function(t){void 0===t&&(t=!1);var r=Date.now();return t?Math.floor(r/1e3):r},Y=function(t,r){var e=[];for(var n in r)e.push([n,r[n]].join("="));return[t,e.join("&")].join("?")},tt=function(){return{_cb:X()}};function rt(t,r){return t===r||t!=t&&r!=r}function et(t,r){for(var e=t.length;e--;)if(rt(t[e][0],r))return e;return-1}var nt=Array.prototype.splice;function ot(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r-1},ot.prototype.set=function(t,r){var e=this.__data__,n=et(e,t);return n<0?(++this.size,e.push([t,r])):e[n][1]=r,this};var it="[object AsyncFunction]",at="[object Function]",ct="[object GeneratorFunction]",ft="[object Proxy]";function st(t){if(!ut(t))return!1;var r=y(t);return r==at||r==ct||r==it||r==ft}var lt,pt=u["__core-js_shared__"],vt=(lt=/[^.]+$/.exec(pt&&pt.keys&&pt.keys.IE_PROTO||""))?"Symbol(src)_1."+lt:"";var dt=Function.prototype.toString;var yt=/^\[object .+?Constructor\]$/,ht=Function.prototype,bt=Object.prototype,gt=ht.toString,_t=bt.hasOwnProperty,jt=RegExp("^"+gt.call(_t).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function mt(t){return!(!ut(t)||function(t){return!!vt&&vt in t}(t))&&(st(t)?jt:yt).test(function(t){if(null!=t){try{return dt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function Ot(t,r){var e=function(t,r){return null==t?void 0:t[r]}(t,r);return mt(e)?e:void 0}var wt=Ot(u,"Map"),Pt=Ot(Object,"create");var St="__lodash_hash_undefined__",At=Object.prototype.hasOwnProperty;var Nt=Object.prototype.hasOwnProperty;var zt="__lodash_hash_undefined__";function Ft(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r-1&&t%1==0&&t<=rr}function nr(t){return null!=t&&er(t.length)&&!st(t)}var or="object"==typeof t&&t&&!t.nodeType&&t,ur=or&&"object"==typeof module&&module&&!module.nodeType&&module,ir=ur&&ur.exports===or?u.Buffer:void 0,ar=(ir?ir.isBuffer:void 0)||function(){return!1},cr={};cr["[object Float32Array]"]=cr["[object Float64Array]"]=cr["[object Int8Array]"]=cr["[object Int16Array]"]=cr["[object Int32Array]"]=cr["[object Uint8Array]"]=cr["[object Uint8ClampedArray]"]=cr["[object Uint16Array]"]=cr["[object Uint32Array]"]=!0,cr["[object Arguments]"]=cr["[object Array]"]=cr["[object ArrayBuffer]"]=cr["[object Boolean]"]=cr["[object DataView]"]=cr["[object Date]"]=cr["[object Error]"]=cr["[object Function]"]=cr["[object Map]"]=cr["[object Number]"]=cr["[object Object]"]=cr["[object RegExp]"]=cr["[object Set]"]=cr["[object String]"]=cr["[object WeakMap]"]=!1;var fr="object"==typeof t&&t&&!t.nodeType&&t,sr=fr&&"object"==typeof module&&module&&!module.nodeType&&module,lr=sr&&sr.exports===fr&&n.process,pr=function(){try{var t=sr&&sr.require&&sr.require("util").types;return t||lr&&lr.binding&&lr.binding("util")}catch(t){}}(),vr=pr&&pr.isTypedArray,dr=vr?function(t){return function(r){return t(r)}}(vr):function(t){return _(t)&&er(t.length)&&!!cr[y(t)]};function yr(t,r){if(("constructor"!==r||"function"!=typeof t[r])&&"__proto__"!=r)return t[r]}var hr=Object.prototype.hasOwnProperty;function br(t,r,e){var n=t[r];hr.call(t,r)&&rt(n,e)&&(void 0!==e||r in t)||Jt(t,r,e)}var gr=9007199254740991,_r=/^(?:0|[1-9]\d*)$/;function jr(t,r){var e=typeof t;return!!(r=null==r?gr:r)&&("number"==e||"symbol"!=e&&_r.test(t))&&t>-1&&t%1==0&&t0){if(++r>=Tr)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}(Er);function Rr(t,r){return Mr(function(t,r,e){return r=xr(void 0===r?t.length-1:r,0),function(){for(var n=arguments,o=-1,u=xr(n.length-r,0),i=Array(u);++o1?r[n-1]:void 0,u=n>2?r[2]:void 0;for(o=Ur.length>3&&"function"==typeof o?(n--,o):void 0,u&&function(t,r,e){if(!ut(e))return!1;var n=typeof r;return!!("number"==n?nr(e)&&jr(r,e.length):"string"==n&&r in e)&&rt(e[r],t)}(r[0],r[1],u)&&(o=n<3?void 0:o,n=1),t=Object(t);++e0;)r[e]=arguments[e+1];return function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];return r.reduce((function(t,r){return Reflect.apply(r,null,W(t))}),Reflect.apply(t,null,e))}},t.chainProcessPromises=function(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];return r.reduce((function(t,r){return t.then((function(t){return r(t)}))}),Reflect.apply(t,null,e))}},t.chainPromises=function(t,r){return void 0===r&&(r=!1),t.reduce((function(t,e){return t.then((function(t){return e.then((function(e){return!1===r?t.concat([e]):qr(t,e)}))}))}),Promise.resolve(!1===r?[]:A(r)?r:{}))},t.checkIsContract=Xr,t.createEvt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return t.join("_")},t.createMutation=ie,t.createMutationStr=function(t,r,e,n){return void 0===e&&(e={}),void 0===n&&(n=!1),JSON.stringify(ie(t,r,e,n))},t.createQuery=ue,t.createQueryStr=function(t,r,e){return void 0===r&&(r=[]),void 0===e&&(e=!1),JSON.stringify(ue(t,r,e))},t.dasherize=function(t){return G(t).replace(/([A-Z])/g,"-$1").replace(/[-_\s]+/g,"-").toLowerCase()},t.extractArgsFromPayload=function(t,r){switch(r){case Br:return t[Lr];case Ir:return[t[Qr],t[Vr]];default:throw new Zr("Unknown "+r+" to extract argument from!")}},t.extractParamsFromContract=function(t,r,e){try{var n=t[r][e];if(!n)throw new Kr(e,r);return n}catch(t){throw new Kr(e,t)}},t.extractSocketPart=Yr,t.formatPayload=ne,t.getCallMethod=function(t){switch(!0){case t===Gr[0]:return Br;case t===Gr[1]:return Ir;default:return!1}},t.getConfigValue=function(t,r){return r&&A(r)&&t in r?r[t]:void 0},t.getMutationFromArgs=fe,t.getMutationFromPayload=function(t){var r=ce(t,fe);if(!1!==r)return r;throw new Wr("[getMutationArgs] Payload is malformed!",t)},t.getNameFromPayload=oe,t.getNamespaceInOrder=function(t,r){var e=[];for(var n in t)n===r?e[1]=n:e[0]=n;return e},t.getQueryFromArgs=ae,t.getQueryFromPayload=function(t){var r=ce(t,ae);if(!1!==r)return r;throw new Wr("[getQueryArgs] Payload is malformed!",t)},t.groupByNamespace=function(t,r){void 0===r&&(r=!1);var e=Yr(t);if(!1===e){if(r)return t;throw new Zr("socket not found in contract!")}var n,o={},u=0;for(var i in e){var a=e[i],c=a.namespace;c&&(o[c]||(++u,o[c]={}),o[c][i]=a,n||a.public&&(n=c))}return{size:u,nspSet:o,publicNamespace:n}},t.inArray=K,t.injectToFn=function(t,r,e,n){void 0===n&&(n=!1);var o=$r(t,r);return!1===n&&void 0!==o?t:(Object.defineProperty(t,r,{value:e,writable:n}),t)},t.isContract=le,t.isFunc=function(t){if("function"==typeof t)return!0;console.error("Expect to be Function type!")},t.isJsonqlErrorObj=se,t.isNotEmpty=function(t){return void 0!==t&&!1!==t&&null!==t&&""!==G(t)},t.isObjectHasKey=Z,t.objDefineProps=function(t,r,e,n){return void 0===n&&(n=null),void 0===Object.getOwnPropertyDescriptor(t,r)&&Object.defineProperty(t,r,{set:e,get:null===n?function(){return null}:n}),t},t.objHasProp=$r,t.packError=function(t,r,e,n){var o;void 0===r&&(r="JsonqlError"),void 0===e&&(e=0),void 0===n&&(n="");var u={detail:t,className:r,statusCode:e,message:n};return JSON.stringify(((o={}).error=se(t)||u,o))},t.packResult=function(t){var r;return JSON.stringify(((r={}).data=t,r))},t.resultHandler=function(t){return Z(t,"data")&&!Z(t,"error")?t.data:t},t.timestamp=X,t.toArray=W,t.toJson=function(t){return"string"==typeof t?function(t){try{return JSON.parse(t)}catch(r){return t}}(t):JSON.parse(JSON.stringify(t))},t.toPayload=ee,t.urlParams=Y,Object.defineProperty(t,"__esModule",{value:!0})})); +!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t=t||self).jsonqlUtils={})}(this,(function(t){"use strict";var r=Array.isArray,e="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},n="object"==typeof e&&e&&e.Object===Object&&e,o="object"==typeof self&&self&&self.Object===Object&&self,u=n||o||Function("return this")(),i=u.Symbol,a=Object.prototype,c=a.hasOwnProperty,f=a.toString,s=i?i.toStringTag:void 0;var l=Object.prototype.toString;var p="[object Null]",v="[object Undefined]",d=i?i.toStringTag:void 0;function y(t){return null==t?void 0===t?v:p:d&&d in Object(t)?function(t){var r=c.call(t,s),e=t[s];try{t[s]=void 0;var n=!0}catch(t){}var o=f.call(t);return n&&(r?t[s]=e:delete t[s]),o}(t):function(t){return l.call(t)}(t)}var h,b,g=(h=Object.getPrototypeOf,b=Object,function(t){return h(b(t))});function _(t){return null!=t&&"object"==typeof t}var j="[object Object]",m=Function.prototype,O=Object.prototype,w=m.toString,P=O.hasOwnProperty,S=w.call(Object);function A(t){if(!_(t)||y(t)!=j)return!1;var r=g(t);if(null===r)return!0;var e=P.call(r,"constructor")&&r.constructor;return"function"==typeof e&&e instanceof e&&w.call(e)==S}var N="[object Symbol]";var z=1/0,F=i?i.prototype:void 0,k=F?F.toString:void 0;function x(t){if("string"==typeof t)return t;if(r(t))return function(t,r){for(var e=-1,n=null==t?0:t.length,o=Array(n);++e=n?t:function(t,r,e){var n=-1,o=t.length;r<0&&(r=-r>o?0:o+r),(e=e>o?o:e)<0&&(e+=o),o=r>e?0:e-r>>>0,r>>>=0;for(var u=Array(o);++n-1;);return e}(o,u),function(t,r){for(var e=t.length;e--&&J(r,t[e],0)>-1;);return e}(o,u)+1).join("")}var K=function(t,r){return!!t.filter((function(t){return t===r})).length},W=function(t){return r(t)?t:[t]},Z=function(t,r){try{var e=Object.keys(t);return K(e,r)}catch(t){return!1}},X=function(t){void 0===t&&(t=!1);var r=Date.now();return t?Math.floor(r/1e3):r},Y=function(t,r){var e=[];for(var n in r)e.push([n,r[n]].join("="));return[t,e.join("&")].join("?")},tt=function(){return{_cb:X()}};function rt(t,r){return t===r||t!=t&&r!=r}function et(t,r){for(var e=t.length;e--;)if(rt(t[e][0],r))return e;return-1}var nt=Array.prototype.splice;function ot(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r-1},ot.prototype.set=function(t,r){var e=this.__data__,n=et(e,t);return n<0?(++this.size,e.push([t,r])):e[n][1]=r,this};var it="[object AsyncFunction]",at="[object Function]",ct="[object GeneratorFunction]",ft="[object Proxy]";function st(t){if(!ut(t))return!1;var r=y(t);return r==at||r==ct||r==it||r==ft}var lt,pt=u["__core-js_shared__"],vt=(lt=/[^.]+$/.exec(pt&&pt.keys&&pt.keys.IE_PROTO||""))?"Symbol(src)_1."+lt:"";var dt=Function.prototype.toString;var yt=/^\[object .+?Constructor\]$/,ht=Function.prototype,bt=Object.prototype,gt=ht.toString,_t=bt.hasOwnProperty,jt=RegExp("^"+gt.call(_t).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function mt(t){return!(!ut(t)||function(t){return!!vt&&vt in t}(t))&&(st(t)?jt:yt).test(function(t){if(null!=t){try{return dt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function Ot(t,r){var e=function(t,r){return null==t?void 0:t[r]}(t,r);return mt(e)?e:void 0}var wt=Ot(u,"Map"),Pt=Ot(Object,"create");var St="__lodash_hash_undefined__",At=Object.prototype.hasOwnProperty;var Nt=Object.prototype.hasOwnProperty;var zt="__lodash_hash_undefined__";function Ft(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r-1&&t%1==0&&t<=rr}function nr(t){return null!=t&&er(t.length)&&!st(t)}var or="object"==typeof t&&t&&!t.nodeType&&t,ur=or&&"object"==typeof module&&module&&!module.nodeType&&module,ir=ur&&ur.exports===or?u.Buffer:void 0,ar=(ir?ir.isBuffer:void 0)||function(){return!1},cr={};cr["[object Float32Array]"]=cr["[object Float64Array]"]=cr["[object Int8Array]"]=cr["[object Int16Array]"]=cr["[object Int32Array]"]=cr["[object Uint8Array]"]=cr["[object Uint8ClampedArray]"]=cr["[object Uint16Array]"]=cr["[object Uint32Array]"]=!0,cr["[object Arguments]"]=cr["[object Array]"]=cr["[object ArrayBuffer]"]=cr["[object Boolean]"]=cr["[object DataView]"]=cr["[object Date]"]=cr["[object Error]"]=cr["[object Function]"]=cr["[object Map]"]=cr["[object Number]"]=cr["[object Object]"]=cr["[object RegExp]"]=cr["[object Set]"]=cr["[object String]"]=cr["[object WeakMap]"]=!1;var fr="object"==typeof t&&t&&!t.nodeType&&t,sr=fr&&"object"==typeof module&&module&&!module.nodeType&&module,lr=sr&&sr.exports===fr&&n.process,pr=function(){try{var t=sr&&sr.require&&sr.require("util").types;return t||lr&&lr.binding&&lr.binding("util")}catch(t){}}(),vr=pr&&pr.isTypedArray,dr=vr?function(t){return function(r){return t(r)}}(vr):function(t){return _(t)&&er(t.length)&&!!cr[y(t)]};function yr(t,r){if(("constructor"!==r||"function"!=typeof t[r])&&"__proto__"!=r)return t[r]}var hr=Object.prototype.hasOwnProperty;function br(t,r,e){var n=t[r];hr.call(t,r)&&rt(n,e)&&(void 0!==e||r in t)||Ct(t,r,e)}var gr=9007199254740991,_r=/^(?:0|[1-9]\d*)$/;function jr(t,r){var e=typeof t;return!!(r=null==r?gr:r)&&("number"==e||"symbol"!=e&&_r.test(t))&&t>-1&&t%1==0&&t0){if(++r>=Tr)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}(Er);function Rr(t,r){return Mr(function(t,r,e){return r=xr(void 0===r?t.length-1:r,0),function(){for(var n=arguments,o=-1,u=xr(n.length-r,0),i=Array(u);++o1?r[n-1]:void 0,u=n>2?r[2]:void 0;for(o=Ur.length>3&&"function"==typeof o?(n--,o):void 0,u&&function(t,r,e){if(!ut(e))return!1;var n=typeof r;return!!("number"==n?nr(e)&&jr(r,e.length):"string"==n&&r in e)&&rt(e[r],t)}(r[0],r[1],u)&&(o=n<3?void 0:o,n=1),t=Object(t);++e0;)r[e]=arguments[e+1];return function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];return r.reduce((function(t,r){return Reflect.apply(r,null,W(t))}),Reflect.apply(t,null,e))}},t.chainProcessPromises=function(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];return r.reduce((function(t,r){return t.then((function(t){return r(t)}))}),Reflect.apply(t,null,e))}},t.chainPromises=function(t,r){return void 0===r&&(r=!1),t.reduce((function(t,e){return t.then((function(t){return e.then((function(e){return!1===r?t.concat([e]):qr(t,e)}))}))}),Promise.resolve(!1===r?[]:A(r)?r:{}))},t.createEvt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return t.join("_")},t.createMutation=ue,t.createMutationStr=function(t,r,e,n){return void 0===e&&(e={}),void 0===n&&(n=!1),JSON.stringify(ue(t,r,e,n))},t.createQuery=oe,t.createQueryStr=function(t,r,e){return void 0===r&&(r=[]),void 0===e&&(e=!1),JSON.stringify(oe(t,r,e))},t.dasherize=function(t){return G(t).replace(/([A-Z])/g,"-$1").replace(/[-_\s]+/g,"-").toLowerCase()},t.extractArgsFromPayload=function(t,r){switch(r){case Br:return t[Lr];case Dr:return[t[Qr],t[Vr]];default:throw new Zr("Unknown "+r+" to extract argument from!")}},t.extractParamsFromContract=function(t,r,e){try{var n=t[r][e];if(!n)throw new Kr(e,r);return n}catch(t){throw new Kr(e,t)}},t.extractSocketPart=Xr,t.formatPayload=ee,t.getCallMethod=function(t){switch(!0){case t===Gr[0]:return Br;case t===Gr[1]:return Dr;default:return!1}},t.getConfigValue=function(t,r){return r&&A(r)&&t in r?r[t]:void 0},t.getMutationFromArgs=ce,t.getMutationFromPayload=function(t){var r=ae(t,ce);if(!1!==r)return r;throw new Wr("[getMutationArgs] Payload is malformed!",t)},t.getNameFromPayload=ne,t.getNamespaceInOrder=function(t,r){var e=[];for(var n in t)n===r?e[1]=n:e[0]=n;return e},t.getQueryFromArgs=ie,t.getQueryFromPayload=function(t){var r=ae(t,ie);if(!1!==r)return r;throw new Wr("[getQueryArgs] Payload is malformed!",t)},t.groupByNamespace=function(t,r){void 0===r&&(r=!1);var e=Xr(t);if(!1===e){if(r)return t;throw new Zr("socket not found in contract!")}var n,o={},u=0;for(var i in e){var a=e[i],c=a.namespace;c&&(o[c]||(++u,o[c]={}),o[c][i]=a,n||a.public&&(n=c))}return{size:u,nspSet:o,publicNamespace:n}},t.inArray=K,t.injectToFn=function(t,r,e,n){void 0===n&&(n=!1);var o=$r(t,r);return!1===n&&void 0!==o?t:(Object.defineProperty(t,r,{value:e,writable:n}),t)},t.isContract=function(t){return!!function(t){return A(t)&&(Z(t,Br)||Z(t,Dr)||Z(t,Ir))}(t)&&t},t.isFunc=function(t){if("function"==typeof t)return!0;console.error("Expect to be Function type!")},t.isJsonqlErrorObj=fe,t.isNotEmpty=function(t){return void 0!==t&&!1!==t&&null!==t&&""!==G(t)},t.isObjectHasKey=Z,t.objDefineProps=function(t,r,e,n){return void 0===n&&(n=null),void 0===Object.getOwnPropertyDescriptor(t,r)&&Object.defineProperty(t,r,{set:e,get:null===n?function(){return null}:n}),t},t.objHasProp=$r,t.packError=function(t,r,e,n){var o;void 0===r&&(r="JsonqlError"),void 0===e&&(e=0),void 0===n&&(n="");var u={detail:t,className:r,statusCode:e,message:n};return JSON.stringify(((o={}).error=fe(t)||u,o))},t.packResult=function(t){var r;return JSON.stringify(((r={}).data=t,r))},t.resultHandler=function(t){return Z(t,"data")&&!Z(t,"error")?t.data:t},t.timestamp=X,t.toArray=W,t.toJson=function(t){return"string"==typeof t?function(t){try{return JSON.parse(t)}catch(r){return t}}(t):JSON.parse(JSON.stringify(t))},t.toPayload=re,t.urlParams=Y,Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=browser.js.map diff --git a/packages/utils/main.js b/packages/utils/main.js index 98101d04..09cacf00 100644 --- a/packages/utils/main.js +++ b/packages/utils/main.js @@ -1,2 +1,2 @@ -"use strict";function _interopDefault(r){return r&&"object"==typeof r&&"default"in r?r.default:r}Object.defineProperty(exports,"__esModule",{value:!0});var fs=_interopDefault(require("fs")),path=require("path"),isArray=Array.isArray,global$1="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},freeGlobal="object"==typeof global$1&&global$1&&global$1.Object===Object&&global$1,freeSelf="object"==typeof self&&self&&self.Object===Object&&self,root=freeGlobal||freeSelf||Function("return this")(),Symbol=root.Symbol,objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty,nativeObjectToString=objectProto.toString,symToStringTag=Symbol?Symbol.toStringTag:void 0;function getRawTag(r){var t=hasOwnProperty.call(r,symToStringTag),e=r[symToStringTag];try{r[symToStringTag]=void 0;var n=!0}catch(r){}var o=nativeObjectToString.call(r);return n&&(t?r[symToStringTag]=e:delete r[symToStringTag]),o}var objectProto$1=Object.prototype,nativeObjectToString$1=objectProto$1.toString;function objectToString(r){return nativeObjectToString$1.call(r)}var nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag$1=Symbol?Symbol.toStringTag:void 0;function baseGetTag(r){return null==r?void 0===r?undefinedTag:nullTag:symToStringTag$1&&symToStringTag$1 in Object(r)?getRawTag(r):objectToString(r)}function overArg(r,t){return function(e){return r(t(e))}}var getPrototype=overArg(Object.getPrototypeOf,Object);function isObjectLike(r){return null!=r&&"object"==typeof r}var objectTag="[object Object]",funcProto=Function.prototype,objectProto$2=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$1=objectProto$2.hasOwnProperty,objectCtorString=funcToString.call(Object);function isPlainObject(r){if(!isObjectLike(r)||baseGetTag(r)!=objectTag)return!1;var t=getPrototype(r);if(null===t)return!0;var e=hasOwnProperty$1.call(t,"constructor")&&t.constructor;return"function"==typeof e&&e instanceof e&&funcToString.call(e)==objectCtorString}function arrayMap(r,t){for(var e=-1,n=null==r?0:r.length,o=Array(n);++eo?0:o+t),(e=e>o?o:e)<0&&(e+=o),o=t>e?0:e-t>>>0,t>>>=0;for(var a=Array(o);++n=n?r:baseSlice(r,t,e)}function baseFindIndex(r,t,e,n){for(var o=r.length,a=e+(n?1:-1);n?a--:++a-1;);return e}function charsStartIndex(r,t){for(var e=-1,n=r.length;++e-1;);return e}function asciiToArray(r){return r.split("")}var rsAstralRange="\\ud800-\\udfff",rsComboMarksRange="\\u0300-\\u036f",reComboHalfMarksRange="\\ufe20-\\ufe2f",rsComboSymbolsRange="\\u20d0-\\u20ff",rsComboRange=rsComboMarksRange+reComboHalfMarksRange+rsComboSymbolsRange,rsVarRange="\\ufe0e\\ufe0f",rsZWJ="\\u200d",reHasUnicode=RegExp("["+rsZWJ+rsAstralRange+rsComboRange+rsVarRange+"]");function hasUnicode(r){return reHasUnicode.test(r)}var rsAstralRange$1="\\ud800-\\udfff",rsComboMarksRange$1="\\u0300-\\u036f",reComboHalfMarksRange$1="\\ufe20-\\ufe2f",rsComboSymbolsRange$1="\\u20d0-\\u20ff",rsComboRange$1=rsComboMarksRange$1+reComboHalfMarksRange$1+rsComboSymbolsRange$1,rsVarRange$1="\\ufe0e\\ufe0f",rsAstral="["+rsAstralRange$1+"]",rsCombo="["+rsComboRange$1+"]",rsFitz="\\ud83c[\\udffb-\\udfff]",rsModifier="(?:"+rsCombo+"|"+rsFitz+")",rsNonAstral="[^"+rsAstralRange$1+"]",rsRegional="(?:\\ud83c[\\udde6-\\uddff]){2}",rsSurrPair="[\\ud800-\\udbff][\\udc00-\\udfff]",rsZWJ$1="\\u200d",reOptMod=rsModifier+"?",rsOptVar="["+rsVarRange$1+"]?",rsOptJoin="(?:"+rsZWJ$1+"(?:"+[rsNonAstral,rsRegional,rsSurrPair].join("|")+")"+rsOptVar+reOptMod+")*",rsSeq=rsOptVar+reOptMod+rsOptJoin,rsSymbol="(?:"+[rsNonAstral+rsCombo+"?",rsCombo,rsRegional,rsSurrPair,rsAstral].join("|")+")",reUnicode=RegExp(rsFitz+"(?="+rsFitz+")|"+rsSymbol+rsSeq,"g");function unicodeToArray(r){return r.match(reUnicode)||[]}function stringToArray(r){return hasUnicode(r)?unicodeToArray(r):asciiToArray(r)}function toString(r){return null==r?"":baseToString(r)}var reTrim=/^\s+|\s+$/g;function trim(r,t,e){if((r=toString(r))&&(e||void 0===t))return r.replace(reTrim,"");if(!r||!(t=baseToString(t)))return r;var n=stringToArray(r),o=stringToArray(t);return castSlice(n,charsStartIndex(n,o),charsEndIndex(n,o)+1).join("")}var inArray=function(r,t){return!!r.filter((function(r){return r===t})).length},toArray=function(r){return isArray(r)?r:[r]},parse=function(r){try{return JSON.parse(r)}catch(t){return r}},isObjectHasKey=function(r,t){try{var e=Object.keys(r);return inArray(e,t)}catch(r){return!1}},createEvt=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return r.join("_")},timestamp=function(r){void 0===r&&(r=!1);var t=Date.now();return r?Math.floor(t/1e3):t},urlParams=function(r,t){var e=[];for(var n in t)e.push([n,t[n]].join("="));return[r,e.join("&")].join("?")},cacheBurstUrl=function(r){return urlParams(r,cacheBurst())},cacheBurst=function(){return{_cb:timestamp()}},dasherize=function(r){return trim(r).replace(/([A-Z])/g,"-$1").replace(/[-_\s]+/g,"-").toLowerCase()},getConfigValue=function(r,t){return t&&isPlainObject(t)&&r in t?t[r]:void 0},toJson=function(r){return"string"==typeof r?parse(r):JSON.parse(JSON.stringify(r))},isNotEmpty=function(r){return void 0!==r&&!1!==r&&null!==r&&""!==trim(r)},chainFns=function(r){for(var t=[],e=arguments.length-1;e-- >0;)t[e]=arguments[e+1];return function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];return t.reduce((function(r,t){return Reflect.apply(t,null,toArray(r))}),Reflect.apply(r,null,e))}};function listCacheClear(){this.__data__=[],this.size=0}function eq(r,t){return r===t||r!=r&&t!=t}function assocIndexOf(r,t){for(var e=r.length;e--;)if(eq(r[e][0],t))return e;return-1}var arrayProto=Array.prototype,splice=arrayProto.splice;function listCacheDelete(r){var t=this.__data__,e=assocIndexOf(t,r);return!(e<0)&&(e==t.length-1?t.pop():splice.call(t,e,1),--this.size,!0)}function listCacheGet(r){var t=this.__data__,e=assocIndexOf(t,r);return e<0?void 0:t[e][1]}function listCacheHas(r){return assocIndexOf(this.__data__,r)>-1}function listCacheSet(r,t){var e=this.__data__,n=assocIndexOf(e,r);return n<0?(++this.size,e.push([r,t])):e[n][1]=t,this}function ListCache(r){var t=-1,e=null==r?0:r.length;for(this.clear();++t-1&&r%1==0&&r<=MAX_SAFE_INTEGER}function isArrayLike(r){return null!=r&&isLength(r.length)&&!isFunction(r)}function isArrayLikeObject(r){return isObjectLike(r)&&isArrayLike(r)}function stubFalse(){return!1}var freeExports$1="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule$1=freeExports$1&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports$1=freeModule$1&&freeModule$1.exports===freeExports$1,Buffer$1=moduleExports$1?root.Buffer:void 0,nativeIsBuffer=Buffer$1?Buffer$1.isBuffer:void 0,isBuffer=nativeIsBuffer||stubFalse,argsTag$1="[object Arguments]",arrayTag="[object Array]",boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",funcTag$1="[object Function]",mapTag="[object Map]",numberTag="[object Number]",objectTag$1="[object Object]",regexpTag="[object RegExp]",setTag="[object Set]",stringTag="[object String]",weakMapTag="[object WeakMap]",arrayBufferTag="[object ArrayBuffer]",dataViewTag="[object DataView]",float32Tag="[object Float32Array]",float64Tag="[object Float64Array]",int8Tag="[object Int8Array]",int16Tag="[object Int16Array]",int32Tag="[object Int32Array]",uint8Tag="[object Uint8Array]",uint8ClampedTag="[object Uint8ClampedArray]",uint16Tag="[object Uint16Array]",uint32Tag="[object Uint32Array]",typedArrayTags={};function baseIsTypedArray(r){return isObjectLike(r)&&isLength(r.length)&&!!typedArrayTags[baseGetTag(r)]}function baseUnary(r){return function(t){return r(t)}}typedArrayTags[float32Tag]=typedArrayTags[float64Tag]=typedArrayTags[int8Tag]=typedArrayTags[int16Tag]=typedArrayTags[int32Tag]=typedArrayTags[uint8Tag]=typedArrayTags[uint8ClampedTag]=typedArrayTags[uint16Tag]=typedArrayTags[uint32Tag]=!0,typedArrayTags[argsTag$1]=typedArrayTags[arrayTag]=typedArrayTags[arrayBufferTag]=typedArrayTags[boolTag]=typedArrayTags[dataViewTag]=typedArrayTags[dateTag]=typedArrayTags[errorTag]=typedArrayTags[funcTag$1]=typedArrayTags[mapTag]=typedArrayTags[numberTag]=typedArrayTags[objectTag$1]=typedArrayTags[regexpTag]=typedArrayTags[setTag]=typedArrayTags[stringTag]=typedArrayTags[weakMapTag]=!1;var freeExports$2="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule$2=freeExports$2&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports$2=freeModule$2&&freeModule$2.exports===freeExports$2,freeProcess=moduleExports$2&&freeGlobal.process,nodeUtil=function(){try{var r=freeModule$2&&freeModule$2.require&&freeModule$2.require("util").types;return r||freeProcess&&freeProcess.binding&&freeProcess.binding("util")}catch(r){}}(),nodeIsTypedArray=nodeUtil&&nodeUtil.isTypedArray,isTypedArray=nodeIsTypedArray?baseUnary(nodeIsTypedArray):baseIsTypedArray;function safeGet(r,t){if(("constructor"!==t||"function"!=typeof r[t])&&"__proto__"!=t)return r[t]}var objectProto$8=Object.prototype,hasOwnProperty$6=objectProto$8.hasOwnProperty;function assignValue(r,t,e){var n=r[t];hasOwnProperty$6.call(r,t)&&eq(n,e)&&(void 0!==e||t in r)||baseAssignValue(r,t,e)}function copyObject(r,t,e,n){var o=!e;e||(e={});for(var a=-1,i=t.length;++a-1&&r%1==0&&r0){if(++t>=HOT_COUNT)return arguments[0]}else t=0;return r.apply(void 0,arguments)}}var setToString=shortOut(baseSetToString);function baseRest(r,t){return setToString(overRest(r,t,identity),r+"")}function isIterateeCall(r,t,e){if(!isObject(e))return!1;var n=typeof t;return!!("number"==n?isArrayLike(e)&&isIndex(t,e.length):"string"==n&&t in e)&&eq(e[t],r)}function createAssigner(r){return baseRest((function(t,e){var n=-1,o=e.length,a=o>1?e[o-1]:void 0,i=o>2?e[2]:void 0;for(a=r.length>3&&"function"==typeof a?(o--,a):void 0,i&&isIterateeCall(e[0],e[1],i)&&(a=o<3?void 0:a,o=1),t=Object(t);++n0)throw new Error("Invalid string. Length must be a multiple of 4");a="="===r[s-2]?2:"="===r[s-1]?1:0,i=new Arr(3*s/4-a),n=a>0?s-4:s;var u=0;for(t=0,e=0;t>16&255,i[u++]=o>>8&255,i[u++]=255&o;return 2===a?(o=revLookup[r.charCodeAt(t)]<<2|revLookup[r.charCodeAt(t+1)]>>4,i[u++]=255&o):1===a&&(o=revLookup[r.charCodeAt(t)]<<10|revLookup[r.charCodeAt(t+1)]<<4|revLookup[r.charCodeAt(t+2)]>>2,i[u++]=o>>8&255,i[u++]=255&o),i}function tripletToBase64(r){return lookup[r>>18&63]+lookup[r>>12&63]+lookup[r>>6&63]+lookup[63&r]}function encodeChunk(r,t,e){for(var n,o=[],a=t;as?s:i+16383));return 1===n?(t=r[e-1],o+=lookup[t>>2],o+=lookup[t<<4&63],o+="=="):2===n&&(t=(r[e-2]<<8)+r[e-1],o+=lookup[t>>10],o+=lookup[t>>4&63],o+=lookup[t<<2&63],o+="="),a.push(o),a.join("")}function read(r,t,e,n,o){var a,i,s=8*o-n-1,u=(1<>1,c=-7,l=e?o-1:0,p=e?-1:1,h=r[t+l];for(l+=p,a=h&(1<<-c)-1,h>>=-c,c+=s;c>0;a=256*a+r[t+l],l+=p,c-=8);for(i=a&(1<<-c)-1,a>>=-c,c+=n;c>0;i=256*i+r[t+l],l+=p,c-=8);if(0===a)a=1-f;else{if(a===u)return i?NaN:1/0*(h?-1:1);i+=Math.pow(2,n),a-=f}return(h?-1:1)*i*Math.pow(2,a-n)}function write(r,t,e,n,o,a){var i,s,u,f=8*a-o-1,c=(1<>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:a-1,g=n?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,i=c):(i=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-i))<1&&(i--,u*=2),(t+=i+l>=1?p/u:p*Math.pow(2,1-l))*u>=2&&(i++,u/=2),i+l>=c?(s=0,i=c):i+l>=1?(s=(t*u-1)*Math.pow(2,o),i+=l):(s=t*Math.pow(2,l-1)*Math.pow(2,o),i=0));o>=8;r[e+h]=255&s,h+=g,s/=256,o-=8);for(i=i<0;r[e+h]=255&i,h+=g,i/=256,f-=8);r[e+h-g]|=128*y}var toString$1={}.toString,isArray$1=Array.isArray||function(r){return"[object Array]"==toString$1.call(r)},INSPECT_MAX_BYTES=50;function kMaxLength(){return Buffer$2.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function createBuffer(r,t){if(kMaxLength()=kMaxLength())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+kMaxLength().toString(16)+" bytes");return 0|r}function internalIsBuffer(r){return!(null==r||!r._isBuffer)}function byteLength(r,t){if(internalIsBuffer(r))return r.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(r)||r instanceof ArrayBuffer))return r.byteLength;"string"!=typeof r&&(r=""+r);var e=r.length;if(0===e)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return utf8ToBytes(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e;case"hex":return e>>>1;case"base64":return base64ToBytes(r).length;default:if(n)return utf8ToBytes(r).length;t=(""+t).toLowerCase(),n=!0}}function slowToString(r,t,e){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(t>>>=0))return"";for(r||(r="utf8");;)switch(r){case"hex":return hexSlice(this,t,e);case"utf8":case"utf-8":return utf8Slice(this,t,e);case"ascii":return asciiSlice(this,t,e);case"latin1":case"binary":return latin1Slice(this,t,e);case"base64":return base64Slice(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,e);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}function swap(r,t,e){var n=r[t];r[t]=r[e],r[e]=n}function bidirectionalIndexOf(r,t,e,n,o){if(0===r.length)return-1;if("string"==typeof e?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=o?0:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(o)return-1;e=r.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof t&&(t=Buffer$2.from(t,n)),internalIsBuffer(t))return 0===t.length?-1:arrayIndexOf(r,t,e,n,o);if("number"==typeof t)return t&=255,Buffer$2.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):arrayIndexOf(r,[t],e,n,o);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(r,t,e,n,o){var a,i=1,s=r.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(r.length<2||t.length<2)return-1;i=2,s/=2,u/=2,e/=2}function f(r,t){return 1===i?r[t]:r.readUInt16BE(t*i)}if(o){var c=-1;for(a=e;as&&(e=s-u),a=e;a>=0;a--){for(var l=!0,p=0;po&&(n=o):n=o;var a=t.length;if(a%2!=0)throw new TypeError("Invalid hex string");n>a/2&&(n=a/2);for(var i=0;i239?4:f>223?3:f>191?2:1;if(o+l<=e)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(a=r[o+1]))&&(u=(31&f)<<6|63&a)>127&&(c=u);break;case 3:a=r[o+1],i=r[o+2],128==(192&a)&&128==(192&i)&&(u=(15&f)<<12|(63&a)<<6|63&i)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:a=r[o+1],i=r[o+2],s=r[o+3],128==(192&a)&&128==(192&i)&&128==(192&s)&&(u=(15&f)<<18|(63&a)<<12|(63&i)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return decodeCodePointsArray(n)}Buffer$2.TYPED_ARRAY_SUPPORT=void 0===global$1.TYPED_ARRAY_SUPPORT||global$1.TYPED_ARRAY_SUPPORT,Buffer$2.poolSize=8192,Buffer$2._augment=function(r){return r.__proto__=Buffer$2.prototype,r},Buffer$2.from=function(r,t,e){return from(null,r,t,e)},Buffer$2.TYPED_ARRAY_SUPPORT&&(Buffer$2.prototype.__proto__=Uint8Array.prototype,Buffer$2.__proto__=Uint8Array),Buffer$2.alloc=function(r,t,e){return alloc(null,r,t,e)},Buffer$2.allocUnsafe=function(r){return allocUnsafe$1(null,r)},Buffer$2.allocUnsafeSlow=function(r){return allocUnsafe$1(null,r)},Buffer$2.isBuffer=isBuffer$1,Buffer$2.compare=function(r,t){if(!internalIsBuffer(r)||!internalIsBuffer(t))throw new TypeError("Arguments must be Buffers");if(r===t)return 0;for(var e=r.length,n=t.length,o=0,a=Math.min(e,n);o0&&(r=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(r+=" ... ")),""},Buffer$2.prototype.compare=function(r,t,e,n,o){if(!internalIsBuffer(r))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===e&&(e=r?r.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||e>r.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=e)return 0;if(n>=o)return-1;if(t>=e)return 1;if(this===r)return 0;for(var a=(o>>>=0)-(n>>>=0),i=(e>>>=0)-(t>>>=0),s=Math.min(a,i),u=this.slice(n,o),f=r.slice(t,e),c=0;co)&&(e=o),r.length>0&&(e<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var a=!1;;)switch(n){case"hex":return hexWrite(this,r,t,e);case"utf8":case"utf-8":return utf8Write(this,r,t,e);case"ascii":return asciiWrite(this,r,t,e);case"latin1":case"binary":return latin1Write(this,r,t,e);case"base64":return base64Write(this,r,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,r,t,e);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}},Buffer$2.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(r){var t=r.length;if(t<=MAX_ARGUMENTS_LENGTH)return String.fromCharCode.apply(String,r);for(var e="",n=0;nn)&&(e=n);for(var o="",a=t;ae)throw new RangeError("Trying to access beyond buffer length")}function checkInt(r,t,e,n,o,a){if(!internalIsBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||tr.length)throw new RangeError("Index out of range")}function objectWriteUInt16(r,t,e,n){t<0&&(t=65535+t+1);for(var o=0,a=Math.min(r.length-e,2);o>>8*(n?o:1-o)}function objectWriteUInt32(r,t,e,n){t<0&&(t=4294967295+t+1);for(var o=0,a=Math.min(r.length-e,4);o>>8*(n?o:3-o)&255}function checkIEEE754(r,t,e,n,o,a){if(e+n>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function writeFloat(r,t,e,n,o){return o||checkIEEE754(r,t,e,4),write(r,t,e,n,23,4),e+4}function writeDouble(r,t,e,n,o){return o||checkIEEE754(r,t,e,8),write(r,t,e,n,52,8),e+8}Buffer$2.prototype.slice=function(r,t){var e,n=this.length;if((r=~~r)<0?(r+=n)<0&&(r=0):r>n&&(r=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(o*=256);)n+=this[r+--t]*o;return n},Buffer$2.prototype.readUInt8=function(r,t){return t||checkOffset(r,1,this.length),this[r]},Buffer$2.prototype.readUInt16LE=function(r,t){return t||checkOffset(r,2,this.length),this[r]|this[r+1]<<8},Buffer$2.prototype.readUInt16BE=function(r,t){return t||checkOffset(r,2,this.length),this[r]<<8|this[r+1]},Buffer$2.prototype.readUInt32LE=function(r,t){return t||checkOffset(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+16777216*this[r+3]},Buffer$2.prototype.readUInt32BE=function(r,t){return t||checkOffset(r,4,this.length),16777216*this[r]+(this[r+1]<<16|this[r+2]<<8|this[r+3])},Buffer$2.prototype.readIntLE=function(r,t,e){r|=0,t|=0,e||checkOffset(r,t,this.length);for(var n=this[r],o=1,a=0;++a=(o*=128)&&(n-=Math.pow(2,8*t)),n},Buffer$2.prototype.readIntBE=function(r,t,e){r|=0,t|=0,e||checkOffset(r,t,this.length);for(var n=t,o=1,a=this[r+--n];n>0&&(o*=256);)a+=this[r+--n]*o;return a>=(o*=128)&&(a-=Math.pow(2,8*t)),a},Buffer$2.prototype.readInt8=function(r,t){return t||checkOffset(r,1,this.length),128&this[r]?-1*(255-this[r]+1):this[r]},Buffer$2.prototype.readInt16LE=function(r,t){t||checkOffset(r,2,this.length);var e=this[r]|this[r+1]<<8;return 32768&e?4294901760|e:e},Buffer$2.prototype.readInt16BE=function(r,t){t||checkOffset(r,2,this.length);var e=this[r+1]|this[r]<<8;return 32768&e?4294901760|e:e},Buffer$2.prototype.readInt32LE=function(r,t){return t||checkOffset(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},Buffer$2.prototype.readInt32BE=function(r,t){return t||checkOffset(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},Buffer$2.prototype.readFloatLE=function(r,t){return t||checkOffset(r,4,this.length),read(this,r,!0,23,4)},Buffer$2.prototype.readFloatBE=function(r,t){return t||checkOffset(r,4,this.length),read(this,r,!1,23,4)},Buffer$2.prototype.readDoubleLE=function(r,t){return t||checkOffset(r,8,this.length),read(this,r,!0,52,8)},Buffer$2.prototype.readDoubleBE=function(r,t){return t||checkOffset(r,8,this.length),read(this,r,!1,52,8)},Buffer$2.prototype.writeUIntLE=function(r,t,e,n){(r=+r,t|=0,e|=0,n)||checkInt(this,r,t,e,Math.pow(2,8*e)-1,0);var o=1,a=0;for(this[t]=255&r;++a=0&&(a*=256);)this[t+o]=r/a&255;return t+e},Buffer$2.prototype.writeUInt8=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,1,255,0),Buffer$2.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),this[t]=255&r,t+1},Buffer$2.prototype.writeUInt16LE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,2,65535,0),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=255&r,this[t+1]=r>>>8):objectWriteUInt16(this,r,t,!0),t+2},Buffer$2.prototype.writeUInt16BE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,2,65535,0),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=r>>>8,this[t+1]=255&r):objectWriteUInt16(this,r,t,!1),t+2},Buffer$2.prototype.writeUInt32LE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,4,4294967295,0),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t+3]=r>>>24,this[t+2]=r>>>16,this[t+1]=r>>>8,this[t]=255&r):objectWriteUInt32(this,r,t,!0),t+4},Buffer$2.prototype.writeUInt32BE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,4,4294967295,0),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=255&r):objectWriteUInt32(this,r,t,!1),t+4},Buffer$2.prototype.writeIntLE=function(r,t,e,n){if(r=+r,t|=0,!n){var o=Math.pow(2,8*e-1);checkInt(this,r,t,e,o-1,-o)}var a=0,i=1,s=0;for(this[t]=255&r;++a>0)-s&255;return t+e},Buffer$2.prototype.writeIntBE=function(r,t,e,n){if(r=+r,t|=0,!n){var o=Math.pow(2,8*e-1);checkInt(this,r,t,e,o-1,-o)}var a=e-1,i=1,s=0;for(this[t+a]=255&r;--a>=0&&(i*=256);)r<0&&0===s&&0!==this[t+a+1]&&(s=1),this[t+a]=(r/i>>0)-s&255;return t+e},Buffer$2.prototype.writeInt8=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,1,127,-128),Buffer$2.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),r<0&&(r=255+r+1),this[t]=255&r,t+1},Buffer$2.prototype.writeInt16LE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,2,32767,-32768),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=255&r,this[t+1]=r>>>8):objectWriteUInt16(this,r,t,!0),t+2},Buffer$2.prototype.writeInt16BE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,2,32767,-32768),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=r>>>8,this[t+1]=255&r):objectWriteUInt16(this,r,t,!1),t+2},Buffer$2.prototype.writeInt32LE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,4,2147483647,-2147483648),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=255&r,this[t+1]=r>>>8,this[t+2]=r>>>16,this[t+3]=r>>>24):objectWriteUInt32(this,r,t,!0),t+4},Buffer$2.prototype.writeInt32BE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=255&r):objectWriteUInt32(this,r,t,!1),t+4},Buffer$2.prototype.writeFloatLE=function(r,t,e){return writeFloat(this,r,t,!0,e)},Buffer$2.prototype.writeFloatBE=function(r,t,e){return writeFloat(this,r,t,!1,e)},Buffer$2.prototype.writeDoubleLE=function(r,t,e){return writeDouble(this,r,t,!0,e)},Buffer$2.prototype.writeDoubleBE=function(r,t,e){return writeDouble(this,r,t,!1,e)},Buffer$2.prototype.copy=function(r,t,e,n){if(e||(e=0),n||0===n||(n=this.length),t>=r.length&&(t=r.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),r.length-t=0;--o)r[o+t]=this[o+e];else if(a<1e3||!Buffer$2.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,e=void 0===e?this.length:e>>>0,r||(r=0),"number"==typeof r)for(a=t;a55295&&e<57344){if(!o){if(e>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(i+1===n){(t-=3)>-1&&a.push(239,191,189);continue}o=e;continue}if(e<56320){(t-=3)>-1&&a.push(239,191,189),o=e;continue}e=65536+(o-55296<<10|e-56320)}else o&&(t-=3)>-1&&a.push(239,191,189);if(o=null,e<128){if((t-=1)<0)break;a.push(e)}else if(e<2048){if((t-=2)<0)break;a.push(e>>6|192,63&e|128)}else if(e<65536){if((t-=3)<0)break;a.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;a.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return a}function asciiToBytes(r){for(var t=[],e=0;e>8,o=e%256,a.push(o),a.push(n);return a}function base64ToBytes(r){return toByteArray(base64clean(r))}function blitBuffer(r,t,e,n){for(var o=0;o=t.length||o>=r.length);++o)t[o+e]=r[o];return o}function isnan(r){return r!=r}function isBuffer$1(r){return null!=r&&(!!r._isBuffer||isFastBuffer(r)||isSlowBuffer(r))}function isFastBuffer(r){return!!r.constructor&&"function"==typeof r.constructor.isBuffer&&r.constructor.isBuffer(r)}function isSlowBuffer(r){return"function"==typeof r.readFloatLE&&"function"==typeof r.slice&&isFastBuffer(r.slice(0,0))}function buff(r,t){return void 0===t&&(t=BASE64_FORMAT),isBuffer$1(r)?r:new Buffer$2.from(r,t)}var replaceErrors=function(r,t){if(t instanceof Error){var e={};return Object.getOwnPropertyNames(t).forEach((function(r){e[r]=t[r]})),e}return t},printError=function(r){return JSON.stringify(r,replaceErrors)};function findFromContract(r,t,e){return!!(e[r]&&e[r][t]&&e[r][t].file&&fs.existsSync(e[r][t].file))&&e[r][t].file}var DOT=".",getDocLen=function(r){return Buffer$2.byteLength(r,"utf8")},headerParser=function(r,t){try{var e=r.headers.accept.split(",");return t?e.filter((function(r){return r===t})):e}catch(r){return[]}},isHeaderPresent=function(r,t){return!!headerParser(r,t).length},getPathToFn=function(r,t,e){var n=e.resolverDir,o=dasherize(r),a=[];e.contract&&e.contract[t]&&e.contract[t].path&&a.push(e.contract[t].path),a.push(path.join(n,t,o,[INDEX_KEY,EXT].join(DOT))),a.push(path.join(n,t,[o,EXT].join(DOT)));for(var i=a.length,s=0;so?0:o+t),(e=e>o?o:e)<0&&(e+=o),o=t>e?0:e-t>>>0,t>>>=0;for(var a=Array(o);++n=n?r:baseSlice(r,t,e)}function baseFindIndex(r,t,e,n){for(var o=r.length,a=e+(n?1:-1);n?a--:++a-1;);return e}function charsStartIndex(r,t){for(var e=-1,n=r.length;++e-1;);return e}function asciiToArray(r){return r.split("")}var rsAstralRange="\\ud800-\\udfff",rsComboMarksRange="\\u0300-\\u036f",reComboHalfMarksRange="\\ufe20-\\ufe2f",rsComboSymbolsRange="\\u20d0-\\u20ff",rsComboRange=rsComboMarksRange+reComboHalfMarksRange+rsComboSymbolsRange,rsVarRange="\\ufe0e\\ufe0f",rsZWJ="\\u200d",reHasUnicode=RegExp("["+rsZWJ+rsAstralRange+rsComboRange+rsVarRange+"]");function hasUnicode(r){return reHasUnicode.test(r)}var rsAstralRange$1="\\ud800-\\udfff",rsComboMarksRange$1="\\u0300-\\u036f",reComboHalfMarksRange$1="\\ufe20-\\ufe2f",rsComboSymbolsRange$1="\\u20d0-\\u20ff",rsComboRange$1=rsComboMarksRange$1+reComboHalfMarksRange$1+rsComboSymbolsRange$1,rsVarRange$1="\\ufe0e\\ufe0f",rsAstral="["+rsAstralRange$1+"]",rsCombo="["+rsComboRange$1+"]",rsFitz="\\ud83c[\\udffb-\\udfff]",rsModifier="(?:"+rsCombo+"|"+rsFitz+")",rsNonAstral="[^"+rsAstralRange$1+"]",rsRegional="(?:\\ud83c[\\udde6-\\uddff]){2}",rsSurrPair="[\\ud800-\\udbff][\\udc00-\\udfff]",rsZWJ$1="\\u200d",reOptMod=rsModifier+"?",rsOptVar="["+rsVarRange$1+"]?",rsOptJoin="(?:"+rsZWJ$1+"(?:"+[rsNonAstral,rsRegional,rsSurrPair].join("|")+")"+rsOptVar+reOptMod+")*",rsSeq=rsOptVar+reOptMod+rsOptJoin,rsSymbol="(?:"+[rsNonAstral+rsCombo+"?",rsCombo,rsRegional,rsSurrPair,rsAstral].join("|")+")",reUnicode=RegExp(rsFitz+"(?="+rsFitz+")|"+rsSymbol+rsSeq,"g");function unicodeToArray(r){return r.match(reUnicode)||[]}function stringToArray(r){return hasUnicode(r)?unicodeToArray(r):asciiToArray(r)}function toString(r){return null==r?"":baseToString(r)}var reTrim=/^\s+|\s+$/g;function trim(r,t,e){if((r=toString(r))&&(e||void 0===t))return r.replace(reTrim,"");if(!r||!(t=baseToString(t)))return r;var n=stringToArray(r),o=stringToArray(t);return castSlice(n,charsStartIndex(n,o),charsEndIndex(n,o)+1).join("")}var inArray=function(r,t){return!!r.filter((function(r){return r===t})).length},toArray=function(r){return isArray(r)?r:[r]},parse=function(r){try{return JSON.parse(r)}catch(t){return r}},isObjectHasKey=function(r,t){try{var e=Object.keys(r);return inArray(e,t)}catch(r){return!1}},createEvt=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return r.join("_")},timestamp=function(r){void 0===r&&(r=!1);var t=Date.now();return r?Math.floor(t/1e3):t},urlParams=function(r,t){var e=[];for(var n in t)e.push([n,t[n]].join("="));return[r,e.join("&")].join("?")},cacheBurstUrl=function(r){return urlParams(r,cacheBurst())},cacheBurst=function(){return{_cb:timestamp()}},dasherize=function(r){return trim(r).replace(/([A-Z])/g,"-$1").replace(/[-_\s]+/g,"-").toLowerCase()},getConfigValue=function(r,t){return t&&isPlainObject(t)&&r in t?t[r]:void 0},toJson=function(r){return"string"==typeof r?parse(r):JSON.parse(JSON.stringify(r))},isNotEmpty=function(r){return void 0!==r&&!1!==r&&null!==r&&""!==trim(r)},chainFns=function(r){for(var t=[],e=arguments.length-1;e-- >0;)t[e]=arguments[e+1];return function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];return t.reduce((function(r,t){return Reflect.apply(t,null,toArray(r))}),Reflect.apply(r,null,e))}};function listCacheClear(){this.__data__=[],this.size=0}function eq(r,t){return r===t||r!=r&&t!=t}function assocIndexOf(r,t){for(var e=r.length;e--;)if(eq(r[e][0],t))return e;return-1}var arrayProto=Array.prototype,splice=arrayProto.splice;function listCacheDelete(r){var t=this.__data__,e=assocIndexOf(t,r);return!(e<0)&&(e==t.length-1?t.pop():splice.call(t,e,1),--this.size,!0)}function listCacheGet(r){var t=this.__data__,e=assocIndexOf(t,r);return e<0?void 0:t[e][1]}function listCacheHas(r){return assocIndexOf(this.__data__,r)>-1}function listCacheSet(r,t){var e=this.__data__,n=assocIndexOf(e,r);return n<0?(++this.size,e.push([r,t])):e[n][1]=t,this}function ListCache(r){var t=-1,e=null==r?0:r.length;for(this.clear();++t-1&&r%1==0&&r<=MAX_SAFE_INTEGER}function isArrayLike(r){return null!=r&&isLength(r.length)&&!isFunction(r)}function isArrayLikeObject(r){return isObjectLike(r)&&isArrayLike(r)}function stubFalse(){return!1}var freeExports$1="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule$1=freeExports$1&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports$1=freeModule$1&&freeModule$1.exports===freeExports$1,Buffer$1=moduleExports$1?root.Buffer:void 0,nativeIsBuffer=Buffer$1?Buffer$1.isBuffer:void 0,isBuffer=nativeIsBuffer||stubFalse,argsTag$1="[object Arguments]",arrayTag="[object Array]",boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",funcTag$1="[object Function]",mapTag="[object Map]",numberTag="[object Number]",objectTag$1="[object Object]",regexpTag="[object RegExp]",setTag="[object Set]",stringTag="[object String]",weakMapTag="[object WeakMap]",arrayBufferTag="[object ArrayBuffer]",dataViewTag="[object DataView]",float32Tag="[object Float32Array]",float64Tag="[object Float64Array]",int8Tag="[object Int8Array]",int16Tag="[object Int16Array]",int32Tag="[object Int32Array]",uint8Tag="[object Uint8Array]",uint8ClampedTag="[object Uint8ClampedArray]",uint16Tag="[object Uint16Array]",uint32Tag="[object Uint32Array]",typedArrayTags={};function baseIsTypedArray(r){return isObjectLike(r)&&isLength(r.length)&&!!typedArrayTags[baseGetTag(r)]}function baseUnary(r){return function(t){return r(t)}}typedArrayTags[float32Tag]=typedArrayTags[float64Tag]=typedArrayTags[int8Tag]=typedArrayTags[int16Tag]=typedArrayTags[int32Tag]=typedArrayTags[uint8Tag]=typedArrayTags[uint8ClampedTag]=typedArrayTags[uint16Tag]=typedArrayTags[uint32Tag]=!0,typedArrayTags[argsTag$1]=typedArrayTags[arrayTag]=typedArrayTags[arrayBufferTag]=typedArrayTags[boolTag]=typedArrayTags[dataViewTag]=typedArrayTags[dateTag]=typedArrayTags[errorTag]=typedArrayTags[funcTag$1]=typedArrayTags[mapTag]=typedArrayTags[numberTag]=typedArrayTags[objectTag$1]=typedArrayTags[regexpTag]=typedArrayTags[setTag]=typedArrayTags[stringTag]=typedArrayTags[weakMapTag]=!1;var freeExports$2="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule$2=freeExports$2&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports$2=freeModule$2&&freeModule$2.exports===freeExports$2,freeProcess=moduleExports$2&&freeGlobal.process,nodeUtil=function(){try{var r=freeModule$2&&freeModule$2.require&&freeModule$2.require("util").types;return r||freeProcess&&freeProcess.binding&&freeProcess.binding("util")}catch(r){}}(),nodeIsTypedArray=nodeUtil&&nodeUtil.isTypedArray,isTypedArray=nodeIsTypedArray?baseUnary(nodeIsTypedArray):baseIsTypedArray;function safeGet(r,t){if(("constructor"!==t||"function"!=typeof r[t])&&"__proto__"!=t)return r[t]}var objectProto$8=Object.prototype,hasOwnProperty$6=objectProto$8.hasOwnProperty;function assignValue(r,t,e){var n=r[t];hasOwnProperty$6.call(r,t)&&eq(n,e)&&(void 0!==e||t in r)||baseAssignValue(r,t,e)}function copyObject(r,t,e,n){var o=!e;e||(e={});for(var a=-1,i=t.length;++a-1&&r%1==0&&r0){if(++t>=HOT_COUNT)return arguments[0]}else t=0;return r.apply(void 0,arguments)}}var setToString=shortOut(baseSetToString);function baseRest(r,t){return setToString(overRest(r,t,identity),r+"")}function isIterateeCall(r,t,e){if(!isObject(e))return!1;var n=typeof t;return!!("number"==n?isArrayLike(e)&&isIndex(t,e.length):"string"==n&&t in e)&&eq(e[t],r)}function createAssigner(r){return baseRest((function(t,e){var n=-1,o=e.length,a=o>1?e[o-1]:void 0,i=o>2?e[2]:void 0;for(a=r.length>3&&"function"==typeof a?(o--,a):void 0,i&&isIterateeCall(e[0],e[1],i)&&(a=o<3?void 0:a,o=1),t=Object(t);++n0)throw new Error("Invalid string. Length must be a multiple of 4");a="="===r[s-2]?2:"="===r[s-1]?1:0,i=new Arr(3*s/4-a),n=a>0?s-4:s;var u=0;for(t=0,e=0;t>16&255,i[u++]=o>>8&255,i[u++]=255&o;return 2===a?(o=revLookup[r.charCodeAt(t)]<<2|revLookup[r.charCodeAt(t+1)]>>4,i[u++]=255&o):1===a&&(o=revLookup[r.charCodeAt(t)]<<10|revLookup[r.charCodeAt(t+1)]<<4|revLookup[r.charCodeAt(t+2)]>>2,i[u++]=o>>8&255,i[u++]=255&o),i}function tripletToBase64(r){return lookup[r>>18&63]+lookup[r>>12&63]+lookup[r>>6&63]+lookup[63&r]}function encodeChunk(r,t,e){for(var n,o=[],a=t;as?s:i+16383));return 1===n?(t=r[e-1],o+=lookup[t>>2],o+=lookup[t<<4&63],o+="=="):2===n&&(t=(r[e-2]<<8)+r[e-1],o+=lookup[t>>10],o+=lookup[t>>4&63],o+=lookup[t<<2&63],o+="="),a.push(o),a.join("")}function read(r,t,e,n,o){var a,i,s=8*o-n-1,u=(1<>1,c=-7,l=e?o-1:0,p=e?-1:1,h=r[t+l];for(l+=p,a=h&(1<<-c)-1,h>>=-c,c+=s;c>0;a=256*a+r[t+l],l+=p,c-=8);for(i=a&(1<<-c)-1,a>>=-c,c+=n;c>0;i=256*i+r[t+l],l+=p,c-=8);if(0===a)a=1-f;else{if(a===u)return i?NaN:1/0*(h?-1:1);i+=Math.pow(2,n),a-=f}return(h?-1:1)*i*Math.pow(2,a-n)}function write(r,t,e,n,o,a){var i,s,u,f=8*a-o-1,c=(1<>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:a-1,g=n?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,i=c):(i=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-i))<1&&(i--,u*=2),(t+=i+l>=1?p/u:p*Math.pow(2,1-l))*u>=2&&(i++,u/=2),i+l>=c?(s=0,i=c):i+l>=1?(s=(t*u-1)*Math.pow(2,o),i+=l):(s=t*Math.pow(2,l-1)*Math.pow(2,o),i=0));o>=8;r[e+h]=255&s,h+=g,s/=256,o-=8);for(i=i<0;r[e+h]=255&i,h+=g,i/=256,f-=8);r[e+h-g]|=128*y}var toString$1={}.toString,isArray$1=Array.isArray||function(r){return"[object Array]"==toString$1.call(r)},INSPECT_MAX_BYTES=50;function kMaxLength(){return Buffer$2.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function createBuffer(r,t){if(kMaxLength()=kMaxLength())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+kMaxLength().toString(16)+" bytes");return 0|r}function internalIsBuffer(r){return!(null==r||!r._isBuffer)}function byteLength(r,t){if(internalIsBuffer(r))return r.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(r)||r instanceof ArrayBuffer))return r.byteLength;"string"!=typeof r&&(r=""+r);var e=r.length;if(0===e)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return utf8ToBytes(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e;case"hex":return e>>>1;case"base64":return base64ToBytes(r).length;default:if(n)return utf8ToBytes(r).length;t=(""+t).toLowerCase(),n=!0}}function slowToString(r,t,e){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(t>>>=0))return"";for(r||(r="utf8");;)switch(r){case"hex":return hexSlice(this,t,e);case"utf8":case"utf-8":return utf8Slice(this,t,e);case"ascii":return asciiSlice(this,t,e);case"latin1":case"binary":return latin1Slice(this,t,e);case"base64":return base64Slice(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,e);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}function swap(r,t,e){var n=r[t];r[t]=r[e],r[e]=n}function bidirectionalIndexOf(r,t,e,n,o){if(0===r.length)return-1;if("string"==typeof e?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=o?0:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(o)return-1;e=r.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof t&&(t=Buffer$2.from(t,n)),internalIsBuffer(t))return 0===t.length?-1:arrayIndexOf(r,t,e,n,o);if("number"==typeof t)return t&=255,Buffer$2.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):arrayIndexOf(r,[t],e,n,o);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(r,t,e,n,o){var a,i=1,s=r.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(r.length<2||t.length<2)return-1;i=2,s/=2,u/=2,e/=2}function f(r,t){return 1===i?r[t]:r.readUInt16BE(t*i)}if(o){var c=-1;for(a=e;as&&(e=s-u),a=e;a>=0;a--){for(var l=!0,p=0;po&&(n=o):n=o;var a=t.length;if(a%2!=0)throw new TypeError("Invalid hex string");n>a/2&&(n=a/2);for(var i=0;i239?4:f>223?3:f>191?2:1;if(o+l<=e)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(a=r[o+1]))&&(u=(31&f)<<6|63&a)>127&&(c=u);break;case 3:a=r[o+1],i=r[o+2],128==(192&a)&&128==(192&i)&&(u=(15&f)<<12|(63&a)<<6|63&i)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:a=r[o+1],i=r[o+2],s=r[o+3],128==(192&a)&&128==(192&i)&&128==(192&s)&&(u=(15&f)<<18|(63&a)<<12|(63&i)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return decodeCodePointsArray(n)}Buffer$2.TYPED_ARRAY_SUPPORT=void 0===global$1.TYPED_ARRAY_SUPPORT||global$1.TYPED_ARRAY_SUPPORT,Buffer$2.poolSize=8192,Buffer$2._augment=function(r){return r.__proto__=Buffer$2.prototype,r},Buffer$2.from=function(r,t,e){return from(null,r,t,e)},Buffer$2.TYPED_ARRAY_SUPPORT&&(Buffer$2.prototype.__proto__=Uint8Array.prototype,Buffer$2.__proto__=Uint8Array),Buffer$2.alloc=function(r,t,e){return alloc(null,r,t,e)},Buffer$2.allocUnsafe=function(r){return allocUnsafe$1(null,r)},Buffer$2.allocUnsafeSlow=function(r){return allocUnsafe$1(null,r)},Buffer$2.isBuffer=isBuffer$1,Buffer$2.compare=function(r,t){if(!internalIsBuffer(r)||!internalIsBuffer(t))throw new TypeError("Arguments must be Buffers");if(r===t)return 0;for(var e=r.length,n=t.length,o=0,a=Math.min(e,n);o0&&(r=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(r+=" ... ")),""},Buffer$2.prototype.compare=function(r,t,e,n,o){if(!internalIsBuffer(r))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===e&&(e=r?r.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||e>r.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=e)return 0;if(n>=o)return-1;if(t>=e)return 1;if(this===r)return 0;for(var a=(o>>>=0)-(n>>>=0),i=(e>>>=0)-(t>>>=0),s=Math.min(a,i),u=this.slice(n,o),f=r.slice(t,e),c=0;co)&&(e=o),r.length>0&&(e<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var a=!1;;)switch(n){case"hex":return hexWrite(this,r,t,e);case"utf8":case"utf-8":return utf8Write(this,r,t,e);case"ascii":return asciiWrite(this,r,t,e);case"latin1":case"binary":return latin1Write(this,r,t,e);case"base64":return base64Write(this,r,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,r,t,e);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}},Buffer$2.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(r){var t=r.length;if(t<=MAX_ARGUMENTS_LENGTH)return String.fromCharCode.apply(String,r);for(var e="",n=0;nn)&&(e=n);for(var o="",a=t;ae)throw new RangeError("Trying to access beyond buffer length")}function checkInt(r,t,e,n,o,a){if(!internalIsBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||tr.length)throw new RangeError("Index out of range")}function objectWriteUInt16(r,t,e,n){t<0&&(t=65535+t+1);for(var o=0,a=Math.min(r.length-e,2);o>>8*(n?o:1-o)}function objectWriteUInt32(r,t,e,n){t<0&&(t=4294967295+t+1);for(var o=0,a=Math.min(r.length-e,4);o>>8*(n?o:3-o)&255}function checkIEEE754(r,t,e,n,o,a){if(e+n>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function writeFloat(r,t,e,n,o){return o||checkIEEE754(r,t,e,4),write(r,t,e,n,23,4),e+4}function writeDouble(r,t,e,n,o){return o||checkIEEE754(r,t,e,8),write(r,t,e,n,52,8),e+8}Buffer$2.prototype.slice=function(r,t){var e,n=this.length;if((r=~~r)<0?(r+=n)<0&&(r=0):r>n&&(r=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(o*=256);)n+=this[r+--t]*o;return n},Buffer$2.prototype.readUInt8=function(r,t){return t||checkOffset(r,1,this.length),this[r]},Buffer$2.prototype.readUInt16LE=function(r,t){return t||checkOffset(r,2,this.length),this[r]|this[r+1]<<8},Buffer$2.prototype.readUInt16BE=function(r,t){return t||checkOffset(r,2,this.length),this[r]<<8|this[r+1]},Buffer$2.prototype.readUInt32LE=function(r,t){return t||checkOffset(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+16777216*this[r+3]},Buffer$2.prototype.readUInt32BE=function(r,t){return t||checkOffset(r,4,this.length),16777216*this[r]+(this[r+1]<<16|this[r+2]<<8|this[r+3])},Buffer$2.prototype.readIntLE=function(r,t,e){r|=0,t|=0,e||checkOffset(r,t,this.length);for(var n=this[r],o=1,a=0;++a=(o*=128)&&(n-=Math.pow(2,8*t)),n},Buffer$2.prototype.readIntBE=function(r,t,e){r|=0,t|=0,e||checkOffset(r,t,this.length);for(var n=t,o=1,a=this[r+--n];n>0&&(o*=256);)a+=this[r+--n]*o;return a>=(o*=128)&&(a-=Math.pow(2,8*t)),a},Buffer$2.prototype.readInt8=function(r,t){return t||checkOffset(r,1,this.length),128&this[r]?-1*(255-this[r]+1):this[r]},Buffer$2.prototype.readInt16LE=function(r,t){t||checkOffset(r,2,this.length);var e=this[r]|this[r+1]<<8;return 32768&e?4294901760|e:e},Buffer$2.prototype.readInt16BE=function(r,t){t||checkOffset(r,2,this.length);var e=this[r+1]|this[r]<<8;return 32768&e?4294901760|e:e},Buffer$2.prototype.readInt32LE=function(r,t){return t||checkOffset(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},Buffer$2.prototype.readInt32BE=function(r,t){return t||checkOffset(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},Buffer$2.prototype.readFloatLE=function(r,t){return t||checkOffset(r,4,this.length),read(this,r,!0,23,4)},Buffer$2.prototype.readFloatBE=function(r,t){return t||checkOffset(r,4,this.length),read(this,r,!1,23,4)},Buffer$2.prototype.readDoubleLE=function(r,t){return t||checkOffset(r,8,this.length),read(this,r,!0,52,8)},Buffer$2.prototype.readDoubleBE=function(r,t){return t||checkOffset(r,8,this.length),read(this,r,!1,52,8)},Buffer$2.prototype.writeUIntLE=function(r,t,e,n){(r=+r,t|=0,e|=0,n)||checkInt(this,r,t,e,Math.pow(2,8*e)-1,0);var o=1,a=0;for(this[t]=255&r;++a=0&&(a*=256);)this[t+o]=r/a&255;return t+e},Buffer$2.prototype.writeUInt8=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,1,255,0),Buffer$2.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),this[t]=255&r,t+1},Buffer$2.prototype.writeUInt16LE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,2,65535,0),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=255&r,this[t+1]=r>>>8):objectWriteUInt16(this,r,t,!0),t+2},Buffer$2.prototype.writeUInt16BE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,2,65535,0),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=r>>>8,this[t+1]=255&r):objectWriteUInt16(this,r,t,!1),t+2},Buffer$2.prototype.writeUInt32LE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,4,4294967295,0),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t+3]=r>>>24,this[t+2]=r>>>16,this[t+1]=r>>>8,this[t]=255&r):objectWriteUInt32(this,r,t,!0),t+4},Buffer$2.prototype.writeUInt32BE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,4,4294967295,0),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=255&r):objectWriteUInt32(this,r,t,!1),t+4},Buffer$2.prototype.writeIntLE=function(r,t,e,n){if(r=+r,t|=0,!n){var o=Math.pow(2,8*e-1);checkInt(this,r,t,e,o-1,-o)}var a=0,i=1,s=0;for(this[t]=255&r;++a>0)-s&255;return t+e},Buffer$2.prototype.writeIntBE=function(r,t,e,n){if(r=+r,t|=0,!n){var o=Math.pow(2,8*e-1);checkInt(this,r,t,e,o-1,-o)}var a=e-1,i=1,s=0;for(this[t+a]=255&r;--a>=0&&(i*=256);)r<0&&0===s&&0!==this[t+a+1]&&(s=1),this[t+a]=(r/i>>0)-s&255;return t+e},Buffer$2.prototype.writeInt8=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,1,127,-128),Buffer$2.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),r<0&&(r=255+r+1),this[t]=255&r,t+1},Buffer$2.prototype.writeInt16LE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,2,32767,-32768),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=255&r,this[t+1]=r>>>8):objectWriteUInt16(this,r,t,!0),t+2},Buffer$2.prototype.writeInt16BE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,2,32767,-32768),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=r>>>8,this[t+1]=255&r):objectWriteUInt16(this,r,t,!1),t+2},Buffer$2.prototype.writeInt32LE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,4,2147483647,-2147483648),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=255&r,this[t+1]=r>>>8,this[t+2]=r>>>16,this[t+3]=r>>>24):objectWriteUInt32(this,r,t,!0),t+4},Buffer$2.prototype.writeInt32BE=function(r,t,e){return r=+r,t|=0,e||checkInt(this,r,t,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),Buffer$2.TYPED_ARRAY_SUPPORT?(this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=255&r):objectWriteUInt32(this,r,t,!1),t+4},Buffer$2.prototype.writeFloatLE=function(r,t,e){return writeFloat(this,r,t,!0,e)},Buffer$2.prototype.writeFloatBE=function(r,t,e){return writeFloat(this,r,t,!1,e)},Buffer$2.prototype.writeDoubleLE=function(r,t,e){return writeDouble(this,r,t,!0,e)},Buffer$2.prototype.writeDoubleBE=function(r,t,e){return writeDouble(this,r,t,!1,e)},Buffer$2.prototype.copy=function(r,t,e,n){if(e||(e=0),n||0===n||(n=this.length),t>=r.length&&(t=r.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),r.length-t=0;--o)r[o+t]=this[o+e];else if(a<1e3||!Buffer$2.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,e=void 0===e?this.length:e>>>0,r||(r=0),"number"==typeof r)for(a=t;a55295&&e<57344){if(!o){if(e>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(i+1===n){(t-=3)>-1&&a.push(239,191,189);continue}o=e;continue}if(e<56320){(t-=3)>-1&&a.push(239,191,189),o=e;continue}e=65536+(o-55296<<10|e-56320)}else o&&(t-=3)>-1&&a.push(239,191,189);if(o=null,e<128){if((t-=1)<0)break;a.push(e)}else if(e<2048){if((t-=2)<0)break;a.push(e>>6|192,63&e|128)}else if(e<65536){if((t-=3)<0)break;a.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;a.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return a}function asciiToBytes(r){for(var t=[],e=0;e>8,o=e%256,a.push(o),a.push(n);return a}function base64ToBytes(r){return toByteArray(base64clean(r))}function blitBuffer(r,t,e,n){for(var o=0;o=t.length||o>=r.length);++o)t[o+e]=r[o];return o}function isnan(r){return r!=r}function isBuffer$1(r){return null!=r&&(!!r._isBuffer||isFastBuffer(r)||isSlowBuffer(r))}function isFastBuffer(r){return!!r.constructor&&"function"==typeof r.constructor.isBuffer&&r.constructor.isBuffer(r)}function isSlowBuffer(r){return"function"==typeof r.readFloatLE&&"function"==typeof r.slice&&isFastBuffer(r.slice(0,0))}function buff(r,t){return void 0===t&&(t=BASE64_FORMAT),isBuffer$1(r)?r:new Buffer$2.from(r,t)}var replaceErrors=function(r,t){if(t instanceof Error){var e={};return Object.getOwnPropertyNames(t).forEach((function(r){e[r]=t[r]})),e}return t},printError=function(r){return JSON.stringify(r,replaceErrors)};function findFromContract(r,t,e){return!!(e[r]&&e[r][t]&&e[r][t].file&&fs.existsSync(e[r][t].file))&&e[r][t].file}var DOT=".",getDocLen=function(r){return Buffer$2.byteLength(r,"utf8")},headerParser=function(r,t){try{var e=r.headers.accept.split(",");return t?e.filter((function(r){return r===t})):e}catch(r){return[]}},isHeaderPresent=function(r,t){return!!headerParser(r,t).length},getPathToFn=function(r,t,e){var n=e.resolverDir,o=dasherize(r),a=[];e.contract&&e.contract[t]&&e.contract[t].path&&a.push(e.contract[t].path),a.push(path.join(n,t,o,[INDEX_KEY,EXT].join(DOT))),a.push(path.join(n,t,[o,EXT].join(DOT)));for(var i=a.length,s=0;s Date: Wed, 20 Nov 2019 11:25:06 +0800 Subject: [PATCH 11/14] update test to verify the new isContract method is correct --- packages/utils/tests/construct.test.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/utils/tests/construct.test.js b/packages/utils/tests/construct.test.js index 0e8c3835..569e9007 100644 --- a/packages/utils/tests/construct.test.js +++ b/packages/utils/tests/construct.test.js @@ -7,7 +7,10 @@ test("It should able to check if an object is contract or not", t => { t.false(isContract('contract')) t.false(isContract([])) t.false(isContract({})) - t.true(isContract({query: {getSomething: {}}})) + + const contract = {query: {getSomething: {}}} + + t.deepEqual(isContract(contract), contract) }) test("Test isObjectHasKey is exported or not", t => { -- Gitee From 0c7dfdbb474a47cb8e5dbd7a6fee42590340be64 Mon Sep 17 00:00:00 2001 From: joelchu Date: Wed, 20 Nov 2019 11:27:38 +0800 Subject: [PATCH 12/14] update the jsonql-utils dep for jsonql-koa and test passed --- packages/koa/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/koa/package.json b/packages/koa/package.json index 1f353e79..9dc7b072 100644 --- a/packages/koa/package.json +++ b/packages/koa/package.json @@ -81,7 +81,7 @@ "jsonql-node-client": "^1.2.3", "jsonql-params-validator": "^1.4.11", "jsonql-resolver": "^0.9.6", - "jsonql-utils": "^0.8.4", + "jsonql-utils": "^0.8.5", "jsonql-web-console": "^0.4.3", "koa-compose": "^4.1.0", "lodash": "^4.17.15" -- Gitee From 6dcaf58bbe9df01f725d9b28bfb961354fb23b8f Mon Sep 17 00:00:00 2001 From: joelchu Date: Wed, 20 Nov 2019 14:12:07 +0800 Subject: [PATCH 13/14] fix the contract missing error --- .../contract/socket-keys/privateKey.pem | 15 - .../contract/socket-keys/publicKey.pem | 6 - .../fixtures/contract/socket/contract.json | 305 ------------------ .../contract/socket/public-contract.json | 287 ---------------- 4 files changed, 613 deletions(-) delete mode 100644 packages/@jsonql/koa/tests/fixtures/contract/socket-keys/privateKey.pem delete mode 100644 packages/@jsonql/koa/tests/fixtures/contract/socket-keys/publicKey.pem delete mode 100644 packages/@jsonql/koa/tests/fixtures/contract/socket/contract.json delete mode 100644 packages/@jsonql/koa/tests/fixtures/contract/socket/public-contract.json diff --git a/packages/@jsonql/koa/tests/fixtures/contract/socket-keys/privateKey.pem b/packages/@jsonql/koa/tests/fixtures/contract/socket-keys/privateKey.pem deleted file mode 100644 index e7a1bcc6..00000000 --- a/packages/@jsonql/koa/tests/fixtures/contract/socket-keys/privateKey.pem +++ /dev/null @@ -1,15 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIICXgIBAAKBgQCn+OM/ttUkDvsQuioEjBNo0ZqvFDjU0P0U9xFnC0xEFX3QE8Mv -54UyymL/ReVxOFhHK4lN431uugVmPqIzmAa/wdxb/6APX4dF/Bfkb4y8yxDH11Ur -+8GpMz8cRCzkwlS1ZTseJalVP6MeLPotT0cK6Rmpl2Ixg4xqpgayzcXi/QIDAQAB -AoGBAKSWy04OQBGiID8Gu89S1l36LMDrZriZw7M8WTAIMQXxrSMrijGxgaIAEDsk -aSuk01OBhHvusmTCIDJMozE9ATZjfCwohBTLuum8FCrx4DtCOGDtsPjwEnw2Q6a8 -0gLYfdDA54rPKTyCVpwzy7Dx9gRYhNv8e0U+NHlHEqjBYNt9AkEA3JmRwqVZfLkl -ZhuNc0BNwQ/rCnNWcld9AmxB3UnE2MwD5qNJ3Sj7Q+DF6veb55JTllFpLSzfy9rb -t2nhbCeJ1wJBAMLtVEV8TEC8YbBtre00fYpEE/gPZq84ii5YN4lGjo4Z8JwQYK0m -5GNKqQ/vrVTxEwCbqCRN5JsJL/Gnjd69Z0sCQQCUG+M6PUvcqm4KpRsOMzFBGw/i -f1eeA1FiLA74pMuuByPjWOSBwT8Z7rLTNBWPn7XRKa2k8Aj91F5KQaNguxcXAkBI -MT2UvoQ/NYW4oeZYg6g7HRuIM6wEGRyULXfkD42cc175bddgSZcsbupOTKYVX3N6 -Niv/xhl0keJ/zV5tsBghAkEAo6NOvUlyCErWgJWFwPnuwpkRer1Lu9x1ECynXutc -VVwl6qXYmd9ySF1kTx0kfE/MdYPO28EmXRm0Guy3hnGuJQ== ------END RSA PRIVATE KEY----- diff --git a/packages/@jsonql/koa/tests/fixtures/contract/socket-keys/publicKey.pem b/packages/@jsonql/koa/tests/fixtures/contract/socket-keys/publicKey.pem deleted file mode 100644 index 97b3b45d..00000000 --- a/packages/@jsonql/koa/tests/fixtures/contract/socket-keys/publicKey.pem +++ /dev/null @@ -1,6 +0,0 @@ ------BEGIN PUBLIC KEY----- -MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCn+OM/ttUkDvsQuioEjBNo0Zqv -FDjU0P0U9xFnC0xEFX3QE8Mv54UyymL/ReVxOFhHK4lN431uugVmPqIzmAa/wdxb -/6APX4dF/Bfkb4y8yxDH11Ur+8GpMz8cRCzkwlS1ZTseJalVP6MeLPotT0cK6Rmp -l2Ixg4xqpgayzcXi/QIDAQAB ------END PUBLIC KEY----- diff --git a/packages/@jsonql/koa/tests/fixtures/contract/socket/contract.json b/packages/@jsonql/koa/tests/fixtures/contract/socket/contract.json deleted file mode 100644 index 5360f6b7..00000000 --- a/packages/@jsonql/koa/tests/fixtures/contract/socket/contract.json +++ /dev/null @@ -1,305 +0,0 @@ -{ - "query": { - "causeError": { - "file": "/home/joel/projects/open-source/jsonql/packages/@jsonql/koa/tests/fixtures/resolvers/query/cause-error.js", - "description": false, - "params": [ - { - "type": [ - "any" - ], - "name": "x", - "description": "param" - } - ], - "returns": [ - { - "type": [ - "any" - ], - "description": "unknown" - } - ] - }, - "getUser": { - "file": "/home/joel/projects/open-source/jsonql/packages/@jsonql/koa/tests/fixtures/resolvers/query/get-user.js", - "description": "This use a spread as parameter", - "params": [ - { - "type": [ - "string" - ], - "name": "args", - "variable": true, - "description": "passing unknown number of param" - } - ], - "returns": [ - { - "type": [ - "any" - ], - "description": "extract from last of the args" - } - ] - }, - "getSecretMsg": { - "file": "/home/joel/projects/open-source/jsonql/packages/@jsonql/koa/tests/fixtures/resolvers/query/private/get-secret-msg.js", - "description": "a hidden private method", - "params": [], - "returns": [ - { - "type": [ - "string" - ], - "description": "a secret message" - } - ] - }, - "alwaysAvailable": { - "public": true, - "file": "/home/joel/projects/open-source/jsonql/packages/@jsonql/koa/tests/fixtures/resolvers/query/public/always-available.js", - "description": "This is a public method that is always available", - "params": [], - "returns": [ - { - "type": [ - "string" - ], - "description": "a message" - } - ] - }, - "testList": { - "file": "/home/joel/projects/open-source/jsonql/packages/@jsonql/koa/tests/fixtures/resolvers/query/test-list.js", - "description": false, - "params": [ - { - "type": [ - "number" - ], - "name": "num", - "description": "a number" - } - ], - "returns": [ - { - "type": [ - "object" - ], - "description": "@TODO need to figure out how to give keys to the returns" - } - ] - } - }, - "mutation": { - "updateList": { - "file": "/home/joel/projects/open-source/jsonql/packages/@jsonql/koa/tests/fixtures/resolvers/mutation/update-list.js", - "description": false, - "params": [ - { - "type": [ - "object" - ], - "name": "payload", - "keys": [ - { - "type": [ - "number" - ], - "name": "user", - "parent": "payload" - } - ] - }, - { - "type": [ - "object" - ], - "name": "condition" - } - ], - "returns": [ - { - "type": [ - "object" - ], - "description": "with user as key" - } - ] - } - }, - "auth": { - "login": { - "file": "/home/joel/projects/open-source/jsonql/packages/@jsonql/koa/tests/fixtures/resolvers/auth/login.js", - "description": "login method", - "params": [ - { - "type": [ - "string" - ], - "name": "name", - "description": "give it a name" - } - ], - "returns": [ - { - "type": [ - "object" - ], - "description": "a userdata object with timestamp" - } - ] - } - }, - "timestamp": 1574056345, - "sourceType": "script", - "socket": { - "causeError": { - "namespace": "jsonql/private", - "file": "/home/joel/projects/open-source/jsonql/packages/@jsonql/koa/tests/fixtures/resolvers/socket/cause-error.js", - "description": false, - "params": [ - { - "type": [ - "string" - ], - "name": "msg", - "description": "a message" - } - ], - "returns": [ - { - "type": [ - "string" - ], - "description": "a message but here we throw an error" - } - ] - }, - "chatroom": { - "namespace": "jsonql/private", - "file": "/home/joel/projects/open-source/jsonql/packages/@jsonql/koa/tests/fixtures/resolvers/socket/chatroom.js", - "description": false, - "params": [ - { - "type": [ - "string" - ], - "name": "msg", - "description": "message" - }, - { - "type": [ - "number" - ], - "name": "timestamp", - "description": "for checking the time" - } - ], - "returns": [ - { - "type": [ - "string" - ], - "description": "reply" - } - ] - }, - "delayFn": { - "namespace": "jsonql/private", - "file": "/home/joel/projects/open-source/jsonql/packages/@jsonql/koa/tests/fixtures/resolvers/socket/delay-fn.js", - "description": false, - "params": [ - { - "type": [ - "string" - ], - "name": "msg", - "description": "a message" - }, - { - "type": [ - "number" - ], - "name": "timestamp", - "description": "a timestamp" - } - ], - "returns": false - }, - "secretChatroom": { - "namespace": "jsonql/private", - "file": "/home/joel/projects/open-source/jsonql/packages/@jsonql/koa/tests/fixtures/resolvers/socket/private/secret-chatroom.js", - "description": false, - "params": [ - { - "type": [ - "string" - ], - "name": "room", - "description": "room name" - }, - { - "type": [ - "any" - ], - "name": "msg", - "description": "message to that room" - } - ], - "returns": [ - { - "type": [ - "any" - ], - "description": "depends" - } - ] - }, - "availableToEveryone": { - "namespace": "jsonql/public", - "public": true, - "file": "/home/joel/projects/open-source/jsonql/packages/@jsonql/koa/tests/fixtures/resolvers/socket/public/available-to-everyone/index.js", - "description": "There is no parameter require for this call", - "params": [], - "returns": [ - { - "type": [ - "string" - ], - "description": "a message" - } - ] - }, - "wsHandler": { - "namespace": "jsonql/private", - "file": "/home/joel/projects/open-source/jsonql/packages/@jsonql/koa/tests/fixtures/resolvers/socket/ws-handler.js", - "description": "method just for testing the ws", - "params": [ - { - "type": [ - "string" - ], - "name": "msg", - "description": "message" - }, - { - "type": [ - "number" - ], - "name": "timestamp", - "description": "timestamp" - } - ], - "returns": [ - { - "type": [ - "string" - ], - "description": "msg + time lapsed" - } - ] - } - } -} diff --git a/packages/@jsonql/koa/tests/fixtures/contract/socket/public-contract.json b/packages/@jsonql/koa/tests/fixtures/contract/socket/public-contract.json deleted file mode 100644 index 6e20a64e..00000000 --- a/packages/@jsonql/koa/tests/fixtures/contract/socket/public-contract.json +++ /dev/null @@ -1,287 +0,0 @@ -{ - "query": { - "helloWorld": { - "params": [], - "returns": [ - { - "type": "string", - "description": "stock message" - } - ] - }, - "causeError": { - "params": [ - { - "type": [ - "any" - ], - "name": "x", - "description": "param" - } - ], - "returns": [ - { - "type": [ - "any" - ], - "description": "unknown" - } - ] - }, - "getUser": { - "params": [ - { - "type": [ - "string" - ], - "name": "args", - "variable": true, - "description": "passing unknown number of param" - } - ], - "returns": [ - { - "type": [ - "any" - ], - "description": "extract from last of the args" - } - ] - }, - "getSecretMsg": { - "params": [], - "returns": [ - { - "type": [ - "string" - ], - "description": "a secret message" - } - ] - }, - "alwaysAvailable": { - "public": true, - "params": [], - "returns": [ - { - "type": [ - "string" - ], - "description": "a message" - } - ] - }, - "testList": { - "params": [ - { - "type": [ - "number" - ], - "name": "num", - "description": "a number" - } - ], - "returns": [ - { - "type": [ - "object" - ], - "description": "@TODO need to figure out how to give keys to the returns" - } - ] - } - }, - "mutation": { - "updateList": { - "params": [ - { - "type": [ - "object" - ], - "name": "payload", - "keys": [ - { - "type": [ - "number" - ], - "name": "user", - "parent": "payload" - } - ] - }, - { - "type": [ - "object" - ], - "name": "condition" - } - ], - "returns": [ - { - "type": [ - "object" - ], - "description": "with user as key" - } - ] - } - }, - "auth": { - "login": { - "params": [ - { - "type": [ - "string" - ], - "name": "name", - "description": "give it a name" - } - ], - "returns": [ - { - "type": [ - "object" - ], - "description": "a userdata object with timestamp" - } - ] - } - }, - "timestamp": 1574056345, - "socket": { - "causeError": { - "namespace": "jsonql/private", - "params": [ - { - "type": [ - "string" - ], - "name": "msg", - "description": "a message" - } - ], - "returns": [ - { - "type": [ - "string" - ], - "description": "a message but here we throw an error" - } - ] - }, - "chatroom": { - "namespace": "jsonql/private", - "params": [ - { - "type": [ - "string" - ], - "name": "msg", - "description": "message" - }, - { - "type": [ - "number" - ], - "name": "timestamp", - "description": "for checking the time" - } - ], - "returns": [ - { - "type": [ - "string" - ], - "description": "reply" - } - ] - }, - "delayFn": { - "namespace": "jsonql/private", - "params": [ - { - "type": [ - "string" - ], - "name": "msg", - "description": "a message" - }, - { - "type": [ - "number" - ], - "name": "timestamp", - "description": "a timestamp" - } - ], - "returns": false - }, - "secretChatroom": { - "namespace": "jsonql/private", - "params": [ - { - "type": [ - "string" - ], - "name": "room", - "description": "room name" - }, - { - "type": [ - "any" - ], - "name": "msg", - "description": "message to that room" - } - ], - "returns": [ - { - "type": [ - "any" - ], - "description": "depends" - } - ] - }, - "availableToEveryone": { - "namespace": "jsonql/public", - "public": true, - "params": [], - "returns": [ - { - "type": [ - "string" - ], - "description": "a message" - } - ] - }, - "wsHandler": { - "namespace": "jsonql/private", - "params": [ - { - "type": [ - "string" - ], - "name": "msg", - "description": "message" - }, - { - "type": [ - "number" - ], - "name": "timestamp", - "description": "timestamp" - } - ], - "returns": [ - { - "type": [ - "string" - ], - "description": "msg + time lapsed" - } - ] - } - } -} -- Gitee From 20a24b6347592878ae0c3687dd5e285a594a4105 Mon Sep 17 00:00:00 2001 From: joelchu Date: Wed, 20 Nov 2019 14:13:11 +0800 Subject: [PATCH 14/14] jsonql-koa to 1.4.15 fix a critical error in the get contract --- packages/koa/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/koa/package.json b/packages/koa/package.json index 9dc7b072..af698938 100644 --- a/packages/koa/package.json +++ b/packages/koa/package.json @@ -1,6 +1,6 @@ { "name": "jsonql-koa", - "version": "1.4.14", + "version": "1.4.15", "description": "jsonql Koa middleware", "main": "main.js", "module": "index.js", -- Gitee