-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from victorfernandesraton/feat/mprove-test-wit…
…h-dist-only Feat/mprove test with dist only
- Loading branch information
Showing
45 changed files
with
1,223 additions
and
7,945 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
/dist | ||
/examples | ||
tsconfig.json | ||
tsconfig.json | ||
esbuild.config.js | ||
*jest* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,4 +101,8 @@ typings/ | |
|
||
# TernJS port file | ||
.tern-port | ||
.idea | ||
.idea | ||
|
||
# ignore vscode | ||
|
||
.vscode |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
var l=class extends Error{constructor(e){super(e)}};var u=class extends l{constructor(e){super(`invalid params ${e}`)}};var s=class o{constructor(e,t,r=""){this.api=e,this.requester=t,this.baseUrl=r}overrideRequest(e){this.requester=e}static generalParse(e){return e.split("-").join("").split(".").join("")}static validateCep(e){return/[0-9]{8}/.test(e)}async execute(e){let t="";typeof e=="number"?t=e.toString():t=e;let r=o.generalParse(t);if(!o.validateCep(r))throw new u(r);return this.handler(r)}handler(e){throw new Error("Not implemented")}};var i=class{#e;constructor(e){this.#e=e}async execute(e){return await Promise.any(this.#e.map(r=>r.execute(e)))}};var p=class{async execute({url:e,body:t,headers:r,method:n,params:x}){let a=new URLSearchParams(x),y={method:n,body:t,headers:r},g=`${e}?${a.toString()}`;return fetch(g,y)}};var m=class extends s{constructor(e){super("apicep",e,"https://ws.apicep.com/cep.json")}async handler(e){let t=await this.requester.execute({url:this.baseUrl,params:{code:e}}),r=await t.json();if(!t.ok)throw new Error(...r);return{cep:r.code.replace("-",""),city:r.city,state:r.state,neighborhood:r.district??"",street:r.address}}};var h=class extends s{constructor(e){super("brasilAPI",e,"https://brasilapi.com.br/api/cep/v1")}async handler(e){let t=await this.requester.execute({url:`${this.baseUrl}/${e}`}),r=await t.json();if(!t.ok)throw new Error(r);return{...r}}};var c=class extends Error{api="";constructor(e,t){t?super(t):super(),this.api=e}};function v(o){return`<?xml version="1.0"?> | ||
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/"> <soapenv:Header /> <soapenv:Body> <cli:consultaCEP> <cep>${o}</cep> </cli:consultaCEP> </soapenv:Body></soapenv:Envelope>`}function b(o){try{let e=o.replace(/\r?\n|\r/g,"").match(/<return>(.*)<\/return>/)?.[0]??"";if(e=="")throw new c(`invalid regex got ${o}`,"correios");let r=e.replace("<return>","").replace("</return>","").split(/</).reduce((n,x)=>{let a=x.split(">");return a.length>1&&a[1].trim().length&&(n[a?.[0]]=a[1]),n},{});if(r?.cep===""||!r?.cep)throw new c("not returnd a cep to parse","correios");return{cep:r.cep??"",state:r.uf??"",city:r.cidade??"",street:r.bairro??"",neighborhood:r.end??""}}catch{throw new c("not implement xml","correios")}}var d=class extends s{constructor(e){super("correios",e,"https://apps.correios.com.br")}async handler(e){let t=await this.requester.execute({url:`${this.baseUrl}/SigepMasterJPA/AtendeClienteService/AtendeCliente`,body:v(e),method:"POST",headers:{"Content-Type":"application/xml"}}),r=await t.text();if(!t.ok)throw new Error(r);return b(r)}};var f=class extends s{static baseUrl;constructor(e){super("viacep",e,"https://viacep.com.br")}async handler(e){let t=await this.requester.execute({url:`${this.baseUrl}/ws/${e}/json`,method:"GET"}),r=await t.json();if(!t.ok)throw new Error(r);return{cep:r?.cep?.replace("-","")??"",state:r?.uf??"",city:r?.localidade??"",street:r?.logradouro??"",neighborhood:r?.bairro??""}}};function w({useDefaultProviders:o=!0,custonProviders:e=[],requester:t=new p}){let r=[];return o&&(r=[new f(t),new h(t),new m(t),new d(t)]),e?.length&&(r=[...r,...e]),t&&(r=[...r.map(n=>(n.overrideRequest(t),n))]),new i(r)}var S=o=>w({useDefaultProviders:!0}).execute(o);var Z=s;export{s as CepService,i as Provider,p as RequestWIthFetch,S as cep,w as factory,Z as service}; |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.