correios-brasil
Advanced tools
Comparing version 2.2.0 to 2.2.1
@@ -53,12 +53,6 @@ // Generated by dts-bundle-generator v5.9.0 | ||
} | ||
declare function consultarCep(cep: string): Promise<void | CepResponse>; | ||
declare function calcularPrecoPrazo(precoPrazo: PrecoPrazoRequest): Promise<void | PrecoPrazoResponse>; | ||
declare function rastrearEncomendas(codes: Array<string>): Promise<void | RastreioResponse>; | ||
declare const Correios: { | ||
consultarCep: typeof consultarCep; | ||
calcularPrecoPrazo: typeof calcularPrecoPrazo; | ||
rastrearEncomendas: typeof rastrearEncomendas; | ||
}; | ||
export default Correios; | ||
export declare function consultarCep(cep: string): Promise<void | CepResponse>; | ||
export declare function calcularPrecoPrazo(precoPrazo: PrecoPrazoRequest): Promise<void | PrecoPrazoResponse>; | ||
export declare function rastrearEncomendas(codes: Array<string>): Promise<void | RastreioResponse>; | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
import e from"node-fetch";import t from"http";import r from"https";import n from"querystring";import o from"iconv-lite";import a from"xml-js";import i from"cheerio"; | ||
import e from"node-fetch";import t from"http";import n from"https";import r from"querystring";import o from"iconv-lite";import i from"xml-js";import c from"cheerio";function a(e){var t=new RegExp(/[^0-9]|[/ /]/g,""),n=e.trim().replace(t,"");if(8!==n.length)throw Error("Cep: "+e+" inválido!");return n} | ||
/*! ***************************************************************************** | ||
@@ -15,2 +15,3 @@ Copyright (c) Microsoft Corporation. | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */var c=function(e,t){return(c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)};var u=function(){return(u=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};var f=Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]};function l(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,a=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i}function p(e){return this instanceof p?(this.v=e,this):new p(e)}var d=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};var m=Object.freeze({__proto__:null,__extends:function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}c(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)},get __assign(){return u},__rest:function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r},__decorate:function(e,t,r,n){var o,a=arguments.length,i=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,n);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(i=(a<3?o(i):a>3?o(t,r,i):o(t,r))||i);return a>3&&i&&Object.defineProperty(t,r,i),i},__param:function(e,t){return function(r,n){t(r,n,e)}},__metadata:function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},__awaiter:function(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{u(n.next(e))}catch(e){a(e)}}function c(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,c)}u((n=n.apply(e,t||[])).next())}))},__generator:function(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},__createBinding:f,__exportStar:function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||f(t,e,r)},__values:l,__read:s,__spread:function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(s(arguments[t]));return e},__spreadArrays:function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var a=arguments[t],i=0,c=a.length;i<c;i++,o++)n[o]=a[i];return n},__spreadArray:function(e,t){for(var r=0,n=t.length,o=e.length;r<n;r++,o++)e[o]=t[r];return e},__await:p,__asyncGenerator:function(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(e,t||[]),a=[];return n={},i("next"),i("throw"),i("return"),n[Symbol.asyncIterator]=function(){return this},n;function i(e){o[e]&&(n[e]=function(t){return new Promise((function(r,n){a.push([e,t,r,n])>1||c(e,t)}))})}function c(e,t){try{(r=o[e](t)).value instanceof p?Promise.resolve(r.value.v).then(u,f):l(a[0][2],r)}catch(e){l(a[0][3],e)}var r}function u(e){c("next",e)}function f(e){c("throw",e)}function l(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}},__asyncDelegator:function(e){var t,r;return t={},n("next"),n("throw",(function(e){throw e})),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,o){t[n]=e[n]?function(t){return(r=!r)?{value:p(e[n](t)),done:"return"===n}:o?o(t):t}:o}},__asyncValues:function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=l(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,o){(function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)})(n,o,(t=e[r](t)).done,t.value)}))}}},__makeTemplateObject:function(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e},__importStar:function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&f(t,e,r);return d(t,e),t},__importDefault:function(e){return e&&e.__esModule?e:{default:e}},__classPrivateFieldGet:function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)},__classPrivateFieldSet:function(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r}});function _(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})})),t}function y(e){var t={exports:{}};return e(t,t.exports),t.exports}y((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.sanitization=void 0,t.sanitization=function(e){const t=new RegExp(/[^0-9]|[/ /]/g,""),r=e.trim().replace(t,"");if(8!==r.length)throw Error(`Cep: ${e} inválido!`);return r}}));var v,h=_(m);y((function(n,o){Object.defineProperty(o,"__esModule",{value:!0}),o.request=void 0;const a=h.__importDefault(e),i=h.__importDefault(t),c=h.__importDefault(r);o.request=function(e,t){return a.default(e,t).then((e=>{if(t.agent=function(e){const t=new i.default.Agent({keepAlive:!0}),r=new c.default.Agent({keepAlive:!0});return function(e){return"http:"==e.protocol?t:r}}(),t.timeout=0,!e.ok)throw new Error(e.statusText);return"application/json; charset=utf-8"!==e.headers.get("content-type")?e.arrayBuffer():e.json()})).catch((t=>new Error(`${e} gerou um erro ${t}`)))}})),function(e){e.BASECEP="https://viacep.com.br/ws",e.BASECORREIOS="https://ws.correios.com.br/calculador/CalcPrecoPrazo.aspx",e.BASERASTREIO="https://www.linkcorreios.com.br",e.WIDENET="https://cep.widenet.host/busca-cep/api/cep"}(v||(v={}));var b,w=y((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.sanitization=void 0,t.sanitization=function(e){const t=new RegExp(/[^0-9]|[/ /]/g,""),r=e.trim().replace(t,"");if(8!==r.length)throw Error(`Cep: ${e} inválido!`);return r}})),g=y((function(n,o){Object.defineProperty(o,"__esModule",{value:!0}),o.request=void 0;const a=h.__importDefault(e),i=h.__importDefault(t),c=h.__importDefault(r);o.request=function(e,t){return a.default(e,t).then((e=>{if(t.agent=function(e){const t=new i.default.Agent({keepAlive:!0}),r=new c.default.Agent({keepAlive:!0});return function(e){return"http:"==e.protocol?t:r}}(),t.timeout=0,!e.ok)throw new Error(e.statusText);return"application/json; charset=utf-8"!==e.headers.get("content-type")?e.arrayBuffer():e.json()})).catch((t=>new Error(`${e} gerou um erro ${t}`)))}}));!function(e){e.BASECEP="https://viacep.com.br/ws",e.BASECORREIOS="https://ws.correios.com.br/calculador/CalcPrecoPrazo.aspx",e.BASERASTREIO="https://www.linkcorreios.com.br",e.WIDENET="https://cep.widenet.host/busca-cep/api/cep"}(b||(b={}));var O=b,S=Object.defineProperty({default:O},"__esModule",{value:!0});h.__importDefault(S),y((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.convertXMLStringToJson=t.convertArrayBufferToString=void 0;const r=h.__importDefault(o),n=h.__importDefault(a);t.convertArrayBufferToString=function(e,t){return r.default.decode(Buffer.from(e),t).toString()},t.convertXMLStringToJson=function(e){return JSON.parse(n.default.xml2json(e,{compact:!0}))}}));var j=y((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.convertXMLStringToJson=t.convertArrayBufferToString=void 0;const r=h.__importDefault(o),n=h.__importDefault(a);t.convertArrayBufferToString=function(e,t){return r.default.decode(Buffer.from(e),t).toString()},t.convertXMLStringToJson=function(e){return JSON.parse(n.default.xml2json(e,{compact:!0}))}}));h.__importDefault(n),h.__importDefault(S),y((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatDestiny=t.formatOrigin=t.formatLocal=t.formatDateTime=t.formatStatus=void 0,t.formatStatus=function(e){return e.replace("Status","").replace(/\s\s+/g," ").replace(":","").trim()},t.formatDateTime=function(e){return e.split(" ").join("").replace(/\s\s+/g," ").replace("Data:","").replace("Hora:","").split("|")},t.formatLocal=function(e){return e.replace("Local","").replace(/\s\s+/g," ").replace(":","").trim()},t.formatOrigin=function(e){return e.replace("Origem","").replace(/\s\s+/g," ").replace(":","").trim()},t.formatDestiny=function(e){return e.replace("Destino","").replace(/\s\s+/g," ").replace(":","").trim()}}));var P=y((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatDestiny=t.formatOrigin=t.formatLocal=t.formatDateTime=t.formatStatus=void 0,t.formatStatus=function(e){return e.replace("Status","").replace(/\s\s+/g," ").replace(":","").trim()},t.formatDateTime=function(e){return e.split(" ").join("").replace(/\s\s+/g," ").replace("Data:","").replace("Hora:","").split("|")},t.formatLocal=function(e){return e.replace("Local","").replace(/\s\s+/g," ").replace(":","").trim()},t.formatOrigin=function(e){return e.replace("Origem","").replace(/\s\s+/g," ").replace(":","").trim()},t.formatDestiny=function(e){return e.replace("Destino","").replace(/\s\s+/g," ").replace(":","").trim()}}));h.__importDefault(i),h.__importDefault(S);const D=h.__importDefault(S);var E=function(e){return new Promise(((t,r)=>g.request(`${D.default.BASECEP}/${w.sanitization(e)}/json`,{method:"GET",headers:{"content-type":"application/json"}}).then((n=>(n.erro&&r(Error(`Cep: ${e} não existe na nossa base`)),t(n))))))},T=Object.defineProperty({default:E},"__esModule",{value:!0});const x=h.__importDefault(n),A=h.__importDefault(S);var C=function(e){const t=e.nCdServico;return Promise.all(t.map((t=>function(e,t){return delete e.nCdServico,new Promise(((r,n)=>{const o=Object.assign(Object.assign({},e),{nCdServico:t,sCepOrigem:w.sanitization(e.sCepOrigem),sCepDestino:w.sanitization(e.sCepDestino),nCdEmpresa:"",sDsSenha:"",sCdMaoPropria:"n",nVlValorDeclarado:0,sCdAvisoRecebimento:"n",StrRetorno:"xml",nIndicaCalculo:3});return g.request(`${A.default.BASECORREIOS}?${x.default.stringify(o)}`,{method:"GET",headers:{"content-type":"application/json"}}).then((e=>{const t=j.convertXMLStringToJson(j.convertArrayBufferToString(e,"iso-8859-1"));var n;r((n=t.Servicos.cServico,Object.keys(n).reduce(((e,t)=>(e[t]=n[t]._text?n[t]._text:n[t]._cdata,e)),{})))}))}))}(e,t)))).then((e=>e))},M=Object.defineProperty({default:C},"__esModule",{value:!0});const R=h.__importDefault(i),B=h.__importDefault(S);var I=function(e){return Promise.all(e.map((e=>function(e){return new Promise(((t,r)=>{g.request(`${B.default.BASERASTREIO}/${e}`,{method:"GET",mode:"no-cors",headers:{"content-type":"text; charset=utf-8","cache-control":"no-cache"}}).then((e=>{t(function(e){const t=R.default.load(e),r=[];t("ul.linha_status").each(((e,t)=>{r.push(t)})),r.shift();return r.map((e=>{const r={};return t(e).find("li").each(((e,n)=>{const o=t(n).text();if(o){if(o.includes("Status")&&(r.status=P.formatStatus(o)),o.includes("Data")){const e=P.formatDateTime(o);r.data=e[0],r.hora=e[1]}o.includes("Local")&&(r.local=P.formatLocal(o)),o.includes("Origem")&&(r.origem=P.formatOrigin(o)),o.includes("Destino")&&(r.destino=P.formatDestiny(o))}})),r})).reverse()}(j.convertArrayBufferToString(e,"utf-8")))}))}))}(e)))).then((e=>e))},k=Object.defineProperty({default:I},"__esModule",{value:!0});const L=h.__importDefault(T),$=h.__importDefault(M),z=h.__importDefault(k);var q={consultarCep:L.default,calcularPrecoPrazo:$.default,rastrearEncomendas:z.default};export default q; | ||
***************************************************************************** */var u,s=function(){return(s=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function l(e,t,n,r){return new(n||(n=Promise))((function(o,i){function c(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}u((r=r.apply(e,t||[])).next())}))}function p(e,t){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;c;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,r=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(o=c.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){c=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){c.label=i[1];break}if(6===i[0]&&c.label<o[1]){c.label=o[1],o=i;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(i);break}o[2]&&c.ops.pop(),c.trys.pop();continue}i=t.call(e,c)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function f(t,n){var r=this;return e(t,n).then((function(e){return l(r,void 0,void 0,(function(){var r;return p(this,(function(o){switch(o.label){case 0:return r=n,[4,h(t)];case 1:if(r.agent=o.sent(),n.timeout=0,!e.ok)throw new Error(e.statusText);return"application/json; charset=utf-8"!==e.headers.get("content-type")?[2,e.arrayBuffer()]:[2,e.json()]}}))}))})).catch((function(e){return new Error(t+" gerou um erro "+e)}))}function h(e){var r=new URL(e),o=new t.Agent({keepAlive:!0}),i=new n.Agent({keepAlive:!0});return"http:"==r.protocol?o:i}!function(e){e.BASECEP="https://viacep.com.br/ws",e.BASECORREIOS="https://ws.correios.com.br/calculador/CalcPrecoPrazo.aspx",e.BASERASTREIO="https://www.linkcorreios.com.br",e.WIDENET="https://cep.widenet.host/busca-cep/api/cep"}(u||(u={}));var m=u;function d(e){return new Promise((function(t,n){return f(m.BASECEP+"/"+a(e)+"/json",{method:"GET",headers:{"content-type":"application/json"}}).then((function(r){return r.erro&&n(Error("Cep: "+e+" não existe na nossa base")),t(r)}))}))}function v(e,t){return o.decode(Buffer.from(e),t).toString()}function w(e){var t=e.nCdServico;return Promise.all(t.map((function(t){return function(e,t){return delete e.nCdServico,new Promise((function(n,o){var c=s(s({},e),{nCdServico:t,sCepOrigem:a(e.sCepOrigem),sCepDestino:a(e.sCepDestino),nCdEmpresa:"",sDsSenha:"",sCdMaoPropria:"n",nVlValorDeclarado:0,sCdAvisoRecebimento:"n",StrRetorno:"xml",nIndicaCalculo:3});return f(m.BASECORREIOS+"?"+r.stringify(c),{method:"GET",headers:{"content-type":"application/json"}}).then((function(e){var t,r,o=(t=v(e,"iso-8859-1"),JSON.parse(i.xml2json(t,{compact:!0})));n((r=o.Servicos.cServico,Object.keys(r).reduce((function(e,t){return e[t]=r[t]._text?r[t]._text:r[t]._cdata,e}),{})))}))}))}(e,t)}))).then((function(e){return e}))}function g(e){return Promise.all(e.map((function(e){return function(e){return new Promise((function(t,n){f(m.BASERASTREIO+"/"+e,{method:"GET",mode:"no-cors",headers:{"content-type":"text; charset=utf-8","cache-control":"no-cache"}}).then((function(e){var n,r,o;t((n=v(e,"utf-8"),r=c.load(n),o=[],r("ul.linha_status").each((function(e,t){o.push(t)})),o.shift(),o.map((function(e){var t={};return r(e).find("li").each((function(e,n){var o=r(n).text();if(o){if(o.includes("Status")&&(t.status=o.replace("Status","").replace(/\s\s+/g," ").replace(":","").trim()),o.includes("Data")){var i=function(e){return e.split(" ").join("").replace(/\s\s+/g," ").replace("Data:","").replace("Hora:","").split("|")}(o);t.data=i[0],t.hora=i[1]}o.includes("Local")&&(t.local=function(e){return e.replace("Local","").replace(/\s\s+/g," ").replace(":","").trim()}(o)),o.includes("Origem")&&(t.origem=function(e){return e.replace("Origem","").replace(/\s\s+/g," ").replace(":","").trim()}(o)),o.includes("Destino")&&(t.destino=function(e){return e.replace("Destino","").replace(/\s\s+/g," ").replace(":","").trim()}(o))}})),t})).reverse()))}))}))}(e)}))).then((function(e){return e}))}export{w as calcularPrecoPrazo,d as consultarCep,g as rastrearEncomendas}; | ||
//# sourceMappingURL=index.es.js.map |
@@ -1,1 +0,16 @@ | ||
"use strict";var e=require("node-fetch"),t=require("http"),r=require("https"),n=require("querystring"),o=require("iconv-lite"),a=require("xml-js"),i=require("cheerio");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=u(e),f=u(t),l=u(r),s=u(n),p=u(o),d=u(a),m=u(i),_=function(e,t){return(_=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)};var y=function(){return(y=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};var v=Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]};function h(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function b(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,a=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i}function w(e){return this instanceof w?(this.v=e,this):new w(e)}var g=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};var O=Object.freeze({__proto__:null,__extends:function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}_(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)},get __assign(){return y},__rest:function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r},__decorate:function(e,t,r,n){var o,a=arguments.length,i=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,n);else for(var u=e.length-1;u>=0;u--)(o=e[u])&&(i=(a<3?o(i):a>3?o(t,r,i):o(t,r))||i);return a>3&&i&&Object.defineProperty(t,r,i),i},__param:function(e,t){return function(r,n){t(r,n,e)}},__metadata:function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},__awaiter:function(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{c(n.next(e))}catch(e){a(e)}}function u(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,u)}c((n=n.apply(e,t||[])).next())}))},__generator:function(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},__createBinding:v,__exportStar:function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||v(t,e,r)},__values:h,__read:b,__spread:function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(b(arguments[t]));return e},__spreadArrays:function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var a=arguments[t],i=0,u=a.length;i<u;i++,o++)n[o]=a[i];return n},__spreadArray:function(e,t){for(var r=0,n=t.length,o=e.length;r<n;r++,o++)e[o]=t[r];return e},__await:w,__asyncGenerator:function(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(e,t||[]),a=[];return n={},i("next"),i("throw"),i("return"),n[Symbol.asyncIterator]=function(){return this},n;function i(e){o[e]&&(n[e]=function(t){return new Promise((function(r,n){a.push([e,t,r,n])>1||u(e,t)}))})}function u(e,t){try{(r=o[e](t)).value instanceof w?Promise.resolve(r.value.v).then(c,f):l(a[0][2],r)}catch(e){l(a[0][3],e)}var r}function c(e){u("next",e)}function f(e){u("throw",e)}function l(e,t){e(t),a.shift(),a.length&&u(a[0][0],a[0][1])}},__asyncDelegator:function(e){var t,r;return t={},n("next"),n("throw",(function(e){throw e})),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,o){t[n]=e[n]?function(t){return(r=!r)?{value:w(e[n](t)),done:"return"===n}:o?o(t):t}:o}},__asyncValues:function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=h(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,o){(function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)})(n,o,(t=e[r](t)).done,t.value)}))}}},__makeTemplateObject:function(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e},__importStar:function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&v(t,e,r);return g(t,e),t},__importDefault:function(e){return e&&e.__esModule?e:{default:e}},__classPrivateFieldGet:function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)},__classPrivateFieldSet:function(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r}});function S(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})})),t}function j(e){var t={exports:{}};return e(t,t.exports),t.exports}j((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.sanitization=void 0,t.sanitization=function(e){const t=new RegExp(/[^0-9]|[/ /]/g,""),r=e.trim().replace(t,"");if(8!==r.length)throw Error(`Cep: ${e} inválido!`);return r}}));var P,D=S(O);j((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.request=void 0;const r=D.__importDefault(c.default),n=D.__importDefault(f.default),o=D.__importDefault(l.default);t.request=function(e,t){return r.default(e,t).then((e=>{if(t.agent=function(e){const t=new n.default.Agent({keepAlive:!0}),r=new o.default.Agent({keepAlive:!0});return function(e){return"http:"==e.protocol?t:r}}(),t.timeout=0,!e.ok)throw new Error(e.statusText);return"application/json; charset=utf-8"!==e.headers.get("content-type")?e.arrayBuffer():e.json()})).catch((t=>new Error(`${e} gerou um erro ${t}`)))}})),function(e){e.BASECEP="https://viacep.com.br/ws",e.BASECORREIOS="https://ws.correios.com.br/calculador/CalcPrecoPrazo.aspx",e.BASERASTREIO="https://www.linkcorreios.com.br",e.WIDENET="https://cep.widenet.host/busca-cep/api/cep"}(P||(P={}));var E,T=j((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.sanitization=void 0,t.sanitization=function(e){const t=new RegExp(/[^0-9]|[/ /]/g,""),r=e.trim().replace(t,"");if(8!==r.length)throw Error(`Cep: ${e} inválido!`);return r}})),x=j((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.request=void 0;const r=D.__importDefault(c.default),n=D.__importDefault(f.default),o=D.__importDefault(l.default);t.request=function(e,t){return r.default(e,t).then((e=>{if(t.agent=function(e){const t=new n.default.Agent({keepAlive:!0}),r=new o.default.Agent({keepAlive:!0});return function(e){return"http:"==e.protocol?t:r}}(),t.timeout=0,!e.ok)throw new Error(e.statusText);return"application/json; charset=utf-8"!==e.headers.get("content-type")?e.arrayBuffer():e.json()})).catch((t=>new Error(`${e} gerou um erro ${t}`)))}}));!function(e){e.BASECEP="https://viacep.com.br/ws",e.BASECORREIOS="https://ws.correios.com.br/calculador/CalcPrecoPrazo.aspx",e.BASERASTREIO="https://www.linkcorreios.com.br",e.WIDENET="https://cep.widenet.host/busca-cep/api/cep"}(E||(E={}));var A=E,C=Object.defineProperty({default:A},"__esModule",{value:!0});D.__importDefault(C),j((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.convertXMLStringToJson=t.convertArrayBufferToString=void 0;const r=D.__importDefault(p.default),n=D.__importDefault(d.default);t.convertArrayBufferToString=function(e,t){return r.default.decode(Buffer.from(e),t).toString()},t.convertXMLStringToJson=function(e){return JSON.parse(n.default.xml2json(e,{compact:!0}))}}));var M=j((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.convertXMLStringToJson=t.convertArrayBufferToString=void 0;const r=D.__importDefault(p.default),n=D.__importDefault(d.default);t.convertArrayBufferToString=function(e,t){return r.default.decode(Buffer.from(e),t).toString()},t.convertXMLStringToJson=function(e){return JSON.parse(n.default.xml2json(e,{compact:!0}))}}));D.__importDefault(s.default),D.__importDefault(C),j((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatDestiny=t.formatOrigin=t.formatLocal=t.formatDateTime=t.formatStatus=void 0,t.formatStatus=function(e){return e.replace("Status","").replace(/\s\s+/g," ").replace(":","").trim()},t.formatDateTime=function(e){return e.split(" ").join("").replace(/\s\s+/g," ").replace("Data:","").replace("Hora:","").split("|")},t.formatLocal=function(e){return e.replace("Local","").replace(/\s\s+/g," ").replace(":","").trim()},t.formatOrigin=function(e){return e.replace("Origem","").replace(/\s\s+/g," ").replace(":","").trim()},t.formatDestiny=function(e){return e.replace("Destino","").replace(/\s\s+/g," ").replace(":","").trim()}}));var R=j((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatDestiny=t.formatOrigin=t.formatLocal=t.formatDateTime=t.formatStatus=void 0,t.formatStatus=function(e){return e.replace("Status","").replace(/\s\s+/g," ").replace(":","").trim()},t.formatDateTime=function(e){return e.split(" ").join("").replace(/\s\s+/g," ").replace("Data:","").replace("Hora:","").split("|")},t.formatLocal=function(e){return e.replace("Local","").replace(/\s\s+/g," ").replace(":","").trim()},t.formatOrigin=function(e){return e.replace("Origem","").replace(/\s\s+/g," ").replace(":","").trim()},t.formatDestiny=function(e){return e.replace("Destino","").replace(/\s\s+/g," ").replace(":","").trim()}}));D.__importDefault(m.default),D.__importDefault(C);const B=D.__importDefault(C);var I=function(e){return new Promise(((t,r)=>x.request(`${B.default.BASECEP}/${T.sanitization(e)}/json`,{method:"GET",headers:{"content-type":"application/json"}}).then((n=>(n.erro&&r(Error(`Cep: ${e} não existe na nossa base`)),t(n))))))},k=Object.defineProperty({default:I},"__esModule",{value:!0});const q=D.__importDefault(s.default),L=D.__importDefault(C);var $=function(e){const t=e.nCdServico;return Promise.all(t.map((t=>function(e,t){return delete e.nCdServico,new Promise(((r,n)=>{const o=Object.assign(Object.assign({},e),{nCdServico:t,sCepOrigem:T.sanitization(e.sCepOrigem),sCepDestino:T.sanitization(e.sCepDestino),nCdEmpresa:"",sDsSenha:"",sCdMaoPropria:"n",nVlValorDeclarado:0,sCdAvisoRecebimento:"n",StrRetorno:"xml",nIndicaCalculo:3});return x.request(`${L.default.BASECORREIOS}?${q.default.stringify(o)}`,{method:"GET",headers:{"content-type":"application/json"}}).then((e=>{const t=M.convertXMLStringToJson(M.convertArrayBufferToString(e,"iso-8859-1"));var n;r((n=t.Servicos.cServico,Object.keys(n).reduce(((e,t)=>(e[t]=n[t]._text?n[t]._text:n[t]._cdata,e)),{})))}))}))}(e,t)))).then((e=>e))},z=Object.defineProperty({default:$},"__esModule",{value:!0});const J=D.__importDefault(m.default),G=D.__importDefault(C);var X=function(e){return Promise.all(e.map((e=>function(e){return new Promise(((t,r)=>{x.request(`${G.default.BASERASTREIO}/${e}`,{method:"GET",mode:"no-cors",headers:{"content-type":"text; charset=utf-8","cache-control":"no-cache"}}).then((e=>{t(function(e){const t=J.default.load(e),r=[];t("ul.linha_status").each(((e,t)=>{r.push(t)})),r.shift();return r.map((e=>{const r={};return t(e).find("li").each(((e,n)=>{const o=t(n).text();if(o){if(o.includes("Status")&&(r.status=R.formatStatus(o)),o.includes("Data")){const e=R.formatDateTime(o);r.data=e[0],r.hora=e[1]}o.includes("Local")&&(r.local=R.formatLocal(o)),o.includes("Origem")&&(r.origem=R.formatOrigin(o)),o.includes("Destino")&&(r.destino=R.formatDestiny(o))}})),r})).reverse()}(M.convertArrayBufferToString(e,"utf-8")))}))}))}(e)))).then((e=>e))},N=Object.defineProperty({default:X},"__esModule",{value:!0});const V=D.__importDefault(k),F=D.__importDefault(z),H=D.__importDefault(N);var W={consultarCep:V.default,calcularPrecoPrazo:F.default,rastrearEncomendas:H.default};module.exports=W; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("node-fetch"),t=require("http"),r=require("https"),n=require("querystring"),o=require("iconv-lite"),a=require("xml-js"),c=require("cheerio");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=i(e),s=i(t),l=i(r),f=i(n),p=i(o),h=i(a),d=i(c);function v(e){var t=new RegExp(/[^0-9]|[/ /]/g,""),r=e.trim().replace(t,"");if(8!==r.length)throw Error("Cep: "+e+" inválido!");return r} | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */var m,w=function(){return(w=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function y(e,t,r,n){return new(r||(r=Promise))((function(o,a){function c(e){try{u(n.next(e))}catch(e){a(e)}}function i(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(c,i)}u((n=n.apply(e,t||[])).next())}))}function b(e,t){var r,n,o,a,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;c;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return c.label++,{value:a[1],done:!1};case 5:c.label++,n=a[1],a=[0];continue;case 7:a=c.ops.pop(),c.trys.pop();continue;default:if(!(o=c.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(6===a[0]&&c.label<o[1]){c.label=o[1],o=a;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(a);break}o[2]&&c.ops.pop(),c.trys.pop();continue}a=t.call(e,c)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,i])}}}function g(e,t){var r=this;return u.default(e,t).then((function(n){return y(r,void 0,void 0,(function(){var r;return b(this,(function(o){switch(o.label){case 0:return r=t,[4,E(e)];case 1:if(r.agent=o.sent(),t.timeout=0,!n.ok)throw new Error(n.statusText);return"application/json; charset=utf-8"!==n.headers.get("content-type")?[2,n.arrayBuffer()]:[2,n.json()]}}))}))})).catch((function(t){return new Error(e+" gerou um erro "+t)}))}function E(e){var t=new URL(e),r=new s.default.Agent({keepAlive:!0}),n=new l.default.Agent({keepAlive:!0});return"http:"==t.protocol?r:n}!function(e){e.BASECEP="https://viacep.com.br/ws",e.BASECORREIOS="https://ws.correios.com.br/calculador/CalcPrecoPrazo.aspx",e.BASERASTREIO="https://www.linkcorreios.com.br",e.WIDENET="https://cep.widenet.host/busca-cep/api/cep"}(m||(m={}));var S=m;function x(e,t){return p.default.decode(Buffer.from(e),t).toString()}exports.calcularPrecoPrazo=function(e){var t=e.nCdServico;return Promise.all(t.map((function(t){return function(e,t){return delete e.nCdServico,new Promise((function(r,n){var o=w(w({},e),{nCdServico:t,sCepOrigem:v(e.sCepOrigem),sCepDestino:v(e.sCepDestino),nCdEmpresa:"",sDsSenha:"",sCdMaoPropria:"n",nVlValorDeclarado:0,sCdAvisoRecebimento:"n",StrRetorno:"xml",nIndicaCalculo:3});return g(S.BASECORREIOS+"?"+f.default.stringify(o),{method:"GET",headers:{"content-type":"application/json"}}).then((function(e){var t,n,o=(t=x(e,"iso-8859-1"),JSON.parse(h.default.xml2json(t,{compact:!0})));r((n=o.Servicos.cServico,Object.keys(n).reduce((function(e,t){return e[t]=n[t]._text?n[t]._text:n[t]._cdata,e}),{})))}))}))}(e,t)}))).then((function(e){return e}))},exports.consultarCep=function(e){return new Promise((function(t,r){return g(S.BASECEP+"/"+v(e)+"/json",{method:"GET",headers:{"content-type":"application/json"}}).then((function(n){return n.erro&&r(Error("Cep: "+e+" não existe na nossa base")),t(n)}))}))},exports.rastrearEncomendas=function(e){return Promise.all(e.map((function(e){return function(e){return new Promise((function(t,r){g(S.BASERASTREIO+"/"+e,{method:"GET",mode:"no-cors",headers:{"content-type":"text; charset=utf-8","cache-control":"no-cache"}}).then((function(e){var r,n,o;t((r=x(e,"utf-8"),n=d.default.load(r),o=[],n("ul.linha_status").each((function(e,t){o.push(t)})),o.shift(),o.map((function(e){var t={};return n(e).find("li").each((function(e,r){var o=n(r).text();if(o){if(o.includes("Status")&&(t.status=o.replace("Status","").replace(/\s\s+/g," ").replace(":","").trim()),o.includes("Data")){var a=function(e){return e.split(" ").join("").replace(/\s\s+/g," ").replace("Data:","").replace("Hora:","").split("|")}(o);t.data=a[0],t.hora=a[1]}o.includes("Local")&&(t.local=function(e){return e.replace("Local","").replace(/\s\s+/g," ").replace(":","").trim()}(o)),o.includes("Origem")&&(t.origem=function(e){return e.replace("Origem","").replace(/\s\s+/g," ").replace(":","").trim()}(o)),o.includes("Destino")&&(t.destino=function(e){return e.replace("Destino","").replace(/\s\s+/g," ").replace(":","").trim()}(o))}})),t})).reverse()))}))}))}(e)}))).then((function(e){return e}))}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "correios-brasil", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "Módulo completo consultar informações sobre o CEP, calcular o preço e os prazos das entregas das encomendas e também realizar o seu rastreio", | ||
@@ -52,11 +52,7 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@types/chai": "^4.2.16", | ||
"@types/cheerio": "^0.22.28", | ||
"@types/mocha": "^8.2.2", | ||
"@types/node-fetch": "^2.5.10", | ||
"cheerio": "^1.0.0-rc.6", | ||
"esm": "^3.2.25", | ||
"iconv-lite": "^0.6.2", | ||
"node-fetch": "^2.6.1", | ||
"rollup-plugin-typescript": "^1.0.1", | ||
"xml-js": "^1.6.11" | ||
@@ -68,2 +64,4 @@ }, | ||
"@rollup/plugin-typescript": "8.2.1", | ||
"@types/chai": "^4.2.16", | ||
"@types/mocha": "^8.2.2", | ||
"@typescript-eslint/eslint-plugin": "^4.22.0", | ||
@@ -79,3 +77,2 @@ "@typescript-eslint/parser": "^4.22.0", | ||
"eslint-plugin-prettier": "^3.4.0", | ||
"esm": "^3.2.25", | ||
"mkdirp": "^1.0.4", | ||
@@ -82,0 +79,0 @@ "mocha": "^8.3.2", |
@@ -1,2 +0,2 @@ | ||
# Correios Brasil -- VERSÃO 2.2.0 | ||
# Correios Brasil -- VERSÃO 2.2.1 | ||
@@ -62,3 +62,3 @@ <h4 align="center"> | ||
```typescript | ||
import { correiosBrasil } from 'correios-brasil'; | ||
import {calcularPrecoPrazo, consultarCep, rastrearEncomendas} from 'correios-brasil'; | ||
``` | ||
@@ -65,0 +65,0 @@ |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
78770
6
18
212
25
- Removed@types/chai@^4.2.16
- Removed@types/mocha@^8.2.2
- Removedesm@^3.2.25
- Removedrollup-plugin-typescript@^1.0.1
- Removed@types/chai@4.3.20(transitive)
- Removed@types/mocha@8.2.3(transitive)
- Removedesm@3.2.25(transitive)
- Removedestree-walker@0.6.1(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedhasown@2.0.2(transitive)
- Removedis-core-module@2.15.1(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedresolve@1.22.8(transitive)
- Removedrollup-plugin-typescript@1.0.1(transitive)
- Removedrollup-pluginutils@2.8.2(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedtslib@2.8.1(transitive)
- Removedtypescript@5.6.3(transitive)