wsdl-to-ts
Advanced tools
Comparing version 0.1.3 to 0.2.0
@@ -8,2 +8,3 @@ #!/usr/bin/env node | ||
const wsdl_to_ts_1 = require("./wsdl-to-ts"); | ||
const opts = {}; | ||
const config = { outdir: "./wsdl", files: [], tslintDisable: ["max-line-length"], tslintEnable: [] }; | ||
@@ -38,2 +39,10 @@ const args = minimist(process.argv.slice(2)); | ||
} | ||
if (args.hasOwnProperty("quote")) { | ||
if (args.quote === "false" || args.quote === "disable" || args.quote === "0") { | ||
opts.quoteProperties = false; | ||
} | ||
else if (args.quote === "true" || args.quote === "1" || !args.quote) { | ||
opts.quoteProperties = true; | ||
} | ||
} | ||
if (args._) { | ||
@@ -59,3 +68,3 @@ config.files.push.apply(config.files, args._); | ||
} | ||
Promise.all(config.files.map(wsdl_to_ts_1.wsdl2ts)). | ||
Promise.all(config.files.map((a) => wsdl_to_ts_1.wsdl2ts(a, opts))). | ||
then((xs) => wsdl_to_ts_1.mergeTypedWsdl.apply(undefined, xs)). | ||
@@ -68,3 +77,3 @@ then(wsdl_to_ts_1.outputTypedWsdl). | ||
const file = config.outdir + "/" + x.file; | ||
const dir = file.replace(/\/[^\/]+$/, ""); | ||
const dir = file.replace(/\/[^/]+$/, ""); | ||
return mkdirpp(dir).then(() => { | ||
@@ -102,3 +111,3 @@ return new Promise((resolve, reject) => { | ||
return new Promise((resolve, reject) => { | ||
const realFile = file.replace(/\.[^\.]+$/, ""); | ||
const realFile = file.replace(/\.[^.]+$/, ""); | ||
fs_1.rename(file, realFile, (err) => { | ||
@@ -105,0 +114,0 @@ if (err) { |
@@ -51,3 +51,3 @@ "use strict"; | ||
if (isArray) { | ||
if (/^[A-Za-z0-9\.]+$/.test(typeClass)) { | ||
if (/^[A-Za-z0-9.]+$/.test(typeClass)) { | ||
typeClass += "[]"; | ||
@@ -86,3 +86,3 @@ } | ||
s = s.trim().replace(/;$/, ""); | ||
if (/^[A-Za-z0-9\.]+$/.test(s)) { | ||
if (/^[A-Za-z0-9.]+$/.test(s)) { | ||
s += "[];"; | ||
@@ -119,6 +119,10 @@ } | ||
} | ||
function wsdlTypeToInterfaceString(d) { | ||
function wsdlTypeToInterfaceString(d, opts = {}) { | ||
const r = []; | ||
for (const k of Object.keys(d)) { | ||
const t = typeof d[k]; | ||
let p = k; | ||
if (opts.quoteProperties || (opts.quoteProperties === undefined && !/^[A-Za-z][A-Za-z0-9_-]*$/.test(k))) { | ||
p = JSON.stringify(k); | ||
} | ||
if (t === "string") { | ||
@@ -129,10 +133,18 @@ const v = d[k]; | ||
r.push(v.substring(0, i)); | ||
r.push(k + ": " + v.substring(i).trim()); | ||
// for types like "xsd:string" only the "string" part is used | ||
const rawtype = v.substring(i).trim(); | ||
const colon = rawtype.indexOf(":"); | ||
if (colon !== -1) { | ||
r.push(p + ": " + rawtype.substring(colon + 1)); | ||
} | ||
else { | ||
r.push(p + ": " + rawtype); | ||
} | ||
} | ||
else { | ||
r.push(k + ": " + v); | ||
r.push(p + ": " + v); | ||
} | ||
} | ||
else { | ||
r.push(k + ": " + wsdlTypeToInterfaceString(d[k]).replace(/\n/g, "\n ") + ";"); | ||
r.push(p + ": " + wsdlTypeToInterfaceString(d[k], opts).replace(/\n/g, "\n ") + ";"); | ||
} | ||
@@ -145,6 +157,6 @@ } | ||
} | ||
function wsdlTypeToInterface(obj, typeCollector) { | ||
return wsdlTypeToInterfaceString(wsdlTypeToInterfaceObj(obj, typeCollector)); | ||
function wsdlTypeToInterface(obj, typeCollector, opts) { | ||
return wsdlTypeToInterfaceString(wsdlTypeToInterfaceObj(obj, typeCollector), opts); | ||
} | ||
function wsdl2ts(wsdlUri) { | ||
function wsdl2ts(wsdlUri, opts) { | ||
return new Promise((resolve, reject) => { | ||
@@ -187,4 +199,4 @@ soap.createClient(wsdlUri, {}, (err, client) => { | ||
// console.log("---- %s", method); | ||
wsdlTypeToInterface(d[service][port][method].input || {}, collector); | ||
wsdlTypeToInterface(d[service][port][method].output || {}, collector); | ||
wsdlTypeToInterface(d[service][port][method].input || {}, collector, opts); | ||
wsdlTypeToInterface(d[service][port][method].output || {}, collector, opts); | ||
} | ||
@@ -220,5 +232,5 @@ const reg = cloneObj(collector.registered); | ||
r.types[service][port]["I" + method + "Input"] = | ||
wsdlTypeToInterface(d[service][port][method].input || {}, collector); | ||
wsdlTypeToInterface(d[service][port][method].input || {}, collector, opts); | ||
r.types[service][port]["I" + method + "Output"] = | ||
wsdlTypeToInterface(d[service][port][method].output || {}, collector); | ||
wsdlTypeToInterface(d[service][port][method].output || {}, collector, opts); | ||
r.methods[service][port][method] = | ||
@@ -225,0 +237,0 @@ "(input: I" + method + "Input, " + |
{ | ||
"name": "wsdl-to-ts", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"description": "Build TypeScript typings for SOAP WSDL", | ||
"main": "lib/wsdl-to-ts.js", | ||
"module": "esm/wsdl-to-ts.js", | ||
"types": "esm/wsdl-to-ts.d.ts", | ||
"scripts": { | ||
"test": "node test/index.js", | ||
"build": "tsc -p tsconfig.json && npm test" | ||
"build": "tsc -p tsconfig.json && tsc -p tsconfig.json -d --outDir esm --module es2015 --target es2016 && npm test" | ||
}, | ||
@@ -13,3 +15,6 @@ "bin": { | ||
}, | ||
"keywords": ["soap", "typescript"], | ||
"keywords": [ | ||
"soap", | ||
"typescript" | ||
], | ||
"author": { | ||
@@ -21,6 +26,7 @@ "name": "TimLuq", | ||
"devDependencies": { | ||
"@types/bluebird": "^3.5.23", | ||
"@types/minimist": "^1.2.0", | ||
"@types/mkdirp": "^0.3.29", | ||
"@types/node": "*", | ||
"@types/soap": "*", | ||
"tslint": "^5.11.0", | ||
"typescript": "^2.2.0" | ||
@@ -31,3 +37,3 @@ }, | ||
"mkdirp": "^0.5.1", | ||
"soap": "^0.19.1" | ||
"soap": "^0.21.0" | ||
}, | ||
@@ -38,5 +44,5 @@ "bugs": { | ||
"repository": { | ||
"type" : "git", | ||
"url" : "https://github.com/TimLuq/wsdl-to-ts.git" | ||
"type": "git", | ||
"url": "https://github.com/TimLuq/wsdl-to-ts.git" | ||
} | ||
} |
# wsdl-to-ts | ||
<a href="https://travis-ci.org/TimLuq/wsdl-to-ts"> | ||
<img src="https://api.travis-ci.org/TimLuq/wsdl-to-ts.svg?branch=master" | ||
alt="build status" /> | ||
</a> | ||
<a href="https://www.npmjs.com/package/wsdl-to-ts"> | ||
<img src="https://img.shields.io/npm/v/wsdl-to-ts.svg" | ||
alt="npm version" /> | ||
</a> | ||
<a href="https://github.com/TimLuq/wsdl-to-ts/blob/master/LICENSE.md"> | ||
<img src="https://img.shields.io/npm/l/wsdl-to-ts.svg" | ||
alt="license" /> | ||
</a> | ||
<a href="https://david-dm.org/TimLuq/wsdl-to-ts"> | ||
<img src="https://david-dm.org/TimLuq/wsdl-to-ts/status.svg" | ||
alt="dependency status" /> | ||
</a> | ||
A CLI tool and library for nodejs to generate TypeScript typings from a WSDL service. | ||
## Installation | ||
Installation is done through [npm](https://npmjs.com). | ||
Installation is done either through [npm](https://npmjs.com) or [yarn](https://yarnpkg.com). | ||
### Installation for Command Line usage | ||
To install CLI tool globally run the following command as root or sudo: | ||
To install CLI tool globally run one of the following command as root or sudo: | ||
```sh | ||
$ npm install -g wsdl-to-ts | ||
$ yarn global add wsdl-to-ts | ||
``` | ||
To install CLI tool for the current user this command may be used (which places working directory at users `$HOME`): | ||
To install CLI tool for the current user one of these commands may be used (which places working directory at users `$HOME`): | ||
```sh | ||
$ cd && npm install wsdl-to-ts | ||
$ cd && yarn add wsdl-to-ts | ||
``` | ||
@@ -21,5 +41,6 @@ | ||
To install a library as a dependency to your current npm project you enter your project directory as the current directory and run the following commands: | ||
To install a library as a dependency to your current npm project you enter your project directory as the current directory and run one of the following commands: | ||
```sh | ||
$ npm install --save wsdl-to-ts | ||
$ yarn add wsdl-to-ts | ||
``` | ||
@@ -29,3 +50,3 @@ | ||
If any more documentation is needed for library usage, other than the IDE completions; feel free to open an [issue](https://github.com/TimLuq/wsdl-to-ts/issues). | ||
If any more documentation is needed for library usage, other than the IDE completions; feel free to open an [issue](https://github.com/TimLuq/wsdl-to-ts/issues). Also take a look at the [type definitions](https://github.com/TimLuq/wsdl-to-ts/blob/master/esm/wsdl-to-ts.d.ts) | ||
@@ -32,0 +53,0 @@ ### Usage for Command Line |
#!/usr/bin/env node | ||
"use strict"; | ||
@@ -6,3 +7,3 @@ import { rename, writeFile } from "fs"; | ||
import * as mkdirp from "mkdirp"; | ||
import { ITypedWsdl, mergeTypedWsdl, outputTypedWsdl, wsdl2ts } from "./wsdl-to-ts"; | ||
import { IInterfaceOptions, ITypedWsdl, mergeTypedWsdl, outputTypedWsdl, wsdl2ts } from "./wsdl-to-ts"; | ||
@@ -16,2 +17,3 @@ interface IConfigObject { | ||
const opts: IInterfaceOptions = {}; | ||
const config: IConfigObject = { outdir: "./wsdl", files: [], tslintDisable: ["max-line-length"], tslintEnable: [] }; | ||
@@ -51,2 +53,10 @@ | ||
if (args.hasOwnProperty("quote")) { | ||
if (args.quote === "false" || args.quote === "disable" || args.quote === "0") { | ||
opts.quoteProperties = false; | ||
} else if (args.quote === "true" || args.quote === "1" || !args.quote) { | ||
opts.quoteProperties = true; | ||
} | ||
} | ||
if (args._) { | ||
@@ -74,3 +84,3 @@ config.files.push.apply(config.files, args._); | ||
Promise.all(config.files.map(wsdl2ts)). | ||
Promise.all(config.files.map((a) => wsdl2ts(a, opts))). | ||
then((xs) => mergeTypedWsdl.apply(undefined, xs)). | ||
@@ -83,3 +93,3 @@ then(outputTypedWsdl). | ||
const file = config.outdir + "/" + x.file; | ||
const dir = file.replace(/\/[^\/]+$/, ""); | ||
const dir = file.replace(/\/[^/]+$/, ""); | ||
return mkdirpp(dir).then(() => { | ||
@@ -115,3 +125,3 @@ return new Promise((resolve, reject) => { | ||
return new Promise((resolve, reject) => { | ||
const realFile = file.replace(/\.[^\.]+$/, ""); | ||
const realFile = file.replace(/\.[^.]+$/, ""); | ||
rename(file, realFile, (err) => { | ||
@@ -118,0 +128,0 @@ if (err) { |
@@ -14,2 +14,6 @@ import * as soap from "soap"; | ||
export interface IInterfaceOptions { | ||
quoteProperties?: boolean; | ||
} | ||
export interface ITypedWsdl { | ||
@@ -72,3 +76,3 @@ client: soap.Client | null; | ||
if (isArray) { | ||
if (/^[A-Za-z0-9\.]+$/.test(typeClass)) { | ||
if (/^[A-Za-z0-9.]+$/.test(typeClass)) { | ||
typeClass += "[]"; | ||
@@ -103,3 +107,3 @@ } else { | ||
s = s.trim().replace(/;$/, ""); | ||
if (/^[A-Za-z0-9\.]+$/.test(s)) { | ||
if (/^[A-Za-z0-9.]+$/.test(s)) { | ||
s += "[];"; | ||
@@ -134,6 +138,10 @@ } else { | ||
function wsdlTypeToInterfaceString(d: { [k: string]: any }): string { | ||
function wsdlTypeToInterfaceString(d: { [k: string]: any }, opts: IInterfaceOptions = {}): string { | ||
const r: string[] = []; | ||
for (const k of Object.keys(d)) { | ||
const t = typeof d[k]; | ||
let p: string = k; | ||
if (opts.quoteProperties || (opts.quoteProperties === undefined && !/^[A-Za-z][A-Za-z0-9_-]*$/.test(k))) { | ||
p = JSON.stringify(k); | ||
} | ||
if (t === "string") { | ||
@@ -144,8 +152,16 @@ const v = d[k]; | ||
r.push(v.substring(0, i)); | ||
r.push(k + ": " + v.substring(i).trim()); | ||
// for types like "xsd:string" only the "string" part is used | ||
const rawtype = v.substring(i).trim(); | ||
const colon = rawtype.indexOf(":"); | ||
if (colon !== -1) { | ||
r.push(p + ": " + rawtype.substring(colon + 1)); | ||
} else { | ||
r.push(p + ": " + rawtype); | ||
} | ||
} else { | ||
r.push(k + ": " + v); | ||
r.push(p + ": " + v); | ||
} | ||
} else { | ||
r.push(k + ": " + wsdlTypeToInterfaceString(d[k]).replace(/\n/g, "\n ") + ";"); | ||
r.push(p + ": " + wsdlTypeToInterfaceString(d[k], opts).replace(/\n/g, "\n ") + ";"); | ||
} | ||
@@ -159,7 +175,7 @@ } | ||
function wsdlTypeToInterface(obj: { [k: string]: any }, typeCollector?: TypeCollector): string { | ||
return wsdlTypeToInterfaceString(wsdlTypeToInterfaceObj(obj, typeCollector)); | ||
function wsdlTypeToInterface(obj: { [k: string]: any }, typeCollector?: TypeCollector, opts?: IInterfaceOptions): string { | ||
return wsdlTypeToInterfaceString(wsdlTypeToInterfaceObj(obj, typeCollector), opts); | ||
} | ||
export function wsdl2ts(wsdlUri: string): Promise<ITypedWsdl> { | ||
export function wsdl2ts(wsdlUri: string, opts?: IInterfaceOptions): Promise<ITypedWsdl> { | ||
return new Promise<soap.Client>((resolve, reject) => { | ||
@@ -205,4 +221,4 @@ soap.createClient(wsdlUri, {}, (err, client) => { | ||
wsdlTypeToInterface(d[service][port][method].input || {}, collector); | ||
wsdlTypeToInterface(d[service][port][method].output || {}, collector); | ||
wsdlTypeToInterface(d[service][port][method].input || {}, collector, opts); | ||
wsdlTypeToInterface(d[service][port][method].output || {}, collector, opts); | ||
} | ||
@@ -242,5 +258,5 @@ | ||
r.types[service][port]["I" + method + "Input"] = | ||
wsdlTypeToInterface(d[service][port][method].input || {}, collector); | ||
wsdlTypeToInterface(d[service][port][method].input || {}, collector, opts); | ||
r.types[service][port]["I" + method + "Output"] = | ||
wsdlTypeToInterface(d[service][port][method].output || {}, collector); | ||
wsdlTypeToInterface(d[service][port][method].output || {}, collector, opts); | ||
r.methods[service][port][method] = | ||
@@ -247,0 +263,0 @@ "(input: I" + method + "Input, " + |
const { wsdl2ts, mergeTypedWsdl, outputTypedWsdl } = require("../lib/wsdl-to-ts"); | ||
/** @type {Array.<{0: string; 1: Promise.<string>}>} */ | ||
const testResults = []; | ||
// test simple case; disregard result | ||
const wsdl = "https://www2.agenciatributaria.gob.es" + | ||
@@ -9,12 +13,261 @@ "/static_files/common/internet/dep/aplicaciones/es/aeat/ssii/fact/ws/"; | ||
Promise.all([ | ||
wsdl2ts(sentWsdl), | ||
wsdl2ts(rcvdWsdl), | ||
]). | ||
testResults.push(["simple", Promise.all([ | ||
wsdl2ts(sentWsdl), | ||
wsdl2ts(rcvdWsdl), | ||
]). | ||
then((xs) => mergeTypedWsdl.apply(undefined, xs)). | ||
then(outputTypedWsdl). | ||
then((xs) => xs.forEach((x) => { | ||
console.log("-- %s --", x.file); | ||
console.log("%s", x.data.join("\n\n")); | ||
})). | ||
catch(console.error); | ||
then(() => "OK") | ||
]); | ||
// test cases that need key excaping; write to files | ||
const sii11 = "https://www.agenciatributaria.es" + | ||
"/static_files/AEAT/Contenidos_Comunes/La_Agencia_Tributaria/Modelos_y_formularios/" + | ||
"Suministro_inmediato_informacion/FicherosSuministros/V_1_1/"; | ||
const sii11Sent = sii11 + "SuministroFactEmitidas.wsdl"; | ||
const sii11Rcvd = sii11 + "SuministroFactRecibidas.wsdl"; | ||
const { readdir, readFile, unlink, writeFile, stat } = require("fs"); | ||
const mkdirp = require("mkdirp"); | ||
/** | ||
* @param {string} dir | ||
* @returns {Promise.<string>} | ||
*/ | ||
function mkdirpP(dir) { | ||
return new Promise((resolve, reject) => { | ||
mkdirp(dir, (err, made) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(made); | ||
} | ||
}); | ||
}); | ||
} | ||
/** | ||
* @param {string} dir | ||
* @returns {Promise.<string[]>} | ||
*/ | ||
function readdirP(dir) { | ||
return new Promise((resolve, reject) => { | ||
readdir(dir, "utf8", (err, files) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(files); | ||
} | ||
}); | ||
}); | ||
} | ||
/** | ||
* @param {string} path | ||
* @returns {Promise.<object>} | ||
*/ | ||
function statP(path) { | ||
return new Promise((resolve, reject) => { | ||
stat(path, (err, stats) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(stats); | ||
} | ||
}); | ||
}); | ||
} | ||
/** | ||
* @param {string} file | ||
* @returns {Promise.<void>} | ||
*/ | ||
function rmfileP(file) { | ||
return new Promise((resolve, reject) => { | ||
unlink(file, (err) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
} | ||
/** | ||
* @param {string} file | ||
* @param {string} data | ||
* @returns {Promise.<void>} | ||
*/ | ||
function writefileP(file, data) { | ||
return new Promise((resolve, reject) => { | ||
writeFile(file, data, "utf8", (err) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
} | ||
/** | ||
* @param {string} file | ||
* @returns {Promise.<string>} | ||
*/ | ||
function readfileP(file) { | ||
return new Promise((resolve, reject) => { | ||
readFile(file, "utf8", (err, data) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(data); | ||
} | ||
}); | ||
}); | ||
} | ||
/** | ||
* @param {string} dir | ||
* @returns {Promise.<string[]>} | ||
*/ | ||
function requrfile(dir) { | ||
return readdirP(dir).then((files) => Promise.all(files.map((sf) => { | ||
const f = dir + "/" + sf; | ||
return statP(f).then((s) => { | ||
if (!s.isDirectory()) { | ||
return [f]; | ||
} else { | ||
return requrfile(f); | ||
} | ||
}); | ||
}))).then((fcoll) => { | ||
/** @type {string[]} */ | ||
const r = []; | ||
for (let i = 0; i < fcoll.length; i++) { | ||
r.push.apply(r, fcoll[i]); | ||
} | ||
return r; | ||
}); | ||
} | ||
/** | ||
* @param {string} dir | ||
* @param {RegExp} pattern | ||
* @returns {Promise.<void>} | ||
*/ | ||
function cleandir(dir, pattern) { | ||
return requrfile(dir).then((files) => { | ||
const fs = files.filter((f) => pattern.test(f)); | ||
if (fs.length) { | ||
return Promise.all(fs.map((f) => rmfileP(f))).then(() => undefined); | ||
} | ||
}); | ||
} | ||
testResults.push(["complex", Promise.all([ | ||
wsdl2ts(sii11Sent, { quoteProperties: true }), | ||
wsdl2ts(sii11Rcvd), | ||
]). | ||
then((xs) => mergeTypedWsdl.apply(undefined, xs)). | ||
then(outputTypedWsdl). | ||
then((xs) => mkdirpP("test/results"). | ||
then(() => cleandir("test/results", /\.ts$/)). | ||
then(() => Promise.all(xs.map((x) => { | ||
const f = "test/results/" + x.file + ".d.ts"; | ||
return mkdirpP(f.replace(/\/[^/]+$/, "")). | ||
then(() => writefileP(f, x.data.join("\n\n"))); | ||
}))) | ||
). | ||
then(() => "OK") | ||
]); | ||
// test values in package.json | ||
const package = require("../package.json"); | ||
testResults.push(["valid main", !package.main ? Promise.reject("No main field in package.json") : | ||
readfileP(package.main).then(() => { | ||
if (!/^(?:.*\/)*lib\//.test(package.main)) { | ||
throw "Expected main js to be in a folder named `lib` but found: " + JSON.stringify(package.main); | ||
} | ||
if (!/\.js$/.test(package.main)) { | ||
throw "Expected main file to have file extension `.js` but found: " + JSON.stringify(package.main); | ||
} | ||
return "OK"; | ||
}) | ||
]); | ||
testResults.push(["valid bin", !package.bin ? Promise.reject("No bin field in package.json") : | ||
!package.bin["wsdl-to-ts"] ? Promise.reject("No wsdl-to-ts property for the bin field in package.json") : | ||
readfileP(package.bin["wsdl-to-ts"]).then((d) => { | ||
const f3 = d.substring(0, 3); | ||
if (!/^(?:.*\/)*lib\//.test(package.bin["wsdl-to-ts"])) { | ||
throw "Expected bin js to be in a folder named `lib` but found: " + JSON.stringify(package.bin["wsdl-to-ts"]); | ||
} | ||
if (!/\.js$/.test(package.bin["wsdl-to-ts"])) { | ||
throw "Expected bin file to have file extension `.js` but found: " + JSON.stringify(package.bin["wsdl-to-ts"]); | ||
} | ||
if (f3 !== "#!/") { | ||
throw "Expected a hashbang sequence as the first tokens but found: " + JSON.stringify(f3) + " in " + package.bin["wsdl-to-ts"]; | ||
} | ||
return "OK"; | ||
}) | ||
]); | ||
testResults.push(["valid module", !package.module ? Promise.reject("No module field in package.json") : | ||
readfileP(package.module).then((d) => { | ||
if (!/^export /m.test(d)) { | ||
throw "Expected at least one export in the module"; | ||
} | ||
if (!/^(?:.*\/)*esm\//.test(package.module)) { | ||
throw "Expected module js to be in a folder named `esm` but found: " + JSON.stringify(package.module); | ||
} | ||
if (!/\.m?js$/.test(package.module)) { | ||
throw "Expected module file to have file extension `.mjs` or `.js` but found: " + JSON.stringify(package.module); | ||
} | ||
return "OK"; | ||
}) | ||
]); | ||
testResults.push(["valid types", !package.types ? Promise.reject("No types field in package.json") : | ||
readfileP(package.types).then((d) => { | ||
if (!/^export /m.test(d)) { | ||
throw "Expected at least one export in the types"; | ||
} | ||
if (!/^(?:.*\/)*esm\//.test(package.types)) { | ||
throw "Expected types source to be in a folder named `esm` but found: " + JSON.stringify(package.types); | ||
} | ||
if (!/\.d\.ts$/.test(package.types)) { | ||
throw "Expected types file to have file extension `.d.ts` but found: " + JSON.stringify(package.types); | ||
} | ||
return "OK"; | ||
}) | ||
]); | ||
// Run the imossible test | ||
const recursiveWsdl = "https://srv6.demo-attendant.advam.com/makeBooking/webservice/booking.wsdl"; | ||
testResults.push(["recursive elements", Promise.all([ | ||
wsdl2ts(recursiveWsdl), | ||
]). | ||
then((xs) => mergeTypedWsdl.apply(undefined, xs)). | ||
then(outputTypedWsdl). | ||
then(() => "OK", (e) => { | ||
if (e && e instanceof RangeError) { | ||
return "Expected error\n " + (e.stack || e); | ||
} | ||
throw e; | ||
}) | ||
]); | ||
// handle results | ||
testResults.forEach((test) => { | ||
test[1].then((r) => { | ||
console.log("Test `%s`:", test[0], r); | ||
}, (e) => { | ||
console.error("Test `%s`: FAIL\n ", test[0], e); | ||
process.exitCode = 1; | ||
}); | ||
}); |
@@ -20,4 +20,5 @@ { | ||
"node_modules", | ||
"lib" | ||
"lib", | ||
"esm" | ||
] | ||
} |
{ | ||
"defaultSeverity": "error", | ||
"defaultSeverity": "warn", | ||
"extends": [ | ||
@@ -8,10 +8,10 @@ "tslint:recommended" | ||
"rules": { | ||
"no-namespace":false, | ||
"no-console":false, | ||
"max-classes-per-file":false, | ||
"no-bitwise": false, | ||
"variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore"], | ||
"max-line-length": false | ||
"no-namespace":false, | ||
"no-console":false, | ||
"max-classes-per-file":false, | ||
"no-bitwise": false, | ||
"variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore"], | ||
"max-line-length": false | ||
}, | ||
"rulesDirectory": [] | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
107576
18
1711
77
6
3
+ Addedbluebird@3.7.2(transitive)
+ Addedfinalhandler@1.2.0(transitive)
+ Addedsoap@0.21.0(transitive)
- Removeddebug@2.2.0(transitive)
- Removedfinalhandler@0.5.1(transitive)
- Removedms@0.7.1(transitive)
- Removedon-finished@2.3.0(transitive)
- Removedsoap@0.19.2(transitive)
- Removedstatuses@1.3.1(transitive)
Updatedsoap@^0.21.0