, object>
> = {
title?: string;
description?: string;
request: RequestDef;
response: {
headers?: RespHeader;
values?: object;
} & Resp;
};
export function convert(...apis: Array<{ request }>) {
return apis.map(a => {
const { path } = a.request;
if (typeof path === "string") {
return a;
}
a.request.path = "/" + path.join("/");
return a;
});
}
/**
* @TJS-type integer
*/
export type Integer = number;
/**
* @TJS-type integer
* @minimum 0
* @maximum 4294967295
*/
export type UInt32 = number;
/**
* @TJS-type integer
* @minimum 0
* @maximum 18446744073709551615
*/
export type UInt64 = number;
/**
* internal API, only for go-swagger
* @param obj
*/
export function replace(obj) {
if (typeof obj !== "object") {
return obj;
}
if (obj == null) {
return true;
}
if (obj.properties) {
const required = obj.required || [];
const properties = obj.properties || {};
obj.properties = Object.keys(properties).reduce(
(p, prop) => {
const currentProp = required.includes(prop)
? {
...p[prop]
}
: {
...p[prop],
"x-nullable": true
};
return {
...p,
[prop]: currentProp
};
},
{ ...properties }
);
}
return Array.isArray(obj)
? obj.map(replace)
: Object.keys(obj).reduce((p, c) => {
p[c] = replace(obj[c]);
return p;
}, {});
}
================================================
FILE: packages/typed/src/util.ts
================================================
export function showHelp(exitcode, help) {
process.stdout.write(help);
process.exit(exitcode);
}
export const flatten = (arr1: any[]) =>
arr1.reduce((acc, val) => acc.concat(val), []);
================================================
FILE: packages/typed/tsconfig.json
================================================
{
"compileOnSave": false,
"compilerOptions": {
"target": "es2015",
"module": "commonjs",
"declaration": true,
"jsx": "preserve",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"removeComments": false,
"preserveConstEnums": true,
"sourceMap": true,
"skipLibCheck": true,
"baseUrl": ".",
"lib": [
"dom",
"es2016"
],
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "lib"
},
"include": ["src/**/*"],
"exclude": [
"node_modules",
"src/__tests__/**",
"src/commands/__tests__/**"
]
}
================================================
FILE: packages/typed/tslint.json
================================================
{
"extends": [
"tslint:latest",
"tslint-config-prettier",
"tslint-plugin-prettier"
],
"rules": {
"prettier": true,
"no-submodule-imports": false,
"interface-over-type-literal": false,
"object-literal-sort-keys": false,
"interface-name": [false, "always-prefix"],
"no-implicit-dependencies": [false, "dev"],
"no-bitwise": false
}
}
================================================
FILE: packages/ui/.babelrc
================================================
{
"presets": [
"@babel/preset-react"
]
}
================================================
FILE: packages/ui/.eslintrc.json
================================================
{
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true,
"jest": true
},
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaVersion": 2020,
"ecmaFeatures": {
"jsx": true
},
"babelOptions": {
"presets": ["@babel/preset-react"]
},
"requireConfigFile": false,
"sourceType": "module"
},
"settings": {
"react": {
"version": "detect"
}
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"prettier"
],
"plugins": [
"react",
"prettier"
],
"rules": {
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"never"
],
"prettier/prettier": "error"
}
}
================================================
FILE: packages/ui/.gitignore
================================================
# See https://help.github.com/ignore-files/ for more about ignoring files.
# dependencies
/node_modules
# testing
/coverage
# production
/build/service-worker.js
/build/asset-manifest.json
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
================================================
FILE: packages/ui/.prettierrc.yml
================================================
---
printWidth: 100
tabWidth: 2
singleQuote: true
trailingComma: none
jsxBracketSameLine: true
semi: false
================================================
FILE: packages/ui/LICENSE
================================================
The MIT License
Copyright © 2018 Recruit Technologies Co.,Ltd.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
================================================
FILE: packages/ui/README.md
================================================
# Agreed UI
UI for [Agreed](https://www.npmjs.com/package/agreed-core)

# Install
```
$ npm install agreed-ui --save-dev
```
# Usage
```
$ agreed-ui --path ./test/agreed.json --port 3000
```
Serve with [Express](https://www.npmjs.com/package/express)
Open http://localhost:3000 to view it in the browser.
```
$ agreed-ui build --path ./test/agreed.json --dest ./build
```
Builds the app for static-hosting to the build folder
# Features
## Set title and description to contract
```
{
title: 'get store information',
description: 'get store information',
request: {
...
},
response: {
...
}
}
```
title and descripion will be displayed at naviation and each section's title
# Development
`npm run start:dev -- --path=./test/agrees/agrees.js `
================================================
FILE: packages/ui/bin/agreed-ui.js
================================================
#!/usr/bin/env node
const path = require('path')
const spawn = require('child_process').spawn
const minimist = require('minimist')
const colo = require('colo')
const execArgv = minimist(process.execArgv)
const argv = minimist(process.argv.slice(2))
function showHelp(exitcode) {
console.log(`
agreed-ui [--path agreed path file (required)][--port request server port default 3000]
agreed-ui build [--path agreed path file (required)][--dest output directory(required)]
agreed-ui --path ./agreed.js --port 4000
agreed-ui build --path ./agreed.js --dest ./build
`)
process.exit(exitcode)
}
const command = argv['_'][0] || 'start'
if (argv.help || command === 'help') {
showHelp(0)
}
if (argv.version || command === 'version') {
const pack = require('../package.json')
console.log(pack.version)
process.exit(0)
}
if (!argv.path) {
console.error(colo.red('[agreed-ui]: --path option is required'))
showHelp(1)
}
if (command === 'build' && !argv.dest) {
console.error(colo.red('[agreed-ui]: --dest option is required'))
showHelp(1)
}
const npm = /^win/.test(process.platform) ? 'npm.cmd' : 'npm'
const child = spawn(
npm,
[
'run',
command,
'--',
`--path=${path.resolve(process.cwd(), argv.path)}`,
argv.dest && `--dest=${path.resolve(process.cwd(), argv.dest)}`,
argv.port && `--port=${argv.port || 3000}`,
].filter(Boolean),
{ cwd: path.resolve(__dirname, '../') }
)
child.stdout.on('data', function(data) {
process.stdout.write(data)
})
child.stderr.on('data', function(data) {
process.stdout.write(data)
})
================================================
FILE: packages/ui/build/index.html
================================================
Agreed UI
================================================
FILE: packages/ui/build/precache-manifest.c7cb397614ac16fe18525a8ed4105b10.js
================================================
self.__precacheManifest = (self.__precacheManifest || []).concat([
{
"revision": "66cb8cbf26c628a82a88f884b999224e",
"url": "./index.html"
},
{
"revision": "b6c3ee666303b94886fc",
"url": "./static/css/main.e92ec541.chunk.css"
},
{
"revision": "400027482ca9a973d5b8",
"url": "./static/js/2.b28c1fbe.chunk.js"
},
{
"revision": "b6c3ee666303b94886fc",
"url": "./static/js/main.ef43f0f5.chunk.js"
},
{
"revision": "f2bf705babb2ec4477fc",
"url": "./static/js/runtime-main.3336eaa2.js"
}
]);
================================================
FILE: packages/ui/build/static/css/main.e92ec541.chunk.css
================================================
@import url(https://fonts.googleapis.com/css?family=Open+Sans:400,400i|PT+Sans);:root{--color:#1a281f;--color-link:rgba(26,40,31,0.7);--color0:#fff;--color1:rgba(26,40,31,0.6);--color2:#635255;--color3:#ce7b91;--color4:#c0e8f9;--color5:#a4bfbd;--color-green:#66bb6a}*{margin:0;padding:0}a{color:rgba(26,40,31,.7);color:var(--color-link)}a:hover{color:#bbb}h1{font-size:1.5rem;margin:2rem 0}h2{font-size:1.2rem;margin:2rem 0 1rem}body{color:#1a281f;color:var(--color);font-family:-apple-system,BlinkMacSystemFont,Helvetica Neue,Segoe UI,sans-serif;min-height:100vh}.wrap,body{display:flex;flex-direction:column}.wrap{align-items:stretch;height:100vh}header{align-items:center;background:#fff;box-shadow:0 0 2.25rem #9da5ab;display:flex;font-family:PT Sans,sans-serif;justify-content:space-between;padding:20px;position:relative;z-index:1}header h1{margin:0}header p{font-weight:700}.container{align-items:stretch;display:flex;flex:1 1}main{flex-grow:3;order:2;padding:20px 0}aside,main{overflow:auto;position:relative}aside{box-shadow:0 0 .5rem #9da5ab;font-weight:300;flex:1 1;order:1;padding:20px;min-width:300px}.search{margin:1rem 0}.search__input{border:none;border-bottom:2px solid #ddd;font-size:1rem;font-weight:300;padding:.5rem 0;-webkit-transition:border-color .1s ease-out;transition:border-color .1s ease-out;width:80%}.search__input:focus{outline:0;display:block;border-bottom:2px solid var(--color5)}.search__group{display:block;font-size:.9rem;margin-top:5px}nav{position:absolute;padding-bottom:20px}nav p{margin:4px 0}details{padding-bottom:7px}summary{color:var(--color5);cursor:pointer;font-size:.9rem;margin-bottom:4px;outline:none}details>p{padding-left:1em;margin-top:3px}details summary::-webkit-details-marker{-webkit-transform:translateY(1px) scale(.7);transform:translateY(1px) scale(.7);opacity:.5}.count{border-radius:8px;border:1px solid var(--color5);background:var(--color5);margin-left:5px;opacity:.6;padding:0 3px;position:relative;top:-1px}.count,.statusLabel{color:var(--color0);display:inline-block;font-size:.5rem}.statusLabel{border-radius:6px;padding:2px 4px;margin-right:.25rem;opacity:.8}.statusLabel--2{background:var(--color-green)}.statusLabel--3{background:var(--color4)}.statusLabel--4{background:var(--color3)}.statusLabel--5{background:var(--color5)}.method{margin-right:5px;font-size:12px;font-weight:300;font-style:normal;border:1px solid #999;color:#999;border-radius:2px;padding:2px 3px;display:inline-block}.method.get{color:#66bb6a;border-color:#66bb6a}.method.delete{color:#999;border-color:#999}.method.put{color:#9e9d24;border-color:#9e9d24}.method.post{color:#f9a825;border-color:#f9a825}.method.patch{color:#9c27b0;border-color:#9c27b0}.definitions{color:var(--color1);margin:1.5em 0}.definitions h1{font-size:1em;color:var(--color5);margin-top:0;margin-bottom:1em;padding-left:0}.definitions>dl,.definitions>p{margin:.25em 1em}.definitions dl dt{color:var(--color3);font-weight:700;font-style:italic}.definitions dl dt:after{content:": "}.definitions dl>*{display:inline-block;margin-right:.5em}button{background-color:initial;border:none;cursor:pointer;outline:none;padding:0;-webkit-appearance:none;-moz-appearance:none;appearance:none}.body{color:var(--color1);padding:0}.body>.buttonGroup{margin-bottom:1em;padding:0 30px}.body>.code{background:#efefef;font-weight:300;font-size:.9rem;max-height:500px;margin:1em 0;overflow:auto;padding:2em}.body>.code ul{background:#efefef!important}.buttonGroup button{margin-right:1em}.tabButton{box-sizing:border-box;color:var(--color5);opacity:.4;font-size:1rem;font-weight:700;padding:0 1px 3px}.tabButton:hover{opacity:1}.tabButton:disabled{color:var(--color5);cursor:auto;opacity:1;border-bottom:2px solid var(--color5)}.onlyButton.tabButton:disabled{border:none}.contents>.agree{padding-top:2rem;margin-bottom:2rem}.contents>.agree:first-child{padding-top:0}.agree .definitions,.agree .description,.agree>h1,.agree>h2,.agree>section{padding:0 30px}.agree h2{color:var(--color);border-left:2px solid #aaa;padding-left:28px}.title{align-items:center;border-left:2px solid var(--color);display:flex;font-family:Open Sans,sans-serif;font-style:italic;margin:0}.title>*{margin-right:.6rem}.description{color:var(--color1);margin:.25rem 0}.contents section h2{color:var(--color);border-left:2px solid #aaa;padding-left:28px}.contents{position:absolute;width:100%}
/*# sourceMappingURL=main.e92ec541.chunk.css.map */
================================================
FILE: packages/ui/build/static/js/2.b28c1fbe.chunk.js
================================================
(this["webpackJsonp@agreed/ui"]=this["webpackJsonp@agreed/ui"]||[]).push([[2],[function(e,t,n){"use strict";e.exports=n(87)},function(e,t){var n=e.exports={version:"2.6.3"};"number"==typeof __e&&(__e=n)},function(e,t,n){"use strict";var r=n(54),a=n(93),o=Object.prototype.toString;function i(e){return"[object Array]"===o.call(e)}function u(e){return null!==e&&"object"===typeof e}function l(e){return"[object Function]"===o.call(e)}function s(e,t){if(null!==e&&"undefined"!==typeof e)if("object"!==typeof e&&(e=[e]),i(e))for(var n=0,r=e.length;n=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}},function(e,t){e.exports={}},function(e,t,n){var r=n(68),a=n(41);e.exports=Object.keys||function(e){return r(e,a)}},function(e,t,n){"use strict";function r(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var n=[],r=!0,a=!1,o=void 0;try{for(var i,u=e[Symbol.iterator]();!(r=(i=u.next()).done)&&(n.push(i.value),!t||n.length!==t);r=!0);}catch(l){a=!0,o=l}finally{try{r||null==u.return||u.return()}finally{if(a)throw o}}return n}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}n.d(t,"a",(function(){return r}))},function(e,t){e.exports=!0},function(e,t){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t){var n=0,r=Math.random();e.exports=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++n+r).toString(36))}},function(e,t){t.f={}.propertyIsEnumerable},function(e,t,n){e.exports={default:n(146),__esModule:!0}},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";function r(e,t){for(var n=0;n=t.length?{value:void 0,done:!0}:(e=r(t,n),this._i+=e.length,{value:e,done:!1})}))},function(e,t){var n=Math.ceil,r=Math.floor;e.exports=function(e){return isNaN(e=+e)?0:(e>0?r:n)(e)}},function(e,t){e.exports=function(e){if(void 0==e)throw TypeError("Can't call method on "+e);return e}},function(e,t,n){var r=n(8);e.exports=function(e,t){if(!r(e))return e;var n,a;if(t&&"function"==typeof(n=e.toString)&&!r(a=n.call(e)))return a;if("function"==typeof(n=e.valueOf)&&!r(a=n.call(e)))return a;if(!t&&"function"==typeof(n=e.toString)&&!r(a=n.call(e)))return a;throw TypeError("Can't convert object to primitive value")}},function(e,t,n){var r=n(12),a=n(117),o=n(41),i=n(39)("IE_PROTO"),u=function(){},l=function(){var e,t=n(66)("iframe"),r=o.length;for(t.style.display="none",n(121).appendChild(t),t.src="javascript:",(e=t.contentWindow.document).open(),e.write("