Comparing version 1.0.25 to 1.0.26
@@ -37,2 +37,3 @@ /** | ||
findParagraphsWithCnkUsingGET(cnk: number, language: string): Promise<Array<models.ParagraphPreview> | any>; | ||
getAddedDocumentUsingGET(chapterName: string, paragraphName: string, verseSeq: number, docSeq: number, language: string): Promise<any | Boolean>; | ||
getAddedDocumentsUsingGET(chapterName: string, paragraphName: string): Promise<Array<models.AddedDocumentPreview> | any>; | ||
@@ -39,0 +40,0 @@ getMppsForParagraphUsingGET(chapterName: string, paragraphName: string): Promise<Array<models.MppPreview> | any>; |
@@ -155,2 +155,21 @@ /** | ||
} | ||
getAddedDocumentUsingGET(chapterName, paragraphName, verseSeq, docSeq, language) { | ||
let _body = null; | ||
const _url = this.host + | ||
"/chap4/sam/docpreview/{chapterName}/{paragraphName}/{verseSeq}/{docSeq}/{language}" | ||
.replace("{chapterName}", chapterName + "") | ||
.replace("{paragraphName}", paragraphName + "") | ||
.replace("{verseSeq}", verseSeq + "") | ||
.replace("{docSeq}", docSeq + "") | ||
.replace("{language}", language + "") + | ||
"?ts=" + | ||
new Date().getTime(); | ||
let headers = this.headers; | ||
headers = headers | ||
.filter(h => h.header !== "Content-Type") | ||
.concat(new XHR.Header("Content-Type", "application/json")); | ||
return XHR.sendCommand("GET", _url, headers, _body) | ||
.then(doc => (doc.contentType.startsWith("application/octet-stream") ? doc.body : true)) | ||
.catch(err => this.handleError(err)); | ||
} | ||
getAddedDocumentsUsingGET(chapterName, paragraphName) { | ||
@@ -157,0 +176,0 @@ let _body = null; |
@@ -8,13 +8,8 @@ export declare namespace XHR { | ||
class Data { | ||
headers: Array<Header> | string; | ||
body: JSON | Array<JSON> | any; | ||
text: string; | ||
type: string; | ||
status: number; | ||
statusText: string; | ||
contentType: string; | ||
documentContent: Document | null; | ||
constructor(jsXHR: XMLHttpRequest); | ||
body: JSON | Array<JSON> | any; | ||
constructor(status: number, contentType: string, body: JSON | Array<JSON> | any); | ||
} | ||
function sendCommand(method: string, url: string, headers: Array<Header> | null, data?: string | any): Promise<Data>; | ||
} |
@@ -11,93 +11,39 @@ export var XHR; | ||
class Data { | ||
constructor(jsXHR) { | ||
this.headers = jsXHR | ||
.getAllResponseHeaders() | ||
.split("\n") | ||
.map(h => h.split(": ")) | ||
.map(head => new Header(head[0], head[1])); | ||
this.contentType = ""; | ||
this.headers.map(head => { | ||
if (head.header && head.header.toLowerCase() === "content-type") { | ||
this.contentType = head.data && head.data.toLowerCase(); | ||
if (head.data.startsWith("application/json")) { | ||
this.body = JSON.parse(jsXHR.response); | ||
} | ||
else if (head.data.startsWith("application/octet-stream")) { | ||
try { | ||
this.body = JSON.parse(jsXHR.response.toString()); | ||
console.log("parse done"); | ||
} | ||
catch (e) { | ||
console.log("parse fail"); | ||
this.body = jsXHR.response; //todo, somethings else | ||
} | ||
} | ||
else { | ||
this.body = jsXHR.response; //"text/plain" | ||
} | ||
} | ||
}); | ||
this.documentContent = jsXHR.responseXML; | ||
this.text = jsXHR.responseText; | ||
this.type = jsXHR.responseType; | ||
this.status = jsXHR.status; | ||
this.statusText = jsXHR.statusText; | ||
constructor(status, contentType, body) { | ||
this.status = status; | ||
this.contentType = contentType; | ||
this.body = body; | ||
} | ||
} | ||
XHR.Data = Data; | ||
function dataFromJSXHR(jsXHR) { | ||
return new Data(jsXHR); | ||
} | ||
function sendCommand(method, url, headers, data = "") { | ||
return new Promise(function (resolve, reject) { | ||
var jsXHR = new XMLHttpRequest(); | ||
jsXHR.open(method, url); | ||
const contentType = headers && | ||
headers.find(it => (it.header ? it.header.toLowerCase() === "content-type" : false)); | ||
if (headers != null) { | ||
headers.forEach(header => { | ||
if (header.header.toLowerCase() !== "content-type" || | ||
header.data !== "multipart/form-data") { | ||
jsXHR.setRequestHeader(header.header, header.data); | ||
} | ||
}); | ||
const contentType = headers && | ||
headers.find(it => (it.header ? it.header.toLowerCase() === "content-type" : false)); | ||
return fetch(url, Object.assign({ | ||
method: method, | ||
credentials: "same-origin", | ||
headers: (headers && | ||
headers | ||
.filter(h => h.header.toLowerCase() !== "content-type" || h.data !== "multipart/form-data") | ||
.reduce((acc, h) => { | ||
acc[h.header] = h.data; | ||
return acc; | ||
}, {})) || | ||
{} | ||
}, method === "POST" || method === "PUT" | ||
? { | ||
body: (!contentType || contentType.data) === "application/json" | ||
? JSON.stringify(data) | ||
: data | ||
} | ||
jsXHR.onload = ev => { | ||
if (jsXHR.status < 200 || jsXHR.status >= 300) { | ||
reject(dataFromJSXHR(jsXHR)); | ||
} | ||
resolve(dataFromJSXHR(jsXHR)); | ||
}; | ||
jsXHR.onerror = ev => { | ||
reject("Error " + method.toUpperCase() + 'ing data to url "'); | ||
}; | ||
if (method === "POST" || method === "PUT") { | ||
if (contentType && contentType.data === "application/json") { | ||
jsXHR.send(JSON.stringify(data)); | ||
} | ||
else { | ||
jsXHR.send(data); | ||
} | ||
} | ||
else { | ||
jsXHR.send(); | ||
} | ||
: {})).then(function (response) { | ||
const ct = response.headers.get("content-type") || "text/plain"; | ||
return (ct.startsWith("application/octet-stream") | ||
? response.arrayBuffer() | ||
: ct.startsWith("application/json") | ||
? response.json() | ||
: response.text()).then(d => new Data(response.status, ct, d)); | ||
}); | ||
} | ||
XHR.sendCommand = sendCommand; | ||
/*export function get(url: string, headers: Array<Header> = null): Promise<Data> { | ||
return sendCommand('GET', url, headers); | ||
} | ||
export function post(url: string, data: string = "", headers: Array<Header> = null): Promise<Data> { | ||
return sendCommand('POST', url, headers, data); | ||
} | ||
export function put(url: string, data: string = "", headers: Array<Header> = null): Promise<Data> { | ||
return sendCommand('PUT', url, headers, data); | ||
} | ||
export function del(url:string, headers:Array<Header> = null):Promise < Data > { | ||
return sendCommand('DELETE', url, headers); | ||
}*/ | ||
})(XHR || (XHR = {})); |
@@ -29,3 +29,5 @@ /** | ||
attest?: models.Eattest; | ||
commonOutput?: models.CommonOutput; | ||
invoicingNumber?: string; | ||
mycarenetConversation?: models.MycarenetConversation; | ||
} |
@@ -31,4 +31,5 @@ /** | ||
invoicingNumber?: string; | ||
kmehrMessage?: Array<string>; | ||
mycarenetConversation?: models.MycarenetConversation; | ||
xades?: Array<string>; | ||
} |
{ | ||
"name": "fhc-api", | ||
"version": "1.0.25", | ||
"version": "1.0.26", | ||
"description": "Typescript version of Freehealth Connector standalone API client", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
444323
11765
1