Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix bin and dump 4.1.0 #29

Merged
merged 4 commits into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions bin/cep-any.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env node
const { argv, exit } = require('node:process')
const { cep } = require('../dist/cjs/index.js');
const { cep } = require('../dist/index');

(async function main() {
const value = argv[2]
const data = await cep(value)
return data
const value = argv[2]
const data = await cep(value)
return data

}())
.then(console.info)
.catch(console.error)
.finally(exit)
.then(console.info)
.catch(console.error)
.finally(exit)
36 changes: 32 additions & 4 deletions dist/esm.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// src/errors/basicError.mjs
var BasicError = class extends Error {
/**
* @param {string} [message]
*/
constructor(message) {
super(message);
}
Expand All @@ -15,16 +18,17 @@ var ParamError = class extends BasicError {
// src/service/index.mjs
var CepService = class _CepService {
/**
* @param {any} api
* @param {any} requester
* @param {string} api
* @param {RequestWIthFetch} requester
* @param {string} [baseUrl='']
*/
constructor(api, requester, baseUrl = "") {
this.api = api;
this.requester = requester;
this.baseUrl = baseUrl;
}
/**
* @param {any} requester
* @param {RequestWIthFetch} requester
*/
overrideRequest(requester) {
this.requester = requester;
Expand Down Expand Up @@ -72,10 +76,14 @@ var CepService = class _CepService {
// src/provider.mjs
var Provider = class {
#services;
/**
* @param {CepService[]} services
*/
constructor(services) {
this.#services = services;
}
/**
* @param {string | number} zipcode
* @returns {Promise<Cep>}
*/
async execute(zipcode) {
Expand All @@ -88,6 +96,14 @@ var Provider = class {

// src/requester/index.mjs
var RequestWIthFetch = class {
/**
* @param {Object} param
* @param {string | URL} param.url
* @param {BodyInit} [param.body]
* @param {Object} [param.headers]
* @param {string} [param.method]
* @param {Object} [param.params]
*/
async execute({ url, body, headers, method, params }) {
const searchParams = new URLSearchParams(params);
const options = {
Expand All @@ -102,11 +118,15 @@ var RequestWIthFetch = class {

// src/service/brasilAPI/index.mjs
var BrasilAPIService = class extends CepService {
/**
* @typedef {import('../../requester/index.mjs').RequestWIthFetch} RequestWIthFetch
* @param {RequestWIthFetch} request
*/
constructor(request) {
super("brasilAPI", request, "https://brasilapi.com.br/api/cep/v1");
}
/**
* @typedef {import('../../types.js').Cep} Cep
* @typedef {import('../../types.ts').Cep} Cep
* @param {string} cep
* @returns {Promise<Cep>}
*/
Expand Down Expand Up @@ -171,6 +191,10 @@ function responseToCep(data) {

// src/service/correios/index.mjs
var CorreiosService = class extends CepService {
/**
* @typedef {import('../../requester/index.mjs').RequestWIthFetch} RequestWIthFetch
* @param {RequestWIthFetch} requester
*/
constructor(requester) {
super("correios", requester, "https://apps.correios.com.br");
}
Expand Down Expand Up @@ -198,6 +222,10 @@ var CorreiosService = class extends CepService {

// src/service/viacep/index.mjs
var ViaCepService = class extends CepService {
/**
* @typedef {import('../../requester/index.mjs').RequestWIthFetch} RequestWIthFetch
* @param {RequestWIthFetch} requester
*/
constructor(requester) {
super("viacep", requester, "https://viacep.com.br");
}
Expand Down
36 changes: 32 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ module.exports = __toCommonJS(src_exports);

// src/errors/basicError.mjs
var BasicError = class extends Error {
/**
* @param {string} [message]
*/
constructor(message) {
super(message);
}
Expand All @@ -46,16 +49,17 @@ var ParamError = class extends BasicError {
// src/service/index.mjs
var CepService = class _CepService {
/**
* @param {any} api
* @param {any} requester
* @param {string} api
* @param {RequestWIthFetch} requester
* @param {string} [baseUrl='']
*/
constructor(api, requester, baseUrl = "") {
this.api = api;
this.requester = requester;
this.baseUrl = baseUrl;
}
/**
* @param {any} requester
* @param {RequestWIthFetch} requester
*/
overrideRequest(requester) {
this.requester = requester;
Expand Down Expand Up @@ -103,10 +107,14 @@ var CepService = class _CepService {
// src/provider.mjs
var Provider = class {
#services;
/**
* @param {CepService[]} services
*/
constructor(services) {
this.#services = services;
}
/**
* @param {string | number} zipcode
* @returns {Promise<Cep>}
*/
async execute(zipcode) {
Expand All @@ -119,6 +127,14 @@ var Provider = class {

// src/requester/index.mjs
var RequestWIthFetch = class {
/**
* @param {Object} param
* @param {string | URL} param.url
* @param {BodyInit} [param.body]
* @param {Object} [param.headers]
* @param {string} [param.method]
* @param {Object} [param.params]
*/
async execute({ url, body, headers, method, params }) {
const searchParams = new URLSearchParams(params);
const options = {
Expand All @@ -133,11 +149,15 @@ var RequestWIthFetch = class {

// src/service/brasilAPI/index.mjs
var BrasilAPIService = class extends CepService {
/**
* @typedef {import('../../requester/index.mjs').RequestWIthFetch} RequestWIthFetch
* @param {RequestWIthFetch} request
*/
constructor(request) {
super("brasilAPI", request, "https://brasilapi.com.br/api/cep/v1");
}
/**
* @typedef {import('../../types.js').Cep} Cep
* @typedef {import('../../types.ts').Cep} Cep
* @param {string} cep
* @returns {Promise<Cep>}
*/
Expand Down Expand Up @@ -202,6 +222,10 @@ function responseToCep(data) {

// src/service/correios/index.mjs
var CorreiosService = class extends CepService {
/**
* @typedef {import('../../requester/index.mjs').RequestWIthFetch} RequestWIthFetch
* @param {RequestWIthFetch} requester
*/
constructor(requester) {
super("correios", requester, "https://apps.correios.com.br");
}
Expand Down Expand Up @@ -229,6 +253,10 @@ var CorreiosService = class extends CepService {

// src/service/viacep/index.mjs
var ViaCepService = class extends CepService {
/**
* @typedef {import('../../requester/index.mjs').RequestWIthFetch} RequestWIthFetch
* @param {RequestWIthFetch} requester
*/
constructor(requester) {
super("viacep", requester, "https://viacep.com.br");
}
Expand Down
109 changes: 70 additions & 39 deletions dist/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,32 @@
declare module "provider" {
/**
* @typedef {import('./types.js').Cep} Cep
*/
export class Provider {
constructor(services: any);
/**
* @returns {Promise<Cep>}
*/
execute(zipcode: any): Promise<Cep>;
#private;
}
export type Cep = import("types").Cep;
}
declare module "requester/index" {
export class RequestWIthFetch {
execute({ url, body, headers, method, params }: {
url: any;
body: any;
headers: any;
method: any;
params: any;
}): Promise<Response>;
}
}
declare module "errors/basicError" {
declare module "errors/basicError" {
export class BasicError extends Error {
constructor(message: any);
}
}
declare module "errors/paramError" {
export class ParamError extends BasicError {
constructor(args: any);
}
import { BasicError } from "errors/basicError.mjs";
}
declare module "requester/index" {
export class RequestWIthFetch {
/**
* @param {Object} param
* @param {string | URL} param.url
* @param {BodyInit} [param.body]
* @param {Object} [param.headers]
* @param {string} [param.method]
* @param {Object} [param.params]
*/
execute({ url, body, headers, method, params }: {
url: string | URL;
body?: BodyInit | undefined;
headers?: any;
method?: string | undefined;
params?: any;
}): Promise<Response>;
}
}
declare module "service/index" {
export class CepService {
/**
Expand All @@ -45,17 +39,18 @@ declare module "service/index" {
*/
static validateCep(zipcode: string): boolean;
/**
* @param {any} api
* @param {any} requester
* @param {string} api
* @param {RequestWIthFetch} requester
* @param {string} [baseUrl='']
*/
constructor(api: any, requester: any, baseUrl?: string);
api: any;
requester: any;
constructor(api: string, requester: RequestWIthFetch, baseUrl?: string | undefined);
api: string;
requester: import("requester/index.mjs").RequestWIthFetch;
baseUrl: string;
/**
* @param {any} requester
* @param {RequestWIthFetch} requester
*/
overrideRequest(requester: any): void;
overrideRequest(requester: RequestWIthFetch): void;
/**
* @param {string | number} zipcode
* @returns {Promise<Cep>}
Expand All @@ -68,12 +63,37 @@ declare module "service/index" {
handler(_zipcode: string | number): Promise<Cep>;
}
export type Cep = import("types").Cep;
export type RequestWIthFetch = import("requester/index").RequestWIthFetch;
}
declare module "provider" {
/**
* @typedef {import('./types.ts').Cep} Cep
* @typedef {import('./service/index.mjs').CepService} CepService
*/
export class Provider {
/**
* @param {CepService[]} services
*/
constructor(services: CepService[]);
/**
* @param {string | number} zipcode
* @returns {Promise<Cep>}
*/
execute(zipcode: string | number): Promise<Cep>;
#private;
}
export type Cep = import("types").Cep;
export type CepService = import("service/index").CepService;
}
declare module "service/brasilAPI/index" {
export class BrasilAPIService extends CepService {
constructor(request: any);
/**
* @typedef {import('../../types.js').Cep} Cep
* @typedef {import('../../requester/index.mjs').RequestWIthFetch} RequestWIthFetch
* @param {RequestWIthFetch} request
*/
constructor(request: import("requester/index.mjs").RequestWIthFetch);
/**
* @typedef {import('../../types.ts').Cep} Cep
* @param {string} cep
* @returns {Promise<Cep>}
*/
Expand All @@ -99,7 +119,11 @@ declare module "service/correios/adapters" {
}
declare module "service/correios/index" {
export class CorreiosService extends CepService {
constructor(requester: any);
/**
* @typedef {import('../../requester/index.mjs').RequestWIthFetch} RequestWIthFetch
* @param {RequestWIthFetch} requester
*/
constructor(requester: import("requester/index.mjs").RequestWIthFetch);
/**
* @typedef {import("../../types.js").Cep} Cep
* @param {string} cep
Expand All @@ -111,7 +135,11 @@ declare module "service/correios/index" {
}
declare module "service/viacep/index" {
export class ViaCepService extends CepService {
constructor(requester: any);
/**
* @typedef {import('../../requester/index.mjs').RequestWIthFetch} RequestWIthFetch
* @param {RequestWIthFetch} requester
*/
constructor(requester: import("requester/index.mjs").RequestWIthFetch);
/**
* @typedef {import("../../types.js").Cep} Cep
* @param {string} cep
Expand Down Expand Up @@ -161,7 +189,10 @@ declare module "index" {
}
declare module "service/apicep/index" {
export class ApiCepService extends CepService {
constructor(request: any);
/**
* @param {import('../index.mjs').RequestWIthFetch} request
*/
constructor(request: import('../index.mjs').RequestWIthFetch);
/**
* @typedef {import('../../types.js').Cep} Cep
* @param {string} cep
Expand Down
Loading
Loading