Коммит
65203b4194
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "quicktype-core",
|
||||
"version": "2.0.0",
|
||||
"version": "2.0.3",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -28,8 +28,14 @@
|
|||
"integrity": "sha512-WR/XtQMjTx4phclpWhfuoFURYPOwiBZD89gCCTG6RETzE70AZPAGGJ0h/t+a/E27MCVf1s2Z+wvH1pVTyckIcA==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/string-hash": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://msmobilecenter.pkgs.visualstudio.com/_packaging/MobileCenter/npm/registry/@types/string-hash/-/string-hash-1.1.1.tgz",
|
||||
"integrity": "sha512-ijt3zdHi2DmZxQpQTmozXszzDo78V4R3EdvX0jFMfnMH2ZzQSmCbaWOMPGXFUYSzSIdStv78HDjg32m5dxc+tA=="
|
||||
},
|
||||
"@types/urijs": {
|
||||
"version": "github:quicktype/types-urijs#a23603a04e31e883a92244bff8515e3d841a8b98"
|
||||
"version": "github:quicktype/types-urijs#a23603a04e31e883a92244bff8515e3d841a8b98",
|
||||
"from": "github:quicktype/types-urijs"
|
||||
},
|
||||
"acorn": {
|
||||
"version": "5.5.3",
|
||||
|
@ -54,7 +60,7 @@
|
|||
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"sprintf-js": "1.0.3"
|
||||
"sprintf-js": "~1.0.2"
|
||||
}
|
||||
},
|
||||
"babel-code-frame": {
|
||||
|
@ -63,9 +69,9 @@
|
|||
"integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"chalk": "1.1.3",
|
||||
"esutils": "2.0.2",
|
||||
"js-tokens": "3.0.2"
|
||||
"chalk": "^1.1.3",
|
||||
"esutils": "^2.0.2",
|
||||
"js-tokens": "^3.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"chalk": {
|
||||
|
@ -74,11 +80,11 @@
|
|||
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-styles": "2.2.1",
|
||||
"escape-string-regexp": "1.0.5",
|
||||
"has-ansi": "2.0.0",
|
||||
"strip-ansi": "3.0.1",
|
||||
"supports-color": "2.0.0"
|
||||
"ansi-styles": "^2.2.1",
|
||||
"escape-string-regexp": "^1.0.2",
|
||||
"has-ansi": "^2.0.0",
|
||||
"strip-ansi": "^3.0.0",
|
||||
"supports-color": "^2.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +101,7 @@
|
|||
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"balanced-match": "1.0.0",
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
}
|
||||
},
|
||||
|
@ -104,10 +110,10 @@
|
|||
"resolved": "https://registry.npmjs.org/brfs/-/brfs-1.6.1.tgz",
|
||||
"integrity": "sha512-OfZpABRQQf+Xsmju8XE9bDjs+uU4vLREGolP7bDgcpsI17QREyZ4Bl+2KLxxx1kCgA0fAIhKQBaBYh+PEcCqYQ==",
|
||||
"requires": {
|
||||
"quote-stream": "1.0.2",
|
||||
"resolve": "1.7.1",
|
||||
"static-module": "2.2.5",
|
||||
"through2": "2.0.3"
|
||||
"quote-stream": "^1.0.1",
|
||||
"resolve": "^1.1.5",
|
||||
"static-module": "^2.2.0",
|
||||
"through2": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"buffer-equal": {
|
||||
|
@ -132,9 +138,9 @@
|
|||
"integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-styles": "3.2.1",
|
||||
"escape-string-regexp": "1.0.5",
|
||||
"supports-color": "5.4.0"
|
||||
"ansi-styles": "^3.2.1",
|
||||
"escape-string-regexp": "^1.0.5",
|
||||
"supports-color": "^5.3.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ansi-styles": {
|
||||
|
@ -143,7 +149,7 @@
|
|||
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"color-convert": "1.9.1"
|
||||
"color-convert": "^1.9.0"
|
||||
}
|
||||
},
|
||||
"supports-color": {
|
||||
|
@ -152,18 +158,27 @@
|
|||
"integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"has-flag": "3.0.0"
|
||||
"has-flag": "^3.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"collection-utils": {
|
||||
"version": "0.0.7",
|
||||
"resolved": "https://registry.npmjs.org/collection-utils/-/collection-utils-0.0.7.tgz",
|
||||
"integrity": "sha512-dV3WboXlSs44BiRlhGLjsMYU0fJzfT3DXqBJuX6W2cPXftrfoFzEoMeWXNVoR4/vjtGtLW/t01JlQsTUPJdGEA==",
|
||||
"requires": {
|
||||
"@types/string-hash": "^1.1.1",
|
||||
"string-hash": "^1.1.3"
|
||||
}
|
||||
},
|
||||
"color-convert": {
|
||||
"version": "1.9.1",
|
||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz",
|
||||
"integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"color-name": "1.1.3"
|
||||
"color-name": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"color-name": {
|
||||
|
@ -189,10 +204,10 @@
|
|||
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
|
||||
"integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
|
||||
"requires": {
|
||||
"buffer-from": "1.0.0",
|
||||
"inherits": "2.0.3",
|
||||
"readable-stream": "2.3.6",
|
||||
"typedarray": "0.0.6"
|
||||
"buffer-from": "^1.0.0",
|
||||
"inherits": "^2.0.3",
|
||||
"readable-stream": "^2.2.2",
|
||||
"typedarray": "^0.0.6"
|
||||
}
|
||||
},
|
||||
"convert-source-map": {
|
||||
|
@ -221,7 +236,7 @@
|
|||
"resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz",
|
||||
"integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=",
|
||||
"requires": {
|
||||
"readable-stream": "2.3.6"
|
||||
"readable-stream": "^2.0.2"
|
||||
}
|
||||
},
|
||||
"escape-string-regexp": {
|
||||
|
@ -235,11 +250,11 @@
|
|||
"resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.9.1.tgz",
|
||||
"integrity": "sha512-6hTjO1NAWkHnDk3OqQ4YrCuwwmGHL9S3nPlzBOUG/R44rda3wLNrfvQ5fkSGjyhHFKM7ALPKcKGrwvCLe0lC7Q==",
|
||||
"requires": {
|
||||
"esprima": "3.1.3",
|
||||
"estraverse": "4.2.0",
|
||||
"esutils": "2.0.2",
|
||||
"optionator": "0.8.2",
|
||||
"source-map": "0.6.1"
|
||||
"esprima": "^3.1.3",
|
||||
"estraverse": "^4.2.0",
|
||||
"esutils": "^2.0.2",
|
||||
"optionator": "^0.8.1",
|
||||
"source-map": "~0.6.1"
|
||||
}
|
||||
},
|
||||
"esprima": {
|
||||
|
@ -262,10 +277,10 @@
|
|||
"resolved": "https://registry.npmjs.org/falafel/-/falafel-2.1.0.tgz",
|
||||
"integrity": "sha1-lrsXdh2rqU9G0AFzizzt86Z/4Gw=",
|
||||
"requires": {
|
||||
"acorn": "5.5.3",
|
||||
"foreach": "2.0.5",
|
||||
"acorn": "^5.0.0",
|
||||
"foreach": "^2.0.5",
|
||||
"isarray": "0.0.1",
|
||||
"object-keys": "1.0.11"
|
||||
"object-keys": "^1.0.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"isarray": {
|
||||
|
@ -302,12 +317,12 @@
|
|||
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"fs.realpath": "1.0.0",
|
||||
"inflight": "1.0.6",
|
||||
"inherits": "2.0.3",
|
||||
"minimatch": "3.0.4",
|
||||
"once": "1.4.0",
|
||||
"path-is-absolute": "1.0.1"
|
||||
"fs.realpath": "^1.0.0",
|
||||
"inflight": "^1.0.4",
|
||||
"inherits": "2",
|
||||
"minimatch": "^3.0.4",
|
||||
"once": "^1.3.0",
|
||||
"path-is-absolute": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"has": {
|
||||
|
@ -315,7 +330,7 @@
|
|||
"resolved": "https://registry.npmjs.org/has/-/has-1.0.1.tgz",
|
||||
"integrity": "sha1-hGFzP1OLCDfJNh45qauelwTcLyg=",
|
||||
"requires": {
|
||||
"function-bind": "1.1.1"
|
||||
"function-bind": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"has-ansi": {
|
||||
|
@ -324,7 +339,7 @@
|
|||
"integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-regex": "2.1.1"
|
||||
"ansi-regex": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"has-flag": {
|
||||
|
@ -339,8 +354,8 @@
|
|||
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"once": "1.4.0",
|
||||
"wrappy": "1.0.2"
|
||||
"once": "^1.3.0",
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"inherits": {
|
||||
|
@ -370,8 +385,8 @@
|
|||
"integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"argparse": "1.0.10",
|
||||
"esprima": "4.0.0"
|
||||
"argparse": "^1.0.7",
|
||||
"esprima": "^4.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"esprima": {
|
||||
|
@ -387,8 +402,8 @@
|
|||
"resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz",
|
||||
"integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=",
|
||||
"requires": {
|
||||
"prelude-ls": "1.1.2",
|
||||
"type-check": "0.3.2"
|
||||
"prelude-ls": "~1.1.2",
|
||||
"type-check": "~0.3.2"
|
||||
}
|
||||
},
|
||||
"magic-string": {
|
||||
|
@ -396,7 +411,7 @@
|
|||
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.22.5.tgz",
|
||||
"integrity": "sha512-oreip9rJZkzvA8Qzk9HFs8fZGF/u7H/gtrE8EN6RjKJ9kh2HlC+yQ2QezifqTZfGyiuAV0dRv5a+y/8gBb1m9w==",
|
||||
"requires": {
|
||||
"vlq": "0.2.3"
|
||||
"vlq": "^0.2.2"
|
||||
}
|
||||
},
|
||||
"merge-source-map": {
|
||||
|
@ -404,7 +419,7 @@
|
|||
"resolved": "https://registry.npmjs.org/merge-source-map/-/merge-source-map-1.0.4.tgz",
|
||||
"integrity": "sha1-pd5GU42uhNQRTMXqArR3KmNGcB8=",
|
||||
"requires": {
|
||||
"source-map": "0.5.7"
|
||||
"source-map": "^0.5.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"source-map": {
|
||||
|
@ -420,7 +435,7 @@
|
|||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"brace-expansion": "1.1.11"
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
},
|
||||
"minimist": {
|
||||
|
@ -444,7 +459,7 @@
|
|||
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"wrappy": "1.0.2"
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"optionator": {
|
||||
|
@ -452,12 +467,12 @@
|
|||
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz",
|
||||
"integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=",
|
||||
"requires": {
|
||||
"deep-is": "0.1.3",
|
||||
"fast-levenshtein": "2.0.6",
|
||||
"levn": "0.3.0",
|
||||
"prelude-ls": "1.1.2",
|
||||
"type-check": "0.3.2",
|
||||
"wordwrap": "1.0.0"
|
||||
"deep-is": "~0.1.3",
|
||||
"fast-levenshtein": "~2.0.4",
|
||||
"levn": "~0.3.0",
|
||||
"prelude-ls": "~1.1.2",
|
||||
"type-check": "~0.3.2",
|
||||
"wordwrap": "~1.0.0"
|
||||
}
|
||||
},
|
||||
"pako": {
|
||||
|
@ -502,8 +517,8 @@
|
|||
"integrity": "sha1-hJY/jJwmuULhU/7rU6rnRlK34LI=",
|
||||
"requires": {
|
||||
"buffer-equal": "0.0.1",
|
||||
"minimist": "1.2.0",
|
||||
"through2": "2.0.3"
|
||||
"minimist": "^1.1.3",
|
||||
"through2": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"readable-stream": {
|
||||
|
@ -511,13 +526,13 @@
|
|||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
|
||||
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
|
||||
"requires": {
|
||||
"core-util-is": "1.0.2",
|
||||
"inherits": "2.0.3",
|
||||
"isarray": "1.0.0",
|
||||
"process-nextick-args": "2.0.0",
|
||||
"safe-buffer": "5.1.2",
|
||||
"string_decoder": "1.1.1",
|
||||
"util-deprecate": "1.0.2"
|
||||
"core-util-is": "~1.0.0",
|
||||
"inherits": "~2.0.3",
|
||||
"isarray": "~1.0.0",
|
||||
"process-nextick-args": "~2.0.0",
|
||||
"safe-buffer": "~5.1.1",
|
||||
"string_decoder": "~1.1.1",
|
||||
"util-deprecate": "~1.0.1"
|
||||
}
|
||||
},
|
||||
"resolve": {
|
||||
|
@ -525,7 +540,7 @@
|
|||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz",
|
||||
"integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==",
|
||||
"requires": {
|
||||
"path-parse": "1.0.5"
|
||||
"path-parse": "^1.0.5"
|
||||
}
|
||||
},
|
||||
"safe-buffer": {
|
||||
|
@ -561,7 +576,7 @@
|
|||
"resolved": "https://registry.npmjs.org/static-eval/-/static-eval-2.0.0.tgz",
|
||||
"integrity": "sha512-6flshd3F1Gwm+Ksxq463LtFd1liC77N/PX1FVVc3OzL3hAmo2fwHFbuArkcfi7s9rTNsLEhcRmXGFZhlgy40uw==",
|
||||
"requires": {
|
||||
"escodegen": "1.9.1"
|
||||
"escodegen": "^1.8.1"
|
||||
}
|
||||
},
|
||||
"static-module": {
|
||||
|
@ -569,20 +584,20 @@
|
|||
"resolved": "https://registry.npmjs.org/static-module/-/static-module-2.2.5.tgz",
|
||||
"integrity": "sha512-D8vv82E/Kpmz3TXHKG8PPsCPg+RAX6cbCOyvjM6x04qZtQ47EtJFVwRsdov3n5d6/6ynrOY9XB4JkaZwB2xoRQ==",
|
||||
"requires": {
|
||||
"concat-stream": "1.6.2",
|
||||
"convert-source-map": "1.5.1",
|
||||
"duplexer2": "0.1.4",
|
||||
"escodegen": "1.9.1",
|
||||
"falafel": "2.1.0",
|
||||
"has": "1.0.1",
|
||||
"magic-string": "0.22.5",
|
||||
"concat-stream": "~1.6.0",
|
||||
"convert-source-map": "^1.5.1",
|
||||
"duplexer2": "~0.1.4",
|
||||
"escodegen": "~1.9.0",
|
||||
"falafel": "^2.1.0",
|
||||
"has": "^1.0.1",
|
||||
"magic-string": "^0.22.4",
|
||||
"merge-source-map": "1.0.4",
|
||||
"object-inspect": "1.4.1",
|
||||
"quote-stream": "1.0.2",
|
||||
"readable-stream": "2.3.6",
|
||||
"shallow-copy": "0.0.1",
|
||||
"static-eval": "2.0.0",
|
||||
"through2": "2.0.3"
|
||||
"object-inspect": "~1.4.0",
|
||||
"quote-stream": "~1.0.2",
|
||||
"readable-stream": "~2.3.3",
|
||||
"shallow-copy": "~0.0.1",
|
||||
"static-eval": "^2.0.0",
|
||||
"through2": "~2.0.3"
|
||||
}
|
||||
},
|
||||
"stream-json": {
|
||||
|
@ -590,16 +605,21 @@
|
|||
"resolved": "https://registry.npmjs.org/stream-json/-/stream-json-0.5.2.tgz",
|
||||
"integrity": "sha512-/QlOLybrc6LkH/oVgXo1lJ8oemRIze/grdpfssLn1Pm8nZVhW4VMOqDDYGaORPodQFxiDEUquQJER5LiBu8Ehg==",
|
||||
"requires": {
|
||||
"parser-toolkit": "0.0.5"
|
||||
"parser-toolkit": ">=0.0.3"
|
||||
}
|
||||
},
|
||||
"string-hash": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/string-hash/-/string-hash-1.1.3.tgz",
|
||||
"integrity": "sha1-6Kr8CsGFW0Zmkp7X3RJ1311sgRs="
|
||||
},
|
||||
"string-to-stream": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/string-to-stream/-/string-to-stream-1.1.1.tgz",
|
||||
"integrity": "sha512-QySF2+3Rwq0SdO3s7BAp4x+c3qsClpPQ6abAmb0DGViiSBAkT5kL6JT2iyzEVP+T1SmzHrQD1TwlP9QAHCc+Sw==",
|
||||
"requires": {
|
||||
"inherits": "2.0.3",
|
||||
"readable-stream": "2.3.6"
|
||||
"inherits": "^2.0.1",
|
||||
"readable-stream": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"string_decoder": {
|
||||
|
@ -607,7 +627,7 @@
|
|||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
|
||||
"requires": {
|
||||
"safe-buffer": "5.1.2"
|
||||
"safe-buffer": "~5.1.0"
|
||||
}
|
||||
},
|
||||
"strip-ansi": {
|
||||
|
@ -616,7 +636,7 @@
|
|||
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-regex": "2.1.1"
|
||||
"ansi-regex": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"supports-color": {
|
||||
|
@ -630,8 +650,8 @@
|
|||
"resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz",
|
||||
"integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=",
|
||||
"requires": {
|
||||
"readable-stream": "2.3.6",
|
||||
"xtend": "4.0.1"
|
||||
"readable-stream": "^2.1.5",
|
||||
"xtend": "~4.0.1"
|
||||
}
|
||||
},
|
||||
"tiny-inflate": {
|
||||
|
@ -651,18 +671,18 @@
|
|||
"integrity": "sha1-EeJrzLiK+gLdDZlWyuPUVAtfVMM=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"babel-code-frame": "6.26.0",
|
||||
"builtin-modules": "1.1.1",
|
||||
"chalk": "2.4.1",
|
||||
"commander": "2.15.1",
|
||||
"diff": "3.5.0",
|
||||
"glob": "7.1.2",
|
||||
"js-yaml": "3.11.0",
|
||||
"minimatch": "3.0.4",
|
||||
"resolve": "1.7.1",
|
||||
"semver": "5.5.0",
|
||||
"tslib": "1.9.1",
|
||||
"tsutils": "2.27.1"
|
||||
"babel-code-frame": "^6.22.0",
|
||||
"builtin-modules": "^1.1.1",
|
||||
"chalk": "^2.3.0",
|
||||
"commander": "^2.12.1",
|
||||
"diff": "^3.2.0",
|
||||
"glob": "^7.1.1",
|
||||
"js-yaml": "^3.7.0",
|
||||
"minimatch": "^3.0.4",
|
||||
"resolve": "^1.3.2",
|
||||
"semver": "^5.3.0",
|
||||
"tslib": "^1.8.0",
|
||||
"tsutils": "^2.12.1"
|
||||
}
|
||||
},
|
||||
"tsutils": {
|
||||
|
@ -671,7 +691,7 @@
|
|||
"integrity": "sha512-AE/7uzp32MmaHvNNFES85hhUDHFdFZp6OAiZcd6y4ZKKIg6orJTm8keYWBhIhrJQH3a4LzNKat7ZPXZt5aTf6w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"tslib": "1.9.1"
|
||||
"tslib": "^1.8.1"
|
||||
}
|
||||
},
|
||||
"type-check": {
|
||||
|
@ -679,7 +699,7 @@
|
|||
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz",
|
||||
"integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=",
|
||||
"requires": {
|
||||
"prelude-ls": "1.1.2"
|
||||
"prelude-ls": "~1.1.2"
|
||||
}
|
||||
},
|
||||
"typedarray": {
|
||||
|
@ -695,9 +715,10 @@
|
|||
},
|
||||
"unicode-properties": {
|
||||
"version": "github:quicktype/unicode-properties#d5fddfea1ef9d05c6479a979e225476063e13f52",
|
||||
"from": "github:quicktype/unicode-properties#dist",
|
||||
"requires": {
|
||||
"brfs": "1.6.1",
|
||||
"unicode-trie": "0.3.1"
|
||||
"brfs": "^1.4.0",
|
||||
"unicode-trie": "^0.3.0"
|
||||
}
|
||||
},
|
||||
"unicode-trie": {
|
||||
|
@ -705,8 +726,8 @@
|
|||
"resolved": "https://registry.npmjs.org/unicode-trie/-/unicode-trie-0.3.1.tgz",
|
||||
"integrity": "sha1-1nHd3YkQGgi6w3tqUWEBBgIFIIU=",
|
||||
"requires": {
|
||||
"pako": "0.2.9",
|
||||
"tiny-inflate": "1.0.2"
|
||||
"pako": "^0.2.5",
|
||||
"tiny-inflate": "^1.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"pako": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "quicktype-core",
|
||||
"version": "2.0.2",
|
||||
"version": "3.0.0",
|
||||
"description": "EXPERIMENTAL: The quicktype engine as a library",
|
||||
"license": "Apache-2.0",
|
||||
"main": "dist/index.js",
|
||||
|
@ -14,6 +14,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@types/urijs": "github:quicktype/types-urijs",
|
||||
"collection-utils": "0.0.7",
|
||||
"js-base64": "^2.4.3",
|
||||
"pako": "^1.0.6",
|
||||
"pluralize": "^7.0.0",
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -13,6 +13,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"quicktype-core": "the build script replaces this",
|
||||
"collection-utils": "0.0.7",
|
||||
"graphql": "^0.11.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "quicktype",
|
||||
"version": "14.0.0",
|
||||
"version": "15.0.0",
|
||||
"license": "Apache-2.0",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
@ -18,6 +18,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"chalk": "^2.4.1",
|
||||
"collection-utils": "0.0.7",
|
||||
"command-line-args": "^4.0.6",
|
||||
"command-line-usage": "^4.1.0",
|
||||
"graphql": "^0.11.7",
|
||||
|
|
|
@ -11,7 +11,7 @@ const defaultHeaders: { [name: string]: string } = {
|
|||
|
||||
const headerRegExp = /^([^:]+):\s*(.*)$/;
|
||||
|
||||
export async function introspectServer(url: string, headerStrings: string[]): Promise<string> {
|
||||
export async function introspectServer(url: string, method: string, headerStrings: string[]): Promise<string> {
|
||||
const headers: { [name: string]: string } = {};
|
||||
|
||||
console.log(`given headers: ${JSON.stringify(headerStrings)}`);
|
||||
|
@ -30,6 +30,7 @@ export async function introspectServer(url: string, headerStrings: string[]): Pr
|
|||
let result;
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
method,
|
||||
headers: headers,
|
||||
body: JSON.stringify({ query: introspectionQuery })
|
||||
});
|
||||
|
@ -40,7 +41,7 @@ export async function introspectServer(url: string, headerStrings: string[]): Pr
|
|||
}
|
||||
|
||||
if (result.errors) {
|
||||
return panic(`Errors in introspection query result: ${result.errors}`);
|
||||
return panic(`Errors in introspection query result: ${JSON.stringify(result.errors)}`);
|
||||
}
|
||||
|
||||
const schemaData = result;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import * as _ from "lodash";
|
||||
import { Readable } from "stream";
|
||||
import { hasOwnProperty, definedMap } from "collection-utils";
|
||||
|
||||
import {
|
||||
Options,
|
||||
|
@ -21,7 +23,6 @@ import {
|
|||
assert,
|
||||
defined,
|
||||
withDefault,
|
||||
mapOptional,
|
||||
assertNever,
|
||||
parseJSON,
|
||||
getStream,
|
||||
|
@ -34,12 +35,10 @@ import { schemaForTypeScriptSources } from "../quicktype-typescript-input";
|
|||
import { GraphQLInput } from "../quicktype-graphql-input";
|
||||
|
||||
import { urlsFromURLGrammar } from "./URLGrammar";
|
||||
import { Readable } from "stream";
|
||||
import { introspectServer } from "./GraphQLIntrospection";
|
||||
import { JSONTypeSource, TypeSource, GraphQLTypeSource, SchemaTypeSource } from "./TypeSource";
|
||||
import { readableFromFileOrURL, readFromFileOrURL, FetchingJSONSchemaStore } from "./NodeIO";
|
||||
import * as telemetry from "./telemetry";
|
||||
import { hasOwnProperty } from "../quicktype-core/support/Support";
|
||||
|
||||
const commandLineArgs = require("command-line-args");
|
||||
const getUsage = require("command-line-usage");
|
||||
|
@ -56,8 +55,8 @@ export interface CLIOptions {
|
|||
srcLang: string;
|
||||
graphqlSchema?: string;
|
||||
graphqlIntrospect?: string;
|
||||
graphqlServerHeader?: string[];
|
||||
template?: string;
|
||||
httpHeader?: string[];
|
||||
httpMethod?: string;
|
||||
out?: string;
|
||||
buildMarkovChain?: string;
|
||||
|
||||
|
@ -280,8 +279,8 @@ function inferCLIOptions(opts: Partial<CLIOptions>, targetLanguage: TargetLangua
|
|||
buildMarkovChain: opts.buildMarkovChain,
|
||||
graphqlSchema: opts.graphqlSchema,
|
||||
graphqlIntrospect: opts.graphqlIntrospect,
|
||||
graphqlServerHeader: opts.graphqlServerHeader,
|
||||
template: opts.template,
|
||||
httpMethod: opts.httpMethod,
|
||||
httpHeader: opts.httpHeader,
|
||||
debug: opts.debug,
|
||||
telemetry: opts.telemetry
|
||||
};
|
||||
|
@ -363,7 +362,13 @@ function makeOptionDefinitions(targetLanguages: TargetLanguage[]): OptionDefinit
|
|||
description: "Introspect GraphQL schema from a server."
|
||||
},
|
||||
{
|
||||
name: "graphql-server-header",
|
||||
name: "http-method",
|
||||
type: String,
|
||||
typeLabel: "METHOD",
|
||||
description: "HTTP method to use for the GraphQL introspection query."
|
||||
},
|
||||
{
|
||||
name: "http-header",
|
||||
type: String,
|
||||
multiple: true,
|
||||
typeLabel: "HEADER",
|
||||
|
@ -684,7 +689,8 @@ export async function makeQuicktypeOptions(
|
|||
if (options.graphqlIntrospect !== undefined) {
|
||||
schemaString = await introspectServer(
|
||||
options.graphqlIntrospect,
|
||||
withDefault<string[]>(options.graphqlServerHeader, [])
|
||||
withDefault(options.httpMethod, "GET"),
|
||||
withDefault<string[]>(options.httpHeader, [])
|
||||
);
|
||||
if (options.graphqlSchema !== undefined) {
|
||||
fs.writeFileSync(options.graphqlSchema, schemaString);
|
||||
|
@ -744,7 +750,7 @@ export async function makeQuicktypeOptions(
|
|||
return messageError("DriverUnknownSourceLanguage", { lang: options.srcLang });
|
||||
}
|
||||
|
||||
const components = mapOptional(d => d.split(","), options.debug);
|
||||
const components = definedMap(options.debug, d => d.split(","));
|
||||
const debugAll = components !== undefined && components.indexOf("all") >= 0;
|
||||
let debugPrintGraph = debugAll;
|
||||
let checkProvenance = debugAll;
|
||||
|
@ -798,7 +804,7 @@ export async function makeQuicktypeOptions(
|
|||
noRender: options.noRender,
|
||||
rendererOptions: options.rendererOptions,
|
||||
leadingComments,
|
||||
outputFilename: mapOptional(path.basename, options.out),
|
||||
outputFilename: definedMap(options.out, path.basename),
|
||||
debugPrintGraph,
|
||||
checkProvenance,
|
||||
debugPrintReconstitution,
|
||||
|
|
|
@ -1,9 +1,3 @@
|
|||
import { TypeAttributeKind, TypeAttributes } from "./TypeAttributes";
|
||||
import { defined, isStringMap, checkStringMap, checkArray } from "./support/Support";
|
||||
import { EnumType, UnionType, Type, ObjectType } from "./Type";
|
||||
import { messageAssert } from "./Messages";
|
||||
import { JSONSchema } from "./input/JSONSchemaStore";
|
||||
import { Ref, JSONSchemaType, JSONSchemaAttributes } from "./input/JSONSchemaInput";
|
||||
import {
|
||||
iterableFirst,
|
||||
mapFromIterable,
|
||||
|
@ -11,7 +5,14 @@ import {
|
|||
mapFromObject,
|
||||
setUnionManyInto,
|
||||
mapMergeInto
|
||||
} from "./support/Containers";
|
||||
} from "collection-utils";
|
||||
|
||||
import { TypeAttributeKind, TypeAttributes } from "./TypeAttributes";
|
||||
import { defined, isStringMap, checkStringMap, checkArray } from "./support/Support";
|
||||
import { EnumType, UnionType, Type, ObjectType } from "./Type";
|
||||
import { messageAssert } from "./Messages";
|
||||
import { JSONSchema } from "./input/JSONSchemaStore";
|
||||
import { Ref, JSONSchemaType, JSONSchemaAttributes } from "./input/JSONSchemaInput";
|
||||
|
||||
export type AccessorEntry = string | Map<string, string>;
|
||||
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
import {
|
||||
setUnion,
|
||||
setFilter,
|
||||
iterableEnumerate,
|
||||
iterableSome,
|
||||
mapFilter,
|
||||
mapSortBy,
|
||||
mapFilterMap,
|
||||
mapSome
|
||||
} from "collection-utils";
|
||||
|
||||
import { Type, ClassType, EnumType, UnionType, TypeKind, ClassProperty, MapType, ObjectType } from "./Type";
|
||||
import { separateNamedTypes, nullableFromUnion, matchTypeExhaustive, isNamedType } from "./TypeUtils";
|
||||
import { Namespace, Name, Namer, FixedName, SimpleName, DependencyName, keywordNamespace } from "./Naming";
|
||||
|
@ -13,16 +24,6 @@ import { descriptionTypeAttributeKind, propertyDescriptionsTypeAttributeKind } f
|
|||
import { enumCaseNames, objectPropertyNames, unionMemberName, getAccessorName } from "./AccessorNames";
|
||||
import { transformationForType, followTargetType } from "./Transformers";
|
||||
import { TargetLanguage } from "./TargetLanguage";
|
||||
import {
|
||||
setUnion,
|
||||
setFilter,
|
||||
iterableEnumerate,
|
||||
iterableSome,
|
||||
mapFilter,
|
||||
mapSortBy,
|
||||
mapFilterMap,
|
||||
mapSome
|
||||
} from "./support/Containers";
|
||||
|
||||
const wordWrap: (s: string) => string = require("wordwrap")(90);
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import { setUnionInto, setFilter, iterableFirst, setSubtract, setIntersect } from "collection-utils";
|
||||
|
||||
import { TypeGraph } from "./TypeGraph";
|
||||
import { Type } from "./Type";
|
||||
import { panic, defined, assert } from "./support/Support";
|
||||
import { Graph } from "./Graph";
|
||||
import { messageError } from "./Messages";
|
||||
import { setUnionInto, setFilter, iterableFirst, setSubtract, setIntersect } from "./support/Containers";
|
||||
|
||||
export type DeclarationKind = "forward" | "define";
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
import { TypeAttributeKind, combineTypeAttributes, emptyTypeAttributes } from "./TypeAttributes";
|
||||
import { JSONSchemaType, Ref, JSONSchemaAttributes } from "./input/JSONSchemaInput";
|
||||
import { JSONSchema } from "./input/JSONSchemaStore";
|
||||
import {
|
||||
mapFilterMap,
|
||||
mapFromObject,
|
||||
|
@ -8,7 +5,11 @@ import {
|
|||
iterableFirst,
|
||||
setUnionManyInto,
|
||||
mapMergeWithInto
|
||||
} from "./support/Containers";
|
||||
} from "collection-utils";
|
||||
|
||||
import { TypeAttributeKind, combineTypeAttributes, emptyTypeAttributes } from "./TypeAttributes";
|
||||
import { JSONSchemaType, Ref, JSONSchemaAttributes } from "./input/JSONSchemaInput";
|
||||
import { JSONSchema } from "./input/JSONSchemaStore";
|
||||
|
||||
class DescriptionTypeAttributeKind extends TypeAttributeKind<ReadonlySet<string>> {
|
||||
constructor() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import * as pluralize from "pluralize";
|
||||
import { setUnion, setMap, setSortBy } from "collection-utils";
|
||||
|
||||
import { TypeGraph } from "./TypeGraph";
|
||||
import { Type, ObjectType } from "./Type";
|
||||
|
@ -6,7 +7,6 @@ import { matchCompoundType, nullableFromUnion } from "./TypeUtils";
|
|||
import { TypeNames, namesTypeAttributeKind, TooManyTypeNames, tooManyNamesThreshold } from "./TypeNames";
|
||||
import { defined, panic, assert } from "./support/Support";
|
||||
import { transformationForType } from "./Transformers";
|
||||
import { setUnion, setMap, setSortBy } from "./support/Containers";
|
||||
|
||||
class UniqueQueue<T> {
|
||||
private readonly _present = new Set<T>();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { setMap } from "collection-utils";
|
||||
|
||||
import { defined, repeated, assert, repeatedCall } from "./support/Support";
|
||||
import { setMap } from "./support/Containers";
|
||||
|
||||
function countComponentGraphNodes(components: number[][]): number {
|
||||
if (components.length === 0) return 0;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { mapMap, EqualityMap } from "collection-utils";
|
||||
|
||||
import { PrimitiveTypeKind, Type, ClassProperty, MaybeTypeIdentity } from "./Type";
|
||||
import { combineTypeAttributesOfTypes } from "./TypeUtils";
|
||||
import {
|
||||
|
@ -12,7 +14,6 @@ import {
|
|||
import { TypeAttributes, emptyTypeAttributes, combineTypeAttributes } from "./TypeAttributes";
|
||||
import { assert, panic, indentationString } from "./support/Support";
|
||||
import { TypeBuilder, StringTypeMapping } from "./TypeBuilder";
|
||||
import { mapMap, EqualityMap } from "./support/Containers";
|
||||
|
||||
export interface TypeLookerUp {
|
||||
lookupTypeRefs(typeRefs: TypeRef[], forwardingRef?: TypeRef): TypeRef | undefined;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { setFilter, setUnion, iterableFirst, mapMapEntries } from "collection-utils";
|
||||
|
||||
import { TypeGraph, TypeRef, typeRefIndex } from "./TypeGraph";
|
||||
import { TargetLanguage } from "./TargetLanguage";
|
||||
import { UnionType, TypeKind, EnumType, Type } from "./Type";
|
||||
|
@ -18,7 +20,6 @@ import {
|
|||
} from "./Transformers";
|
||||
import { TypeAttributes, emptyTypeAttributes } from "./TypeAttributes";
|
||||
import { StringTypes } from "./StringTypes";
|
||||
import { setFilter, setUnion, iterableFirst, mapMapEntries } from "./support/Containers";
|
||||
|
||||
function transformationAttributes(
|
||||
graph: TypeGraph,
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { defined, assert, panic } from "./support/Support";
|
||||
import {
|
||||
setUnion,
|
||||
setUnionInto,
|
||||
|
@ -12,7 +11,9 @@ import {
|
|||
iterableFirst,
|
||||
iterableEvery,
|
||||
mapMergeInto
|
||||
} from "./support/Containers";
|
||||
} from "collection-utils";
|
||||
|
||||
import { defined, assert, panic } from "./support/Support";
|
||||
|
||||
export class Namespace {
|
||||
readonly forbiddenNamespaces: ReadonlySet<Namespace>;
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import { iterableEnumerate } from "collection-utils";
|
||||
|
||||
import { TypeGraph } from "./TypeGraph";
|
||||
import { Name, Namespace, assignNames } from "./Naming";
|
||||
import { Source, Sourcelike, NewlineSource, annotated, sourcelikeToSource, newline } from "./Source";
|
||||
import { AnnotationData, IssueAnnotationData } from "./Annotation";
|
||||
import { assert, panic } from "./support/Support";
|
||||
import { TargetLanguage } from "./TargetLanguage";
|
||||
import { iterableEnumerate } from "./support/Containers";
|
||||
|
||||
export type RenderResult = {
|
||||
sources: ReadonlyMap<string, Source>;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { mapFirst } from "collection-utils";
|
||||
|
||||
import * as targetLanguages from "./language/All";
|
||||
import { TargetLanguage } from "./TargetLanguage";
|
||||
import { SerializedRenderResult, Annotation, Location, Span } from "./Source";
|
||||
|
@ -16,7 +18,6 @@ import { messageError } from "./Messages";
|
|||
import { InputData } from "./input/Inputs";
|
||||
import { flattenStrings } from "./rewrites/FlattenStrings";
|
||||
import { makeTransformations } from "./MakeTransformations";
|
||||
import { mapFirst } from "./support/Containers";
|
||||
|
||||
export function getTargetLanguage(nameOrInstance: string | TargetLanguage): TargetLanguage {
|
||||
if (typeof nameOrInstance === "object") {
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { arrayIntercalate, iterableMax } from "collection-utils";
|
||||
|
||||
import { AnnotationData } from "./Annotation";
|
||||
import { Name } from "./Naming";
|
||||
import { defined, assertNever, panic, assert, withDefault } from "./support/Support";
|
||||
import { repeatString } from "./support/Strings";
|
||||
import { arrayIntercalate, iterableMax } from "./support/Containers";
|
||||
|
||||
export type Source =
|
||||
| TextSource
|
||||
|
|
|
@ -1,8 +1,17 @@
|
|||
import {
|
||||
mapMap,
|
||||
iterableFirst,
|
||||
setIntersect,
|
||||
hashCodeOf,
|
||||
areEqual,
|
||||
mapMergeWithInto,
|
||||
definedMap
|
||||
} from "collection-utils";
|
||||
|
||||
import { TypeAttributeKind } from "./TypeAttributes";
|
||||
import { addHashCode, defined, assert, mapOptional } from "./support/Support";
|
||||
import { addHashCode, defined, assert } from "./support/Support";
|
||||
import { StringTypeMapping } from "./TypeBuilder";
|
||||
import { PrimitiveStringTypeKind } from "./Type";
|
||||
import { mapMap, iterableFirst, setIntersect, hashCodeOf, areEqual, mapMergeWithInto } from "./support/Containers";
|
||||
|
||||
export class StringTypes {
|
||||
static readonly unrestricted: StringTypes = new StringTypes(undefined, false, false, false);
|
||||
|
@ -75,7 +84,7 @@ export class StringTypes {
|
|||
const other = othersArray[i];
|
||||
|
||||
if (cases === undefined) {
|
||||
cases = mapOptional(m => new Map(m), other.cases);
|
||||
cases = definedMap(other.cases, m => new Map(m));
|
||||
} else if (other.cases !== undefined) {
|
||||
const thisCases = cases;
|
||||
const otherCases = other.cases;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { mapMap } from "collection-utils";
|
||||
|
||||
import { TypeGraph } from "./TypeGraph";
|
||||
import { Renderer, RenderContext } from "./Renderer";
|
||||
import { OptionDefinition, Option } from "./RendererOptions";
|
||||
|
@ -6,7 +8,6 @@ import { StringTypeMapping } from "./TypeBuilder";
|
|||
import { defined } from "./support/Support";
|
||||
import { ConvenienceRenderer } from "./ConvenienceRenderer";
|
||||
import { UnionType } from "./Type";
|
||||
import { mapMap } from "./support/Containers";
|
||||
|
||||
export abstract class TargetLanguage {
|
||||
constructor(readonly displayName: string, readonly names: string[], readonly extension: string) {}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import stringHash = require("string-hash");
|
||||
import { setUnionInto, areEqual, hashCodeOf, definedMap } from "collection-utils";
|
||||
|
||||
import { UnionType, Type, EnumType, PrimitiveType } from "./Type";
|
||||
import { TypeAttributeKind } from "./TypeAttributes";
|
||||
import { panic, addHashCode, assert, mapOptional, indentationString } from "./support/Support";
|
||||
import { panic, addHashCode, assert, indentationString } from "./support/Support";
|
||||
import { BaseGraphRewriteBuilder } from "./GraphRewriting";
|
||||
import { setUnionInto, areEqual, hashCodeOf } from "./support/Containers";
|
||||
import { TypeRef, derefTypeRef, TypeGraph } from "./TypeGraph";
|
||||
|
||||
function debugStringForType(t: Type): string {
|
||||
|
@ -131,7 +131,7 @@ export class DecodingTransformer extends ProducerTransformer {
|
|||
return new DecodingTransformer(
|
||||
builder.typeGraph,
|
||||
builder.reconstituteTypeRef(this.sourceTypeRef),
|
||||
mapOptional(xfer => xfer.reconstitute(builder), this.consumer)
|
||||
definedMap(this.consumer, xfer => xfer.reconstitute(builder))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -490,7 +490,7 @@ export class StringProducerTransformer extends ProducerTransformer {
|
|||
return new StringProducerTransformer(
|
||||
builder.typeGraph,
|
||||
builder.reconstituteTypeRef(this.sourceTypeRef),
|
||||
mapOptional(xfer => xfer.reconstitute(builder), this.consumer),
|
||||
definedMap(this.consumer, xfer => xfer.reconstitute(builder)),
|
||||
this.result
|
||||
);
|
||||
}
|
||||
|
@ -531,7 +531,7 @@ export class ParseDateTimeTransformer extends ProducerTransformer {
|
|||
return new ParseDateTimeTransformer(
|
||||
builder.typeGraph,
|
||||
builder.reconstituteTypeRef(this.sourceTypeRef),
|
||||
mapOptional(xfer => xfer.reconstitute(builder), this.consumer)
|
||||
definedMap(this.consumer, xfer => xfer.reconstitute(builder))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -561,7 +561,7 @@ export class StringifyDateTimeTransformer extends ProducerTransformer {
|
|||
return new StringifyDateTimeTransformer(
|
||||
builder.typeGraph,
|
||||
builder.reconstituteTypeRef(this.sourceTypeRef),
|
||||
mapOptional(xfer => xfer.reconstitute(builder), this.consumer)
|
||||
definedMap(this.consumer, xfer => xfer.reconstitute(builder))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
import { defined, panic, assert, mapOptional, hashCodeInit, addHashCode } from "./support/Support";
|
||||
import { TypeReconstituter, BaseGraphRewriteBuilder } from "./GraphRewriting";
|
||||
import { TypeNames, namesTypeAttributeKind } from "./TypeNames";
|
||||
import { TypeAttributes } from "./TypeAttributes";
|
||||
import { messageAssert } from "./Messages";
|
||||
import {
|
||||
iterableEvery,
|
||||
iterableFind,
|
||||
|
@ -18,8 +13,15 @@ import {
|
|||
setSortBy,
|
||||
setFilter,
|
||||
setUnionInto,
|
||||
mapSortToArray
|
||||
} from "./support/Containers";
|
||||
mapSortToArray,
|
||||
definedMap
|
||||
} from "collection-utils";
|
||||
|
||||
import { defined, panic, assert, hashCodeInit, addHashCode } from "./support/Support";
|
||||
import { TypeReconstituter, BaseGraphRewriteBuilder } from "./GraphRewriting";
|
||||
import { TypeNames, namesTypeAttributeKind } from "./TypeNames";
|
||||
import { TypeAttributes } from "./TypeAttributes";
|
||||
import { messageAssert } from "./Messages";
|
||||
import { TypeRef, attributesForTypeRef, derefTypeRef, TypeGraph, typeRefIndex } from "./TypeGraph";
|
||||
|
||||
export type DateTimeTypeKind = "date" | "time" | "date-time";
|
||||
|
@ -490,7 +492,7 @@ export class ObjectType extends Type {
|
|||
const sortedProperties = this.getSortedProperties();
|
||||
const propertiesInNewOrder = canonicalOrder ? sortedProperties : this.getProperties();
|
||||
const maybePropertyTypes = builder.lookupMap(mapMap(sortedProperties, cp => cp.typeRef));
|
||||
const maybeAdditionalProperties = mapOptional(r => builder.lookup(r), this._additionalPropertiesRef);
|
||||
const maybeAdditionalProperties = definedMap(this._additionalPropertiesRef, r => builder.lookup(r));
|
||||
|
||||
if (
|
||||
maybePropertyTypes !== undefined &&
|
||||
|
@ -538,7 +540,7 @@ export class ObjectType extends Type {
|
|||
const properties = mapMap(propertiesInNewOrder, (cp, n) =>
|
||||
builder.makeClassProperty(defined(reconstitutedTypes.get(n)), cp.isOptional)
|
||||
);
|
||||
const additionalProperties = mapOptional(r => builder.reconstitute(r), this._additionalPropertiesRef);
|
||||
const additionalProperties = definedMap(this._additionalPropertiesRef, r => builder.reconstitute(r));
|
||||
builder.setObjectProperties(properties, additionalProperties);
|
||||
}
|
||||
}
|
||||
|
@ -588,7 +590,7 @@ export class MapType extends ObjectType {
|
|||
readonly kind: "map";
|
||||
|
||||
constructor(typeRef: TypeRef, graph: TypeGraph, valuesRef: TypeRef | undefined) {
|
||||
super(typeRef, graph, "map", false, mapOptional(() => new Map(), valuesRef), valuesRef);
|
||||
super(typeRef, graph, "map", false, definedMap(valuesRef, () => new Map()), valuesRef);
|
||||
}
|
||||
|
||||
// FIXME: Remove and use `getAdditionalProperties()` instead.
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import stringHash = require("string-hash");
|
||||
import { mapFilterMap, mapFilter, mapTranspose, mapMap } from "collection-utils";
|
||||
|
||||
import { panic, assert } from "./support/Support";
|
||||
import { Type } from "./Type";
|
||||
import { BaseGraphRewriteBuilder } from "./GraphRewriting";
|
||||
import { mapFilterMap, mapFilter, mapTranspose, mapMap } from "./support/Containers";
|
||||
|
||||
export class TypeAttributeKind<T> {
|
||||
constructor(readonly name: string) {}
|
||||
|
|
|
@ -1,3 +1,16 @@
|
|||
import {
|
||||
EqualityMap,
|
||||
mapMap,
|
||||
mapSortByKey,
|
||||
iterableEvery,
|
||||
mapFilter,
|
||||
mapFind,
|
||||
setMap,
|
||||
areEqual,
|
||||
setUnionManyInto,
|
||||
definedMap
|
||||
} from "collection-utils";
|
||||
|
||||
import {
|
||||
PrimitiveTypeKind,
|
||||
Type,
|
||||
|
@ -24,19 +37,8 @@ import {
|
|||
import { removeNullFromUnion } from "./TypeUtils";
|
||||
import { TypeGraph, TypeRef, makeTypeRef, derefTypeRef, typeRefIndex } from "./TypeGraph";
|
||||
import { TypeAttributes, combineTypeAttributes, TypeAttributeKind, emptyTypeAttributes } from "./TypeAttributes";
|
||||
import { defined, assert, panic, mapOptional, withDefault } from "./support/Support";
|
||||
import { defined, assert, panic, withDefault } from "./support/Support";
|
||||
import { stringTypesTypeAttributeKind, StringTypes } from "./StringTypes";
|
||||
import {
|
||||
EqualityMap,
|
||||
mapMap,
|
||||
mapSortByKey,
|
||||
iterableEvery,
|
||||
mapFilter,
|
||||
mapFind,
|
||||
setMap,
|
||||
areEqual,
|
||||
setUnionManyInto
|
||||
} from "./support/Containers";
|
||||
|
||||
// FIXME: Don't infer provenance. All original types should be present in
|
||||
// non-inferred form in the final graph.
|
||||
|
@ -318,7 +320,7 @@ export class TypeBuilder {
|
|||
additionalProperties: TypeRef | undefined,
|
||||
forwardingRef?: TypeRef
|
||||
): TypeRef {
|
||||
properties = mapOptional(p => this.modifyPropertiesIfNecessary(p), properties);
|
||||
properties = definedMap(properties, p => this.modifyPropertiesIfNecessary(p));
|
||||
return this.addType(
|
||||
forwardingRef,
|
||||
tref => new ObjectType(tref, this.typeGraph, "object", true, properties, additionalProperties),
|
||||
|
@ -406,7 +408,7 @@ export class TypeBuilder {
|
|||
properties: ReadonlyMap<string, ClassProperty> | undefined,
|
||||
forwardingRef?: TypeRef
|
||||
): TypeRef {
|
||||
properties = mapOptional(p => this.modifyPropertiesIfNecessary(p), properties);
|
||||
properties = definedMap(properties, p => this.modifyPropertiesIfNecessary(p));
|
||||
return this.addType(
|
||||
forwardingRef,
|
||||
tref => new ClassType(tref, this.typeGraph, isFixed, properties),
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { iterableFirst, setFilter, setUnionManyInto, setSubtract, mapMap, mapSome, setMap } from "collection-utils";
|
||||
|
||||
import { Type, ClassType, UnionType, IntersectionType } from "./Type";
|
||||
import { separateNamedTypes, SeparatedNamedTypes, isNamedType, combineTypeAttributesOfTypes } from "./TypeUtils";
|
||||
import { defined, assert, mustNotBeCalled, panic } from "./support/Support";
|
||||
|
@ -7,7 +9,6 @@ import { TypeNames, namesTypeAttributeKind } from "./TypeNames";
|
|||
import { Graph } from "./Graph";
|
||||
import { TypeAttributeKind, TypeAttributes, emptyTypeAttributes } from "./TypeAttributes";
|
||||
import { messageError } from "./Messages";
|
||||
import { iterableFirst, setFilter, setUnionManyInto, setSubtract, mapMap, mapSome, setMap } from "./support/Containers";
|
||||
|
||||
export type TypeRef = number;
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import * as pluralize from "pluralize";
|
||||
import { setMap, iterableFirst, iterableSkip, setUnionInto, definedMap } from "collection-utils";
|
||||
|
||||
import { panic, defined, assert, mapOptional } from "./support/Support";
|
||||
import { panic, defined, assert } from "./support/Support";
|
||||
import { TypeAttributeKind, TypeAttributes } from "./TypeAttributes";
|
||||
import { splitIntoWords } from "./support/Strings";
|
||||
import { Chance } from "./support/Chance";
|
||||
import { setMap, iterableFirst, iterableSkip, setUnionInto } from "./support/Containers";
|
||||
|
||||
let chance: Chance;
|
||||
let usedRandomNames: Set<string>;
|
||||
|
@ -121,7 +121,7 @@ export class RegularTypeNames extends TypeNames {
|
|||
add(namesArray: TypeNames[], startIndex: number = 0): TypeNames {
|
||||
let newNames = new Set(this.names);
|
||||
let newAreInferred = this.areInferred;
|
||||
let newAlternativeNames = mapOptional(s => new Set(s), this._alternativeNames);
|
||||
let newAlternativeNames = definedMap(this._alternativeNames, s => new Set(s));
|
||||
|
||||
for (let i = startIndex; i < namesArray.length; i++) {
|
||||
const other = namesArray[i];
|
||||
|
@ -184,7 +184,7 @@ export class RegularTypeNames extends TypeNames {
|
|||
singularize(): TypeNames {
|
||||
return TypeNames.make(
|
||||
setMap(this.names, pluralize.singular),
|
||||
mapOptional(an => setMap(an, pluralize.singular), this._alternativeNames),
|
||||
definedMap(this._alternativeNames, an => setMap(an, pluralize.singular)),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { setFilter, setSortBy, iterableFirst, setUnion, EqualityMap } from "collection-utils";
|
||||
|
||||
import { defined, panic, assert, assertNever } from "./support/Support";
|
||||
import { TypeAttributes, combineTypeAttributes, emptyTypeAttributes, CombinationKind } from "./TypeAttributes";
|
||||
import {
|
||||
|
@ -13,7 +15,6 @@ import {
|
|||
UnionType
|
||||
} from "./Type";
|
||||
import { stringTypesTypeAttributeKind, StringTypes } from "./StringTypes";
|
||||
import { setFilter, setSortBy, iterableFirst, setUnion, EqualityMap } from "./support/Containers";
|
||||
|
||||
export function assertIsObject(t: Type): ObjectType {
|
||||
if (t instanceof ObjectType) {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { iterableFirst, setUnionInto } from "collection-utils";
|
||||
|
||||
import { Type, ClassProperty, UnionType, ObjectType } from "./Type";
|
||||
import { assertIsObject } from "./TypeUtils";
|
||||
import { TypeBuilder } from "./TypeBuilder";
|
||||
|
@ -5,7 +7,6 @@ import { TypeLookerUp, GraphRewriteBuilder, BaseGraphRewriteBuilder } from "./Gr
|
|||
import { UnionBuilder, TypeRefUnionAccumulator } from "./UnionBuilder";
|
||||
import { panic, assert, defined } from "./support/Support";
|
||||
import { TypeAttributes, combineTypeAttributes, emptyTypeAttributes } from "./TypeAttributes";
|
||||
import { iterableFirst, setUnionInto } from "./support/Containers";
|
||||
import { TypeRef, derefTypeRef } from "./TypeGraph";
|
||||
|
||||
function getCliqueProperties(
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { mapMerge, mapUpdateInto, mapMap, setUnionInto } from "collection-utils";
|
||||
|
||||
import { TypeKind, PrimitiveStringTypeKind, Type, UnionType } from "./Type";
|
||||
import { matchTypeExhaustive } from "./TypeUtils";
|
||||
import {
|
||||
|
@ -9,7 +11,6 @@ import {
|
|||
import { defined, assert, panic, assertNever } from "./support/Support";
|
||||
import { TypeBuilder } from "./TypeBuilder";
|
||||
import { StringTypes, stringTypesTypeAttributeKind } from "./StringTypes";
|
||||
import { mapMerge, mapUpdateInto, mapMap, setUnionInto } from "./support/Containers";
|
||||
import { TypeRef } from "./TypeGraph";
|
||||
|
||||
// FIXME: This interface is badly designed. All the properties
|
||||
|
|
|
@ -23,7 +23,6 @@ export {
|
|||
assert,
|
||||
defined,
|
||||
withDefault,
|
||||
mapOptional,
|
||||
assertNever,
|
||||
parseJSON,
|
||||
checkStringMap,
|
||||
|
@ -32,7 +31,6 @@ export {
|
|||
StringInput,
|
||||
toString
|
||||
} from "./support/Support";
|
||||
export { mapMap, setMap, iterableFirst, mapFromObject } from "./support/Containers";
|
||||
export { getStream } from "./get-stream/index";
|
||||
export { train as trainMarkovChain } from "./MarkovChain";
|
||||
export { QuickTypeError, messageError, messageAssert } from "./Messages";
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import * as URI from "urijs";
|
||||
import { iterableFirst, iterableFind, iterableSome, setFilterMap } from "collection-utils";
|
||||
|
||||
import {
|
||||
Ref,
|
||||
|
@ -28,7 +29,6 @@ import { TypeInference } from "./Inference";
|
|||
import { TargetLanguage } from "../TargetLanguage";
|
||||
import { languageNamed } from "../language/All";
|
||||
import { accessorNamesAttributeProducer } from "../AccessorNames";
|
||||
import { iterableFirst, iterableFind, iterableSome, setFilterMap } from "../support/Containers";
|
||||
|
||||
class InputJSONSchemaStore extends JSONSchemaStore {
|
||||
constructor(private readonly _inputs: Map<string, StringInput>, private readonly _delegate?: JSONSchemaStore) {
|
||||
|
|
|
@ -1,30 +1,6 @@
|
|||
import * as pluralize from "pluralize";
|
||||
import * as URI from "urijs";
|
||||
import stringHash = require("string-hash");
|
||||
|
||||
import { PrimitiveTypeKind } from "../Type";
|
||||
import {
|
||||
panic,
|
||||
assertNever,
|
||||
StringMap,
|
||||
assert,
|
||||
defined,
|
||||
addHashCode,
|
||||
mapOptional,
|
||||
hasOwnProperty
|
||||
} from "../support/Support";
|
||||
import { TypeBuilder } from "../TypeBuilder";
|
||||
import { TypeNames } from "../TypeNames";
|
||||
import { makeNamesTypeAttributes, modifyTypeNames, singularizeTypeNames } from "../TypeNames";
|
||||
import {
|
||||
TypeAttributes,
|
||||
makeTypeAttributesInferred,
|
||||
emptyTypeAttributes,
|
||||
combineTypeAttributes
|
||||
} from "../TypeAttributes";
|
||||
import { JSONSchema, JSONSchemaStore } from "./JSONSchemaStore";
|
||||
import { messageAssert, messageError } from "../Messages";
|
||||
import { StringTypes } from "../StringTypes";
|
||||
import {
|
||||
setFilter,
|
||||
EqualityMap,
|
||||
|
@ -40,8 +16,26 @@ import {
|
|||
arrayLast,
|
||||
arrayGetFromEnd,
|
||||
arrayPop,
|
||||
hashCodeOf
|
||||
} from "../support/Containers";
|
||||
hashCodeOf,
|
||||
hasOwnProperty,
|
||||
definedMap
|
||||
} from "collection-utils";
|
||||
|
||||
import { PrimitiveTypeKind } from "../Type";
|
||||
import { panic, assertNever, StringMap, assert, defined, addHashCode } from "../support/Support";
|
||||
import { TypeBuilder } from "../TypeBuilder";
|
||||
import { TypeNames } from "../TypeNames";
|
||||
import { makeNamesTypeAttributes, modifyTypeNames, singularizeTypeNames } from "../TypeNames";
|
||||
import {
|
||||
TypeAttributes,
|
||||
makeTypeAttributesInferred,
|
||||
emptyTypeAttributes,
|
||||
combineTypeAttributes
|
||||
} from "../TypeAttributes";
|
||||
import { JSONSchema, JSONSchemaStore } from "./JSONSchemaStore";
|
||||
import { messageAssert, messageError } from "../Messages";
|
||||
import { StringTypes } from "../StringTypes";
|
||||
|
||||
import { TypeRef } from "../TypeGraph";
|
||||
|
||||
export enum PathElementKind {
|
||||
|
@ -310,7 +304,7 @@ export class Ref {
|
|||
}
|
||||
|
||||
hashCode(): number {
|
||||
let acc = hashCodeOf(mapOptional(u => u.toString(), this.addressURI));
|
||||
let acc = hashCodeOf(definedMap(this.addressURI, u => u.toString()));
|
||||
for (const pe of this.path) {
|
||||
acc = addHashCode(acc, pe.kind);
|
||||
switch (pe.kind) {
|
||||
|
@ -501,9 +495,9 @@ export async function addTypesInSchema(
|
|||
const canonizer = new Canonizer();
|
||||
|
||||
async function resolveVirtualRef(base: Location | undefined, virtualRef: Ref): Promise<[JSONSchema, Location]> {
|
||||
const [canonical, fullVirtual] = canonizer.canonize(mapOptional(b => b.virtualRef, base), virtualRef);
|
||||
const [canonical, fullVirtual] = canonizer.canonize(definedMap(base, b => b.virtualRef), virtualRef);
|
||||
assert(canonical.hasAddress, "Canonical ref can't be resolved without an address");
|
||||
const schema = await getFromStore(store, canonical.address, mapOptional(l => l.canonicalRef, base));
|
||||
const schema = await getFromStore(store, canonical.address, definedMap(base, l => l.canonicalRef));
|
||||
canonizer.addSchema(schema, canonical.address);
|
||||
return [canonical.lookupRef(schema), new Location(canonical, fullVirtual)];
|
||||
}
|
||||
|
@ -567,7 +561,7 @@ export async function addTypesInSchema(
|
|||
|
||||
async function convertToType(schema: StringMap, loc: Location, typeAttributes: TypeAttributes): Promise<TypeRef> {
|
||||
const enumArray = Array.isArray(schema.enum) ? schema.enum : undefined;
|
||||
const typeSet = mapOptional(t => checkTypeList(t, loc), schema.type);
|
||||
const typeSet = definedMap(schema.type, t => checkTypeList(t, loc));
|
||||
|
||||
function isTypeIncluded(name: JSONSchemaType): boolean {
|
||||
if (typeSet !== undefined && !typeSet.has(name)) {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { arrayIntercalate, toReadonlyArray, iterableFirst, iterableFind } from "collection-utils";
|
||||
|
||||
import { TargetLanguage } from "../TargetLanguage";
|
||||
import { Type, ClassType, EnumType, UnionType } from "../Type";
|
||||
import { nullableFromUnion, matchType, removeNullFromUnion } from "../TypeUtils";
|
||||
|
@ -19,7 +21,6 @@ import { StringOption, EnumOption, BooleanOption, Option, getOptionValues, Optio
|
|||
import { assert } from "../support/Support";
|
||||
import { Declaration } from "../DeclarationIR";
|
||||
import { RenderContext } from "../Renderer";
|
||||
import { arrayIntercalate, toReadonlyArray, iterableFirst, iterableFind } from "../support/Containers";
|
||||
|
||||
const pascalValue: [string, NamingStyle] = ["pascal-case", "pascal"];
|
||||
const underscoreValue: [string, NamingStyle] = ["underscore-case", "underscore"];
|
||||
|
@ -675,7 +676,7 @@ export class CPlusPlusRenderer extends ConvenienceRenderer {
|
|||
if (this._options.justTypes) return;
|
||||
this.forEachTopLevel(
|
||||
"leading",
|
||||
(t: Type, name:Name) => this.emitTopLevelTypedef(t, name),
|
||||
(t: Type, name: Name) => this.emitTopLevelTypedef(t, name),
|
||||
t => this.namedTypeToNameForTopLevel(t) === undefined
|
||||
);
|
||||
this.emitMultiline(`
|
||||
|
@ -748,8 +749,12 @@ inline ${optionalType}<T> get_optional(const json &j, const char *property) {
|
|||
if (this.haveUnions) {
|
||||
this.emitOptionalHelpers();
|
||||
}
|
||||
this.forEachObject("leading-and-interposing", (c: ClassType, className: Name) => this.emitClassFunctions(c, className));
|
||||
this.forEachEnum("leading-and-interposing", (e: EnumType, enumName: Name) => this.emitEnumFunctions(e, enumName));
|
||||
this.forEachObject("leading-and-interposing", (c: ClassType, className: Name) =>
|
||||
this.emitClassFunctions(c, className)
|
||||
);
|
||||
this.forEachEnum("leading-and-interposing", (e: EnumType, enumName: Name) =>
|
||||
this.emitEnumFunctions(e, enumName)
|
||||
);
|
||||
if (this.haveUnions) {
|
||||
this.ensureBlankLine();
|
||||
this.emitAllUnionFunctions();
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { arrayIntercalate } from "collection-utils";
|
||||
|
||||
import { Type, EnumType, UnionType, ClassType, ClassProperty } from "../Type";
|
||||
import { matchType, nullableFromUnion, removeNullFromUnion, directlyReachableSingleNamedType } from "../TypeUtils";
|
||||
import { Sourcelike, maybeAnnotated, modifySource } from "../Source";
|
||||
|
@ -32,7 +34,6 @@ import {
|
|||
StringifyDateTimeTransformer
|
||||
} from "../Transformers";
|
||||
import { RenderContext } from "../Renderer";
|
||||
import { arrayIntercalate } from "../support/Containers";
|
||||
|
||||
const unicode = require("unicode-properties");
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { mapContains, arrayIntercalate } from "collection-utils";
|
||||
|
||||
import { TargetLanguage } from "../TargetLanguage";
|
||||
import { EnumOption, StringOption, BooleanOption, Option, getOptionValues, OptionValues } from "../RendererOptions";
|
||||
import { Type, ClassType, UnionType, EnumType, ClassProperty } from "../Type";
|
||||
|
@ -21,7 +23,6 @@ import { defined } from "../support/Support";
|
|||
import { Sourcelike, annotated, MultiWord, singleWord, multiWord, parenIfNeeded } from "../Source";
|
||||
import { anyTypeIssueAnnotation, nullTypeIssueAnnotation } from "../Annotation";
|
||||
import { RenderContext } from "../Renderer";
|
||||
import { mapContains, arrayIntercalate } from "../support/Containers";
|
||||
|
||||
export const elmOptions = {
|
||||
justTypes: new BooleanOption("just-types", "Plain types only", false),
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { mapFirst, iterableFirst } from "collection-utils";
|
||||
|
||||
import { TargetLanguage } from "../TargetLanguage";
|
||||
import { Type, UnionType, EnumType, ObjectType } from "../Type";
|
||||
import { matchTypeExhaustive } from "../TypeUtils";
|
||||
|
@ -15,7 +17,6 @@ import { StringTypeMapping } from "../TypeBuilder";
|
|||
import { descriptionTypeAttributeKind } from "../Description";
|
||||
import { Option } from "../RendererOptions";
|
||||
import { RenderContext } from "../Renderer";
|
||||
import { mapFirst, iterableFirst } from "../support/Containers";
|
||||
|
||||
export class JSONSchemaTargetLanguage extends TargetLanguage {
|
||||
constructor() {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { arrayIntercalate } from "collection-utils";
|
||||
|
||||
import { Type, ClassProperty, ClassType, ObjectType } from "../Type";
|
||||
import { matchType, directlyReachableSingleNamedType } from "../TypeUtils";
|
||||
import {
|
||||
|
@ -17,7 +19,6 @@ import { ConvenienceRenderer } from "../ConvenienceRenderer";
|
|||
import { TargetLanguage } from "../TargetLanguage";
|
||||
import { BooleanOption, Option, OptionValues, getOptionValues } from "../RendererOptions";
|
||||
import { RenderContext } from "../Renderer";
|
||||
import { arrayIntercalate } from "../support/Containers";
|
||||
|
||||
const unicode = require("unicode-properties");
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { iterableSome, arrayIntercalate } from "collection-utils";
|
||||
|
||||
import { anyTypeIssueAnnotation, nullTypeIssueAnnotation } from "../Annotation";
|
||||
import { ConvenienceRenderer, ForbiddenWordsInfo } from "../ConvenienceRenderer";
|
||||
import { Name, Namer, funPrefixNamer } from "../Naming";
|
||||
|
@ -24,7 +26,6 @@ import { TargetLanguage } from "../TargetLanguage";
|
|||
import { ArrayType, ClassProperty, ClassType, EnumType, MapType, ObjectType, Type, UnionType } from "../Type";
|
||||
import { matchType, nullableFromUnion, removeNullFromUnion } from "../TypeUtils";
|
||||
import { RenderContext } from "../Renderer";
|
||||
import { iterableSome, arrayIntercalate } from "../support/Containers";
|
||||
|
||||
export enum Framework {
|
||||
None,
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { iterableSome, iterableFirst, mapContains, mapFirst, mapSome } from "collection-utils";
|
||||
|
||||
import { TargetLanguage } from "../TargetLanguage";
|
||||
import { Type, ClassType, EnumType, ArrayType, MapType, UnionType, ClassProperty } from "../Type";
|
||||
import { matchType, nullableFromUnion } from "../TypeUtils";
|
||||
|
@ -20,7 +22,6 @@ import { ConvenienceRenderer, ForbiddenWordsInfo } from "../ConvenienceRenderer"
|
|||
import { StringOption, BooleanOption, EnumOption, Option, getOptionValues, OptionValues } from "../RendererOptions";
|
||||
import { assert, defined } from "../support/Support";
|
||||
import { RenderContext } from "../Renderer";
|
||||
import { iterableSome, iterableFirst, mapContains, mapFirst, mapSome } from "../support/Containers";
|
||||
|
||||
const unicode = require("unicode-properties");
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { mapFirst } from "collection-utils";
|
||||
|
||||
import { TargetLanguage } from "../TargetLanguage";
|
||||
import { ConvenienceRenderer, ForbiddenWordsInfo } from "../ConvenienceRenderer";
|
||||
import {
|
||||
|
@ -22,7 +24,6 @@ import { anyTypeIssueAnnotation, nullTypeIssueAnnotation } from "../Annotation";
|
|||
import { BooleanOption, EnumOption, Option, getOptionValues, OptionValues } from "../RendererOptions";
|
||||
import { defined } from "../support/Support";
|
||||
import { RenderContext } from "../Renderer";
|
||||
import { mapFirst } from "../support/Containers";
|
||||
|
||||
export enum Density {
|
||||
Normal,
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { arrayIntercalate } from "collection-utils";
|
||||
|
||||
import { TargetLanguage } from "../TargetLanguage";
|
||||
import { Type, ClassType, EnumType, UnionType, ArrayType, MapType, TypeKind, ClassProperty } from "../Type";
|
||||
import { matchType, nullableFromUnion, removeNullFromUnion } from "../TypeUtils";
|
||||
|
@ -24,7 +26,6 @@ import {
|
|||
addPrefixIfNecessary
|
||||
} from "../support/Strings";
|
||||
import { RenderContext } from "../Renderer";
|
||||
import { arrayIntercalate } from "../support/Containers";
|
||||
|
||||
const MAX_SAMELINE_PROPERTIES = 4;
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { iterableFirst, mapFilter, iterableSome, iterableReduce } from "collection-utils";
|
||||
|
||||
import { PrimitiveType } from "../Type";
|
||||
import { stringTypesForType } from "../TypeUtils";
|
||||
import { TypeGraph, TypeRef } from "../TypeGraph";
|
||||
|
@ -6,7 +8,6 @@ import { GraphRewriteBuilder } from "../GraphRewriting";
|
|||
import { assert, defined } from "../support/Support";
|
||||
import { emptyTypeAttributes } from "../TypeAttributes";
|
||||
import { StringTypes } from "../StringTypes";
|
||||
import { iterableFirst, mapFilter, iterableSome, iterableReduce } from "../support/Containers";
|
||||
|
||||
const MIN_LENGTH_FOR_ENUM = 10;
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { iterableFirst } from "collection-utils";
|
||||
|
||||
import { PrimitiveType, UnionType, Type } from "../Type";
|
||||
import { stringTypesForType, combineTypeAttributesOfTypes } from "../TypeUtils";
|
||||
import { TypeGraph, TypeRef } from "../TypeGraph";
|
||||
|
@ -5,7 +7,6 @@ import { StringTypeMapping } from "../TypeBuilder";
|
|||
import { GraphRewriteBuilder } from "../GraphRewriting";
|
||||
import { assert, defined } from "../support/Support";
|
||||
import { combineTypeAttributes } from "../TypeAttributes";
|
||||
import { iterableFirst } from "../support/Containers";
|
||||
|
||||
// A union needs replacing if it contains more than one string type, one of them being
|
||||
// a basic string type.
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { setFilter, iterableSome } from "collection-utils";
|
||||
|
||||
import { TypeGraph, TypeRef, derefTypeRef } from "../TypeGraph";
|
||||
import { Type, UnionType, IntersectionType } from "../Type";
|
||||
import { makeGroupsToFlatten } from "../TypeUtils";
|
||||
|
@ -7,7 +9,6 @@ import { GraphRewriteBuilder } from "../GraphRewriting";
|
|||
import { unifyTypes, UnifyUnionBuilder } from "../UnifyClasses";
|
||||
import { messageAssert } from "../Messages";
|
||||
import { emptyTypeAttributes } from "../TypeAttributes";
|
||||
import { setFilter, iterableSome } from "../support/Containers";
|
||||
|
||||
export function flattenUnions(
|
||||
graph: TypeGraph,
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { iterableFirst, iterableEvery, setMap } from "collection-utils";
|
||||
|
||||
import { Type, ClassType, setOperationCasesEqual, ClassProperty } from "../Type";
|
||||
import { removeNullFromType } from "../TypeUtils";
|
||||
import { defined, panic } from "../support/Support";
|
||||
|
@ -6,7 +8,6 @@ import { StringTypeMapping } from "../TypeBuilder";
|
|||
import { GraphRewriteBuilder } from "../GraphRewriting";
|
||||
import { unifyTypes, unionBuilderForUnification } from "../UnifyClasses";
|
||||
import { MarkovChain, load, evaluate } from "../MarkovChain";
|
||||
import { iterableFirst, iterableEvery, setMap } from "../support/Containers";
|
||||
|
||||
const mapSizeThreshold = 20;
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import { setFilter, iterableFirst, mapMap, setMap } from "collection-utils";
|
||||
|
||||
import { TypeGraph, TypeRef } from "../TypeGraph";
|
||||
import { StringTypeMapping } from "../TypeBuilder";
|
||||
import { GraphRewriteBuilder } from "../GraphRewriting";
|
||||
import { ObjectType, ClassProperty } from "../Type";
|
||||
import { defined } from "../support/Support";
|
||||
import { emptyTypeAttributes } from "../TypeAttributes";
|
||||
import { setFilter, iterableFirst, mapMap, setMap } from "../support/Containers";
|
||||
|
||||
export function replaceObjectType(
|
||||
graph: TypeGraph,
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
import {
|
||||
iterableFirst,
|
||||
iterableEvery,
|
||||
setFilter,
|
||||
mapMapEntries,
|
||||
mapMergeWithInto,
|
||||
mapMap,
|
||||
mapUpdateInto,
|
||||
setMap,
|
||||
iterableFind,
|
||||
setIntersect,
|
||||
setUnionInto
|
||||
} from "collection-utils";
|
||||
|
||||
import { TypeGraph, TypeRef } from "../TypeGraph";
|
||||
import { StringTypeMapping, TypeBuilder } from "../TypeBuilder";
|
||||
import { GraphRewriteBuilder, TypeLookerUp } from "../GraphRewriting";
|
||||
|
@ -22,19 +36,6 @@ import {
|
|||
emptyTypeAttributes,
|
||||
makeTypeAttributesInferred
|
||||
} from "../TypeAttributes";
|
||||
import {
|
||||
iterableFirst,
|
||||
iterableEvery,
|
||||
setFilter,
|
||||
mapMapEntries,
|
||||
mapMergeWithInto,
|
||||
mapMap,
|
||||
mapUpdateInto,
|
||||
setMap,
|
||||
iterableFind,
|
||||
setIntersect,
|
||||
setUnionInto
|
||||
} from "../support/Containers";
|
||||
|
||||
function canResolve(t: IntersectionType): boolean {
|
||||
const members = setOperationMembersRecursively(t, undefined)[0];
|
||||
|
|
|
@ -1,520 +0,0 @@
|
|||
import stringHash = require("string-hash");
|
||||
|
||||
import { hashCodeInit, addHashCode, panic } from "./Support";
|
||||
|
||||
export function iterableFind<T>(it: Iterable<T>, p: (v: T) => boolean): T | undefined {
|
||||
for (const v of it) {
|
||||
if (p(v)) {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function iterableEvery<T>(it: Iterable<T>, p: (v: T) => boolean): boolean {
|
||||
for (const v of it) {
|
||||
if (!p(v)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
export function iterableSome<T>(it: Iterable<T>, p: (v: T) => boolean): boolean {
|
||||
for (const v of it) {
|
||||
if (p(v)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function iterableFirst<T>(it: Iterable<T>): T | undefined {
|
||||
for (const v of it) {
|
||||
return v;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function iterableMax(it: Iterable<number>): number | undefined {
|
||||
let max: number | undefined = undefined;
|
||||
for (const v of it) {
|
||||
if (max === undefined || v > max) {
|
||||
max = v;
|
||||
}
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
export function iterableMinBy<T>(it: Iterable<T>, key: (v: T) => number): T | undefined {
|
||||
let min: number | undefined = undefined;
|
||||
let minValue: T | undefined = undefined;
|
||||
for (const v of it) {
|
||||
const k = key(v);
|
||||
if (min === undefined || k < min) {
|
||||
min = k;
|
||||
minValue = v;
|
||||
}
|
||||
}
|
||||
return minValue;
|
||||
}
|
||||
|
||||
export function iterableReduce<R, V>(it: Iterable<V>, unit: R, reducer: (r: R, v: V) => R): R {
|
||||
let result = unit;
|
||||
for (const v of it) {
|
||||
result = reducer(result, v);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function* iterableEnumerate<T>(it: Iterable<T>): IterableIterator<[number, T]> {
|
||||
let i = 0;
|
||||
for (const v of it) {
|
||||
yield [i, v];
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
export function* iterableSkip<T>(it: Iterable<T>, n: number): IterableIterator<T> {
|
||||
let i = 0;
|
||||
for (const v of it) {
|
||||
if (i >= n) {
|
||||
yield v;
|
||||
} else {
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** n === 1 will give the last element. */
|
||||
export function arrayGetFromEnd<T>(arr: ReadonlyArray<T>, i: number): T | undefined {
|
||||
const l = arr.length;
|
||||
if (i > l) return undefined;
|
||||
return arr[l - i];
|
||||
}
|
||||
|
||||
export function arrayLast<T>(arr: ReadonlyArray<T>): T | undefined {
|
||||
return arrayGetFromEnd(arr, 1);
|
||||
}
|
||||
|
||||
export function arrayPop<T>(arr: ReadonlyArray<T>): T[] {
|
||||
const l = arr.length;
|
||||
if (l === 0) {
|
||||
return panic("Cannot pop empty array");
|
||||
}
|
||||
return arr.slice(0, l - 1);
|
||||
}
|
||||
|
||||
export function arrayIntercalate<T>(separator: T, items: Iterable<T>): T[] {
|
||||
const acc: T[] = [];
|
||||
for (const x of items) {
|
||||
if (acc.length > 0) acc.push(separator);
|
||||
acc.push(x);
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
|
||||
export async function arrayMapSync<T, U>(set: Iterable<T>, f: (v: T, i: number) => Promise<U>): Promise<U[]> {
|
||||
const result: U[] = [];
|
||||
let i = 0;
|
||||
for (const v of set) {
|
||||
result.push(await f(v, i));
|
||||
i += 1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function toReadonlyArray<T>(it: Iterable<T>): ReadonlyArray<T> {
|
||||
if (Array.isArray(it)) return it;
|
||||
return Array.from(it);
|
||||
}
|
||||
|
||||
export function mapMap<K, V, W>(m: Iterable<[K, V]>, f: (v: V, k: K) => W): Map<K, W> {
|
||||
const result = new Map<K, W>();
|
||||
for (const [k, v] of m) {
|
||||
result.set(k, f(v, k));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function mapFirst<K, V>(m: ReadonlyMap<K, V>): V | undefined {
|
||||
for (const v of m.values()) {
|
||||
return v;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function mapContains<K, V>(m: ReadonlyMap<K, V>, valueToFind: V): boolean {
|
||||
for (const v of m.values()) {
|
||||
if (v === valueToFind) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function mapSome<K, V>(m: Iterable<[K, V]>, p: (v: V, k: K) => boolean): boolean {
|
||||
for (const [k, v] of m) {
|
||||
if (p(v, k)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function mapMergeInto<K, V>(dest: Map<K, V>, src: Iterable<[K, V]>): Map<K, V> {
|
||||
for (const [k, v] of src) {
|
||||
dest.set(k, v);
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
export function mapMerge<K, V>(ma: Iterable<[K, V]>, mb: Iterable<[K, V]>): Map<K, V> {
|
||||
const result = new Map(ma);
|
||||
mapMergeInto(result, mb);
|
||||
return result;
|
||||
}
|
||||
|
||||
export function mapMergeWithInto<K, V>(
|
||||
ma: Map<K, V>,
|
||||
merger: (va: V, vb: V, k: K) => V,
|
||||
mb: Iterable<[K, V]>
|
||||
): Map<K, V> {
|
||||
for (const [k, vb] of mb) {
|
||||
const va = ma.get(k);
|
||||
const v = va === undefined ? vb : merger(va, vb, k);
|
||||
ma.set(k, v);
|
||||
}
|
||||
return ma;
|
||||
}
|
||||
|
||||
export function mapMergeWith<K, V>(
|
||||
ma: Iterable<[K, V]>,
|
||||
merger: (va: V, vb: V, k: K) => V,
|
||||
mb: Iterable<[K, V]>
|
||||
): Map<K, V> {
|
||||
const result = new Map(ma);
|
||||
mapMergeWithInto(result, merger, mb);
|
||||
return result;
|
||||
}
|
||||
|
||||
export function mapFilter<K, V>(m: Iterable<[K, V]>, p: (v: V, k: K) => boolean): Map<K, V> {
|
||||
const result = new Map<K, V>();
|
||||
for (const [k, v] of m) {
|
||||
if (p(v, k)) {
|
||||
result.set(k, v);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function mapFilterMap<K, V, W>(m: Iterable<[K, V]>, f: (v: V, k: K) => W | undefined): Map<K, W> {
|
||||
const result = new Map<K, W>();
|
||||
for (const [k, v] of m) {
|
||||
const w = f(v, k);
|
||||
if (w !== undefined) {
|
||||
result.set(k, w);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function compareKeys(sa: any, sb: any): number {
|
||||
if (sa < sb) return -1;
|
||||
if (sa > sb) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
export function mapSortToArray<K, V>(m: Iterable<[K, V]>, sortKey: (v: V, k: K) => number | string): [K, V][] {
|
||||
const arr = Array.from(m);
|
||||
arr.sort(([ka, va], [kb, vb]) => {
|
||||
const sa = sortKey(va, ka);
|
||||
const sb = sortKey(vb, kb);
|
||||
return compareKeys(sa, sb);
|
||||
});
|
||||
return arr;
|
||||
}
|
||||
|
||||
export function mapSortBy<K, V>(m: Iterable<[K, V]>, sortKey: (v: V, k: K) => number | string): Map<K, V> {
|
||||
return new Map(mapSortToArray(m, sortKey));
|
||||
}
|
||||
|
||||
export function mapSortByKey<K extends number | string, V>(m: Iterable<[K, V]>): Map<K, V> {
|
||||
return mapSortBy(m, (_, k) => k);
|
||||
}
|
||||
|
||||
export function mapMapEntries<K, L, V, W>(m: Iterable<[K, V]>, f: (v: V, k: K) => [L, W]): Map<L, W> {
|
||||
const result = new Map<L, W>();
|
||||
for (const [k, v] of m) {
|
||||
const [l, w] = f(v, k);
|
||||
result.set(l, w);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function mapUpdateInto<K, V>(m: Map<K, V>, k: K, updater: (v: V | undefined) => V): Map<K, V> {
|
||||
m.set(k, updater(m.get(k)));
|
||||
return m;
|
||||
}
|
||||
|
||||
export function mapFromObject<V>(obj: { [k: string]: V }): Map<string, V> {
|
||||
const result = new Map<string, V>();
|
||||
for (const k of Object.getOwnPropertyNames(obj)) {
|
||||
result.set(k, obj[k]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function mapFromIterable<K, V>(it: Iterable<K>, valueForKey: (k: K) => V): Map<K, V> {
|
||||
const result = new Map<K, V>();
|
||||
for (const k of it) {
|
||||
result.set(k, valueForKey(k));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function mapFind<K, V>(it: Iterable<[K, V]>, p: (v: V, k: K) => boolean): V | undefined {
|
||||
for (const [k, v] of it) {
|
||||
if (p(v, k)) {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function mapTranspose<K, V>(maps: ReadonlyMap<K, V>[]): Map<K, V[]> {
|
||||
const result = new Map<K, V[]>();
|
||||
for (const m of maps) {
|
||||
for (const [k, v] of m) {
|
||||
let arr = result.get(k);
|
||||
if (arr === undefined) {
|
||||
arr = [];
|
||||
result.set(k, arr);
|
||||
}
|
||||
arr.push(v);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function mapMapSync<K, V, W>(m: Iterable<[K, V]>, f: (v: V, k: K) => Promise<W>): Promise<Map<K, W>> {
|
||||
const result = new Map<K, W>();
|
||||
for (const [k, v] of m) {
|
||||
result.set(k, await f(v, k));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function setUnionManyInto<T>(dest: Set<T>, srcs: Iterable<Iterable<T>>): Set<T> {
|
||||
for (const src of srcs) {
|
||||
for (const v of src) {
|
||||
dest.add(v);
|
||||
}
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
export function setUnionInto<T>(dest: Set<T>, ...srcs: Iterable<T>[]): Set<T> {
|
||||
return setUnionManyInto(dest, srcs);
|
||||
}
|
||||
|
||||
export function setIntersect<T>(s1: Iterable<T>, s2: ReadonlySet<T>): Set<T> {
|
||||
const result = new Set();
|
||||
for (const v of s1) {
|
||||
if (s2.has(v)) {
|
||||
result.add(v);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function setSubtract<T>(src: Iterable<T>, diff: Iterable<T>): Set<T> {
|
||||
const result = new Set(src);
|
||||
for (const v of diff) {
|
||||
result.delete(v);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function setUnion<T>(...sets: Iterable<T>[]): Set<T> {
|
||||
const result = new Set<T>();
|
||||
setUnionInto(result, ...sets);
|
||||
return result;
|
||||
}
|
||||
|
||||
export function setMap<T, U>(set: Iterable<T>, f: (v: T) => U): Set<U> {
|
||||
const result = new Set<U>();
|
||||
for (const v of set) {
|
||||
result.add(f(v));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function setFilter<T>(set: Iterable<T>, p: (v: T) => boolean): Set<T> {
|
||||
const result = new Set<T>();
|
||||
for (const v of set) {
|
||||
if (p(v)) {
|
||||
result.add(v);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function setFilterMap<T, U>(set: Iterable<T>, f: (v: T) => U | undefined): Set<U> {
|
||||
const result = new Set<U>();
|
||||
for (const v of set) {
|
||||
const u = f(v);
|
||||
if (u !== undefined) {
|
||||
result.add(u);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function setSortBy<T>(it: Iterable<T>, sortKey: (v: T) => number | string): Set<T> {
|
||||
const arr = Array.from(it);
|
||||
arr.sort((a, b) => compareKeys(sortKey(a), sortKey(b)));
|
||||
return new Set(arr);
|
||||
}
|
||||
|
||||
export function setGroupBy<T, G>(it: Iterable<T>, grouper: (v: T) => G): Map<G, Set<T>> {
|
||||
const result = new Map<G, Set<T>>();
|
||||
for (const v of it) {
|
||||
const g = grouper(v);
|
||||
let group = result.get(g);
|
||||
if (group === undefined) {
|
||||
group = new Set();
|
||||
result.set(g, group);
|
||||
}
|
||||
group.add(v);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function toReadonlySet<T>(it: Iterable<T>): ReadonlySet<T> {
|
||||
if (it instanceof Set) return it;
|
||||
return new Set(it);
|
||||
}
|
||||
|
||||
export class EqualityMap<K, V> {
|
||||
private readonly _map = new Map<number, [K, V]>();
|
||||
|
||||
set(k: K, v: V): void {
|
||||
let h = hashCodeOf(k) | 0;
|
||||
for (;;) {
|
||||
const kvp = this._map.get(h);
|
||||
if (kvp === undefined) {
|
||||
this._map.set(h, [k, v]);
|
||||
return;
|
||||
}
|
||||
if (areEqual(k, kvp[0])) {
|
||||
kvp[1] = v;
|
||||
return;
|
||||
}
|
||||
h = (h + 1) | 0;
|
||||
}
|
||||
}
|
||||
|
||||
get(k: K): V | undefined {
|
||||
let h = hashCodeOf(k) | 0;
|
||||
for (;;) {
|
||||
const kvp = this._map.get(h);
|
||||
if (kvp === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
if (areEqual(k, kvp[0])) {
|
||||
return kvp[1];
|
||||
}
|
||||
h = (h + 1) | 0;
|
||||
}
|
||||
}
|
||||
|
||||
has(k: K): boolean {
|
||||
return this.get(k) !== undefined;
|
||||
}
|
||||
|
||||
*values(): IterableIterator<V> {
|
||||
for (const [_h, [_k, v]] of this._map) {
|
||||
yield v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function areEqual(a: any, b: any): boolean {
|
||||
if (a === b) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (typeof a.equals === "function" && typeof b.equals === "function") {
|
||||
return a.equals(b);
|
||||
}
|
||||
|
||||
if (a instanceof Set && b instanceof Set) {
|
||||
if (a.size !== b.size) return false;
|
||||
|
||||
for (const x of a) {
|
||||
if (!b.has(x)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (a instanceof Map && b instanceof Map) {
|
||||
if (a.size !== b.size) return false;
|
||||
|
||||
for (const [k, v] of a) {
|
||||
const w = b.get(k);
|
||||
if (!areEqual(v, w)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Array.isArray(a) && Array.isArray(b)) {
|
||||
const n = a.length;
|
||||
if (n !== b.length) return false;
|
||||
|
||||
for (let i = 0; i < n; i++) {
|
||||
if (!areEqual(a[i], b[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export function hashCodeOf(x: any): number {
|
||||
if (typeof x === "number") return x | 0;
|
||||
if (typeof x === "string") return stringHash(x);
|
||||
|
||||
let h = hashCodeInit;
|
||||
|
||||
if (x === undefined) return h;
|
||||
if (x === true) return (h + 1) | 0;
|
||||
if (x === false) return (h + 2) | 0;
|
||||
|
||||
if (typeof x.hashCode === "function") return x.hashCode();
|
||||
|
||||
if (x instanceof Set) {
|
||||
for (const y of x) {
|
||||
h += hashCodeOf(y);
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
if (x instanceof Map) {
|
||||
let g = hashCodeInit;
|
||||
for (const [k, v] of x) {
|
||||
g += hashCodeOf(k);
|
||||
h += hashCodeOf(v);
|
||||
}
|
||||
return addHashCode(g, h);
|
||||
}
|
||||
|
||||
if (Array.isArray(x)) {
|
||||
for (const y of x) {
|
||||
h = addHashCode(h, hashCodeOf(y));
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
return panic(`Cannot hash ${x}`);
|
||||
}
|
|
@ -6,10 +6,6 @@ import { messageError } from "../Messages";
|
|||
|
||||
const stringToStream = require("string-to-stream");
|
||||
|
||||
export function hasOwnProperty(obj: object, name: string): boolean {
|
||||
return Object.prototype.hasOwnProperty.call(obj, name);
|
||||
}
|
||||
|
||||
export function findInArray<T>(arr: T[], p: (t: T) => boolean): T | undefined {
|
||||
for (const t of arr) {
|
||||
if (p(t)) return t;
|
||||
|
@ -59,11 +55,6 @@ export function checkArray<T>(x: any, checkItem?: (v: any) => v is T): T[] {
|
|||
return x;
|
||||
}
|
||||
|
||||
export function mapOptional<T, U>(f: (x: T) => U, x: T | undefined): U | undefined {
|
||||
if (x === undefined) return undefined;
|
||||
return f(x);
|
||||
}
|
||||
|
||||
export function defined<T>(x: T | undefined): T {
|
||||
if (x !== undefined) return x;
|
||||
return panic("Defined value expected, but got undefined");
|
||||
|
|
|
@ -10,6 +10,7 @@ import {
|
|||
FieldNode
|
||||
} from "graphql/language/ast";
|
||||
import * as graphql from "graphql/language";
|
||||
import { setMap, iterableFirst, mapFromObject } from "collection-utils";
|
||||
|
||||
import {
|
||||
UnionType,
|
||||
|
@ -29,9 +30,6 @@ import {
|
|||
emptyTypeAttributes,
|
||||
StringTypes,
|
||||
Input,
|
||||
setMap,
|
||||
iterableFirst,
|
||||
mapFromObject,
|
||||
derefTypeRef
|
||||
} from "../quicktype-core";
|
||||
|
||||
|
@ -443,6 +441,10 @@ function makeGraphQLQueryTypes(
|
|||
return panic(`Duplicate query name ${queryName}`);
|
||||
}
|
||||
const dataType = query.makeType(builder, odn, queryName);
|
||||
const dataOrNullType = builder.getUnionType(
|
||||
emptyTypeAttributes,
|
||||
new Set([dataType, builder.getPrimitiveType("null")])
|
||||
);
|
||||
const errorType = builder.getClassType(
|
||||
namesTypeAttributeKind.makeAttributes(TypeNames.make(new Set(["error"]), new Set(["graphQLError"]), false)),
|
||||
mapFromObject({
|
||||
|
@ -462,7 +464,7 @@ function makeGraphQLQueryTypes(
|
|||
const t = builder.getClassType(
|
||||
makeNamesTypeAttributes(queryName, false),
|
||||
mapFromObject({
|
||||
data: builder.makeClassProperty(dataType, false),
|
||||
data: builder.makeClassProperty(dataOrNullType, false),
|
||||
errors: builder.makeClassProperty(errorArray, true)
|
||||
})
|
||||
);
|
||||
|
|
Загрузка…
Ссылка в новой задаче